@@ -85,6 +85,8 @@ pub struct DelayedPaymentOutputDescriptor {
85
85
}
86
86
impl DelayedPaymentOutputDescriptor {
87
87
/// The maximum length a well-formed witness spending one of these should have.
88
+ /// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
89
+ /// shorter.
88
90
// Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
89
91
// redeemscript push length.
90
92
pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1 ;
@@ -117,6 +119,8 @@ pub struct StaticPaymentOutputDescriptor {
117
119
}
118
120
impl StaticPaymentOutputDescriptor {
119
121
/// The maximum length a well-formed witness spending one of these should have.
122
+ /// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
123
+ /// shorter.
120
124
// Calculated as 1 byte legnth + 73 byte signature, 1 byte empty vec push, 1 byte length plus
121
125
// redeemscript push length.
122
126
pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 34 ;
@@ -1194,6 +1198,8 @@ impl KeysManager {
1194
1198
witness : Witness :: new ( ) ,
1195
1199
} ) ;
1196
1200
witness_weight += StaticPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1201
+ #[ cfg( feature = "grind_signatures" ) ]
1202
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1197
1203
input_value += descriptor. output . value ;
1198
1204
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
1199
1205
} ,
@@ -1205,6 +1211,8 @@ impl KeysManager {
1205
1211
witness : Witness :: new ( ) ,
1206
1212
} ) ;
1207
1213
witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1214
+ #[ cfg( feature = "grind_signatures" ) ]
1215
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1208
1216
input_value += descriptor. output . value ;
1209
1217
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
1210
1218
} ,
@@ -1216,6 +1224,8 @@ impl KeysManager {
1216
1224
witness : Witness :: new ( ) ,
1217
1225
} ) ;
1218
1226
witness_weight += 1 + 73 + 34 ;
1227
+ #[ cfg( feature = "grind_signatures" ) ]
1228
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1219
1229
input_value += output. value ;
1220
1230
if !output_set. insert ( * outpoint) { return Err ( ( ) ) ; }
1221
1231
}
0 commit comments