@@ -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 ;
@@ -1188,6 +1192,8 @@ impl KeysManager {
11881192 witness : Witness :: new ( ) ,
11891193 } ) ;
11901194 witness_weight += StaticPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1195+ #[ cfg( feature = "grind_signatures" ) ]
1196+ { witness_weight -= 1 ; } // Guarantees a low R signature
11911197 input_value += descriptor. output . value ;
11921198 if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
11931199 } ,
@@ -1199,6 +1205,8 @@ impl KeysManager {
11991205 witness : Witness :: new ( ) ,
12001206 } ) ;
12011207 witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
1208+ #[ cfg( feature = "grind_signatures" ) ]
1209+ { witness_weight -= 1 ; } // Guarantees a low R signature
12021210 input_value += descriptor. output . value ;
12031211 if !output_set. insert ( descriptor. outpoint ) { return Err ( ( ) ) ; }
12041212 } ,
@@ -1210,6 +1218,8 @@ impl KeysManager {
12101218 witness : Witness :: new ( ) ,
12111219 } ) ;
12121220 witness_weight += 1 + 73 + 34 ;
1221+ #[ cfg( feature = "grind_signatures" ) ]
1222+ { witness_weight -= 1 ; } // Guarantees a low R signature
12131223 input_value += output. value ;
12141224 if !output_set. insert ( * outpoint) { return Err ( ( ) ) ; }
12151225 }
0 commit comments