input: add CommitmentToRemoteConfirmed witness type

This commit is contained in:
Johan T. Halseth committed 2020-03-09 12:10:59 +01:00
1 parent 990992ce94
commit 6deb913a8d
2 files changed
+43 -2

No files matched your search

+27 -2
View File
@@ -48,8 +48,9 @@ type StandardWitnessType uint16
var _ WitnessType = (StandardWitnessType)(0)
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 our output
// on our local commitment transaction after a relative lock-time
// lockout.
CommitmentTimeLock StandardWitnessType = 0
// CommitmentNoDelay is a witness that allows us to spend a settled
@@ -119,6 +120,11 @@ const (
// type, but it omits the tweak that randomizes the key we need to
// spend with a channel peer supplied set of randomness.
CommitSpendNoDelayTweakless StandardWitnessType = 12
// CommitmentToRemoteConfirmed is a witness that allows us to spend our
// output on the counterparty's commitment transaction after a
// confirmation.
CommitmentToRemoteConfirmed StandardWitnessType = 13
)
// String returns a human readable version of the target WitnessType.
@@ -129,6 +135,9 @@ func (wt StandardWitnessType) String() string {
case CommitmentTimeLock:
return "CommitmentTimeLock"
case CommitmentToRemoteConfirmed:
return "CommitmentToRemoteConfirmed"
case CommitmentNoDelay:
return "CommitmentNoDelay"
@@ -197,6 +206,18 @@ func (wt StandardWitnessType) WitnessGenerator(signer Signer,
Witness: witness,
}, nil
case CommitmentToRemoteConfirmed:
witness, err := CommitSpendToRemoteConfirmed(
signer, desc, tx,
)
if err != nil {
return nil, err
}
return &Script{
Witness: witness,
}, nil
case CommitmentNoDelay:
witness, err := CommitSpendNoDelay(signer, desc, tx, false)
if err != nil {
@@ -323,6 +344,10 @@ func (wt StandardWitnessType) SizeUpperBound() (int, bool, error) {
case CommitmentTimeLock:
return ToLocalTimeoutWitnessSize, false, nil
// 1 CSV time locked output to us on remote commitment.
case CommitmentToRemoteConfirmed:
return ToRemoteConfirmedWitnessSize, false, nil
// Outgoing second layer HTLC's that have confirmed within the
// chain, and the output they produced is now mature enough to
// sweep.