From 7888c6e04077ba7256d0be4b5adf880b6966a7f0 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Sun, 1 Oct 2017 20:54:23 -0700 Subject: [PATCH] lnwallet/witnessgen: add HtlcOfferedTimeLock witness type --- lnwallet/witnessgen.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lnwallet/witnessgen.go b/lnwallet/witnessgen.go index 434bff4e7..c48b7f900 100644 --- a/lnwallet/witnessgen.go +++ b/lnwallet/witnessgen.go @@ -13,17 +13,18 @@ import ( type WitnessType uint16 const ( - // CommitmentTimeLock is a witness that allows us to spend the output of a - // commitment transaction after a relative lock-time lockout. + // CommitmentTimeLock is a witness that allows us to spend the output of + // a commitment transaction after a relative lock-time lockout. CommitmentTimeLock WitnessType = 0 - // CommitmentNoDelay is a witness that allows us to spend a settled no-delay - // output immediately on a counterparty's commitment transaction. + // CommitmentNoDelay is a witness that allows us to spend a settled + // no-delay output immediately on a counterparty's commitment + // transaction. CommitmentNoDelay WitnessType = 1 - // CommitmentRevoke is a witness that allows us to sweep the settled output - // of a malicious counterparty's who broadcasts a revoked commitment - // transaction. + // CommitmentRevoke is a witness that allows us to sweep the settled + // output of a malicious counterparty's who broadcasts a revoked + // commitment transaction. CommitmentRevoke WitnessType = 2 // HtlcOfferedRevoke is a witness that allows us to sweep an HTLC @@ -33,6 +34,15 @@ const ( // HtlcAcceptedRevoke is a witness that allows us to sweep an HTLC // output that we accepted from the counterparty. HtlcAcceptedRevoke WitnessType = 4 + + // HtlcOfferedTimeout is a witness that allows us to sweep an HTLC + // output that we extended to a party, but was never fulfilled. + HtlcOfferedTimeout WitnessType = 5 + + // HtlcAcceptedSuccess is a witness that allows us to sweep an HTLC + // output that was offered to us, and for which we have a payment + // preimage. + HtlcAcceptedSuccess WitnessType = 6 ) // WitnessGenerator represents a function which is able to generate the final @@ -64,6 +74,8 @@ func (wt WitnessType) GenWitnessFunc(signer Signer, return ReceiverHtlcSpendRevoke(signer, desc, tx) case HtlcAcceptedRevoke: return SenderHtlcSpendRevoke(signer, desc, tx) + case HtlcOfferedTimeout: + return HtlcSpendSuccess(signer, desc, tx) default: return nil, fmt.Errorf("unknown witness type: %v", wt) }