mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Merge pull request #2744 from rmalonson/destinationscript
Add channel_keys_id as param in get_destination_script to support gen…
This commit is contained in:
commit
146a291f15
7 changed files with 16 additions and 15 deletions
|
@ -270,7 +270,7 @@ impl SignerProvider for KeyProvider {
|
|||
})
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
|
||||
let secp_ctx = Secp256k1::signing_only();
|
||||
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();
|
||||
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
|
||||
|
|
|
@ -392,7 +392,7 @@ impl SignerProvider for KeyProvider {
|
|||
))
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
|
||||
let secp_ctx = Secp256k1::signing_only();
|
||||
let channel_monitor_claim_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
|
||||
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
|
||||
|
|
|
@ -199,7 +199,7 @@ impl SignerProvider for KeyProvider {
|
|||
|
||||
fn read_chan_signer(&self, _data: &[u8]) -> Result<TestChannelSigner, DecodeError> { unreachable!() }
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> { unreachable!() }
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> { unreachable!() }
|
||||
|
||||
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { unreachable!() }
|
||||
}
|
||||
|
|
|
@ -5962,7 +5962,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
|
|||
}
|
||||
}
|
||||
|
||||
let destination_script = match signer_provider.get_destination_script() {
|
||||
let destination_script = match signer_provider.get_destination_script(channel_keys_id) {
|
||||
Ok(script) => script,
|
||||
Err(_) => return Err(APIError::ChannelUnavailable { err: "Failed to get destination script".to_owned()}),
|
||||
};
|
||||
|
@ -6589,7 +6589,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
|
|||
}
|
||||
}
|
||||
|
||||
let destination_script = match signer_provider.get_destination_script() {
|
||||
let destination_script = match signer_provider.get_destination_script(channel_keys_id) {
|
||||
Ok(script) => script,
|
||||
Err(_) => return Err(ChannelError::Close("Failed to get destination script".to_owned())),
|
||||
};
|
||||
|
@ -7874,7 +7874,7 @@ use crate::ln::channelmanager::{self, HTLCSource, PaymentId};
|
|||
|
||||
fn read_chan_signer(&self, _data: &[u8]) -> Result<Self::Signer, DecodeError> { panic!(); }
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
|
||||
let secp_ctx = Secp256k1::signing_only();
|
||||
let channel_monitor_claim_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
|
||||
let channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
|
||||
|
|
|
@ -2590,8 +2590,8 @@ fn do_test_forming_justice_tx_from_monitor_updates(broadcast_initial_commitment:
|
|||
// 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);
|
||||
let destination_script0 = chanmon_cfgs[0].keys_manager.get_destination_script().unwrap();
|
||||
let destination_script1 = chanmon_cfgs[1].keys_manager.get_destination_script().unwrap();
|
||||
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 = vec![WatchtowerPersister::new(destination_script0),
|
||||
WatchtowerPersister::new(destination_script1)];
|
||||
let node_cfgs = create_node_cfgs_with_persisters(2, &chanmon_cfgs, persisters.iter().collect());
|
||||
|
|
|
@ -903,8 +903,9 @@ pub trait SignerProvider {
|
|||
/// If this function returns an error, this will result in a channel failing to open.
|
||||
///
|
||||
/// This method should return a different value each time it is called, to avoid linking
|
||||
/// on-chain funds across channels as controlled to the same user.
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()>;
|
||||
/// on-chain funds across channels as controlled to the same user. `channel_keys_id` may be
|
||||
/// used to derive a unique value for each channel.
|
||||
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()>;
|
||||
|
||||
/// Get a script pubkey which we will send funds to when closing a channel.
|
||||
///
|
||||
|
@ -1804,7 +1805,7 @@ impl SignerProvider for KeysManager {
|
|||
InMemorySigner::read(&mut io::Cursor::new(reader), self)
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
|
||||
Ok(self.destination_script.clone())
|
||||
}
|
||||
|
||||
|
@ -1911,8 +1912,8 @@ impl SignerProvider for PhantomKeysManager {
|
|||
self.inner.read_chan_signer(reader)
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
|
||||
self.inner.get_destination_script()
|
||||
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
|
||||
self.inner.get_destination_script(channel_keys_id)
|
||||
}
|
||||
|
||||
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
|
||||
|
|
|
@ -192,7 +192,7 @@ impl SignerProvider for OnlyReadsKeysInterface {
|
|||
))
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> { Err(()) }
|
||||
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> { Err(()) }
|
||||
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { Err(()) }
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ impl SignerProvider for TestKeysInterface {
|
|||
))
|
||||
}
|
||||
|
||||
fn get_destination_script(&self) -> Result<ScriptBuf, ()> { self.backing.get_destination_script() }
|
||||
fn get_destination_script(&self, channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> { self.backing.get_destination_script(channel_keys_id) }
|
||||
|
||||
fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
|
||||
match &mut *self.expectations.lock().unwrap() {
|
||||
|
|
Loading…
Add table
Reference in a new issue