cnct/contract_resolvers: reliably publish commit sweep
This commit is contained in:
parent
1b0d8e8f13
commit
b7aebd92cf
@ -1258,18 +1258,33 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
|
|||||||
log.Infof("%T(%v): sweeping commit output with tx=%v", c,
|
log.Infof("%T(%v): sweeping commit output with tx=%v", c,
|
||||||
c.chanPoint, spew.Sdump(c.sweepTx))
|
c.chanPoint, spew.Sdump(c.sweepTx))
|
||||||
|
|
||||||
// Finally, we'll broadcast the sweep transaction to the
|
// With the sweep transaction constructed, we'll now Checkpoint
|
||||||
// network.
|
// our state.
|
||||||
if err := c.PublishTx(c.sweepTx); err != nil {
|
if err := c.Checkpoint(c); err != nil {
|
||||||
|
log.Errorf("unable to Checkpoint: %v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// With the sweep transaction checkpointed, we'll now publish
|
||||||
|
// the transaction. Upon restart, the resolver will immediately
|
||||||
|
// take the case below since the sweep tx is checkpointed.
|
||||||
|
err := c.PublishTx(c.sweepTx)
|
||||||
|
if err != nil && err != lnwallet.ErrDoubleSpend {
|
||||||
log.Errorf("%T(%v): unable to publish sweep tx: %v",
|
log.Errorf("%T(%v): unable to publish sweep tx: %v",
|
||||||
c, c.chanPoint, err)
|
c, c.chanPoint, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// With the sweep transaction confirmed, we'll now Checkpoint
|
// If the sweep transaction has been generated, and the remote party
|
||||||
// our state.
|
// broadcast the commit transaction, we'll republish it for reliability
|
||||||
if err := c.Checkpoint(c); err != nil {
|
// to ensure it confirms. The resolver will enter this case after
|
||||||
log.Errorf("unable to Checkpoint: %v", err)
|
// checkpointing in the case above, ensuring we reliably on restarts.
|
||||||
|
case c.sweepTx != nil && !isLocalCommitTx:
|
||||||
|
err := c.PublishTx(c.sweepTx)
|
||||||
|
if err != nil && err != lnwallet.ErrDoubleSpend {
|
||||||
|
log.Errorf("%T(%v): unable to publish sweep tx: %v",
|
||||||
|
c, c.chanPoint, err)
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, this is our commitment transaction, So we'll obtain the
|
// Otherwise, this is our commitment transaction, So we'll obtain the
|
||||||
|
Loading…
Reference in New Issue
Block a user