@@ -85,6 +85,8 @@ pub struct DelayedPaymentOutputDescriptor {
8585}
8686impl DelayedPaymentOutputDescriptor {
8787 /// 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.
8890 // Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
8991 // redeemscript push length.
9092 pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1 ;
@@ -117,6 +119,8 @@ pub struct StaticPaymentOutputDescriptor {
117119}
118120impl StaticPaymentOutputDescriptor {
119121 /// 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.
120124 // Calculated as 1 byte legnth + 73 byte signature, 1 byte empty vec push, 1 byte length plus
121125 // redeemscript push length.
122126 pub const MAX_WITNESS_LENGTH : usize = 1 + 73 + 34 ;
@@ -1194,6 +1198,8 @@ impl KeysManager {
11941198 witness : Witness :: new ( ) ,
11951199 } ) ;
11961200 witness_weight += StaticPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1201+ #[ cfg( feature = "grind_signatures" ) ]
1202+ { witness_weight -= 1 ; } // Guarantees a low R signature
11971203 input_value += descriptor. output . value ;
11981204 if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
11991205 } ,
@@ -1205,6 +1211,8 @@ impl KeysManager {
12051211 witness : Witness :: new ( ) ,
12061212 } ) ;
12071213 witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1214+ #[ cfg( feature = "grind_signatures" ) ]
1215+ { witness_weight -= 1 ; } // Guarantees a low R signature
12081216 input_value += descriptor. output . value ;
12091217 if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
12101218 } ,
@@ -1216,6 +1224,8 @@ impl KeysManager {
12161224 witness : Witness :: new ( ) ,
12171225 } ) ;
12181226 witness_weight += 1 + 73 + 34 ;
1227+ #[ cfg( feature = "grind_signatures" ) ]
1228+ { witness_weight -= 1 ; } // Guarantees a low R signature
12191229 input_value += output. value ;
12201230 if !output_set. insert ( * outpoint) { return Err ( ( ) ) ; }
12211231 }
0 commit comments