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

View File

@ -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)

View File

@ -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],
},
},
},
}