Skip to content

Commit 9e0d38a

Browse files
committed
f! docs
1 parent 88c7552 commit 9e0d38a

File tree

2 files changed

+39
-23
lines changed

2 files changed

+39
-23
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,11 +2378,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
23782378
for htlc in htlcs {
23792379
match htlc {
23802380
ExternalHTLCClaim::SecondStage {
2381-
amount, per_commitment_number, redeem_script, preimage, counterparty_sig
2381+
amount_sats, per_commitment_number, redeem_script, preimage, counterparty_sig
23822382
} => htlc_descriptors.push(HTLCDescriptor::SecondStage {
23832383
channel_keys_id: self.channel_keys_id,
23842384
channel_value_satoshis: self.channel_value_satoshis,
2385-
amount,
2385+
amount_satoshis: amount_sats,
23862386
per_commitment_number,
23872387
redeem_script,
23882388
preimage,

lightning/src/util/events.rs

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,37 @@ pub struct AnchorDescriptor {
227227
pub outpoint: OutPoint,
228228
}
229229

230+
#[cfg(anchors)]
231+
/// A descriptor used to sign for a commitment transaction's HTLC output.
232+
#[derive(Clone, Debug)]
233+
pub enum HTLCDescriptor {
234+
/// A variant used to sign for HTLC inputs being spent by their pre-signed second-stage
235+
/// transactions.
236+
SecondStage {
237+
/// A unique identifier used along with `channel_value_satoshis` to re-derive the
238+
/// [`InMemorySigner`] required to sign `input`.
239+
///
240+
/// [`InMemorySigner`]: crate::chain::keysinterface::InMemorySigner
241+
channel_keys_id: [u8; 32],
242+
/// The value in satoshis of the channel we're attempting to spend the anchor output of. This is
243+
/// used along with `channel_keys_id` to re-derive the [`InMemorySigner`] required to sign
244+
/// `input`.
245+
///
246+
/// [`InMemorySigner`]: crate::chain::keysinterface::InMemorySigner
247+
channel_value_satoshis: u64,
248+
/// The amount in satoshis of the HTLC output in the commitment transaction.
249+
amount_satoshis: u64,
250+
/// The number of the commitment transaction in which the HTLC output lives.
251+
per_commitment_number: u64,
252+
/// The redeem script that satisfies the HTLC output script.
253+
redeem_script: Script,
254+
/// The preimage, if one exists, to claim the HTLC output with.
255+
preimage: Option<PaymentPreimage>,
256+
/// The counterparty's signature required to spend the HTLC output.
257+
counterparty_sig: Signature
258+
}
259+
}
260+
230261
#[cfg(anchors)]
231262
/// Represents the different types of transactions, originating from LDK, to be bumped.
232263
#[derive(Clone, Debug)]
@@ -294,18 +325,16 @@ pub enum BumpTransactionEvent {
294325
/// onchain. With the zero-HTLC-transaction-fee variant of anchor outputs, the pre-signed HTLC
295326
/// transactions have a zero fee, thus requiring additional inputs and/or outputs to be attached
296327
/// for a timely confirmation within the chain. These additional inputs and/or outputs must be
297-
/// appended to the enclosed `tx_template` to meet the target feerate. Consumers must ensure the
298-
/// order of pre-existing inputs and outputs within `tx_template` are not changed, as it is
299-
/// crucial to the validity of the transaction itself. Failure to meet the target feerate
300-
/// decreases the confirmation odds of the transaction, possinly resulting in a loss of funds.
301-
/// Once the transaction is amended to meet the target feerate, it must be signed for and
302-
/// broadcast by the consumer of the event.
328+
/// appended to the enclosed `tx_template` to meet the target feerate. Failure to meet the
329+
/// target feerate decreases the confirmation odds of the transaction, possibly resulting in a
330+
/// loss of funds. Once the transaction is amended to meet the target feerate, it must be signed
331+
/// for and broadcast by the consumer of the event.
303332
///
304333
/// The consumer should be able to sign for any of the additional inputs added to `tx_template`.
305334
/// To sign HTLC inputs, an [`InMemorySigner`] should be re-derived through
306335
/// [`KeysManager::derive_channel_keys`] with the help of `channel_keys_id` and
307-
/// `AnchorDescriptor::channel_value_satoshis`. Each HTLC input's signature can be computed
308-
/// with [`InMemorySigner::sign_holder_htlc_transaction`], which can then be provided to
336+
/// `channel_value_satoshis`. Each HTLC input's signature can be computed with
337+
/// [`InMemorySigner::sign_holder_htlc_transaction`], which can then be provided to
309338
/// [`build_htlc_input_witness`] along with the enclosed [`HTLCDescriptor`] to obtain the full
310339
/// witness required to spend.
311340
///
@@ -328,19 +357,6 @@ pub enum BumpTransactionEvent {
328357
},
329358
}
330359

331-
#[derive(Clone, Debug)]
332-
pub enum HTLCDescriptor {
333-
SecondStage {
334-
channel_keys_id: [u8; 32],
335-
channel_value_satoshis: u64,
336-
amount: u64,
337-
per_commitment_number: u64,
338-
redeem_script: Script,
339-
preimage: Option<PaymentPreimage>,
340-
counterparty_sig: Signature
341-
}
342-
}
343-
344360
/// An Event which you should probably take some action in response to.
345361
///
346362
/// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use

0 commit comments

Comments
 (0)