multi: update packages due to recent SignDescriptor and WalletController changes

This commit is contained in:
Olaoluwa Osuntokun 2018-02-17 15:29:01 -08:00
parent 0d1a40fb46
commit 4b20e805fe
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
9 changed files with 229 additions and 100 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
@ -405,7 +406,7 @@ func initBreachedOutputs() error {
return fmt.Errorf("unable to parse pubkey: %v", return fmt.Errorf("unable to parse pubkey: %v",
breachKeys[i]) breachKeys[i])
} }
bo.signDesc.PubKey = pubkey bo.signDesc.KeyDesc.PubKey = pubkey
} }
return nil return nil
@ -1272,12 +1273,22 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
}, },
CsvDelay: uint16(csvTimeoutAlice), CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: aliceKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
PaymentBasePoint: aliceKeyPub, },
DelayBasePoint: aliceKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
} }
bobCfg := channeldb.ChannelConfig{ bobCfg := channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{ ChannelConstraints: channeldb.ChannelConstraints{
@ -1287,24 +1298,40 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
}, },
CsvDelay: uint16(csvTimeoutBob), CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: bobKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: bobKeyPub, PubKey: bobKeyPub,
PaymentBasePoint: bobKeyPub, },
DelayBasePoint: bobKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: bobKeyPub, PubKey: bobKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
} }
bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, testHdSeed, aliceKeyPub) bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize())
bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) if err != nil {
return nil, nil, nil, err
}
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:])
aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, testHdSeed, bobKeyPub) aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize())
alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) if err != nil {
return nil, nil, nil, err
}
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err

View File

@ -133,13 +133,13 @@ func newChainWatcher(chanState *channeldb.OpenChannel,
var stateHint [lnwallet.StateHintSize]byte var stateHint [lnwallet.StateHintSize]byte
if chanState.IsInitiator { if chanState.IsInitiator {
stateHint = lnwallet.DeriveStateHintObfuscator( stateHint = lnwallet.DeriveStateHintObfuscator(
chanState.LocalChanCfg.PaymentBasePoint, chanState.LocalChanCfg.PaymentBasePoint.PubKey,
chanState.RemoteChanCfg.PaymentBasePoint, chanState.RemoteChanCfg.PaymentBasePoint.PubKey,
) )
} else { } else {
stateHint = lnwallet.DeriveStateHintObfuscator( stateHint = lnwallet.DeriveStateHintObfuscator(
chanState.RemoteChanCfg.PaymentBasePoint, chanState.RemoteChanCfg.PaymentBasePoint.PubKey,
chanState.LocalChanCfg.PaymentBasePoint, chanState.LocalChanCfg.PaymentBasePoint.PubKey,
) )
} }

View File

@ -19,6 +19,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@ -940,12 +941,22 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
MinHTLC: msg.HtlcMinimum, MinHTLC: msg.HtlcMinimum,
MaxAcceptedHtlcs: maxHtlcs, MaxAcceptedHtlcs: maxHtlcs,
}, },
CsvDelay: remoteCsvDelay, CsvDelay: remoteCsvDelay,
MultiSigKey: copyPubKey(msg.FundingKey), MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: copyPubKey(msg.RevocationPoint), PubKey: copyPubKey(msg.FundingKey),
PaymentBasePoint: copyPubKey(msg.PaymentPoint), },
DelayBasePoint: copyPubKey(msg.DelayedPaymentPoint), RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: copyPubKey(msg.HtlcPoint), PubKey: copyPubKey(msg.RevocationPoint),
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.PaymentPoint),
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.DelayedPaymentPoint),
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.HtlcPoint),
},
}, },
} }
err = reservation.ProcessSingleContribution(remoteContribution) err = reservation.ProcessSingleContribution(remoteContribution)
@ -974,11 +985,11 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
HtlcMinimum: ourContribution.MinHTLC, HtlcMinimum: ourContribution.MinHTLC,
CsvDelay: uint16(remoteCsvDelay), CsvDelay: uint16(remoteCsvDelay),
MaxAcceptedHTLCs: maxHtlcs, MaxAcceptedHTLCs: maxHtlcs,
FundingKey: ourContribution.MultiSigKey, FundingKey: ourContribution.MultiSigKey.PubKey,
RevocationPoint: ourContribution.RevocationBasePoint, RevocationPoint: ourContribution.RevocationBasePoint.PubKey,
PaymentPoint: ourContribution.PaymentBasePoint, PaymentPoint: ourContribution.PaymentBasePoint.PubKey,
DelayedPaymentPoint: ourContribution.DelayBasePoint, DelayedPaymentPoint: ourContribution.DelayBasePoint.PubKey,
HtlcPoint: ourContribution.HtlcBasePoint, HtlcPoint: ourContribution.HtlcBasePoint.PubKey,
FirstCommitmentPoint: ourContribution.FirstCommitmentPoint, FirstCommitmentPoint: ourContribution.FirstCommitmentPoint,
} }
err = f.cfg.SendToPeer(fmsg.peerAddress.IdentityKey, &fundingAccept) err = f.cfg.SendToPeer(fmsg.peerAddress.IdentityKey, &fundingAccept)
@ -1057,11 +1068,21 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
MinHTLC: msg.HtlcMinimum, MinHTLC: msg.HtlcMinimum,
MaxAcceptedHtlcs: maxHtlcs, MaxAcceptedHtlcs: maxHtlcs,
}, },
MultiSigKey: copyPubKey(msg.FundingKey), MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: copyPubKey(msg.RevocationPoint), PubKey: copyPubKey(msg.FundingKey),
PaymentBasePoint: copyPubKey(msg.PaymentPoint), },
DelayBasePoint: copyPubKey(msg.DelayedPaymentPoint), RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: copyPubKey(msg.HtlcPoint), PubKey: copyPubKey(msg.RevocationPoint),
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.PaymentPoint),
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.DelayedPaymentPoint),
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.HtlcPoint),
},
}, },
} }
remoteContribution.CsvDelay = f.cfg.RequiredRemoteDelay(resCtx.chanAmt) remoteContribution.CsvDelay = f.cfg.RequiredRemoteDelay(resCtx.chanAmt)
@ -1818,10 +1839,11 @@ func (f *fundingManager) addToRouterGraph(completeChan *channeldb.OpenChannel,
// will be the one that's carrying the HTLC towards us. // will be the one that's carrying the HTLC towards us.
remoteMinHTLC := completeChan.RemoteChanCfg.MinHTLC remoteMinHTLC := completeChan.RemoteChanCfg.MinHTLC
ann, err := f.newChanAnnouncement(f.cfg.IDKey, completeChan.IdentityPub, ann, err := f.newChanAnnouncement(
completeChan.LocalChanCfg.MultiSigKey, f.cfg.IDKey, completeChan.IdentityPub,
completeChan.RemoteChanCfg.MultiSigKey, *shortChanID, chanID, completeChan.LocalChanCfg.MultiSigKey.PubKey,
remoteMinHTLC, completeChan.RemoteChanCfg.MultiSigKey.PubKey, *shortChanID,
chanID, remoteMinHTLC,
) )
if err != nil { if err != nil {
return fmt.Errorf("error generating channel "+ return fmt.Errorf("error generating channel "+
@ -1927,10 +1949,11 @@ func (f *fundingManager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
// Create and broadcast the proofs required to make this channel // Create and broadcast the proofs required to make this channel
// public and usable for other nodes for routing. // public and usable for other nodes for routing.
err = f.announceChannel(f.cfg.IDKey, completeChan.IdentityPub, err = f.announceChannel(
completeChan.LocalChanCfg.MultiSigKey, f.cfg.IDKey, completeChan.IdentityPub,
completeChan.RemoteChanCfg.MultiSigKey, *shortChanID, chanID, completeChan.LocalChanCfg.MultiSigKey.PubKey,
remoteMinHTLC, completeChan.RemoteChanCfg.MultiSigKey.PubKey,
*shortChanID, chanID, remoteMinHTLC,
) )
if err != nil { if err != nil {
return fmt.Errorf("channel announcement failed: %v", err) return fmt.Errorf("channel announcement failed: %v", err)
@ -2440,11 +2463,11 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
FeePerKiloWeight: uint32(commitFeePerKw), FeePerKiloWeight: uint32(commitFeePerKw),
CsvDelay: uint16(remoteCsvDelay), CsvDelay: uint16(remoteCsvDelay),
MaxAcceptedHTLCs: maxHtlcs, MaxAcceptedHTLCs: maxHtlcs,
FundingKey: ourContribution.MultiSigKey, FundingKey: ourContribution.MultiSigKey.PubKey,
RevocationPoint: ourContribution.RevocationBasePoint, RevocationPoint: ourContribution.RevocationBasePoint.PubKey,
PaymentPoint: ourContribution.PaymentBasePoint, PaymentPoint: ourContribution.PaymentBasePoint.PubKey,
HtlcPoint: ourContribution.HtlcBasePoint, HtlcPoint: ourContribution.HtlcBasePoint.PubKey,
DelayedPaymentPoint: ourContribution.DelayBasePoint, DelayedPaymentPoint: ourContribution.DelayBasePoint.PubKey,
FirstCommitmentPoint: ourContribution.FirstCommitmentPoint, FirstCommitmentPoint: ourContribution.FirstCommitmentPoint,
ChannelFlags: channelFlags, ChannelFlags: channelFlags,
} }

View File

@ -16,6 +16,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@ -150,12 +151,14 @@ func init() {
func createTestWallet(cdb *channeldb.DB, netParams *chaincfg.Params, func createTestWallet(cdb *channeldb.DB, netParams *chaincfg.Params,
notifier chainntnfs.ChainNotifier, wc lnwallet.WalletController, notifier chainntnfs.ChainNotifier, wc lnwallet.WalletController,
signer lnwallet.Signer, bio lnwallet.BlockChainIO, signer lnwallet.Signer, keyRing keychain.SecretKeyRing,
bio lnwallet.BlockChainIO,
estimator lnwallet.FeeEstimator) (*lnwallet.LightningWallet, error) { estimator lnwallet.FeeEstimator) (*lnwallet.LightningWallet, error) {
wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{ wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{
Database: cdb, Database: cdb,
Notifier: notifier, Notifier: notifier,
SecretKeyRing: keyRing,
WalletController: wc, WalletController: wc,
Signer: signer, Signer: signer,
ChainIO: bio, ChainIO: bio,
@ -212,8 +215,14 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
return nil, err return nil, err
} }
lnw, err := createTestWallet(cdb, netParams, keyRing := &mockSecretKeyRing{
chainNotifier, wc, signer, bio, estimator) rootKey: alicePrivKey,
}
lnw, err := createTestWallet(
cdb, netParams, chainNotifier, wc, signer, keyRing, bio,
estimator,
)
if err != nil { if err != nil {
t.Fatalf("unable to create test ln wallet: %v", err) t.Fatalf("unable to create test ln wallet: %v", err)
} }

View File

@ -557,7 +557,7 @@ func (m *mockSigner) SignOutputRaw(tx *wire.MsgTx, signDesc *lnwallet.SignDescri
witnessScript := signDesc.WitnessScript witnessScript := signDesc.WitnessScript
privKey := m.key privKey := m.key
if !privKey.PubKey().IsEqual(signDesc.PubKey) { if !privKey.PubKey().IsEqual(signDesc.KeyDesc.PubKey) {
return nil, fmt.Errorf("incorrect key passed") return nil, fmt.Errorf("incorrect key passed")
} }

View File

@ -22,6 +22,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
@ -132,34 +133,60 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
fundingTxIn := wire.NewTxIn(prevOut, nil, nil) fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
aliceCfg := channeldb.ChannelConfig{ aliceCfg := channeldb.ChannelConfig{
ChannelConstraints: *aliceConstraints, ChannelConstraints: *aliceConstraints,
CsvDelay: uint16(csvTimeoutAlice), CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: aliceKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
PaymentBasePoint: aliceKeyPub, },
DelayBasePoint: aliceKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
} }
bobCfg := channeldb.ChannelConfig{ bobCfg := channeldb.ChannelConfig{
ChannelConstraints: *bobConstraints, ChannelConstraints: *bobConstraints,
CsvDelay: uint16(csvTimeoutBob), CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: bobKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: bobKeyPub, PubKey: bobKeyPub,
PaymentBasePoint: bobKeyPub, },
DelayBasePoint: bobKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: bobKeyPub, PubKey: bobKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
} }
bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, hash, aliceKeyPub) bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize())
bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) if err != nil {
return nil, nil, nil, nil, err
}
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err
} }
bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:])
aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, hash, bobKeyPub) aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize())
alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) if err != nil {
return nil, nil, nil, nil, err
}
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err

38
mock.go
View File

@ -6,6 +6,7 @@ import (
"sync" "sync"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/chaincfg"
@ -28,7 +29,7 @@ func (m *mockSigner) SignOutputRaw(tx *wire.MsgTx,
witnessScript := signDesc.WitnessScript witnessScript := signDesc.WitnessScript
privKey := m.key privKey := m.key
if !privKey.PubKey().IsEqual(signDesc.PubKey) { if !privKey.PubKey().IsEqual(signDesc.KeyDesc.PubKey) {
return nil, fmt.Errorf("incorrect key passed") return nil, fmt.Errorf("incorrect key passed")
} }
@ -218,16 +219,6 @@ func (*mockWalletController) GetPrivKey(a btcutil.Address) (*btcec.PrivateKey, e
return nil, nil return nil, nil
} }
// NewRawKey will be called to get keys to be used for the funding tx and the
// commitment tx.
func (m *mockWalletController) NewRawKey() (*btcec.PublicKey, error) {
return m.rootKey.PubKey(), nil
}
// FetchRootKey will be called to provide the wallet with a root key.
func (m *mockWalletController) FetchRootKey() (*btcec.PrivateKey, error) {
return m.rootKey, nil
}
func (*mockWalletController) SendOutputs(outputs []*wire.TxOut, func (*mockWalletController) SendOutputs(outputs []*wire.TxOut,
_ lnwallet.SatPerVByte) (*chainhash.Hash, error) { _ lnwallet.SatPerVByte) (*chainhash.Hash, error) {
@ -272,6 +263,31 @@ func (*mockWalletController) Stop() error {
return nil return nil
} }
type mockSecretKeyRing struct {
rootKey *btcec.PrivateKey
}
func (m *mockSecretKeyRing) DeriveNextKey(keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error) {
return keychain.KeyDescriptor{
PubKey: m.rootKey.PubKey(),
}, nil
}
func (m *mockSecretKeyRing) DeriveKey(keyLoc keychain.KeyLocator) (keychain.KeyDescriptor, error) {
return keychain.KeyDescriptor{
PubKey: m.rootKey.PubKey(),
}, nil
}
func (m *mockSecretKeyRing) DerivePrivKey(keyDesc keychain.KeyDescriptor) (*btcec.PrivateKey, error) {
return m.rootKey, nil
}
func (m *mockSecretKeyRing) ScalarMult(keyDesc keychain.KeyDescriptor,
pubKey *btcec.PublicKey) ([]byte, error) {
return nil, nil
}
type mockPreimageCache struct { type mockPreimageCache struct {
sync.Mutex sync.Mutex
preimageMap map[[32]byte][]byte preimageMap map[[32]byte][]byte

View File

@ -11,6 +11,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
@ -79,12 +80,22 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
}, },
CsvDelay: uint16(csvTimeoutAlice), CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: aliceKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
PaymentBasePoint: aliceKeyPub, },
DelayBasePoint: aliceKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: aliceKeyPub, PubKey: aliceKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: aliceKeyPub,
},
} }
bobCfg := channeldb.ChannelConfig{ bobCfg := channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{ ChannelConstraints: channeldb.ChannelConstraints{
@ -94,24 +105,40 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
}, },
CsvDelay: uint16(csvTimeoutBob), CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: bobKeyPub, MultiSigKey: keychain.KeyDescriptor{
RevocationBasePoint: bobKeyPub, PubKey: bobKeyPub,
PaymentBasePoint: bobKeyPub, },
DelayBasePoint: bobKeyPub, RevocationBasePoint: keychain.KeyDescriptor{
HtlcBasePoint: bobKeyPub, PubKey: bobKeyPub,
},
PaymentBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
DelayBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
HtlcBasePoint: keychain.KeyDescriptor{
PubKey: bobKeyPub,
},
} }
bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, testHdSeed, aliceKeyPub) bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize())
bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) if err != nil {
return nil, nil, nil, nil, err
}
bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot)
bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err
} }
bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:])
aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, testHdSeed, bobKeyPub) aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize())
alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) if err != nil {
return nil, nil, nil, nil, err
}
alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot)
aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0)
if err != nil { if err != nil {
return nil, nil, nil, nil, err return nil, nil, nil, nil, err

View File

@ -319,7 +319,7 @@ func init() {
if err != nil { if err != nil {
panic(fmt.Sprintf("unable to parse pub key during init: %v", err)) panic(fmt.Sprintf("unable to parse pub key during init: %v", err))
} }
signDescriptors[i].PubKey = pk signDescriptors[i].KeyDesc.PubKey = pk
} }
for i := range kidOutputs { for i := range kidOutputs {