@@ -178,6 +178,7 @@ impl Writeable for CounterpartyCommitmentSecrets {
178
178
writer. write_all ( secret) ?;
179
179
writer. write_all ( & byte_utils:: be64_to_array ( * idx) ) ?;
180
180
}
181
+ write_tlv_fields ! ( writer, { } , { } ) ;
181
182
Ok ( ( ) )
182
183
}
183
184
}
@@ -188,7 +189,7 @@ impl Readable for CounterpartyCommitmentSecrets {
188
189
* secret = Readable :: read ( reader) ?;
189
190
* idx = Readable :: read ( reader) ?;
190
191
}
191
-
192
+ read_tlv_fields ! ( reader , { } , { } ) ;
192
193
Ok ( Self { old_secrets } )
193
194
}
194
195
}
@@ -322,8 +323,13 @@ pub struct TxCreationKeys {
322
323
pub broadcaster_delayed_payment_key : PublicKey ,
323
324
}
324
325
325
- impl_writeable ! ( TxCreationKeys , 33 * 5 ,
326
- { per_commitment_point, revocation_key, broadcaster_htlc_key, countersignatory_htlc_key, broadcaster_delayed_payment_key } ) ;
326
+ impl_writeable_tlv_based ! ( TxCreationKeys , {
327
+ ( 0 , per_commitment_point) ,
328
+ ( 2 , revocation_key) ,
329
+ ( 4 , broadcaster_htlc_key) ,
330
+ ( 6 , countersignatory_htlc_key) ,
331
+ ( 8 , broadcaster_delayed_payment_key) ,
332
+ } , { } , { } ) ;
327
333
328
334
/// One counterparty's public keys which do not change over the life of a channel.
329
335
#[ derive( Clone , PartialEq ) ]
@@ -349,14 +355,13 @@ pub struct ChannelPublicKeys {
349
355
pub htlc_basepoint : PublicKey ,
350
356
}
351
357
352
- impl_writeable ! ( ChannelPublicKeys , 33 * 5 , {
353
- funding_pubkey,
354
- revocation_basepoint,
355
- payment_point,
356
- delayed_payment_basepoint,
357
- htlc_basepoint
358
- } ) ;
359
-
358
+ impl_writeable_tlv_based ! ( ChannelPublicKeys , {
359
+ ( 0 , funding_pubkey) ,
360
+ ( 2 , revocation_basepoint) ,
361
+ ( 4 , payment_point) ,
362
+ ( 6 , delayed_payment_basepoint) ,
363
+ ( 8 , htlc_basepoint) ,
364
+ } , { } , { } ) ;
360
365
361
366
impl TxCreationKeys {
362
367
/// Create per-state keys from channel base points and the per-commitment point.
@@ -429,23 +434,11 @@ pub struct HTLCOutputInCommitment {
429
434
pub transaction_output_index : Option < u32 > ,
430
435
}
431
436
432
- impl HTLCOutputInCommitment {
433
- pub ( crate ) fn deserialization_dummy ( ) -> Self {
434
- Self {
435
- offered : false ,
436
- amount_msat : 0 ,
437
- cltv_expiry : 0 ,
438
- payment_hash : PaymentHash ( [ 0 ; 32 ] ) ,
439
- transaction_output_index : None ,
440
- }
441
- }
442
- }
443
-
444
437
impl_writeable_tlv_based ! ( HTLCOutputInCommitment , {
445
- ( 0 , offered, false ) ,
446
- ( 2 , amount_msat, 0 ) ,
447
- ( 4 , cltv_expiry, 0 ) ,
448
- ( 6 , payment_hash, PaymentHash ( [ 0 ; 32 ] ) ) ,
438
+ ( 0 , offered) ,
439
+ ( 2 , amount_msat) ,
440
+ ( 4 , cltv_expiry) ,
441
+ ( 6 , payment_hash) ,
449
442
} , {
450
443
( 8 , transaction_output_index)
451
444
} , { } ) ;
@@ -632,18 +625,19 @@ impl ChannelTransactionParameters {
632
625
}
633
626
}
634
627
635
- impl_writeable ! ( CounterpartyChannelTransactionParameters , 0 , {
636
- pubkeys,
637
- selected_contest_delay
638
- } ) ;
628
+ impl_writeable_tlv_based ! ( CounterpartyChannelTransactionParameters , {
629
+ ( 0 , pubkeys) ,
630
+ ( 2 , selected_contest_delay) ,
631
+ } , { } , { } ) ;
639
632
640
- impl_writeable ! ( ChannelTransactionParameters , 0 , {
641
- holder_pubkeys,
642
- holder_selected_contest_delay,
643
- is_outbound_from_holder,
644
- counterparty_parameters,
645
- funding_outpoint
646
- } ) ;
633
+ impl_writeable_tlv_based ! ( ChannelTransactionParameters , {
634
+ ( 0 , holder_pubkeys) ,
635
+ ( 2 , holder_selected_contest_delay) ,
636
+ ( 4 , is_outbound_from_holder) ,
637
+ } , {
638
+ ( 6 , counterparty_parameters) ,
639
+ ( 8 , funding_outpoint) ,
640
+ } , { } ) ;
647
641
648
642
/// Static channel fields used to build transactions given per-commitment fields, organized by
649
643
/// broadcaster/countersignatory.
@@ -725,8 +719,12 @@ impl PartialEq for HolderCommitmentTransaction {
725
719
}
726
720
}
727
721
728
- impl_writeable ! ( HolderCommitmentTransaction , 0 , {
729
- inner, counterparty_sig, counterparty_htlc_sigs, holder_sig_first
722
+ impl_writeable_tlv_based ! ( HolderCommitmentTransaction , {
723
+ ( 0 , inner) ,
724
+ ( 2 , counterparty_sig) ,
725
+ ( 4 , holder_sig_first) ,
726
+ } , { } , {
727
+ ( 6 , counterparty_htlc_sigs) ,
730
728
} ) ;
731
729
732
730
impl HolderCommitmentTransaction {
@@ -810,7 +808,10 @@ pub struct BuiltCommitmentTransaction {
810
808
pub txid : Txid ,
811
809
}
812
810
813
- impl_writeable ! ( BuiltCommitmentTransaction , 0 , { transaction, txid } ) ;
811
+ impl_writeable_tlv_based ! ( BuiltCommitmentTransaction , {
812
+ ( 0 , transaction) ,
813
+ ( 2 , txid)
814
+ } , { } , { } ) ;
814
815
815
816
impl BuiltCommitmentTransaction {
816
817
/// Get the SIGHASH_ALL sighash value of the transaction.
@@ -893,15 +894,15 @@ impl Readable for Vec<HTLCOutputInCommitment> {
893
894
}
894
895
}
895
896
896
- impl_writeable ! ( CommitmentTransaction , 0 , {
897
- commitment_number,
898
- to_broadcaster_value_sat,
899
- to_countersignatory_value_sat,
900
- feerate_per_kw,
901
- htlcs,
902
- keys,
903
- built
904
- } ) ;
897
+ impl_writeable_tlv_based ! ( CommitmentTransaction , {
898
+ ( 0 , commitment_number) ,
899
+ ( 2 , to_broadcaster_value_sat) ,
900
+ ( 4 , to_countersignatory_value_sat) ,
901
+ ( 6 , feerate_per_kw) ,
902
+ ( 8 , htlcs) ,
903
+ ( 10 , keys) ,
904
+ ( 12 , built) ,
905
+ } , { } , { } ) ;
905
906
906
907
impl CommitmentTransaction {
907
908
/// Construct an object of the class while assigning transaction output indices to HTLCs.
0 commit comments