Skip to content

Commit

Permalink
Merge pull request #8431 from ziggie1984/unhandled-witness-type-taproot
Browse files Browse the repository at this point in the history
walletrpc: Add Taproot witness types to rpc.
  • Loading branch information
yyforyongyu authored Jan 30, 2024
2 parents dd7b186 + 13e20e9 commit c89005c
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 151 deletions.
3 changes: 3 additions & 0 deletions docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@

* The AMP struct in payment hops will [now be populated](https://github.com/lightningnetwork/lnd/pull/7976) when the AMP TLV is set.

* [Add Taproot witness types
to rpc](https://github.com/lightningnetwork/lnd/pull/8431)

# New Features
## Functional Enhancements

Expand Down
388 changes: 245 additions & 143 deletions lnrpc/walletrpc/walletkit.pb.go

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions lnrpc/walletrpc/walletkit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,91 @@ enum WitnessType {
to an output which is under complete control of the backing wallet.
*/
TAPROOT_PUB_KEY_SPEND = 22;

/*
A witness type that allows us to spend our settled local commitment after a
CSV delay when we force close the channel.
*/
TAPROOT_LOCAL_COMMIT_SPEND = 23;

/*
A witness type that allows us to spend our settled local commitment after
a CSV delay when the remote party has force closed the channel.
*/
TAPROOT_REMOTE_COMMIT_SPEND = 24;

/*
A witness type that we'll use for spending our own anchor output.
*/
TAPROOT_ANCHOR_SWEEP_SPEND = 25;

/*
A witness that allows us to timeout an HTLC we offered to the remote party
on our commitment transaction. We use this when we need to go on chain to
time out an HTLC.
*/
TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL = 26;

/*
A witness type that allows us to sweep an HTLC we accepted on our commitment
transaction after we go to the second level on chain.
*/
TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL = 27;

/*
A witness that allows us to sweep an HTLC on the revoked transaction of the
remote party that goes to the second level.
*/
TAPROOT_HTLC_SECOND_LEVEL_REVOKE = 28;

/*
A witness that allows us to sweep an HTLC sent to us by the remote party
in the event that they broadcast a revoked state.
*/
TAPROOT_HTLC_ACCEPTED_REVOKE = 29;

/*
A witness that allows us to sweep an HTLC we offered to the remote party if
they broadcast a revoked commitment.
*/
TAPROOT_HTLC_OFFERED_REVOKE = 30;

/*
A witness that allows us to sweep an HTLC we offered to the remote party
that lies on the commitment transaction for the remote party. We can spend
this output after the absolute CLTV timeout of the HTLC as passed.
*/
TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT = 31;

/*
A witness type that allows us to sign the second level HTLC timeout
transaction when spending from an HTLC residing on our local commitment
transaction.
This is used by the sweeper to re-sign inputs if it needs to aggregate
several second level HTLCs.
*/
TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT = 32;

/*
A witness that allows us to sweep an HTLC that was offered to us by the
remote party for a taproot channels. We use this witness in the case that
the remote party goes to chain, and we know the pre-image to the HTLC. We
can sweep this without any additional timeout.
*/
TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS = 33;

/*
A witness type that allows us to sweep the HTLC offered to us on our local
commitment transaction. We'll use this when we need to go on chain to sweep
the HTLC. In this case, this is the second level HTLC success transaction.
*/
TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS = 34;

/*
A witness that allows us to sweep the settled output of a malicious
counterparty's who broadcasts a revoked taproot commitment transaction.
*/
TAPROOT_COMMITMENT_REVOKE = 35;
}

message PendingSweep {
Expand Down
17 changes: 15 additions & 2 deletions lnrpc/walletrpc/walletkit.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2094,10 +2094,23 @@
"LEASE_COMMITMENT_TO_REMOTE_CONFIRMED",
"LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL",
"LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL",
"TAPROOT_PUB_KEY_SPEND"
"TAPROOT_PUB_KEY_SPEND",
"TAPROOT_LOCAL_COMMIT_SPEND",
"TAPROOT_REMOTE_COMMIT_SPEND",
"TAPROOT_ANCHOR_SWEEP_SPEND",
"TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL",
"TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL",
"TAPROOT_HTLC_SECOND_LEVEL_REVOKE",
"TAPROOT_HTLC_ACCEPTED_REVOKE",
"TAPROOT_HTLC_OFFERED_REVOKE",
"TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT",
"TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT",
"TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS",
"TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS",
"TAPROOT_COMMITMENT_REVOKE"
],
"default": "UNKNOWN_WITNESS",
"description": " - COMMITMENT_TIME_LOCK: A witness that allows us to spend the output of a commitment transaction\nafter a relative lock-time lockout.\n - COMMITMENT_NO_DELAY: A witness that allows us to spend a settled no-delay output immediately on a\ncounterparty's commitment transaction.\n - COMMITMENT_REVOKE: A witness that allows us to sweep the settled output of a malicious\ncounterparty's who broadcasts a revoked commitment transaction.\n - HTLC_OFFERED_REVOKE: A witness that allows us to sweep an HTLC which we offered to the remote\nparty in the case that they broadcast a revoked commitment state.\n - HTLC_ACCEPTED_REVOKE: A witness that allows us to sweep an HTLC output sent to us in the case that\nthe remote party broadcasts a revoked commitment state.\n - HTLC_OFFERED_TIMEOUT_SECOND_LEVEL: A witness that allows us to sweep an HTLC output that we extended to a\nparty, but was never fulfilled. This HTLC output isn't directly on the\ncommitment transaction, but is the result of a confirmed second-level HTLC\ntransaction. As a result, we can only spend this after a CSV delay.\n - HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL: A witness that allows us to sweep an HTLC output that was offered to us, and\nfor which we have a payment preimage. This HTLC output isn't directly on our\ncommitment transaction, but is the result of confirmed second-level HTLC\ntransaction. As a result, we can only spend this after a CSV delay.\n - HTLC_OFFERED_REMOTE_TIMEOUT: A witness that allows us to sweep an HTLC that we offered to the remote\nparty which lies in the commitment transaction of the remote party. We can\nspend this output after the absolute CLTV timeout of the HTLC as passed.\n - HTLC_ACCEPTED_REMOTE_SUCCESS: A witness that allows us to sweep an HTLC that was offered to us by the\nremote party. We use this witness in the case that the remote party goes to\nchain, and we know the pre-image to the HTLC. We can sweep this without any\nadditional timeout.\n - HTLC_SECOND_LEVEL_REVOKE: A witness that allows us to sweep an HTLC from the remote party's commitment\ntransaction in the case that the broadcast a revoked commitment, but then\nalso immediately attempt to go to the second level to claim the HTLC.\n - WITNESS_KEY_HASH: A witness type that allows us to spend a regular p2wkh output that's sent to\nan output which is under complete control of the backing wallet.\n - NESTED_WITNESS_KEY_HASH: A witness type that allows us to sweep an output that sends to a nested P2SH\nscript that pays to a key solely under our control.\n - COMMITMENT_ANCHOR: A witness type that allows us to spend our anchor on the commitment\ntransaction.\n - COMMITMENT_NO_DELAY_TWEAKLESS: A witness type that is similar to the COMMITMENT_NO_DELAY type,\nbut it omits the tweak that randomizes the key we need to\nspend with a channel peer supplied set of randomness.\n - COMMITMENT_TO_REMOTE_CONFIRMED: A witness type that allows us to spend our output on the counterparty's\ncommitment transaction after a confirmation.\n - HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED: A witness type that allows us to sweep an HTLC output that we extended\nto a party, but was never fulfilled. This _is_ the HTLC output directly\non our commitment transaction, and the input to the second-level HTLC\ntimeout transaction. It can only be spent after CLTV expiry, and\ncommitment confirmation.\n - HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED: A witness type that allows us to sweep an HTLC output that was offered\nto us, and for which we have a payment preimage. This _is_ the HTLC\noutput directly on our commitment transaction, and the input to the\nsecond-level HTLC success transaction. It can only be spent after the\ncommitment has confirmed.\n - LEASE_COMMITMENT_TIME_LOCK: A witness type that allows us to spend our output on our local\ncommitment transaction after a relative and absolute lock-time lockout as\npart of the script enforced lease commitment type.\n - LEASE_COMMITMENT_TO_REMOTE_CONFIRMED: A witness type that allows us to spend our output on the counterparty's\ncommitment transaction after a confirmation and absolute locktime as part\nof the script enforced lease commitment type.\n - LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL: A witness type that allows us to sweep an HTLC output that we extended\nto a party, but was never fulfilled. This HTLC output isn't directly on\nthe commitment transaction, but is the result of a confirmed second-level\nHTLC transaction. As a result, we can only spend this after a CSV delay\nand CLTV locktime as part of the script enforced lease commitment type.\n - LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL: A witness type that allows us to sweep an HTLC output that was offered\nto us, and for which we have a payment preimage. This HTLC output isn't\ndirectly on our commitment transaction, but is the result of confirmed\nsecond-level HTLC transaction. As a result, we can only spend this after\na CSV delay and CLTV locktime as part of the script enforced lease\ncommitment type.\n - TAPROOT_PUB_KEY_SPEND: A witness type that allows us to spend a regular p2tr output that's sent\nto an output which is under complete control of the backing wallet."
"description": " - COMMITMENT_TIME_LOCK: A witness that allows us to spend the output of a commitment transaction\nafter a relative lock-time lockout.\n - COMMITMENT_NO_DELAY: A witness that allows us to spend a settled no-delay output immediately on a\ncounterparty's commitment transaction.\n - COMMITMENT_REVOKE: A witness that allows us to sweep the settled output of a malicious\ncounterparty's who broadcasts a revoked commitment transaction.\n - HTLC_OFFERED_REVOKE: A witness that allows us to sweep an HTLC which we offered to the remote\nparty in the case that they broadcast a revoked commitment state.\n - HTLC_ACCEPTED_REVOKE: A witness that allows us to sweep an HTLC output sent to us in the case that\nthe remote party broadcasts a revoked commitment state.\n - HTLC_OFFERED_TIMEOUT_SECOND_LEVEL: A witness that allows us to sweep an HTLC output that we extended to a\nparty, but was never fulfilled. This HTLC output isn't directly on the\ncommitment transaction, but is the result of a confirmed second-level HTLC\ntransaction. As a result, we can only spend this after a CSV delay.\n - HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL: A witness that allows us to sweep an HTLC output that was offered to us, and\nfor which we have a payment preimage. This HTLC output isn't directly on our\ncommitment transaction, but is the result of confirmed second-level HTLC\ntransaction. As a result, we can only spend this after a CSV delay.\n - HTLC_OFFERED_REMOTE_TIMEOUT: A witness that allows us to sweep an HTLC that we offered to the remote\nparty which lies in the commitment transaction of the remote party. We can\nspend this output after the absolute CLTV timeout of the HTLC as passed.\n - HTLC_ACCEPTED_REMOTE_SUCCESS: A witness that allows us to sweep an HTLC that was offered to us by the\nremote party. We use this witness in the case that the remote party goes to\nchain, and we know the pre-image to the HTLC. We can sweep this without any\nadditional timeout.\n - HTLC_SECOND_LEVEL_REVOKE: A witness that allows us to sweep an HTLC from the remote party's commitment\ntransaction in the case that the broadcast a revoked commitment, but then\nalso immediately attempt to go to the second level to claim the HTLC.\n - WITNESS_KEY_HASH: A witness type that allows us to spend a regular p2wkh output that's sent to\nan output which is under complete control of the backing wallet.\n - NESTED_WITNESS_KEY_HASH: A witness type that allows us to sweep an output that sends to a nested P2SH\nscript that pays to a key solely under our control.\n - COMMITMENT_ANCHOR: A witness type that allows us to spend our anchor on the commitment\ntransaction.\n - COMMITMENT_NO_DELAY_TWEAKLESS: A witness type that is similar to the COMMITMENT_NO_DELAY type,\nbut it omits the tweak that randomizes the key we need to\nspend with a channel peer supplied set of randomness.\n - COMMITMENT_TO_REMOTE_CONFIRMED: A witness type that allows us to spend our output on the counterparty's\ncommitment transaction after a confirmation.\n - HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED: A witness type that allows us to sweep an HTLC output that we extended\nto a party, but was never fulfilled. This _is_ the HTLC output directly\non our commitment transaction, and the input to the second-level HTLC\ntimeout transaction. It can only be spent after CLTV expiry, and\ncommitment confirmation.\n - HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED: A witness type that allows us to sweep an HTLC output that was offered\nto us, and for which we have a payment preimage. This _is_ the HTLC\noutput directly on our commitment transaction, and the input to the\nsecond-level HTLC success transaction. It can only be spent after the\ncommitment has confirmed.\n - LEASE_COMMITMENT_TIME_LOCK: A witness type that allows us to spend our output on our local\ncommitment transaction after a relative and absolute lock-time lockout as\npart of the script enforced lease commitment type.\n - LEASE_COMMITMENT_TO_REMOTE_CONFIRMED: A witness type that allows us to spend our output on the counterparty's\ncommitment transaction after a confirmation and absolute locktime as part\nof the script enforced lease commitment type.\n - LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL: A witness type that allows us to sweep an HTLC output that we extended\nto a party, but was never fulfilled. This HTLC output isn't directly on\nthe commitment transaction, but is the result of a confirmed second-level\nHTLC transaction. As a result, we can only spend this after a CSV delay\nand CLTV locktime as part of the script enforced lease commitment type.\n - LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL: A witness type that allows us to sweep an HTLC output that was offered\nto us, and for which we have a payment preimage. This HTLC output isn't\ndirectly on our commitment transaction, but is the result of confirmed\nsecond-level HTLC transaction. As a result, we can only spend this after\na CSV delay and CLTV locktime as part of the script enforced lease\ncommitment type.\n - TAPROOT_PUB_KEY_SPEND: A witness type that allows us to spend a regular p2tr output that's sent\nto an output which is under complete control of the backing wallet.\n - TAPROOT_LOCAL_COMMIT_SPEND: A witness type that allows us to spend our settled local commitment after a\nCSV delay when we force close the channel.\n - TAPROOT_REMOTE_COMMIT_SPEND: A witness type that allows us to spend our settled local commitment after\na CSV delay when the remote party has force closed the channel.\n - TAPROOT_ANCHOR_SWEEP_SPEND: A witness type that we'll use for spending our own anchor output.\n - TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL: A witness that allows us to timeout an HTLC we offered to the remote party\non our commitment transaction. We use this when we need to go on chain to\ntime out an HTLC.\n - TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL: A witness type that allows us to sweep an HTLC we accepted on our commitment\ntransaction after we go to the second level on chain.\n - TAPROOT_HTLC_SECOND_LEVEL_REVOKE: A witness that allows us to sweep an HTLC on the revoked transaction of the\nremote party that goes to the second level.\n - TAPROOT_HTLC_ACCEPTED_REVOKE: A witness that allows us to sweep an HTLC sent to us by the remote party\nin the event that they broadcast a revoked state.\n - TAPROOT_HTLC_OFFERED_REVOKE: A witness that allows us to sweep an HTLC we offered to the remote party if\nthey broadcast a revoked commitment.\n - TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT: A witness that allows us to sweep an HTLC we offered to the remote party\nthat lies on the commitment transaction for the remote party. We can spend\nthis output after the absolute CLTV timeout of the HTLC as passed.\n - TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT: A witness type that allows us to sign the second level HTLC timeout\ntransaction when spending from an HTLC residing on our local commitment\ntransaction.\nThis is used by the sweeper to re-sign inputs if it needs to aggregate\nseveral second level HTLCs.\n - TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS: A witness that allows us to sweep an HTLC that was offered to us by the\nremote party for a taproot channels. We use this witness in the case that\nthe remote party goes to chain, and we know the pre-image to the HTLC. We\ncan sweep this without any additional timeout.\n - TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS: A witness type that allows us to sweep the HTLC offered to us on our local\ncommitment transaction. We'll use this when we need to go on chain to sweep\nthe HTLC. In this case, this is the second level HTLC success transaction.\n - TAPROOT_COMMITMENT_REVOKE: A witness that allows us to sweep the settled output of a malicious\ncounterparty's who broadcasts a revoked taproot commitment transaction."
}
}
}
13 changes: 13 additions & 0 deletions lnrpc/walletrpc/walletkit_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ var (
input.LeaseHtlcOfferedTimeoutSecondLevel: WitnessType_LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL,
input.LeaseHtlcAcceptedSuccessSecondLevel: WitnessType_LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL,
input.TaprootPubKeySpend: WitnessType_TAPROOT_PUB_KEY_SPEND,
input.TaprootLocalCommitSpend: WitnessType_TAPROOT_LOCAL_COMMIT_SPEND,
input.TaprootRemoteCommitSpend: WitnessType_TAPROOT_REMOTE_COMMIT_SPEND,
input.TaprootAnchorSweepSpend: WitnessType_TAPROOT_ANCHOR_SWEEP_SPEND,
input.TaprootHtlcOfferedTimeoutSecondLevel: WitnessType_TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL,
input.TaprootHtlcAcceptedSuccessSecondLevel: WitnessType_TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL,
input.TaprootHtlcSecondLevelRevoke: WitnessType_TAPROOT_HTLC_SECOND_LEVEL_REVOKE,
input.TaprootHtlcAcceptedRevoke: WitnessType_TAPROOT_HTLC_ACCEPTED_REVOKE,
input.TaprootHtlcOfferedRevoke: WitnessType_TAPROOT_HTLC_OFFERED_REVOKE,
input.TaprootHtlcOfferedRemoteTimeout: WitnessType_TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT,
input.TaprootHtlcLocalOfferedTimeout: WitnessType_TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT,
input.TaprootHtlcAcceptedRemoteSuccess: WitnessType_TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS,
input.TaprootHtlcAcceptedLocalSuccess: WitnessType_TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS,
input.TaprootCommitmentRevoke: WitnessType_TAPROOT_COMMITMENT_REVOKE,
}
)

Expand Down
Loading

0 comments on commit c89005c

Please sign in to comment.