@@ -60,6 +60,11 @@ use crate::util::invoice::construct_invoice_preimage;
60
60
#[ derive( Hash , Copy , Clone , PartialEq , Eq , Debug ) ]
61
61
pub struct KeyMaterial ( pub [ u8 ; 32 ] ) ;
62
62
63
+ #[ cfg( feature = "grind_signatures" ) ]
64
+ const ECDSA_SIGNATURE_SIZE : usize = 72 ;
65
+ #[ cfg( not( feature = "grind_signatures" ) ) ]
66
+ const ECDSA_SIGNATURE_SIZE : usize = 73 ;
67
+
63
68
/// Information about a spendable output to a P2WSH script.
64
69
///
65
70
/// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this.
@@ -85,9 +90,9 @@ pub struct DelayedPaymentOutputDescriptor {
85
90
}
86
91
impl DelayedPaymentOutputDescriptor {
87
92
/// The maximum length a well-formed witness spending one of these should have.
88
- // Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
93
+ // Calculated as 1 byte length + ECDSA signature, 1 byte empty vec push, 1 byte length plus
89
94
// redeemscript push length.
90
- pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1 ;
95
+ pub const MAX_WITNESS_LENGTH : usize = 1 + ECDSA_SIGNATURE_SIZE + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1 ;
91
96
}
92
97
93
98
impl_writeable_tlv_based ! ( DelayedPaymentOutputDescriptor , {
@@ -117,9 +122,9 @@ pub struct StaticPaymentOutputDescriptor {
117
122
}
118
123
impl StaticPaymentOutputDescriptor {
119
124
/// The maximum length a well-formed witness spending one of these should have.
120
- // Calculated as 1 byte legnth + 73 byte signature, 1 byte empty vec push, 1 byte length plus
125
+ // Calculated as 1 byte legnth + ECDSA signature, 1 byte empty vec push, 1 byte length plus
121
126
// redeemscript push length.
122
- pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 34 ;
127
+ pub const MAX_WITNESS_LENGTH : usize = 1 + ECDSA_SIGNATURE_SIZE + 34 ;
123
128
}
124
129
impl_writeable_tlv_based ! ( StaticPaymentOutputDescriptor , {
125
130
( 0 , outpoint, required) ,
@@ -1209,7 +1214,7 @@ impl KeysManager {
1209
1214
sequence : Sequence :: ZERO ,
1210
1215
witness : Witness :: new ( ) ,
1211
1216
} ) ;
1212
- witness_weight += 1 + 73 + 34 ;
1217
+ witness_weight += 1 + ECDSA_SIGNATURE_SIZE + 34 ;
1213
1218
input_value += output. value ;
1214
1219
if !output_set. insert ( * outpoint) { return Err ( ( ) ) ; }
1215
1220
}
0 commit comments