Skip to content

Commit 83af951

Browse files
authored
Merge pull request #2749 from TheBlueMatt/2023-11-2744-followups
Add `channel_keys_id` to `SpendableOutputDescriptor::StaticOutput`
2 parents 146a291 + d5710fd commit 83af951

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lightning/src/chain/channelmonitor.rs

+2
Original file line numberDiff line numberDiff line change
@@ -4082,6 +4082,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40824082
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
40834083
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
40844084
output: outp.clone(),
4085+
channel_keys_id: Some(self.channel_keys_id),
40854086
});
40864087
}
40874088
if let Some(ref broadcasted_holder_revokable_script) = self.broadcasted_holder_revokable_script {
@@ -4110,6 +4111,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41104111
spendable_outputs.push(SpendableOutputDescriptor::StaticOutput {
41114112
outpoint: OutPoint { txid: tx.txid(), index: i as u16 },
41124113
output: outp.clone(),
4114+
channel_keys_id: Some(self.channel_keys_id),
41134115
});
41144116
}
41154117
}

lightning/src/sign/mod.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ pub enum SpendableOutputDescriptor {
202202
outpoint: OutPoint,
203203
/// The output which is referenced by the given outpoint.
204204
output: TxOut,
205+
/// The `channel_keys_id` for the channel which this output came from.
206+
///
207+
/// For channels which were generated on LDK 0.0.119 or later, this is the value which was
208+
/// passed to the [`SignerProvider::get_destination_script`] call which provided this
209+
/// output script.
210+
///
211+
/// For channels which were generated prior to LDK 0.0.119, no such argument existed,
212+
/// however this field may still be filled in if such data is available.
213+
channel_keys_id: Option<[u8; 32]>
205214
},
206215
/// An output to a P2WSH script which can be spent with a single signature after an `OP_CSV`
207216
/// delay.
@@ -265,6 +274,7 @@ pub enum SpendableOutputDescriptor {
265274
impl_writeable_tlv_based_enum!(SpendableOutputDescriptor,
266275
(0, StaticOutput) => {
267276
(0, outpoint, required),
277+
(1, channel_keys_id, option),
268278
(2, output, required),
269279
},
270280
;
@@ -365,7 +375,7 @@ impl SpendableOutputDescriptor {
365375
{ witness_weight -= 1; } // Guarantees a low R signature
366376
input_value += descriptor.output.value;
367377
},
368-
SpendableOutputDescriptor::StaticOutput { ref outpoint, ref output } => {
378+
SpendableOutputDescriptor::StaticOutput { ref outpoint, ref output, .. } => {
369379
if !output_set.insert(*outpoint) { return Err(()); }
370380
input.push(TxIn {
371381
previous_output: outpoint.into_bitcoin_outpoint(),
@@ -1640,7 +1650,7 @@ impl KeysManager {
16401650
let witness = keys_cache.as_ref().unwrap().0.sign_dynamic_p2wsh_input(&psbt.unsigned_tx, input_idx, &descriptor, &secp_ctx)?;
16411651
psbt.inputs[input_idx].final_script_witness = Some(witness);
16421652
},
1643-
SpendableOutputDescriptor::StaticOutput { ref outpoint, ref output } => {
1653+
SpendableOutputDescriptor::StaticOutput { ref outpoint, ref output, .. } => {
16441654
let input_idx = psbt.unsigned_tx.input.iter().position(|i| i.previous_output == outpoint.into_bitcoin_outpoint()).ok_or(())?;
16451655
let derivation_idx = if output.script_pubkey == self.destination_script {
16461656
1

0 commit comments

Comments
 (0)