@@ -115,16 +115,8 @@ pub struct DelayedPaymentOutputDescriptor {
115
115
///
116
116
/// Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later.
117
117
pub channel_transaction_parameters : Option < ChannelTransactionParameters > ,
118
- }
119
-
120
- impl DelayedPaymentOutputDescriptor {
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.
124
- // Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
125
- // redeemscript push length.
126
- pub const MAX_WITNESS_LENGTH : u64 =
127
- 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH as u64 + 1 ;
118
+ /// Witness weight
119
+ pub witness_weight : u64 ,
128
120
}
129
121
130
122
impl_writeable_tlv_based ! ( DelayedPaymentOutputDescriptor , {
@@ -136,6 +128,8 @@ impl_writeable_tlv_based!(DelayedPaymentOutputDescriptor, {
136
128
( 10 , channel_keys_id, required) ,
137
129
( 12 , channel_value_satoshis, required) ,
138
130
( 13 , channel_transaction_parameters, option) ,
131
+ // Don't break downgrades ?
132
+ ( 15 , witness_weight, ( default_value, 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH as u64 + 1 ) ) ,
139
133
} ) ;
140
134
141
135
pub ( crate ) const P2WPKH_WITNESS_WEIGHT : u64 = 1 /* num stack items */ +
@@ -483,7 +477,7 @@ impl SpendableOutputDescriptor {
483
477
sequence : Sequence ( descriptor. to_self_delay as u32 ) ,
484
478
witness : Witness :: new ( ) ,
485
479
} ) ;
486
- witness_weight += DelayedPaymentOutputDescriptor :: MAX_WITNESS_LENGTH ;
480
+ witness_weight += descriptor . witness_weight ;
487
481
#[ cfg( feature = "grind_signatures" ) ]
488
482
{
489
483
// Guarantees a low R signature
@@ -1100,6 +1094,16 @@ pub trait ChannelSigner {
1100
1094
P2WPKH_WITNESS_WEIGHT
1101
1095
}
1102
1096
}
1097
+
1098
+ /// Gets the weight of the witness that spends a `to_local` output
1099
+ fn get_to_local_witness_weight ( & self ) -> u64 {
1100
+ // The maximum length a well-formed witness spending one of these should have.
1101
+ // Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
1102
+ // shorter.
1103
+ // Calculated as 1 byte length + 73 byte signature, 1 byte empty vec push, 1 byte length plus
1104
+ // redeemscript push length.
1105
+ 1 + 73 + 1 + chan_utils:: REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH as u64 + 1
1106
+ }
1103
1107
}
1104
1108
1105
1109
/// Specifies the recipient of an invoice.
0 commit comments