@@ -25,6 +25,8 @@ use ln::msgs::DecodeError;
25
25
use ln:: PaymentPreimage ;
26
26
use ln:: chan_utils;
27
27
use ln:: chan_utils:: { TxCreationKeys , ChannelTransactionParameters , HolderCommitmentTransaction } ;
28
+ use ln:: package:: InputDescriptors ;
29
+ use ln:: package;
28
30
use chain:: chaininterface:: { FeeEstimator , BroadcasterInterface , ConfirmationTarget , MIN_RELAY_FEE_SAT_PER_1000_WEIGHT } ;
29
31
use chain:: channelmonitor:: { ANTI_REORG_DELAY , CLTV_SHARED_CLAIM_BUFFER , InputMaterial , ClaimRequest } ;
30
32
use chain:: keysinterface:: { Sign , KeysInterface } ;
@@ -123,62 +125,6 @@ impl Readable for ClaimTxBumpMaterial {
123
125
}
124
126
}
125
127
126
- #[ derive( PartialEq , Clone , Copy ) ]
127
- pub ( crate ) enum InputDescriptors {
128
- RevokedOfferedHTLC ,
129
- RevokedReceivedHTLC ,
130
- OfferedHTLC ,
131
- ReceivedHTLC ,
132
- RevokedOutput , // either a revoked to_holder output on commitment tx, a revoked HTLC-Timeout output or a revoked HTLC-Success output
133
- }
134
-
135
- impl Writeable for InputDescriptors {
136
- fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
137
- match self {
138
- & InputDescriptors :: RevokedOfferedHTLC => {
139
- writer. write_all ( & [ 0 ; 1 ] ) ?;
140
- } ,
141
- & InputDescriptors :: RevokedReceivedHTLC => {
142
- writer. write_all ( & [ 1 ; 1 ] ) ?;
143
- } ,
144
- & InputDescriptors :: OfferedHTLC => {
145
- writer. write_all ( & [ 2 ; 1 ] ) ?;
146
- } ,
147
- & InputDescriptors :: ReceivedHTLC => {
148
- writer. write_all ( & [ 3 ; 1 ] ) ?;
149
- }
150
- & InputDescriptors :: RevokedOutput => {
151
- writer. write_all ( & [ 4 ; 1 ] ) ?;
152
- }
153
- }
154
- Ok ( ( ) )
155
- }
156
- }
157
-
158
- impl Readable for InputDescriptors {
159
- fn read < R : :: std:: io:: Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
160
- let input_descriptor = match <u8 as Readable >:: read ( reader) ? {
161
- 0 => {
162
- InputDescriptors :: RevokedOfferedHTLC
163
- } ,
164
- 1 => {
165
- InputDescriptors :: RevokedReceivedHTLC
166
- } ,
167
- 2 => {
168
- InputDescriptors :: OfferedHTLC
169
- } ,
170
- 3 => {
171
- InputDescriptors :: ReceivedHTLC
172
- } ,
173
- 4 => {
174
- InputDescriptors :: RevokedOutput
175
- }
176
- _ => return Err ( DecodeError :: InvalidValue ) ,
177
- } ;
178
- Ok ( input_descriptor)
179
- }
180
- }
181
-
182
128
macro_rules! subtract_high_prio_fee {
183
129
( $logger: ident, $fee_estimator: expr, $value: expr, $predicted_weight: expr, $used_feerate: expr) => {
184
130
{
@@ -271,7 +217,7 @@ pub struct OnchainTxHandler<ChannelSigner: Sign> {
271
217
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
272
218
prev_holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > ,
273
219
274
- signer : ChannelSigner ,
220
+ pub ( super ) signer : ChannelSigner ,
275
221
pub ( crate ) channel_transaction_parameters : ChannelTransactionParameters ,
276
222
277
223
// Used to track claiming requests. If claim tx doesn't confirm before height timer expiration we need to bump
@@ -305,7 +251,7 @@ pub struct OnchainTxHandler<ChannelSigner: Sign> {
305
251
306
252
latest_height : u32 ,
307
253
308
- secp_ctx : Secp256k1 < secp256k1:: All > ,
254
+ pub ( super ) secp_ctx : Secp256k1 < secp256k1:: All > ,
309
255
}
310
256
311
257
impl < ChannelSigner : Sign > OnchainTxHandler < ChannelSigner > {
@@ -460,36 +406,6 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
460
406
}
461
407
}
462
408
463
- pub ( crate ) fn get_witnesses_weight ( inputs : & [ InputDescriptors ] ) -> usize {
464
- let mut tx_weight = 2 ; // count segwit flags
465
- for inp in inputs {
466
- // We use expected weight (and not actual) as signatures and time lock delays may vary
467
- tx_weight += match inp {
468
- // number_of_witness_elements + sig_length + revocation_sig + pubkey_length + revocationpubkey + witness_script_length + witness_script
469
- & InputDescriptors :: RevokedOfferedHTLC => {
470
- 1 + 1 + 73 + 1 + 33 + 1 + 133
471
- } ,
472
- // number_of_witness_elements + sig_length + revocation_sig + pubkey_length + revocationpubkey + witness_script_length + witness_script
473
- & InputDescriptors :: RevokedReceivedHTLC => {
474
- 1 + 1 + 73 + 1 + 33 + 1 + 139
475
- } ,
476
- // number_of_witness_elements + sig_length + counterpartyhtlc_sig + preimage_length + preimage + witness_script_length + witness_script
477
- & InputDescriptors :: OfferedHTLC => {
478
- 1 + 1 + 73 + 1 + 32 + 1 + 133
479
- } ,
480
- // number_of_witness_elements + sig_length + revocation_sig + pubkey_length + revocationpubkey + witness_script_length + witness_script
481
- & InputDescriptors :: ReceivedHTLC => {
482
- 1 + 1 + 73 + 1 + 1 + 1 + 139
483
- } ,
484
- // number_of_witness_elements + sig_length + revocation_sig + true_length + op_true + witness_script_length + witness_script
485
- & InputDescriptors :: RevokedOutput => {
486
- 1 + 1 + 73 + 1 + 1 + 1 + 77
487
- } ,
488
- } ;
489
- }
490
- tx_weight
491
- }
492
-
493
409
/// In LN, output claimed are time-sensitive, which means we have to spend them before reaching some timelock expiration. At in-channel
494
410
/// output detection, we generate a first version of a claim tx and associate to it a height timer. A height timer is an absolute block
495
411
/// height than once reached we should generate a new bumped "version" of the claim tx to be sure than we safely claim outputs before
@@ -581,11 +497,11 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
581
497
for per_outp_material in cached_claim_datas. per_input_material . values ( ) {
582
498
match per_outp_material {
583
499
& InputMaterial :: Revoked { ref input_descriptor, ref amount, .. } => {
584
- inputs_witnesses_weight += Self :: get_witnesses_weight ( & [ * input_descriptor] ) ;
500
+ inputs_witnesses_weight += package :: get_witnesses_weight ( & [ * input_descriptor] ) ;
585
501
amt += * amount;
586
502
} ,
587
503
& InputMaterial :: CounterpartyHTLC { ref preimage, ref htlc, .. } => {
588
- inputs_witnesses_weight += Self :: get_witnesses_weight ( if preimage. is_some ( ) { & [ InputDescriptors :: OfferedHTLC ] } else { & [ InputDescriptors :: ReceivedHTLC ] } ) ;
504
+ inputs_witnesses_weight += package :: get_witnesses_weight ( if preimage. is_some ( ) { & [ InputDescriptors :: OfferedHTLC ] } else { & [ InputDescriptors :: ReceivedHTLC ] } ) ;
589
505
amt += htlc. amount_msat / 1000 ;
590
506
} ,
591
507
& InputMaterial :: HolderHTLC { .. } => {
0 commit comments