projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simplify HolderHTLCOutput constructor and track CLTV expiry
[rust-lightning]
/
lightning
/
src
/
chain
/
package.rs
diff --git
a/lightning/src/chain/package.rs
b/lightning/src/chain/package.rs
index 9e92e2031bc1afe90c0d90d1c7f2a9322b298521..bb44604317f630f97e911d5cd158b6802851e8b4 100644
(file)
--- a/
lightning/src/chain/package.rs
+++ b/
lightning/src/chain/package.rs
@@
-213,21
+213,33
@@
impl_writeable_tlv_based!(CounterpartyReceivedHTLCOutput, {
pub(crate) struct HolderHTLCOutput {
preimage: Option<PaymentPreimage>,
amount: u64,
pub(crate) struct HolderHTLCOutput {
preimage: Option<PaymentPreimage>,
amount: u64,
+ /// Defaults to 0 for HTLC-Success transactions, which have no expiry
+ cltv_expiry: u32,
}
impl HolderHTLCOutput {
}
impl HolderHTLCOutput {
- pub(crate) fn build
(preimage: Option<PaymentPreimage>, amount: u64
) -> Self {
+ pub(crate) fn build
_offered(amount: u64, cltv_expiry: u32
) -> Self {
HolderHTLCOutput {
HolderHTLCOutput {
- preimage,
- amount
+ preimage: None,
+ amount,
+ cltv_expiry,
+ }
+ }
+
+ pub(crate) fn build_accepted(preimage: PaymentPreimage, amount: u64) -> Self {
+ HolderHTLCOutput {
+ preimage: Some(preimage),
+ amount,
+ cltv_expiry: 0,
}
}
}
impl_writeable_tlv_based!(HolderHTLCOutput, {
(0, amount),
}
}
}
impl_writeable_tlv_based!(HolderHTLCOutput, {
(0, amount),
+ (2, cltv_expiry),
}, {
}, {
- (
2
, preimage),
+ (
4
, preimage),
}, {});
/// A struct to describe the channel output on the funding transaction.
}, {});
/// A struct to describe the channel output on the funding transaction.
@@
-879,7
+891,7
@@
mod tests {
() => {
{
let preimage = PaymentPreimage([2;32]);
() => {
{
let preimage = PaymentPreimage([2;32]);
- PackageSolvingData::HolderHTLCOutput(HolderHTLCOutput::build
(Some(preimage)
, 0))
+ PackageSolvingData::HolderHTLCOutput(HolderHTLCOutput::build
_accepted(preimage
, 0))
}
}
}
}
}
}