From 2d421b8e3c1ff9ed45d6380a4ac1603bac0b19d7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 30 May 2018 22:16:57 -0700 Subject: [PATCH] breacharbiter: update breachArbiter to register for conf's using pkScripts --- breacharbiter.go | 14 ++++++++++---- breacharbiter_test.go | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/breacharbiter.go b/breacharbiter.go index 4d31ca36..950fc497 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -196,8 +196,10 @@ func (b *breachArbiter) Start() error { // Register for a notification when the breach transaction is // confirmed on chain. breachTXID := retInfo.commitHash + breachScript := retInfo.breachedOutputs[0].signDesc.Output.PkScript confChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn( - &breachTXID, 1, retInfo.breachHeight) + &breachTXID, breachScript, 1, retInfo.breachHeight, + ) if err != nil { brarLog.Errorf("unable to register for conf updates "+ "for txid: %v, err: %v", breachTXID, err) @@ -556,8 +558,10 @@ justiceTxBroadcast: // notify the caller that initiated the retribution workflow that the // deed has been done. justiceTXID := finalTx.TxHash() + justiceScript := finalTx.TxOut[0].PkScript confChan, err = b.cfg.Notifier.RegisterConfirmationsNtfn( - &justiceTXID, 1, breachConfHeight) + &justiceTXID, justiceScript, 1, breachConfHeight, + ) if err != nil { brarLog.Errorf("unable to register for conf for txid(%v): %v", justiceTXID, err) @@ -720,8 +724,10 @@ func (b *breachArbiter) handleBreachHandoff(breachEvent *ContractBreachEvent) { // confirmed in the chain to ensure we're not dealing with a moving // target. breachTXID := &retInfo.commitHash - cfChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn(breachTXID, 1, - retInfo.breachHeight) + breachScript := retInfo.breachedOutputs[0].signDesc.Output.PkScript + cfChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn( + breachTXID, breachScript, 1, retInfo.breachHeight, + ) if err != nil { brarLog.Errorf("unable to register for conf updates for "+ "txid: %v, err: %v", breachTXID, err) diff --git a/breacharbiter_test.go b/breacharbiter_test.go index 6c13d668..85d10fe9 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -1012,6 +1012,11 @@ func TestBreachHandoffSuccess(t *testing.T) { ProcessACK: make(chan error, 1), BreachRetribution: &lnwallet.BreachRetribution{ BreachTransaction: bobClose.CloseTx, + LocalOutputSignDesc: &lnwallet.SignDescriptor{ + Output: &wire.TxOut{ + PkScript: breachKeys[0], + }, + }, }, } contractBreaches <- breach @@ -1039,6 +1044,11 @@ func TestBreachHandoffSuccess(t *testing.T) { ProcessACK: make(chan error, 1), BreachRetribution: &lnwallet.BreachRetribution{ BreachTransaction: bobClose.CloseTx, + LocalOutputSignDesc: &lnwallet.SignDescriptor{ + Output: &wire.TxOut{ + PkScript: breachKeys[0], + }, + }, }, } @@ -1083,6 +1093,11 @@ func TestBreachHandoffFail(t *testing.T) { ProcessACK: make(chan error, 1), BreachRetribution: &lnwallet.BreachRetribution{ BreachTransaction: bobClose.CloseTx, + LocalOutputSignDesc: &lnwallet.SignDescriptor{ + Output: &wire.TxOut{ + PkScript: breachKeys[0], + }, + }, }, } contractBreaches <- breach @@ -1130,6 +1145,11 @@ func TestBreachHandoffFail(t *testing.T) { ProcessACK: make(chan error, 1), BreachRetribution: &lnwallet.BreachRetribution{ BreachTransaction: bobClose.CloseTx, + LocalOutputSignDesc: &lnwallet.SignDescriptor{ + Output: &wire.TxOut{ + PkScript: breachKeys[0], + }, + }, }, }