@@ -16,6 +16,7 @@ use core::ops::Deref;
1616use crate :: chain:: chaininterface:: BroadcasterInterface ;
1717use crate :: chain:: ClaimId ;
1818use crate :: io_extras:: sink;
19+ use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
1920use crate :: ln:: chan_utils;
2021use crate :: ln:: chan_utils:: {
2122 ANCHOR_INPUT_WITNESS_WEIGHT , HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT ,
@@ -74,6 +75,15 @@ pub struct AnchorDescriptor {
7475}
7576
7677impl AnchorDescriptor {
78+ /// Returns the UTXO to be spent by the anchor input, which can be obtained via
79+ /// [`Self::unsigned_tx_input`].
80+ pub fn spending_utxo ( & self ) -> TxOut {
81+ TxOut {
82+ script_pubkey : self . witness_script ( ) . to_v0_p2wsh ( ) ,
83+ value : ANCHOR_OUTPUT_VALUE_SATOSHI ,
84+ }
85+ }
86+
7787 /// Returns the unsigned transaction input spending the anchor output in the commitment
7888 /// transaction.
7989 pub fn unsigned_tx_input ( & self ) -> TxIn {
@@ -134,6 +144,15 @@ pub struct HTLCDescriptor {
134144}
135145
136146impl HTLCDescriptor {
147+ /// Returns the UTXO to be spent by the HTLC input, which can be obtained via
148+ /// [`Self::unsigned_tx_input`].
149+ pub fn spending_utxo < C : secp256k1:: Signing + secp256k1:: Verification > ( & self , secp : & Secp256k1 < C > ) -> TxOut {
150+ TxOut {
151+ script_pubkey : self . witness_script ( secp) . to_v0_p2wsh ( ) ,
152+ value : self . htlc . amount_msat / 1000 ,
153+ }
154+ }
155+
137156 /// Returns the unsigned transaction input spending the HTLC output in the commitment
138157 /// transaction.
139158 pub fn unsigned_tx_input ( & self ) -> TxIn {
0 commit comments