contractcourt: update chain watcher to make funding pkScript for spend ntfn

This commit is contained in:
Olaoluwa Osuntokun 2018-07-17 19:42:17 -07:00
parent ac9f9bd061
commit 08e11d197d
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 17 additions and 4 deletions

@ -173,8 +173,21 @@ func (c *chainWatcher) Start() error {
heightHint = chanState.FundingBroadcastHeight heightHint = chanState.FundingBroadcastHeight
} }
localKey := chanState.LocalChanCfg.MultiSigKey.PubKey.SerializeCompressed()
remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey.SerializeCompressed()
multiSigScript, err := lnwallet.GenMultiSigScript(
localKey, remoteKey,
)
if err != nil {
return err
}
pkScript, err := lnwallet.WitnessScriptHash(multiSigScript)
if err != nil {
return err
}
spendNtfn, err := c.cfg.notifier.RegisterSpendNtfn( spendNtfn, err := c.cfg.notifier.RegisterSpendNtfn(
fundingOut, heightHint, fundingOut, pkScript, heightHint,
) )
if err != nil { if err != nil {
return err return err

@ -6,11 +6,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
) )
type mockNotifier struct { type mockNotifier struct {
@ -35,7 +35,7 @@ func (m *mockNotifier) Start() error {
func (m *mockNotifier) Stop() error { func (m *mockNotifier) Stop() error {
return nil return nil
} }
func (m *mockNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, func (m *mockNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, _ []byte,
heightHint uint32) (*chainntnfs.SpendEvent, error) { heightHint uint32) (*chainntnfs.SpendEvent, error) {
return &chainntnfs.SpendEvent{ return &chainntnfs.SpendEvent{
Spend: m.spendChan, Spend: m.spendChan,