contractcourt: update conf ntfn registartions to use pkScript not txid

This commit is contained in:
Olaoluwa Osuntokun 2018-05-30 22:07:54 -07:00
parent 21847dc691
commit c707577e99
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
3 changed files with 12 additions and 8 deletions

@ -5,13 +5,13 @@ import (
"sync"
"sync/atomic"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
)
// ResolutionMsg is a message sent by resolvers to outside sub-systems once an

@ -17,7 +17,7 @@ type mockNotifier struct {
spendChan chan *chainntnfs.SpendDetail
}
func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, numConfs,
func (m *mockNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, numConfs,
heightHint uint32) (*chainntnfs.ConfirmationEvent, error) {
return nil, nil
}

@ -211,8 +211,9 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
// Otherwise, this is our commitment, so we'll watch for the
// second-level transaction to be sufficiently confirmed.
secondLevelTXID := h.htlcResolution.SignedTimeoutTx.TxHash()
sweepScript := h.htlcResolution.SignedTimeoutTx.TxOut[0].PkScript
confNtfn, err := h.Notifier.RegisterConfirmationsNtfn(
&secondLevelTXID, 1, h.broadcastHeight,
&secondLevelTXID, sweepScript, 1, h.broadcastHeight,
)
if err != nil {
return nil, err
@ -521,8 +522,9 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
// With the sweep transaction broadcast, we'll wait for its
// confirmation.
sweepTXID := h.sweepTx.TxHash()
sweepScript := h.sweepTx.TxOut[0].PkScript
confNtfn, err := h.Notifier.RegisterConfirmationsNtfn(
&sweepTXID, 1, h.broadcastHeight,
&sweepTXID, sweepScript, 1, h.broadcastHeight,
)
if err != nil {
return nil, err
@ -1193,8 +1195,9 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
//
// TODO(roasbeef): instead sweep asap if remote commit? yeh
commitTXID := c.commitResolution.SelfOutPoint.Hash
sweepScript := c.commitResolution.SelfOutputSignDesc.Output.PkScript
confNtfn, err := c.Notifier.RegisterConfirmationsNtfn(
&commitTXID, 1, c.broadcastHeight,
&commitTXID, sweepScript, 1, c.broadcastHeight,
)
if err != nil {
return nil, err
@ -1329,8 +1332,9 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
// Now we'll wait until the sweeping transaction has been fully
// confirmed. Once it's confirmed, we can mark this contract resolved.
sweepTXID := c.sweepTx.TxHash()
sweepingScript := c.sweepTx.TxOut[0].PkScript
confNtfn, err = c.Notifier.RegisterConfirmationsNtfn(
&sweepTXID, 1, c.broadcastHeight,
&sweepTXID, sweepingScript, 1, c.broadcastHeight,
)
if err != nil {
return nil, err