Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let ChannelSigner set and spend LN scriptpubkeys #3512

Closed
wants to merge 54 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a775008
Add `ChannelSigner::get_channel_parameters`
tankyleo Jan 13, 2025
42d65da
Let `ChannelSigner` set `to_remote` script pubkey
tankyleo Dec 7, 2024
857ab29
Let `ChannelSigner` set `to_local` script pubkey
tankyleo Dec 13, 2024
8283838
Let `ChannelSigner` set htlc tx script pubkey
tankyleo Dec 13, 2024
2e8b3f8
Let `ChannelSigner` build the punishment witness
tankyleo Dec 15, 2024
70b9df6
Ask `ChannelSigner` the weight of the punishment witness
tankyleo Dec 20, 2024
907684b
Remove unused `RevokedOutput` fields
tankyleo Dec 20, 2024
4234663
Let `ChannelSigner` build the htlc punishment witness
tankyleo Dec 20, 2024
b0a20d8
Remove unused `RevokedHTLCOutput` fields
tankyleo Dec 20, 2024
2868379
Ask `ChannelSigner` the weight of the htlc punishment witness
tankyleo Dec 20, 2024
77d5e24
Let `ChannelSigner` build the counterparty htlc sweep witness
tankyleo Dec 20, 2024
563efd5
Remove unused `CounterpartyOfferedHTLCOutput` fields
tankyleo Dec 20, 2024
b7a37ca
Remove unused `CounterpartyReceivedHTLCOutput` fields
tankyleo Dec 20, 2024
35901b5
Ask `ChannelSigner` the weight of counterparty htlc output sweeps
tankyleo Dec 22, 2024
b88a2ac
Let `sign_holder_commitment` build the commitment tx witness
tankyleo Dec 22, 2024
4de22fa
Let `unsafe_sign_holder_commitment` build the commitment tx witness
tankyleo Dec 22, 2024
4c96432
Let `sign_holder_htlc_transaction` build the htlc tx witness
tankyleo Dec 22, 2024
9687da3
Relax `EcdsaChannelSigner` to `ChannelSigner` in `mod chain`
tankyleo Dec 22, 2024
0e3227e
Ask `ChannelSigner` the weight of the htlc tx input
tankyleo Dec 23, 2024
a9c3844
Let `ChannelSigner` set commit tx htlc output script pubkey
tankyleo Dec 24, 2024
ec40758
Remove `TxCreationKeys` from `CommitmentTransaction::internal_build_o…
tankyleo Dec 24, 2024
207b70f
Let `ChannelSigner` set commit tx anchor output script pubkey
tankyleo Jan 14, 2025
557a754
Let `ChannelSigner` build the anchor sweep witness
tankyleo Dec 25, 2024
7ec1efc
Ask `ChannelSigner` the weight of the anchor tx input
tankyleo Jan 6, 2025
f95a7c0
Mark `PackageSolvingData::HolderHTLCOutput` weight unreachable
tankyleo Jan 7, 2025
a606d03
Remove unused `HolderFundingOutput` fields
tankyleo Jan 10, 2025
03d6a40
Add `ChannelTransactionParameters::channel_type_features`
tankyleo Jan 13, 2025
fbc1b5c
Delete `EcdsaChannelSigner::sign_justice_revoked_output`
tankyleo Jan 14, 2025
5f27ad7
Delete `EcdsaChannelSigner::sign_justice_revoked_htlc`
tankyleo Jan 14, 2025
fc2a45e
Delete `EcdsaChannelSigner::sign_counterparty_htlc_transaction`
tankyleo Jan 14, 2025
c9050a5
Delete `EcdsaChannelSigner::sign_holder_anchor_input`
tankyleo Jan 14, 2025
c20b8fc
Add `ChannelSigner::get_to_remote_witness_weight`
tankyleo Jan 16, 2025
3ab0293
Add `ChannelSigner::get_to_local_witness_weight`
tankyleo Jan 16, 2025
61fc584
Delete `StaticPaymentOutputDescriptor::witness_script`
tankyleo Jan 16, 2025
2ed352c
Delete `HTLCDescriptor::tx_input_witness`
tankyleo Jan 16, 2025
fd1a47a
Delete `TrustedCommitmentTransaction::get_htlc_sigs`
tankyleo Jan 18, 2025
6ea5589
Move commitment tx sig validation from `FundedChannel` to `ChannelSig…
tankyleo Jan 18, 2025
e2f73a5
Move htlc tx sig validation from `FundedChannel` to `ChannelSigner`
tankyleo Jan 18, 2025
ccf9824
Delete `InitialRemoteCommitmentReceiver::check_counterparty_commitmen…
tankyleo Jan 18, 2025
5fc079b
Call `validate_counterparty_revocation` on `ChannelSigner` directly
tankyleo Jan 18, 2025
79f1ca8
f: Make id of revoked outputs in HTLC transactions generic over HTLC …
tankyleo Jan 27, 2025
0c2b44b
f: Make Counterparty{*}HTLCOutput ser backwards compatible
tankyleo Jan 20, 2025
7484c3b
f: Use `ChannelSigner::get_anchor_txout` to id the anchor output
tankyleo Jan 27, 2025
9ab6948
Remove generic from `CommitmentTransaction::internal_build_outputs`
tankyleo Jan 27, 2025
bb16170
Let `ChannelSigner` build the outputs of the commit tx
tankyleo Jan 27, 2025
09cbb8b
Let `ChannelSigner` build the inputs of the commit tx
tankyleo Jan 27, 2025
22c9a5c
Let `ChannelSigner` build the commit tx
tankyleo Jan 27, 2025
9d05b78
Add `ChannelSigner::validate_closing_signature`
tankyleo Feb 9, 2025
b06273b
Add `ChannelSigner::build_signed_closing_transaction`
tankyleo Feb 9, 2025
e6e4acf
Add `ChannelSigner::provide_counterparty_parameters`
tankyleo Feb 13, 2025
70788e0
Add `ChannelSigner::provide_funding_outpoint`
tankyleo Feb 13, 2025
77b6fd4
Provide counterparty parameters in accept channel checks
tankyleo Feb 13, 2025
e711b26
Add `ChannelSigner::get_funding_spk`
tankyleo Feb 13, 2025
bb13acb
Add `ChannelContext::get_funding_spk`
tankyleo Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Let ChannelSigner build the commit tx
  • Loading branch information
tankyleo committed Jan 27, 2025

Verified

This commit was signed with the committer’s verified signature.
redcode Manuel Sainz de Baranda y Goñi
commit 22c9a5cb37aefb3b546c89d632c3480b4f4f0c5d
18 changes: 2 additions & 16 deletions lightning/src/ln/chan_utils.rs
Original file line number Diff line number Diff line change
@@ -1451,10 +1451,8 @@ impl CommitmentTransaction {

// Sort outputs and populate output indices while keeping track of the auxiliary data
let htlcs: Vec<&mut HTLCOutputInCommitment> = htlcs_with_aux.iter_mut().map(|(htlc, _)| htlc).collect();
let (outputs, sorted_htlcs) = signer.build_outputs(&keys.per_commitment_point, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs, secp_ctx, is_holder_tx, commitment_number).unwrap();
let (transaction, sorted_htlcs) = signer.build_transaction(&keys.per_commitment_point, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs, secp_ctx, is_holder_tx, commitment_number);

let (obscured_commitment_transaction_number, txins) = signer.build_inputs(commitment_number, is_holder_tx);
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
let txid = transaction.compute_txid();
CommitmentTransaction {
commitment_number,
@@ -1481,13 +1479,10 @@ impl CommitmentTransaction {
}

fn internal_rebuild_transaction<Signer: ChannelSigner>(&self, per_commitment_point: &PublicKey, signer: &Signer, secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool) -> Result<BuiltCommitmentTransaction, ()> {
let (obscured_commitment_transaction_number, txins) = signer.build_inputs(self.commitment_number, is_holder_tx);

let mut htlcs: Vec<_> = self.htlcs.iter().map(|h| h.clone()).collect();
let htlcs: Vec<&mut HTLCOutputInCommitment> = htlcs.iter_mut().collect();
let (outputs, _) = signer.build_outputs(per_commitment_point, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, htlcs, secp_ctx, is_holder_tx, self.commitment_number)?;
let (transaction, _) = signer.build_transaction(per_commitment_point, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, htlcs, secp_ctx, is_holder_tx, self.commitment_number);

let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
let txid = transaction.compute_txid();
let built_transaction = BuiltCommitmentTransaction {
transaction,
@@ -1496,15 +1491,6 @@ impl CommitmentTransaction {
Ok(built_transaction)
}

fn make_transaction(obscured_commitment_transaction_number: u64, txins: Vec<TxIn>, outputs: Vec<TxOut>) -> Transaction {
Transaction {
version: Version::TWO,
lock_time: LockTime::from_consensus(((0x20 as u32) << 8 * 3) | ((obscured_commitment_transaction_number & 0xffffffu64) as u32)),
input: txins,
output: outputs,
}
}

/// The backwards-counting commitment number
pub fn commitment_number(&self) -> u64 {
self.commitment_number
33 changes: 33 additions & 0 deletions lightning/src/sign/mod.rs
Original file line number Diff line number Diff line change
@@ -1258,6 +1258,39 @@ pub trait ChannelSigner {
};
(obscured_commitment_transaction_number, txins)
}

/// Builds a commitment transaction
fn build_transaction(
&self, per_commitment_point: &PublicKey, to_broadcaster_value_sat: Amount,
to_countersignatory_value_sat: Amount, htlcs: Vec<&mut HTLCOutputInCommitment>,
secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool, commitment_number: u64,
) -> (Transaction, Vec<HTLCOutputInCommitment>) {
let (obscured_commitment_transaction_number, txins) =
self.build_inputs(commitment_number, is_holder_tx);
let (txouts, sorted_htlcs) = self
.build_outputs(
per_commitment_point,
to_broadcaster_value_sat,
to_countersignatory_value_sat,
htlcs,
secp_ctx,
is_holder_tx,
commitment_number,
)
.unwrap();
(
Transaction {
version: Version::TWO,
lock_time: LockTime::from_consensus(
((0x20 as u32) << 8 * 3)
| ((obscured_commitment_transaction_number & 0xffffffu64) as u32),
),
input: txins,
output: txouts,
},
sorted_htlcs,
)
}
}

/// Specifies the recipient of an invoice.