@@ -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,16 +434,14 @@ pub struct HTLCOutputInCommitment {
429
434
pub transaction_output_index : Option < u32 > ,
430
435
}
431
436
432
- impl_writeable_len_match ! ( HTLCOutputInCommitment , {
433
- { HTLCOutputInCommitment { transaction_output_index: None , .. } , HTLC_OUTPUT_IN_COMMITMENT_SIZE - 4 } ,
434
- { _, HTLC_OUTPUT_IN_COMMITMENT_SIZE }
435
- } , {
436
- offered,
437
- amount_msat,
438
- cltv_expiry,
439
- payment_hash,
440
- transaction_output_index
441
- } ) ;
437
+ impl_writeable_tlv_based ! ( HTLCOutputInCommitment , {
438
+ ( 0 , offered) ,
439
+ ( 2 , amount_msat) ,
440
+ ( 4 , cltv_expiry) ,
441
+ ( 6 , payment_hash) ,
442
+ } , {
443
+ ( 8 , transaction_output_index)
444
+ } , { } ) ;
442
445
443
446
#[ inline]
444
447
pub ( crate ) fn get_htlc_redeemscript_with_explicit_keys ( htlc : & HTLCOutputInCommitment , broadcaster_htlc_key : & PublicKey , countersignatory_htlc_key : & PublicKey , revocation_key : & PublicKey ) -> Script {
@@ -622,18 +625,19 @@ impl ChannelTransactionParameters {
622
625
}
623
626
}
624
627
625
- impl_writeable ! ( CounterpartyChannelTransactionParameters , 0 , {
626
- pubkeys,
627
- selected_contest_delay
628
- } ) ;
628
+ impl_writeable_tlv_based ! ( CounterpartyChannelTransactionParameters , {
629
+ ( 0 , pubkeys) ,
630
+ ( 2 , selected_contest_delay) ,
631
+ } , { } , { } ) ;
629
632
630
- impl_writeable ! ( ChannelTransactionParameters , 0 , {
631
- holder_pubkeys,
632
- holder_selected_contest_delay,
633
- is_outbound_from_holder,
634
- counterparty_parameters,
635
- funding_outpoint
636
- } ) ;
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
+ } , { } ) ;
637
641
638
642
/// Static channel fields used to build transactions given per-commitment fields, organized by
639
643
/// broadcaster/countersignatory.
@@ -715,8 +719,12 @@ impl PartialEq for HolderCommitmentTransaction {
715
719
}
716
720
}
717
721
718
- impl_writeable ! ( HolderCommitmentTransaction , 0 , {
719
- 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) ,
720
728
} ) ;
721
729
722
730
impl HolderCommitmentTransaction {
@@ -800,7 +808,10 @@ pub struct BuiltCommitmentTransaction {
800
808
pub txid : Txid ,
801
809
}
802
810
803
- impl_writeable ! ( BuiltCommitmentTransaction , 0 , { transaction, txid } ) ;
811
+ impl_writeable_tlv_based ! ( BuiltCommitmentTransaction , {
812
+ ( 0 , transaction) ,
813
+ ( 2 , txid)
814
+ } , { } , { } ) ;
804
815
805
816
impl BuiltCommitmentTransaction {
806
817
/// Get the SIGHASH_ALL sighash value of the transaction.
@@ -883,15 +894,15 @@ impl Readable for Vec<HTLCOutputInCommitment> {
883
894
}
884
895
}
885
896
886
- impl_writeable ! ( CommitmentTransaction , 0 , {
887
- commitment_number,
888
- to_broadcaster_value_sat,
889
- to_countersignatory_value_sat,
890
- feerate_per_kw,
891
- htlcs,
892
- keys,
893
- built
894
- } ) ;
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
+ } , { } , { } ) ;
895
906
896
907
impl CommitmentTransaction {
897
908
/// Construct an object of the class while assigning transaction output indices to HTLCs.
0 commit comments