Skip to content

Commit 712b385

Browse files
committed
Assume splicing input value from channel parameters
1 parent bbe590d commit 712b385

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

lightning/src/sign/ecdsa.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,17 @@ pub trait EcdsaChannelSigner: ChannelSigner {
247247
/// In splicing, the previous funding transaction output is spent as the input of
248248
/// the new funding transaction, and is a 2-of-2 multisig.
249249
///
250+
/// `channel_parameters`: The [`ChannelTransactionParameters`] for the channel's current funding
251+
/// transaction that is being spent in the splice transaction to sign. A new set of
252+
/// [`ChannelTransactionParameters`] will become available for the new funding transaction.
253+
///
250254
/// `input_index`: The index of the input within the new funding transaction `tx`,
251255
/// spending the previous funding transaction's output
252256
///
253-
/// `input_value`: The value of the previous funding transaction output.
254-
///
255257
/// This method is *not* asynchronous. If an `Err` is returned, the channel will be immediately
256258
/// closed.
257259
fn sign_splicing_funding_input(
258260
&self, channel_parameters: &ChannelTransactionParameters, tx: &Transaction,
259-
input_index: usize, input_value: u64, secp_ctx: &Secp256k1<secp256k1::All>,
261+
input_index: usize, secp_ctx: &Secp256k1<secp256k1::All>,
260262
) -> Result<Signature, ()>;
261263
}

lightning/src/sign/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,9 +1755,17 @@ impl EcdsaChannelSigner for InMemorySigner {
17551755

17561756
fn sign_splicing_funding_input(
17571757
&self, channel_parameters: &ChannelTransactionParameters, tx: &Transaction,
1758-
input_index: usize, input_value: u64, secp_ctx: &Secp256k1<secp256k1::All>,
1758+
input_index: usize, secp_ctx: &Secp256k1<secp256k1::All>,
17591759
) -> Result<Signature, ()> {
17601760
assert!(channel_parameters.is_populated(), "Channel parameters must be fully populated");
1761+
assert_eq!(
1762+
tx.input[input_index].previous_output,
1763+
channel_parameters
1764+
.funding_outpoint
1765+
.as_ref()
1766+
.expect("Funding outpoint must be known prior to signing")
1767+
.into_bitcoin_outpoint()
1768+
);
17611769

17621770
let funding_key = self.funding_key(channel_parameters.splice_parent_funding_txid);
17631771
let funding_pubkey = funding_key.public_key(secp_ctx);
@@ -1769,7 +1777,7 @@ impl EcdsaChannelSigner for InMemorySigner {
17691777
.p2wsh_signature_hash(
17701778
input_index,
17711779
&funding_redeemscript,
1772-
Amount::from_sat(input_value),
1780+
Amount::from_sat(channel_parameters.channel_value_satoshis),
17731781
EcdsaSighashType::All,
17741782
)
17751783
.unwrap()[..];

lightning/src/util/dyn_signer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ delegate!(DynSigner, EcdsaChannelSigner, inner,
160160
fn sign_holder_htlc_transaction(, htlc_tx: &Transaction, input: usize,
161161
htlc_descriptor: &HTLCDescriptor, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()>,
162162
fn sign_splicing_funding_input(, channel_parameters: &ChannelTransactionParameters,
163-
tx: &Transaction, input_index: usize, input_value: u64,
164-
secp_ctx: &Secp256k1<All>) -> Result<Signature, ()>
163+
tx: &Transaction, input_index: usize, secp_ctx: &Secp256k1<All>) -> Result<Signature, ()>
165164
);
166165

167166
delegate!(DynSigner, ChannelSigner,

lightning/src/util/test_channel_signer.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,9 @@ impl EcdsaChannelSigner for TestChannelSigner {
486486

487487
fn sign_splicing_funding_input(
488488
&self, channel_parameters: &ChannelTransactionParameters, tx: &Transaction,
489-
input_index: usize, input_value: u64, secp_ctx: &Secp256k1<secp256k1::All>,
489+
input_index: usize, secp_ctx: &Secp256k1<secp256k1::All>,
490490
) -> Result<Signature, ()> {
491-
self.inner.sign_splicing_funding_input(
492-
channel_parameters,
493-
tx,
494-
input_index,
495-
input_value,
496-
secp_ctx,
497-
)
491+
self.inner.sign_splicing_funding_input(channel_parameters, tx, input_index, secp_ctx)
498492
}
499493
}
500494

0 commit comments

Comments
 (0)