contractcourt: extract which timeout HTLC output to watch into new method
This commit is contained in:
2 files changed
+38
-27
No files matched your search
@@ -148,6 +148,39 @@ func (h *htlcTimeoutResolver) claimCleanUp(commitSpend *chainntnfs.SpendDetail)
|
||||
h.resolved = true
|
||||
return nil, h.Checkpoint(h)
|
||||
}
|
||||
|
||||
// chainDetailsToWatch returns the output and script which we use to watch for
|
||||
// spends from the direct HTLC output on the commitment transaction.
|
||||
//
|
||||
// TODO(joostjager): output already set properly in
|
||||
// lnwallet.newOutgoingHtlcResolution? And script too?
|
||||
func (h *htlcTimeoutResolver) chainDetailsToWatch() (*wire.OutPoint, []byte, error) {
|
||||
// If there's no timeout transaction, then the claim output is the
|
||||
// output directly on the commitment transaction, so we'll just use
|
||||
// that.
|
||||
if h.htlcResolution.SignedTimeoutTx == nil {
|
||||
outPointToWatch := h.htlcResolution.ClaimOutpoint
|
||||
scriptToWatch := h.htlcResolution.SweepSignDesc.Output.PkScript
|
||||
|
||||
return &outPointToWatch, scriptToWatch, nil
|
||||
}
|
||||
|
||||
// If this is the remote party's commitment, then we'll need to grab
|
||||
// watch the output that our timeout transaction points to. We can
|
||||
// directly grab the outpoint, then also extract the witness script
|
||||
// (the last element of the witness stack) to re-construct the pkScript
|
||||
// we need to watch.
|
||||
outPointToWatch := h.htlcResolution.SignedTimeoutTx.TxIn[0].PreviousOutPoint
|
||||
witness := h.htlcResolution.SignedTimeoutTx.TxIn[0].Witness
|
||||
scriptToWatch, err := input.WitnessScriptHash(
|
||||
witness[len(witness)-1],
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return &outPointToWatch, scriptToWatch, nil
|
||||
}
|
||||
// Resolve kicks off full resolution of an outgoing HTLC output. If it's our
|
||||
// commitment, it isn't resolved until we see the second level HTLC txn
|
||||
// confirmed. If it's the remote party's commitment, we don't resolve until we
|
||||
|
||||
Reference in new issue
Block a user