Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ impl SignerProvider for KeyProvider {
.into_script())
}

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
fn get_shutdown_scriptpubkey(&self, _channel_keys_id: [u8; 32]) -> Result<ShutdownScript, ()> {
let secp_ctx = Secp256k1::signing_only();
#[rustfmt::skip]
let secret_key = SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, self.node_secret[31]]).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl SignerProvider for KeyProvider {
.into_script())
}

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
fn get_shutdown_scriptpubkey(&self, _channel_keys_id: [u8; 32]) -> Result<ShutdownScript, ()> {
let secp_ctx = Secp256k1::signing_only();
let secret_key = SecretKey::from_slice(&[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl SignerProvider for KeyProvider {
unreachable!()
}

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
fn get_shutdown_scriptpubkey(&self, _channel_keys_id: [u8; 32]) -> Result<ShutdownScript, ()> {
unreachable!()
}
}
Expand Down
5 changes: 3 additions & 2 deletions lightning/src/ln/async_signer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,9 @@ fn do_test_closing_signed(extra_closing_signed: bool, reconnect: bool) {
if extra_closing_signed {
let node_1_closing_signed_2_bad = {
let mut node_1_closing_signed_2 = node_1_closing_signed.clone();
let holder_script = nodes[0].keys_manager.get_shutdown_scriptpubkey().unwrap();
let counterparty_script = nodes[1].keys_manager.get_shutdown_scriptpubkey().unwrap();
let holder_script = nodes[0].keys_manager.get_shutdown_scriptpubkey([0; 32]).unwrap();
let counterparty_script =
nodes[1].keys_manager.get_shutdown_scriptpubkey([0; 32]).unwrap();
let funding_outpoint = bitcoin::OutPoint { txid: funding_tx.compute_txid(), vout: 0 };
let closing_tx_2 = ClosingTransaction::new(
50000,
Expand Down
29 changes: 17 additions & 12 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4085,7 +4085,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {

let shutdown_scriptpubkey =
if config.channel_handshake_config.commit_upfront_shutdown_pubkey {
match signer_provider.get_shutdown_scriptpubkey() {
match signer_provider.get_shutdown_scriptpubkey(channel_keys_id) {
Ok(scriptpubkey) => Some(scriptpubkey),
Err(_) => {
return Err(ChannelError::close(
Expand Down Expand Up @@ -4408,7 +4408,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {

let shutdown_scriptpubkey =
if config.channel_handshake_config.commit_upfront_shutdown_pubkey {
match signer_provider.get_shutdown_scriptpubkey() {
match signer_provider.get_shutdown_scriptpubkey(channel_keys_id) {
Ok(scriptpubkey) => Some(scriptpubkey),
Err(_) => {
return Err(APIError::ChannelUnavailable {
Expand Down Expand Up @@ -11197,14 +11197,15 @@ where
Some(_) => false,
None => {
assert!(send_shutdown);
let shutdown_scriptpubkey = match signer_provider.get_shutdown_scriptpubkey() {
Ok(scriptpubkey) => scriptpubkey,
Err(_) => {
return Err(ChannelError::close(
"Failed to get shutdown scriptpubkey".to_owned(),
))
},
};
let shutdown_scriptpubkey =
match signer_provider.get_shutdown_scriptpubkey(self.context.channel_keys_id) {
Ok(scriptpubkey) => scriptpubkey,
Err(_) => {
return Err(ChannelError::close(
"Failed to get shutdown scriptpubkey".to_owned(),
))
},
};
if !shutdown_scriptpubkey.is_compatible(their_features) {
return Err(ChannelError::close(format!(
"Provided a scriptpubkey format not accepted by peer: {}",
Expand Down Expand Up @@ -14420,7 +14421,9 @@ where
Some(script) => script,
None => {
// otherwise, use the shutdown scriptpubkey provided by the signer
match signer_provider.get_shutdown_scriptpubkey() {
match signer_provider
.get_shutdown_scriptpubkey(self.context.channel_keys_id)
{
Ok(scriptpubkey) => scriptpubkey,
Err(_) => {
return Err(APIError::ChannelUnavailable {
Expand Down Expand Up @@ -17488,7 +17491,9 @@ mod tests {
.into_script())
}

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
fn get_shutdown_scriptpubkey(
&self, _channel_keys_id: [u8; 32],
) -> Result<ShutdownScript, ()> {
let secp_ctx = Secp256k1::signing_only();
let hex = "0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
let channel_close_key =
Expand Down
15 changes: 14 additions & 1 deletion lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ use crate::prelude::*;
use crate::sync::{Arc, Mutex, RwLock};
use alloc::collections::BTreeSet;
use bitcoin::hashes::Hash;
use bitcoin::hex::FromHex;
use core::iter::repeat;
use lightning_macros::xtest;

Expand Down Expand Up @@ -1030,7 +1031,19 @@ fn do_test_forming_justice_tx_from_monitor_updates(broadcast_initial_commitment:
// is properly formed and can be broadcasted/confirmed successfully in the event
// that a revoked commitment transaction is broadcasted
// (Similar to `revoked_output_claim` test but we get the justice tx + broadcast manually)
let chanmon_cfgs = create_chanmon_cfgs(2);
//
// Use legacy (V1) key derivation so that the destination scripts we hand to the watchtower
// match the per-node static destination scripts that the channels close to. With per-channel
// (V2) derivation each channel uses a distinct destination script which we cannot predict
// before the channel is created.
let node0_key_id =
<[u8; 32]>::from_hex("0000000000000000000000004D49E5DA0000000000000000000000000000002A")
.unwrap();
let node1_key_id =
<[u8; 32]>::from_hex("0000000000000000000000004D49E5DAD000D6201F116BAFD379F1D61DF161B9")
.unwrap();
let predefined_key_ids = Some(vec![node0_key_id, node1_key_id]);
let chanmon_cfgs = create_chanmon_cfgs_with_legacy_keys(2, predefined_key_ids);
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script([0; 32]).unwrap();
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script([0; 32]).unwrap();
let persisters = [
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/shutdown_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ fn test_unsupported_anysegwit_shutdown_script() {

// Check that using an unsupported shutdown script fails and a supported one succeeds.
let supported_shutdown_script =
chanmon_cfgs[1].keys_manager.get_shutdown_scriptpubkey().unwrap();
chanmon_cfgs[1].keys_manager.get_shutdown_scriptpubkey([0; 32]).unwrap();
let unsupported_witness_program = WitnessProgram::new(WitnessVersion::V16, &[0, 40]).unwrap();
let unsupported_shutdown_script =
ShutdownScript::new_witness_program(&unsupported_witness_program).unwrap();
Expand Down
Loading
Loading