X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fkeysinterface.rs;h=3ccab2ce9dabb0b36f9876210a1d39bd5faff98d;hb=0517b18a01cc3b1bad9b7101e400055656da44db;hp=b1290708b95f70a71ebf6193cceb1677aa3150bd;hpb=16edbd41963f79638325f1864f21e9d4520fe859;p=rust-lightning diff --git a/lightning/src/chain/keysinterface.rs b/lightning/src/chain/keysinterface.rs index b1290708..3ccab2ce 100644 --- a/lightning/src/chain/keysinterface.rs +++ b/lightning/src/chain/keysinterface.rs @@ -85,6 +85,8 @@ pub struct DelayedPaymentOutputDescriptor { } impl DelayedPaymentOutputDescriptor { /// The maximum length a well-formed witness spending one of these should have. + /// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte + /// shorter. // Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus // redeemscript push length. pub const MAX_WITNESS_LENGTH: usize = 1 + 73 + 1 + chan_utils::REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH + 1; @@ -117,6 +119,8 @@ pub struct StaticPaymentOutputDescriptor { } impl StaticPaymentOutputDescriptor { /// The maximum length a well-formed witness spending one of these should have. + /// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte + /// shorter. // Calculated as 1 byte legnth + 73 byte signature, 1 byte empty vec push, 1 byte length plus // redeemscript push length. pub const MAX_WITNESS_LENGTH: usize = 1 + 73 + 34; @@ -1188,6 +1192,8 @@ impl KeysManager { witness: Witness::new(), }); witness_weight += StaticPaymentOutputDescriptor::MAX_WITNESS_LENGTH; + #[cfg(feature = "grind_signatures")] + { witness_weight -= 1; } // Guarantees a low R signature input_value += descriptor.output.value; if !output_set.insert(descriptor.outpoint) { return Err(()); } }, @@ -1199,6 +1205,8 @@ impl KeysManager { witness: Witness::new(), }); witness_weight += DelayedPaymentOutputDescriptor::MAX_WITNESS_LENGTH; + #[cfg(feature = "grind_signatures")] + { witness_weight -= 1; } // Guarantees a low R signature input_value += descriptor.output.value; if !output_set.insert(descriptor.outpoint) { return Err(()); } }, @@ -1210,6 +1218,8 @@ impl KeysManager { witness: Witness::new(), }); witness_weight += 1 + 73 + 34; + #[cfg(feature = "grind_signatures")] + { witness_weight -= 1; } // Guarantees a low R signature input_value += output.value; if !output_set.insert(*outpoint) { return Err(()); } }