@@ -18,6 +18,7 @@ use core::ops::Deref;
1818use crate :: chain:: chaininterface:: BroadcasterInterface ;
1919use crate :: chain:: ClaimId ;
2020use crate :: io_extras:: sink;
21+ use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
2122use crate :: ln:: chan_utils;
2223use crate :: ln:: chan_utils:: {
2324 ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
@@ -76,6 +77,15 @@ pub struct AnchorDescriptor {
7677}
7778
7879impl 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 previous_utxo ( & self ) -> TxOut {
83+ TxOut {
84+ script_pubkey : self . witness_script ( ) . to_v0_p2wsh ( ) ,
85+ value : ANCHOR_OUTPUT_VALUE_SATOSHI ,
86+ }
87+ }
88+
7989 /// Returns the unsigned transaction input spending the anchor output in the commitment
8090 /// transaction.
8191 pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -136,6 +146,15 @@ pub struct HTLCDescriptor {
136146}
137147
138148impl 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 previous_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+
139158 /// Returns the unsigned transaction input spending the HTLC output in the commitment
140159 /// transaction.
141160 pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -322,6 +341,8 @@ pub enum BumpTransactionEvent {
322341pub struct Input {
323342 /// The unique identifier of the input.
324343 pub outpoint : OutPoint ,
344+ /// The UTXO being spent by the input.
345+ pub previous_utxo : TxOut ,
325346 /// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
326347 /// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
327348 /// script.
@@ -661,6 +682,7 @@ where
661682 ) -> Result < Transaction , ( ) > {
662683 let must_spend = vec ! [ Input {
663684 outpoint: anchor_descriptor. outpoint,
685+ previous_utxo: anchor_descriptor. previous_utxo( ) ,
664686 satisfaction_weight: commitment_tx. weight( ) as u64 + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT ,
665687 } ] ;
666688 let coin_selection = self . utxo_source . select_confirmed_utxos (
@@ -727,6 +749,7 @@ where
727749 let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
728750 must_spend. push ( Input {
729751 outpoint : htlc_input. previous_output . clone ( ) ,
752+ previous_utxo : htlc_descriptor. previous_utxo ( & self . secp ) ,
730753 satisfaction_weight : EMPTY_SCRIPT_SIG_WEIGHT + if htlc_descriptor. preimage . is_some ( ) {
731754 HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT
732755 } else {
0 commit comments