breacharbiter: update breachArbiter to register for conf's using pkScripts

This commit is contained in:
Olaoluwa Osuntokun 2018-05-30 22:16:57 -07:00
parent 8aef43360f
commit 2d421b8e3c
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
2 changed files with 30 additions and 4 deletions

@ -196,8 +196,10 @@ func (b *breachArbiter) Start() error {
// Register for a notification when the breach transaction is // Register for a notification when the breach transaction is
// confirmed on chain. // confirmed on chain.
breachTXID := retInfo.commitHash breachTXID := retInfo.commitHash
breachScript := retInfo.breachedOutputs[0].signDesc.Output.PkScript
confChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn( confChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn(
&breachTXID, 1, retInfo.breachHeight) &breachTXID, breachScript, 1, retInfo.breachHeight,
)
if err != nil { if err != nil {
brarLog.Errorf("unable to register for conf updates "+ brarLog.Errorf("unable to register for conf updates "+
"for txid: %v, err: %v", breachTXID, err) "for txid: %v, err: %v", breachTXID, err)
@ -556,8 +558,10 @@ justiceTxBroadcast:
// notify the caller that initiated the retribution workflow that the // notify the caller that initiated the retribution workflow that the
// deed has been done. // deed has been done.
justiceTXID := finalTx.TxHash() justiceTXID := finalTx.TxHash()
justiceScript := finalTx.TxOut[0].PkScript
confChan, err = b.cfg.Notifier.RegisterConfirmationsNtfn( confChan, err = b.cfg.Notifier.RegisterConfirmationsNtfn(
&justiceTXID, 1, breachConfHeight) &justiceTXID, justiceScript, 1, breachConfHeight,
)
if err != nil { if err != nil {
brarLog.Errorf("unable to register for conf for txid(%v): %v", brarLog.Errorf("unable to register for conf for txid(%v): %v",
justiceTXID, err) 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 // confirmed in the chain to ensure we're not dealing with a moving
// target. // target.
breachTXID := &retInfo.commitHash breachTXID := &retInfo.commitHash
cfChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn(breachTXID, 1, breachScript := retInfo.breachedOutputs[0].signDesc.Output.PkScript
retInfo.breachHeight) cfChan, err := b.cfg.Notifier.RegisterConfirmationsNtfn(
breachTXID, breachScript, 1, retInfo.breachHeight,
)
if err != nil { if err != nil {
brarLog.Errorf("unable to register for conf updates for "+ brarLog.Errorf("unable to register for conf updates for "+
"txid: %v, err: %v", breachTXID, err) "txid: %v, err: %v", breachTXID, err)

@ -1012,6 +1012,11 @@ func TestBreachHandoffSuccess(t *testing.T) {
ProcessACK: make(chan error, 1), ProcessACK: make(chan error, 1),
BreachRetribution: &lnwallet.BreachRetribution{ BreachRetribution: &lnwallet.BreachRetribution{
BreachTransaction: bobClose.CloseTx, BreachTransaction: bobClose.CloseTx,
LocalOutputSignDesc: &lnwallet.SignDescriptor{
Output: &wire.TxOut{
PkScript: breachKeys[0],
},
},
}, },
} }
contractBreaches <- breach contractBreaches <- breach
@ -1039,6 +1044,11 @@ func TestBreachHandoffSuccess(t *testing.T) {
ProcessACK: make(chan error, 1), ProcessACK: make(chan error, 1),
BreachRetribution: &lnwallet.BreachRetribution{ BreachRetribution: &lnwallet.BreachRetribution{
BreachTransaction: bobClose.CloseTx, 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), ProcessACK: make(chan error, 1),
BreachRetribution: &lnwallet.BreachRetribution{ BreachRetribution: &lnwallet.BreachRetribution{
BreachTransaction: bobClose.CloseTx, BreachTransaction: bobClose.CloseTx,
LocalOutputSignDesc: &lnwallet.SignDescriptor{
Output: &wire.TxOut{
PkScript: breachKeys[0],
},
},
}, },
} }
contractBreaches <- breach contractBreaches <- breach
@ -1130,6 +1145,11 @@ func TestBreachHandoffFail(t *testing.T) {
ProcessACK: make(chan error, 1), ProcessACK: make(chan error, 1),
BreachRetribution: &lnwallet.BreachRetribution{ BreachRetribution: &lnwallet.BreachRetribution{
BreachTransaction: bobClose.CloseTx, BreachTransaction: bobClose.CloseTx,
LocalOutputSignDesc: &lnwallet.SignDescriptor{
Output: &wire.TxOut{
PkScript: breachKeys[0],
},
},
}, },
} }