@@ -18,6 +18,7 @@ use core::ops::Deref;
18
18
use crate :: chain:: chaininterface:: BroadcasterInterface ;
19
19
use crate :: chain:: ClaimId ;
20
20
use crate :: io_extras:: sink;
21
+ use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
21
22
use crate :: ln:: chan_utils;
22
23
use crate :: ln:: chan_utils:: {
23
24
ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
@@ -76,6 +77,15 @@ pub struct AnchorDescriptor {
76
77
}
77
78
78
79
impl AnchorDescriptor {
80
+ /// Returns the UTXO to be spent by the anchor input, which can be obtained via
81
+ /// [`Self::unsigned_tx_input`].
82
+ pub fn spending_utxo ( & self ) -> TxOut {
83
+ TxOut {
84
+ script_pubkey : self . witness_script ( ) . to_v0_p2wsh ( ) ,
85
+ value : ANCHOR_OUTPUT_VALUE_SATOSHI ,
86
+ }
87
+ }
88
+
79
89
/// Returns the unsigned transaction input spending the anchor output in the commitment
80
90
/// transaction.
81
91
pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -136,6 +146,15 @@ pub struct HTLCDescriptor {
136
146
}
137
147
138
148
impl HTLCDescriptor {
149
+ /// Returns the UTXO to be spent by the HTLC input, which can be obtained via
150
+ /// [`Self::unsigned_tx_input`].
151
+ pub fn spending_utxo < C : secp256k1:: Signing + secp256k1:: Verification > ( & self , secp : & Secp256k1 < C > ) -> TxOut {
152
+ TxOut {
153
+ script_pubkey : self . witness_script ( secp) . to_v0_p2wsh ( ) ,
154
+ value : self . htlc . amount_msat / 1000 ,
155
+ }
156
+ }
157
+
139
158
/// Returns the unsigned transaction input spending the HTLC output in the commitment
140
159
/// transaction.
141
160
pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -322,6 +341,8 @@ pub enum BumpTransactionEvent {
322
341
pub struct Input {
323
342
/// The unique identifier of the input.
324
343
pub outpoint : OutPoint ,
344
+ /// The UTXO being spent by the input.
345
+ pub utxo : TxOut ,
325
346
/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
326
347
/// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
327
348
/// script.
@@ -661,6 +682,7 @@ where
661
682
) -> Result < Transaction , ( ) > {
662
683
let must_spend = vec ! [ Input {
663
684
outpoint: anchor_descriptor. outpoint,
685
+ utxo: anchor_descriptor. spending_utxo( ) ,
664
686
satisfaction_weight: commitment_tx. weight( ) as u64 + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT ,
665
687
} ] ;
666
688
let coin_selection = self . utxo_source . select_confirmed_utxos (
@@ -727,6 +749,7 @@ where
727
749
let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
728
750
must_spend. push ( Input {
729
751
outpoint : htlc_input. previous_output . clone ( ) ,
752
+ utxo : htlc_descriptor. spending_utxo ( & self . secp ) ,
730
753
satisfaction_weight : EMPTY_SCRIPT_SIG_WEIGHT + if htlc_descriptor. preimage . is_some ( ) {
731
754
HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT
732
755
} else {
0 commit comments