@@ -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 previous_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 {
@@ -139,6 +149,15 @@ pub struct HTLCDescriptor {
139
149
}
140
150
141
151
impl HTLCDescriptor {
152
+ /// Returns the UTXO to be spent by the HTLC input, which can be obtained via
153
+ /// [`Self::unsigned_tx_input`].
154
+ pub fn previous_utxo < C : secp256k1:: Signing + secp256k1:: Verification > ( & self , secp : & Secp256k1 < C > ) -> TxOut {
155
+ TxOut {
156
+ script_pubkey : self . witness_script ( secp) . to_v0_p2wsh ( ) ,
157
+ value : self . htlc . amount_msat / 1000 ,
158
+ }
159
+ }
160
+
142
161
/// Returns the unsigned transaction input spending the HTLC output in the commitment
143
162
/// transaction.
144
163
pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -325,6 +344,8 @@ pub enum BumpTransactionEvent {
325
344
pub struct Input {
326
345
/// The unique identifier of the input.
327
346
pub outpoint : OutPoint ,
347
+ /// The UTXO being spent by the input.
348
+ pub previous_utxo : TxOut ,
328
349
/// The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
329
350
/// [`TxIn::witness`], each with their lengths included, required to satisfy the output's
330
351
/// script.
@@ -664,6 +685,7 @@ where
664
685
) -> Result < Transaction , ( ) > {
665
686
let must_spend = vec ! [ Input {
666
687
outpoint: anchor_descriptor. outpoint,
688
+ previous_utxo: anchor_descriptor. previous_utxo( ) ,
667
689
satisfaction_weight: commitment_tx. weight( ) as u64 + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT ,
668
690
} ] ;
669
691
let coin_selection = self . utxo_source . select_confirmed_utxos (
@@ -730,6 +752,7 @@ where
730
752
let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
731
753
must_spend. push ( Input {
732
754
outpoint : htlc_input. previous_output . clone ( ) ,
755
+ previous_utxo : htlc_descriptor. previous_utxo ( & self . secp ) ,
733
756
satisfaction_weight : EMPTY_SCRIPT_SIG_WEIGHT + if htlc_descriptor. preimage . is_some ( ) {
734
757
HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT
735
758
} else {
0 commit comments