Skip to content

Commit 45d86ea

Browse files
committed
Migrate packages sub-fields to TLV serialization
1 parent c8bc1b6 commit 45d86ea

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

lightning/src/chain/package.rs

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use bitcoin::hash_types::Txid;
2121
use bitcoin::secp256k1::key::{SecretKey,PublicKey};
2222

2323
use ln::PaymentPreimage;
24-
use ln::chan_utils::{TxCreationKeys, HTLCOutputInCommitment, HTLC_OUTPUT_IN_COMMITMENT_SIZE};
24+
use ln::chan_utils::{TxCreationKeys, HTLCOutputInCommitment};
2525
use ln::chan_utils;
2626
use ln::msgs::DecodeError;
2727
use chain::chaininterface::{FeeEstimator, ConfirmationTarget, MIN_RELAY_FEE_SAT_PER_1000_WEIGHT};
@@ -86,15 +86,15 @@ impl RevokedOutput {
8686
}
8787
}
8888

89-
impl_writeable!(RevokedOutput, 33*3 + 32 + 8 + 8 + 2, {
90-
per_commitment_point,
91-
counterparty_delayed_payment_base_key,
92-
counterparty_htlc_base_key,
93-
per_commitment_key,
94-
weight,
95-
amount,
96-
on_counterparty_tx_csv
97-
});
89+
impl_writeable_tlv_based!(RevokedOutput, {
90+
(0, per_commitment_point),
91+
(2, counterparty_delayed_payment_base_key),
92+
(4, counterparty_htlc_base_key),
93+
(6, per_commitment_key),
94+
(8, weight),
95+
(10, amount),
96+
(12, on_counterparty_tx_csv),
97+
}, {}, {});
9898

9999
/// A struct to describe a revoked offered output and corresponding information to generate a
100100
/// solving witness.
@@ -130,15 +130,15 @@ impl RevokedHTLCOutput {
130130
}
131131
}
132132

133-
impl_writeable!(RevokedHTLCOutput, 33*3 + 32 + 8 + 8 + HTLC_OUTPUT_IN_COMMITMENT_SIZE, {
134-
per_commitment_point,
135-
counterparty_delayed_payment_base_key,
136-
counterparty_htlc_base_key,
137-
per_commitment_key,
138-
weight,
139-
amount,
140-
htlc
141-
});
133+
impl_writeable_tlv_based!(RevokedHTLCOutput, {
134+
(0, per_commitment_point),
135+
(2, counterparty_delayed_payment_base_key),
136+
(4, counterparty_htlc_base_key),
137+
(6, per_commitment_key),
138+
(8, weight),
139+
(10, amount),
140+
(12, htlc),
141+
}, {}, {});
142142

143143
/// A struct to describe a HTLC output on a counterparty commitment transaction.
144144
///
@@ -167,13 +167,13 @@ impl CounterpartyOfferedHTLCOutput {
167167
}
168168
}
169169

170-
impl_writeable!(CounterpartyOfferedHTLCOutput, 33*3 + 32 + HTLC_OUTPUT_IN_COMMITMENT_SIZE, {
171-
per_commitment_point,
172-
counterparty_delayed_payment_base_key,
173-
counterparty_htlc_base_key,
174-
preimage,
175-
htlc
176-
});
170+
impl_writeable_tlv_based!(CounterpartyOfferedHTLCOutput, {
171+
(0, per_commitment_point),
172+
(2, counterparty_delayed_payment_base_key),
173+
(4, counterparty_htlc_base_key),
174+
(6, preimage),
175+
(8, htlc),
176+
}, {}, {});
177177

178178
/// A struct to describe a HTLC output on a counterparty commitment transaction.
179179
///
@@ -198,12 +198,12 @@ impl CounterpartyReceivedHTLCOutput {
198198
}
199199
}
200200

201-
impl_writeable!(CounterpartyReceivedHTLCOutput, 33*3 + HTLC_OUTPUT_IN_COMMITMENT_SIZE, {
202-
per_commitment_point,
203-
counterparty_delayed_payment_base_key,
204-
counterparty_htlc_base_key,
205-
htlc
206-
});
201+
impl_writeable_tlv_based!(CounterpartyReceivedHTLCOutput, {
202+
(0, per_commitment_point),
203+
(2, counterparty_delayed_payment_base_key),
204+
(4, counterparty_htlc_base_key),
205+
(6, htlc),
206+
}, {}, {});
207207

208208
/// A struct to describe a HTLC output on holder commitment transaction.
209209
///
@@ -224,10 +224,11 @@ impl HolderHTLCOutput {
224224
}
225225
}
226226

227-
impl_writeable!(HolderHTLCOutput, 0, {
228-
preimage,
229-
amount
230-
});
227+
impl_writeable_tlv_based!(HolderHTLCOutput, {
228+
(0, amount),
229+
}, {
230+
(2, preimage),
231+
}, {});
231232

232233
/// A struct to describe the channel output on the funding transaction.
233234
///
@@ -245,9 +246,9 @@ impl HolderFundingOutput {
245246
}
246247
}
247248

248-
impl_writeable!(HolderFundingOutput, 0, {
249-
funding_redeemscript
250-
});
249+
impl_writeable_tlv_based!(HolderFundingOutput, {
250+
(0, funding_redeemscript),
251+
}, {}, {});
251252

252253
/// A wrapper encapsulating all in-protocol differing outputs types.
253254
///

0 commit comments

Comments
 (0)