Skip to content

Commit d04d58f

Browse files
committed
Add channel_keys_id as param in get_destination_script to support generating a different destination script for each channel.
1 parent 870a0f1 commit d04d58f

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl SignerProvider for KeyProvider {
270270
})
271271
}
272272

273-
fn get_destination_script(&self) -> Result<Script, ()> {
273+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> {
274274
let secp_ctx = Secp256k1::signing_only();
275275
let channel_monitor_claim_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, 2, self.node_secret[31]]).unwrap();
276276
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl SignerProvider for KeyProvider {
391391
))
392392
}
393393

394-
fn get_destination_script(&self) -> Result<Script, ()> {
394+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> {
395395
let secp_ctx = Secp256k1::signing_only();
396396
let channel_monitor_claim_key = SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
397397
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());

fuzz/src/onion_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl SignerProvider for KeyProvider {
199199

200200
fn read_chan_signer(&self, _data: &[u8]) -> Result<TestChannelSigner, DecodeError> { unreachable!() }
201201

202-
fn get_destination_script(&self) -> Result<Script, ()> { unreachable!() }
202+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> { unreachable!() }
203203

204204
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { unreachable!() }
205205
}

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5950,7 +5950,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
59505950
}
59515951
}
59525952

5953-
let destination_script = match signer_provider.get_destination_script() {
5953+
let destination_script = match signer_provider.get_destination_script(channel_keys_id) {
59545954
Ok(script) => script,
59555955
Err(_) => return Err(APIError::ChannelUnavailable { err: "Failed to get destination script".to_owned()}),
59565956
};
@@ -6577,7 +6577,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
65776577
}
65786578
}
65796579

6580-
let destination_script = match signer_provider.get_destination_script() {
6580+
let destination_script = match signer_provider.get_destination_script(channel_keys_id) {
65816581
Ok(script) => script,
65826582
Err(_) => return Err(ChannelError::Close("Failed to get destination script".to_owned())),
65836583
};
@@ -7862,7 +7862,7 @@ mod tests {
78627862

78637863
fn read_chan_signer(&self, _data: &[u8]) -> Result<Self::Signer, DecodeError> { panic!(); }
78647864

7865-
fn get_destination_script(&self) -> Result<Script, ()> {
7865+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> {
78667866
let secp_ctx = Secp256k1::signing_only();
78677867
let channel_monitor_claim_key = SecretKey::from_slice(&hex::decode("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
78687868
let channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,8 +2589,8 @@ fn do_test_forming_justice_tx_from_monitor_updates(broadcast_initial_commitment:
25892589
// that a revoked commitment transaction is broadcasted
25902590
// (Similar to `revoked_output_claim` test but we get the justice tx + broadcast manually)
25912591
let chanmon_cfgs = create_chanmon_cfgs(2);
2592-
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script().unwrap();
2593-
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script().unwrap();
2592+
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script([0; 32]).unwrap();
2593+
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script([0; 32]).unwrap();
25942594
let persisters = vec![WatchtowerPersister::new(destination_script0),
25952595
WatchtowerPersister::new(destination_script1)];
25962596
let node_cfgs = create_node_cfgs_with_persisters(2, &chanmon_cfgs, persisters.iter().collect());

lightning/src/sign/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ pub trait SignerProvider {
905905
///
906906
/// This method should return a different value each time it is called, to avoid linking
907907
/// on-chain funds across channels as controlled to the same user.
908-
fn get_destination_script(&self) -> Result<Script, ()>;
908+
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<Script, ()>;
909909

910910
/// Get a script pubkey which we will send funds to when closing a channel.
911911
///
@@ -1791,7 +1791,7 @@ impl SignerProvider for KeysManager {
17911791
InMemorySigner::read(&mut io::Cursor::new(reader), self)
17921792
}
17931793

1794-
fn get_destination_script(&self) -> Result<Script, ()> {
1794+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> {
17951795
Ok(self.destination_script.clone())
17961796
}
17971797

@@ -1898,8 +1898,8 @@ impl SignerProvider for PhantomKeysManager {
18981898
self.inner.read_chan_signer(reader)
18991899
}
19001900

1901-
fn get_destination_script(&self) -> Result<Script, ()> {
1902-
self.inner.get_destination_script()
1901+
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<Script, ()> {
1902+
self.inner.get_destination_script(channel_keys_id)
19031903
}
19041904

19051905
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {

lightning/src/util/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl SignerProvider for OnlyReadsKeysInterface {
193193
))
194194
}
195195

196-
fn get_destination_script(&self) -> Result<Script, ()> { Err(()) }
196+
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<Script, ()> { Err(()) }
197197
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { Err(()) }
198198
}
199199

@@ -1122,7 +1122,7 @@ impl SignerProvider for TestKeysInterface {
11221122
))
11231123
}
11241124

1125-
fn get_destination_script(&self) -> Result<Script, ()> { self.backing.get_destination_script() }
1125+
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<Script, ()> { self.backing.get_destination_script(channel_keys_id) }
11261126

11271127
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
11281128
match &mut *self.expectations.lock().unwrap() {

0 commit comments

Comments
 (0)