From 4b20e805fe8e8b2c02f7af37bf5363f0cd83db11 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 17 Feb 2018 15:29:01 -0800 Subject: [PATCH] multi: update packages due to recent SignDescriptor and WalletController changes --- breacharbiter_test.go | 61 ++++++++++++++++++------- contractcourt/chain_watcher.go | 8 ++-- fundingmanager.go | 81 ++++++++++++++++++++++------------ fundingmanager_test.go | 15 +++++-- htlcswitch/mock.go | 2 +- htlcswitch/test_utils.go | 63 ++++++++++++++++++-------- mock.go | 38 +++++++++++----- test_utils.go | 59 ++++++++++++++++++------- utxonursery_test.go | 2 +- 9 files changed, 229 insertions(+), 100 deletions(-) diff --git a/breacharbiter_test.go b/breacharbiter_test.go index 0fd093ee..6ce445db 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -20,6 +20,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/htlcswitch" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/shachain" @@ -405,7 +406,7 @@ func initBreachedOutputs() error { return fmt.Errorf("unable to parse pubkey: %v", breachKeys[i]) } - bo.signDesc.PubKey = pubkey + bo.signDesc.KeyDesc.PubKey = pubkey } return nil @@ -1272,12 +1273,22 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa MinHTLC: 0, MaxAcceptedHtlcs: uint16(rand.Int31()), }, - CsvDelay: uint16(csvTimeoutAlice), - MultiSigKey: aliceKeyPub, - RevocationBasePoint: aliceKeyPub, - PaymentBasePoint: aliceKeyPub, - DelayBasePoint: aliceKeyPub, - HtlcBasePoint: aliceKeyPub, + CsvDelay: uint16(csvTimeoutAlice), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, } bobCfg := channeldb.ChannelConfig{ ChannelConstraints: channeldb.ChannelConstraints{ @@ -1287,24 +1298,40 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa MinHTLC: 0, MaxAcceptedHtlcs: uint16(rand.Int31()), }, - CsvDelay: uint16(csvTimeoutBob), - MultiSigKey: bobKeyPub, - RevocationBasePoint: bobKeyPub, - PaymentBasePoint: bobKeyPub, - DelayBasePoint: bobKeyPub, - HtlcBasePoint: bobKeyPub, + CsvDelay: uint16(csvTimeoutBob), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, } - bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, testHdSeed, aliceKeyPub) - bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) + bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, err + } + bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, err } bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) - aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, testHdSeed, bobKeyPub) - alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) + aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, err + } + alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, err diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index 067a265b..efdeddb7 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -133,13 +133,13 @@ func newChainWatcher(chanState *channeldb.OpenChannel, var stateHint [lnwallet.StateHintSize]byte if chanState.IsInitiator { stateHint = lnwallet.DeriveStateHintObfuscator( - chanState.LocalChanCfg.PaymentBasePoint, - chanState.RemoteChanCfg.PaymentBasePoint, + chanState.LocalChanCfg.PaymentBasePoint.PubKey, + chanState.RemoteChanCfg.PaymentBasePoint.PubKey, ) } else { stateHint = lnwallet.DeriveStateHintObfuscator( - chanState.RemoteChanCfg.PaymentBasePoint, - chanState.LocalChanCfg.PaymentBasePoint, + chanState.RemoteChanCfg.PaymentBasePoint.PubKey, + chanState.LocalChanCfg.PaymentBasePoint.PubKey, ) } diff --git a/fundingmanager.go b/fundingmanager.go index 4614c18b..8762da98 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -19,6 +19,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/htlcswitch" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" @@ -940,12 +941,22 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) { MinHTLC: msg.HtlcMinimum, MaxAcceptedHtlcs: maxHtlcs, }, - CsvDelay: remoteCsvDelay, - MultiSigKey: copyPubKey(msg.FundingKey), - RevocationBasePoint: copyPubKey(msg.RevocationPoint), - PaymentBasePoint: copyPubKey(msg.PaymentPoint), - DelayBasePoint: copyPubKey(msg.DelayedPaymentPoint), - HtlcBasePoint: copyPubKey(msg.HtlcPoint), + CsvDelay: remoteCsvDelay, + MultiSigKey: keychain.KeyDescriptor{ + PubKey: copyPubKey(msg.FundingKey), + }, + RevocationBasePoint: keychain.KeyDescriptor{ + 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) @@ -974,11 +985,11 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) { HtlcMinimum: ourContribution.MinHTLC, CsvDelay: uint16(remoteCsvDelay), MaxAcceptedHTLCs: maxHtlcs, - FundingKey: ourContribution.MultiSigKey, - RevocationPoint: ourContribution.RevocationBasePoint, - PaymentPoint: ourContribution.PaymentBasePoint, - DelayedPaymentPoint: ourContribution.DelayBasePoint, - HtlcPoint: ourContribution.HtlcBasePoint, + FundingKey: ourContribution.MultiSigKey.PubKey, + RevocationPoint: ourContribution.RevocationBasePoint.PubKey, + PaymentPoint: ourContribution.PaymentBasePoint.PubKey, + DelayedPaymentPoint: ourContribution.DelayBasePoint.PubKey, + HtlcPoint: ourContribution.HtlcBasePoint.PubKey, FirstCommitmentPoint: ourContribution.FirstCommitmentPoint, } err = f.cfg.SendToPeer(fmsg.peerAddress.IdentityKey, &fundingAccept) @@ -1057,11 +1068,21 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) { MinHTLC: msg.HtlcMinimum, MaxAcceptedHtlcs: maxHtlcs, }, - MultiSigKey: copyPubKey(msg.FundingKey), - RevocationBasePoint: copyPubKey(msg.RevocationPoint), - PaymentBasePoint: copyPubKey(msg.PaymentPoint), - DelayBasePoint: copyPubKey(msg.DelayedPaymentPoint), - HtlcBasePoint: copyPubKey(msg.HtlcPoint), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: copyPubKey(msg.FundingKey), + }, + RevocationBasePoint: keychain.KeyDescriptor{ + 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) @@ -1818,10 +1839,11 @@ func (f *fundingManager) addToRouterGraph(completeChan *channeldb.OpenChannel, // will be the one that's carrying the HTLC towards us. remoteMinHTLC := completeChan.RemoteChanCfg.MinHTLC - ann, err := f.newChanAnnouncement(f.cfg.IDKey, completeChan.IdentityPub, - completeChan.LocalChanCfg.MultiSigKey, - completeChan.RemoteChanCfg.MultiSigKey, *shortChanID, chanID, - remoteMinHTLC, + ann, err := f.newChanAnnouncement( + f.cfg.IDKey, completeChan.IdentityPub, + completeChan.LocalChanCfg.MultiSigKey.PubKey, + completeChan.RemoteChanCfg.MultiSigKey.PubKey, *shortChanID, + chanID, remoteMinHTLC, ) if err != nil { 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 // public and usable for other nodes for routing. - err = f.announceChannel(f.cfg.IDKey, completeChan.IdentityPub, - completeChan.LocalChanCfg.MultiSigKey, - completeChan.RemoteChanCfg.MultiSigKey, *shortChanID, chanID, - remoteMinHTLC, + err = f.announceChannel( + f.cfg.IDKey, completeChan.IdentityPub, + completeChan.LocalChanCfg.MultiSigKey.PubKey, + completeChan.RemoteChanCfg.MultiSigKey.PubKey, + *shortChanID, chanID, remoteMinHTLC, ) if err != nil { return fmt.Errorf("channel announcement failed: %v", err) @@ -2440,11 +2463,11 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) { FeePerKiloWeight: uint32(commitFeePerKw), CsvDelay: uint16(remoteCsvDelay), MaxAcceptedHTLCs: maxHtlcs, - FundingKey: ourContribution.MultiSigKey, - RevocationPoint: ourContribution.RevocationBasePoint, - PaymentPoint: ourContribution.PaymentBasePoint, - HtlcPoint: ourContribution.HtlcBasePoint, - DelayedPaymentPoint: ourContribution.DelayBasePoint, + FundingKey: ourContribution.MultiSigKey.PubKey, + RevocationPoint: ourContribution.RevocationBasePoint.PubKey, + PaymentPoint: ourContribution.PaymentBasePoint.PubKey, + HtlcPoint: ourContribution.HtlcBasePoint.PubKey, + DelayedPaymentPoint: ourContribution.DelayBasePoint.PubKey, FirstCommitmentPoint: ourContribution.FirstCommitmentPoint, ChannelFlags: channelFlags, } diff --git a/fundingmanager_test.go b/fundingmanager_test.go index dc575074..451287ca 100644 --- a/fundingmanager_test.go +++ b/fundingmanager_test.go @@ -16,6 +16,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/contractcourt" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" @@ -150,12 +151,14 @@ func init() { func createTestWallet(cdb *channeldb.DB, netParams *chaincfg.Params, 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) { wallet, err := lnwallet.NewLightningWallet(lnwallet.Config{ Database: cdb, Notifier: notifier, + SecretKeyRing: keyRing, WalletController: wc, Signer: signer, ChainIO: bio, @@ -212,8 +215,14 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, return nil, err } - lnw, err := createTestWallet(cdb, netParams, - chainNotifier, wc, signer, bio, estimator) + keyRing := &mockSecretKeyRing{ + rootKey: alicePrivKey, + } + + lnw, err := createTestWallet( + cdb, netParams, chainNotifier, wc, signer, keyRing, bio, + estimator, + ) if err != nil { t.Fatalf("unable to create test ln wallet: %v", err) } diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 7b6e5803..d3704e95 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -557,7 +557,7 @@ func (m *mockSigner) SignOutputRaw(tx *wire.MsgTx, signDesc *lnwallet.SignDescri witnessScript := signDesc.WitnessScript privKey := m.key - if !privKey.PubKey().IsEqual(signDesc.PubKey) { + if !privKey.PubKey().IsEqual(signDesc.KeyDesc.PubKey) { return nil, fmt.Errorf("incorrect key passed") } diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 7549568d..70418fb0 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -22,6 +22,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/contractcourt" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/shachain" @@ -132,34 +133,60 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, fundingTxIn := wire.NewTxIn(prevOut, nil, nil) aliceCfg := channeldb.ChannelConfig{ - ChannelConstraints: *aliceConstraints, - CsvDelay: uint16(csvTimeoutAlice), - MultiSigKey: aliceKeyPub, - RevocationBasePoint: aliceKeyPub, - PaymentBasePoint: aliceKeyPub, - DelayBasePoint: aliceKeyPub, - HtlcBasePoint: aliceKeyPub, + ChannelConstraints: *aliceConstraints, + CsvDelay: uint16(csvTimeoutAlice), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, } bobCfg := channeldb.ChannelConfig{ - ChannelConstraints: *bobConstraints, - CsvDelay: uint16(csvTimeoutBob), - MultiSigKey: bobKeyPub, - RevocationBasePoint: bobKeyPub, - PaymentBasePoint: bobKeyPub, - DelayBasePoint: bobKeyPub, - HtlcBasePoint: bobKeyPub, + ChannelConstraints: *bobConstraints, + CsvDelay: uint16(csvTimeoutBob), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, } - bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, hash, aliceKeyPub) - bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) + bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, nil, err + } + bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, nil, err } bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) - aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, hash, bobKeyPub) - alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) + aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, nil, err + } + alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, nil, err diff --git a/mock.go b/mock.go index 39a2eba2..2e47532c 100644 --- a/mock.go +++ b/mock.go @@ -6,6 +6,7 @@ import ( "sync" "github.com/lightningnetwork/lnd/chainntnfs" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnwallet" "github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/chaincfg" @@ -28,7 +29,7 @@ func (m *mockSigner) SignOutputRaw(tx *wire.MsgTx, witnessScript := signDesc.WitnessScript privKey := m.key - if !privKey.PubKey().IsEqual(signDesc.PubKey) { + if !privKey.PubKey().IsEqual(signDesc.KeyDesc.PubKey) { return nil, fmt.Errorf("incorrect key passed") } @@ -218,16 +219,6 @@ func (*mockWalletController) GetPrivKey(a btcutil.Address) (*btcec.PrivateKey, e 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, _ lnwallet.SatPerVByte) (*chainhash.Hash, error) { @@ -272,6 +263,31 @@ func (*mockWalletController) Stop() error { 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 { sync.Mutex preimageMap map[[32]byte][]byte diff --git a/test_utils.go b/test_utils.go index 2f279c30..891afebe 100644 --- a/test_utils.go +++ b/test_utils.go @@ -11,6 +11,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/htlcswitch" + "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/shachain" @@ -79,12 +80,22 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), }, - CsvDelay: uint16(csvTimeoutAlice), - MultiSigKey: aliceKeyPub, - RevocationBasePoint: aliceKeyPub, - PaymentBasePoint: aliceKeyPub, - DelayBasePoint: aliceKeyPub, - HtlcBasePoint: aliceKeyPub, + CsvDelay: uint16(csvTimeoutAlice), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: aliceKeyPub, + }, } bobCfg := channeldb.ChannelConfig{ ChannelConstraints: channeldb.ChannelConstraints{ @@ -94,24 +105,40 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), }, - CsvDelay: uint16(csvTimeoutBob), - MultiSigKey: bobKeyPub, - RevocationBasePoint: bobKeyPub, - PaymentBasePoint: bobKeyPub, - DelayBasePoint: bobKeyPub, - HtlcBasePoint: bobKeyPub, + CsvDelay: uint16(csvTimeoutBob), + MultiSigKey: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + RevocationBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + PaymentBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + DelayBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, + HtlcBasePoint: keychain.KeyDescriptor{ + PubKey: bobKeyPub, + }, } - bobRoot := lnwallet.DeriveRevocationRoot(bobKeyPriv, testHdSeed, aliceKeyPub) - bobPreimageProducer := shachain.NewRevocationProducer(bobRoot) + bobRoot, err := chainhash.NewHash(bobKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, nil, err + } + bobPreimageProducer := shachain.NewRevocationProducer(*bobRoot) bobFirstRevoke, err := bobPreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, nil, err } bobCommitPoint := lnwallet.ComputeCommitmentPoint(bobFirstRevoke[:]) - aliceRoot := lnwallet.DeriveRevocationRoot(aliceKeyPriv, testHdSeed, bobKeyPub) - alicePreimageProducer := shachain.NewRevocationProducer(aliceRoot) + aliceRoot, err := chainhash.NewHash(aliceKeyPriv.Serialize()) + if err != nil { + return nil, nil, nil, nil, err + } + alicePreimageProducer := shachain.NewRevocationProducer(*aliceRoot) aliceFirstRevoke, err := alicePreimageProducer.AtIndex(0) if err != nil { return nil, nil, nil, nil, err diff --git a/utxonursery_test.go b/utxonursery_test.go index 3727e0ce..e950aed1 100644 --- a/utxonursery_test.go +++ b/utxonursery_test.go @@ -319,7 +319,7 @@ func init() { if err != nil { 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 {