@@ -40,7 +40,7 @@ use crate::ln::channel_state::{ChannelShutdownState, CounterpartyForwardingInfo,
40
40
use crate::ln::channelmanager::{self, OpenChannelMessage, PendingHTLCStatus, HTLCSource, SentHTLCId, HTLCFailureMsg, PendingHTLCInfo, RAACommitmentOrder, PaymentClaimDetails, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA, MAX_LOCAL_BREAKDOWN_TIMEOUT};
41
41
use crate::ln::chan_utils::{
42
42
CounterpartyCommitmentSecrets, TxCreationKeys, HTLCOutputInCommitment, htlc_success_tx_weight,
43
- htlc_timeout_tx_weight, make_funding_redeemscript, ChannelPublicKeys, CommitmentTransaction,
43
+ htlc_timeout_tx_weight, ChannelPublicKeys, CommitmentTransaction,
44
44
HolderCommitmentTransaction, ChannelTransactionParameters,
45
45
CounterpartyChannelTransactionParameters, MAX_HTLCS,
46
46
get_commitment_transaction_number_obscure_factor,
@@ -1823,7 +1823,7 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
1823
1823
return Err(ChannelError::close("Failed to advance holder commitment point".to_owned()));
1824
1824
}
1825
1825
1826
- let funding_txo_script = context.get_funding_redeemscript().to_p2wsh ();
1826
+ let funding_txo_script = context.get_funding_spk ();
1827
1827
let funding_txo = context.get_funding_txo().unwrap();
1828
1828
let obscure_factor = get_commitment_transaction_number_obscure_factor(&context.get_holder_pubkeys().payment_point, &context.get_counterparty_pubkeys().payment_point, context.is_outbound());
1829
1829
let shutdown_script = context.shutdown_scriptpubkey.clone().map(|script| script.into_inner());
@@ -1973,7 +1973,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1973
1973
let transaction_number = self.unfunded_context.transaction_number();
1974
1974
1975
1975
let mut output_index = None;
1976
- let expected_spk = self.context.get_funding_redeemscript().to_p2wsh ();
1976
+ let expected_spk = self.context.get_funding_spk ();
1977
1977
for (idx, outp) in signing_session.unsigned_tx.outputs().enumerate() {
1978
1978
if outp.script_pubkey() == &expected_spk && outp.value() == self.context.get_value_satoshis() {
1979
1979
if output_index.is_some() {
@@ -3390,11 +3390,8 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3390
3390
TxCreationKeys::derive_new(&self.secp_ctx, &self.counterparty_cur_commitment_point.unwrap(), &counterparty_pubkeys.delayed_payment_basepoint, &counterparty_pubkeys.htlc_basepoint, revocation_basepoint, htlc_basepoint)
3391
3391
}
3392
3392
3393
- /// Gets the redeemscript for the funding transaction output (ie the funding transaction output
3394
- /// pays to get_funding_redeemscript().to_p2wsh()).
3395
- /// Panics if called before accept_channel/InboundV1Channel::new
3396
- pub fn get_funding_redeemscript(&self) -> ScriptBuf {
3397
- make_funding_redeemscript(&self.get_holder_pubkeys().funding_pubkey, self.counterparty_funding_pubkey())
3393
+ pub fn get_funding_spk(&self) -> ScriptBuf {
3394
+ self.holder_signer.as_ref().get_funding_spk()
3398
3395
}
3399
3396
3400
3397
fn counterparty_funding_pubkey(&self) -> &PublicKey {
@@ -7471,7 +7468,7 @@ impl<SP: Deref> FundedChannel<SP> where
7471
7468
if self.context.funding_tx_confirmation_height == 0 {
7472
7469
if tx.compute_txid() == funding_txo.txid {
7473
7470
let txo_idx = funding_txo.index as usize;
7474
- if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.context.get_funding_redeemscript().to_p2wsh () ||
7471
+ if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.context.get_funding_spk () ||
7475
7472
tx.output[txo_idx].value.to_sat() != self.context.channel_value_satoshis {
7476
7473
if self.context.is_outbound() {
7477
7474
// If we generated the funding transaction and it doesn't match what it
@@ -8167,7 +8164,7 @@ impl<SP: Deref> FundedChannel<SP> where
8167
8164
8168
8165
log_trace!(logger, "Signed remote commitment tx {} (txid {}) with redeemscript {} -> {} in channel {}",
8169
8166
encode::serialize_hex(&commitment_stats.tx.trust().built_transaction().transaction),
8170
- &counterparty_commitment_txid, encode::serialize_hex(&self.context.get_funding_redeemscript ()),
8167
+ &counterparty_commitment_txid, encode::serialize_hex(&self.context.get_funding_spk ()),
8171
8168
log_bytes!(signature.serialize_compact()[..]), &self.context.channel_id());
8172
8169
8173
8170
for (ref htlc_sig, ref htlc) in htlc_signatures.iter().zip(htlcs) {
@@ -9126,7 +9123,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
9126
9123
is_initiator: false,
9127
9124
inputs_to_contribute: funding_inputs,
9128
9125
outputs_to_contribute: Vec::new(),
9129
- expected_remote_shared_funding_output: Some((context.get_funding_redeemscript().to_p2wsh (), context.channel_value_satoshis)),
9126
+ expected_remote_shared_funding_output: Some((context.get_funding_spk (), context.channel_value_satoshis)),
9130
9127
}
9131
9128
).map_err(|_| ChannelError::Close((
9132
9129
"V2 channel rejected due to sender error".into(),
@@ -10515,7 +10512,7 @@ mod tests {
10515
10512
node_a_chan.context.holder_dust_limit_satoshis = 1560;
10516
10513
10517
10514
// Node A --> Node B: funding created
10518
- let output_script = node_a_chan.context.get_funding_redeemscript ();
10515
+ let output_script = node_a_chan.context.get_funding_spk ();
10519
10516
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
10520
10517
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
10521
10518
}]};
@@ -10645,7 +10642,7 @@ mod tests {
10645
10642
node_a_chan.accept_channel(&accept_channel_msg, &config.channel_handshake_limits, &channelmanager::provided_init_features(&config)).unwrap();
10646
10643
10647
10644
// Node A --> Node B: funding created
10648
- let output_script = node_a_chan.context.get_funding_redeemscript ();
10645
+ let output_script = node_a_chan.context.get_funding_spk ();
10649
10646
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
10650
10647
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
10651
10648
}]};
@@ -10834,7 +10831,7 @@ mod tests {
10834
10831
node_a_chan.context.holder_dust_limit_satoshis = 1560;
10835
10832
10836
10833
// Node A --> Node B: funding created
10837
- let output_script = node_a_chan.context.get_funding_redeemscript ();
10834
+ let output_script = node_a_chan.context.get_funding_spk ();
10838
10835
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
10839
10836
value: Amount::from_sat(10000000), script_pubkey: output_script.clone(),
10840
10837
}]};
@@ -10904,7 +10901,7 @@ mod tests {
10904
10901
).unwrap();
10905
10902
outbound_chan.accept_channel(&inbound_chan.get_accept_channel_message(&&logger).unwrap(), &config.channel_handshake_limits, &features).unwrap();
10906
10903
let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
10907
- value: Amount::from_sat(10000000), script_pubkey: outbound_chan.context.get_funding_redeemscript (),
10904
+ value: Amount::from_sat(10000000), script_pubkey: outbound_chan.context.get_funding_spk (),
10908
10905
}]};
10909
10906
let funding_outpoint = OutPoint{ txid: tx.compute_txid(), index: 0 };
10910
10907
let funding_created = outbound_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap().unwrap();
@@ -11118,7 +11115,7 @@ mod tests {
11118
11115
};
11119
11116
let trusted_tx = commitment_tx.trust();
11120
11117
let unsigned_tx = trusted_tx.built_transaction();
11121
- let redeemscript = chan.context.get_funding_redeemscript( );
11118
+ let redeemscript = chan_utils::make_funding_redeemscript(& chan.context.get_holder_pubkeys().funding_pubkey, chan.context.counterparty_funding_pubkey() );
11122
11119
let counterparty_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_sig_hex).unwrap()[..]).unwrap();
11123
11120
let sighash = unsigned_tx.get_sighash_all(&redeemscript, chan.context.channel_value_satoshis);
11124
11121
log_trace!(logger, "unsigned_tx = {}", serialize(&unsigned_tx.transaction).as_hex());
@@ -12021,7 +12018,7 @@ mod tests {
12021
12018
).unwrap();
12022
12019
12023
12020
// Fund the channel with a batch funding transaction.
12024
- let output_script = node_a_chan.context.get_funding_redeemscript ();
12021
+ let output_script = node_a_chan.context.get_funding_spk ();
12025
12022
let tx = Transaction {
12026
12023
version: Version::ONE,
12027
12024
lock_time: LockTime::ZERO,
0 commit comments