@@ -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 ;
@@ -1188,6 +1192,8 @@ impl KeysManager {
1188
1192
witness : Witness :: new ( ) ,
1189
1193
} ) ;
1190
1194
witness_weight += StaticPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1195
+ #[ cfg( feature = "grind_signatures" ) ]
1196
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1191
1197
input_value += descriptor. output . value ;
1192
1198
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
1193
1199
} ,
@@ -1199,6 +1205,8 @@ impl KeysManager {
1199
1205
witness : Witness :: new ( ) ,
1200
1206
} ) ;
1201
1207
witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1208
+ #[ cfg( feature = "grind_signatures" ) ]
1209
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1202
1210
input_value += descriptor. output . value ;
1203
1211
if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
1204
1212
} ,
@@ -1210,6 +1218,8 @@ impl KeysManager {
1210
1218
witness : Witness :: new ( ) ,
1211
1219
} ) ;
1212
1220
witness_weight += 1 + 73 + 34 ;
1221
+ #[ cfg( feature = "grind_signatures" ) ]
1222
+ { witness_weight -= 1 ; } // Guarantees a low R signature
1213
1223
input_value += output. value ;
1214
1224
if !output_set. insert ( * outpoint) { return Err ( ( ) ) ; }
1215
1225
}
0 commit comments