@@ -31,7 +31,7 @@ const SIP_HARDENED_CHILD_INDEX: u32 = 787;
3131
3232/// Information about a generated SIP address.
3333#[ derive( Debug , Clone ) ]
34- pub ( crate ) struct SipAddressInfo {
34+ pub struct SipAddressInfo {
3535 /// The BIP32 derivation index.
3636 pub index : u32 ,
3737 /// The derived user public key.
@@ -45,7 +45,7 @@ pub(crate) struct SipAddressInfo {
4545/// Key derivation uses BIP32: user keys are derived at `m/787'/<index>` from the node's
4646/// master key. The server (LSP) public key and CSV delay are obtained during the initial
4747/// SIP protocol exchange and remain fixed for the lifetime of the wallet.
48- pub ( crate ) struct SipWallet {
48+ pub struct SipWallet {
4949 /// BIP32 extended private key for deriving user keys.
5050 user_xpriv : Xpriv ,
5151 /// The server (LSP) public key used in all SIP addresses.
@@ -68,7 +68,7 @@ impl SipWallet {
6868 ///
6969 /// The `master_xpriv` should be the node's master extended private key. SIP user keys are
7070 /// derived from it at `m/787'/<index>`.
71- pub ( crate ) fn new (
71+ pub fn new (
7272 master_xpriv : Xpriv , server_pubkey : PublicKey , csv_delay : u16 , network : Network ,
7373 logger : Arc < Logger > ,
7474 ) -> Self {
@@ -103,25 +103,25 @@ impl SipWallet {
103103 }
104104
105105 /// Derives the user public key for the given address index.
106- pub ( crate ) fn derive_user_pubkey ( & self , index : u32 ) -> PublicKey {
106+ pub fn derive_user_pubkey ( & self , index : u32 ) -> PublicKey {
107107 let secp = Secp256k1 :: new ( ) ;
108108 PublicKey :: from_secret_key ( & secp, & self . derive_user_secret_key ( index) )
109109 }
110110
111111 /// Returns the server (LSP) public key.
112- pub ( crate ) fn server_pubkey ( & self ) -> PublicKey {
112+ pub fn server_pubkey ( & self ) -> PublicKey {
113113 self . server_pubkey
114114 }
115115
116116 /// Returns the CSV delay in blocks.
117- pub ( crate ) fn csv_delay ( & self ) -> u16 {
117+ pub fn csv_delay ( & self ) -> u16 {
118118 self . csv_delay
119119 }
120120
121121 /// Generates a new SIP deposit address.
122122 ///
123123 /// Each call increments the internal derivation index, producing a unique address.
124- pub ( crate ) fn new_address ( & self ) -> SipAddressInfo {
124+ pub fn new_address ( & self ) -> SipAddressInfo {
125125 let index = self . next_index . fetch_add ( 1 , Ordering :: Relaxed ) ;
126126 let user_pk = self . derive_user_pubkey ( index) ;
127127 let witness_script =
@@ -138,7 +138,7 @@ impl SipWallet {
138138
139139 /// Returns the satisfaction weight for cooperative spends from SIP addresses managed by this
140140 /// wallet. This is constant for all addresses since they share the same script structure.
141- pub ( crate ) fn cooperative_satisfaction_weight ( & self ) -> bitcoin:: Weight {
141+ pub fn cooperative_satisfaction_weight ( & self ) -> bitcoin:: Weight {
142142 // Use index 0 as representative -- all SIP addresses have the same script structure
143143 // and thus the same satisfaction weight.
144144 let user_pk = self . derive_user_pubkey ( 0 ) ;
@@ -151,7 +151,7 @@ impl SipWallet {
151151 ///
152152 /// The chain source should watch these for incoming transactions. This returns the
153153 /// P2WSH scriptPubKey for each generated SIP address.
154- pub ( crate ) fn script_pubkeys_to_watch ( & self ) -> Vec < bitcoin:: ScriptBuf > {
154+ pub fn script_pubkeys_to_watch ( & self ) -> Vec < bitcoin:: ScriptBuf > {
155155 let addresses = self . addresses . lock ( ) . unwrap ( ) ;
156156 addresses
157157 . values ( )
@@ -169,7 +169,7 @@ impl SipWallet {
169169 /// Registers a newly discovered UTXO at a SIP address.
170170 ///
171171 /// Called when the chain source discovers a deposit to one of our SIP addresses.
172- pub ( crate ) fn register_utxo (
172+ pub fn register_utxo (
173173 & self , outpoint : OutPoint , value : Amount , address_index : u32 , prevtx : Transaction ,
174174 ) {
175175 let user_pk = self . derive_user_pubkey ( address_index) ;
@@ -197,7 +197,7 @@ impl SipWallet {
197197 }
198198
199199 /// Updates a UTXO's state to confirmed.
200- pub ( crate ) fn confirm_utxo ( & self , outpoint : & OutPoint , confirmed_at_height : u32 ) {
200+ pub fn confirm_utxo ( & self , outpoint : & OutPoint , confirmed_at_height : u32 ) {
201201 let mut utxos = self . utxos . lock ( ) . unwrap ( ) ;
202202 if let Some ( utxo) = utxos. get_mut ( outpoint) {
203203 if matches ! ( utxo. state, SipUtxoState :: Unconfirmed ) {
@@ -215,7 +215,7 @@ impl SipWallet {
215215 /// Updates UTXO states based on the current chain tip height.
216216 ///
217217 /// Transitions confirmed UTXOs to `CsvExpired` when the relative timelock has elapsed.
218- pub ( crate ) fn update_csv_expiry ( & self , current_height : u32 ) {
218+ pub fn update_csv_expiry ( & self , current_height : u32 ) {
219219 let mut utxos = self . utxos . lock ( ) . unwrap ( ) ;
220220 for utxo in utxos. values_mut ( ) {
221221 if utxo. csv_expired ( current_height)
@@ -233,32 +233,32 @@ impl SipWallet {
233233 }
234234
235235 /// Returns all tracked SIP UTXOs that are confirmed and eligible for swapping.
236- pub ( crate ) fn swappable_utxos ( & self ) -> Vec < SipUtxo > {
236+ pub fn swappable_utxos ( & self ) -> Vec < SipUtxo > {
237237 self . utxos . lock ( ) . unwrap ( ) . values ( ) . filter ( |u| u. is_swappable ( ) ) . cloned ( ) . collect ( )
238238 }
239239
240240 /// Returns all tracked SIP UTXOs whose CSV has expired and are eligible for refund.
241- pub ( crate ) fn refundable_utxos ( & self ) -> Vec < SipUtxo > {
241+ pub fn refundable_utxos ( & self ) -> Vec < SipUtxo > {
242242 self . utxos . lock ( ) . unwrap ( ) . values ( ) . filter ( |u| u. is_refundable ( ) ) . cloned ( ) . collect ( )
243243 }
244244
245245 /// Returns information about all tracked SIP UTXOs for the public API.
246- pub ( crate ) fn list_utxos ( & self ) -> Vec < SipUtxoInfo > {
246+ pub fn list_utxos ( & self ) -> Vec < SipUtxoInfo > {
247247 self . utxos . lock ( ) . unwrap ( ) . values ( ) . map ( SipUtxoInfo :: from) . collect ( )
248248 }
249249
250250 /// Returns the total balance across all non-terminal SIP UTXOs.
251- pub ( crate ) fn total_balance ( & self ) -> Amount {
251+ pub fn total_balance ( & self ) -> Amount {
252252 self . utxos . lock ( ) . unwrap ( ) . values ( ) . filter ( |u| !u. is_terminal ( ) ) . map ( |u| u. value ) . sum ( )
253253 }
254254
255255 /// Returns the balance of confirmed, swappable SIP UTXOs.
256- pub ( crate ) fn spendable_balance ( & self ) -> Amount {
256+ pub fn spendable_balance ( & self ) -> Amount {
257257 self . utxos . lock ( ) . unwrap ( ) . values ( ) . filter ( |u| u. is_swappable ( ) ) . map ( |u| u. value ) . sum ( )
258258 }
259259
260260 /// Returns the balance of unconfirmed SIP UTXOs.
261- pub ( crate ) fn pending_balance ( & self ) -> Amount {
261+ pub fn pending_balance ( & self ) -> Amount {
262262 self . utxos
263263 . lock ( )
264264 . unwrap ( )
@@ -271,18 +271,18 @@ impl SipWallet {
271271 /// Returns the user secret key for signing a cooperative or refund spend.
272272 ///
273273 /// This is used by the SIP protocol handlers when constructing spending transactions.
274- pub ( crate ) fn signing_key ( & self , address_index : u32 ) -> SecretKey {
274+ pub fn signing_key ( & self , address_index : u32 ) -> SecretKey {
275275 self . derive_user_secret_key ( address_index)
276276 }
277277
278278 /// Looks up the address index for a given SIP address, if it was generated by this wallet.
279- pub ( crate ) fn address_index_for ( & self , address : & Address ) -> Option < u32 > {
279+ pub fn address_index_for ( & self , address : & Address ) -> Option < u32 > {
280280 let addresses = self . addresses . lock ( ) . unwrap ( ) ;
281281 addresses. iter ( ) . find ( |( _, info) | & info. address == address) . map ( |( index, _) | * index)
282282 }
283283
284284 /// Marks a UTXO as swap-initiated.
285- pub ( crate ) fn mark_swap_initiated (
285+ pub fn mark_swap_initiated (
286286 & self , outpoint : & OutPoint , channel_id : lightning:: ln:: types:: ChannelId ,
287287 ) {
288288 let mut utxos = self . utxos . lock ( ) . unwrap ( ) ;
@@ -301,7 +301,7 @@ impl SipWallet {
301301 }
302302
303303 /// Marks a UTXO as swapped (terminal state).
304- pub ( crate ) fn mark_swapped (
304+ pub fn mark_swapped (
305305 & self , outpoint : & OutPoint , channel_id : lightning:: ln:: types:: ChannelId ,
306306 ) {
307307 let mut utxos = self . utxos . lock ( ) . unwrap ( ) ;
@@ -312,7 +312,7 @@ impl SipWallet {
312312 }
313313
314314 /// Marks a UTXO as refunded (terminal state).
315- pub ( crate ) fn mark_refunded ( & self , outpoint : & OutPoint , spending_txid : Txid ) {
315+ pub fn mark_refunded ( & self , outpoint : & OutPoint , spending_txid : Txid ) {
316316 let mut utxos = self . utxos . lock ( ) . unwrap ( ) ;
317317 if let Some ( utxo) = utxos. get_mut ( outpoint) {
318318 log_info ! ( self . logger, "SIP UTXO {} refunded via {}" , outpoint, spending_txid) ;
@@ -324,7 +324,7 @@ impl SipWallet {
324324 ///
325325 /// Returns the signed transaction and the outpoints being swept, or `None` if no UTXOs are
326326 /// eligible for refund.
327- pub ( crate ) fn build_refund_transaction (
327+ pub fn build_refund_transaction (
328328 & self , destination : bitcoin:: ScriptBuf , fee_rate : FeeRate ,
329329 ) -> Option < ( Transaction , Vec < OutPoint > ) > {
330330 let secp = Secp256k1 :: new ( ) ;
0 commit comments