This enables implementers to generate a different destination script for each channel.
})
}
- 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());
))
}
- 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());
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!() }
}
}
}
- 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()}),
};
}
}
- 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())),
};
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());
// 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());
/// 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.
///
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())
}
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, ()> {
))
}
- 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(()) }
}
))
}
- 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() {