Skip to content

Commit 9835510

Browse files
committed
f - FundingLocked
1 parent efe8314 commit 9835510

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10592,8 +10592,7 @@ where
1059210592
your_last_per_commitment_secret: remote_last_secret,
1059310593
my_current_per_commitment_point: dummy_pubkey,
1059410594
next_funding_txid: self.maybe_get_next_funding_txid(),
10595-
your_last_funding_locked_txid: None,
10596-
my_current_funding_locked_txid: None,
10595+
my_current_funding_locked: None,
1059710596
}
1059810597
}
1059910598

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11049,8 +11049,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1104911049
your_last_per_commitment_secret: [1u8; 32],
1105011050
my_current_per_commitment_point: PublicKey::from_slice(&[2u8; 33]).unwrap(),
1105111051
next_funding_txid: None,
11052-
your_last_funding_locked_txid: None,
11053-
my_current_funding_locked_txid: None,
11052+
my_current_funding_locked: None,
1105411053
},
1105511054
});
1105611055
return Err(MsgHandleErrInternal::send_err_msg_no_close(

lightning/src/ln/msgs.rs

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -927,16 +927,28 @@ pub struct ChannelReestablish {
927927
/// * `channel_reestablish`-sending node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
928928
/// * `channel_reestablish`-receiving node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
929929
pub next_funding_txid: Option<Txid>,
930-
/// The last funding txid received by the sending node, which may be:
931-
/// - the txid of the last `splice_locked` it received, otherwise
932-
/// - the txid of the funding transaction if it received `channel_ready`, or else
933-
/// - `None` if it has never received `channel_ready` or `splice_locked`
934-
pub your_last_funding_locked_txid: Option<Txid>,
935930
/// The last funding txid sent by the sending node, which may be:
936931
/// - the txid of the last `splice_locked` it sent, otherwise
937932
/// - the txid of the funding transaction if it sent `channel_ready`, or else
938933
/// - `None` if it has never sent `channel_ready` or `splice_locked`
939-
pub my_current_funding_locked_txid: Option<Txid>,
934+
///
935+
/// Also contains a bitfield indicating which messages should be retransmitted.
936+
pub my_current_funding_locked: Option<FundingLocked>,
937+
}
938+
939+
/// Information exchanged during channel reestablishment about the last funding locked.
940+
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
941+
pub struct FundingLocked {
942+
/// The last txid sent by the sending node, which may be either from the last `splice_locked` or
943+
/// for the initial funding transaction if it sent `channel_ready`.
944+
pub txid: Txid,
945+
946+
/// A bitfield indicating which messages should be retransmitted by the receiving node.
947+
///
948+
/// | Bit Position | Name |
949+
/// | ------------- | --------------------------|
950+
/// | 0 | `announcement_signatures` |
951+
pub retransmit_flags: u8,
940952
}
941953

942954
/// An [`announcement_signatures`] message to be sent to or received from a peer.
@@ -2821,8 +2833,12 @@ impl_writeable_msg!(ChannelReestablish, {
28212833
my_current_per_commitment_point,
28222834
}, {
28232835
(0, next_funding_txid, option),
2824-
(1, your_last_funding_locked_txid, option),
2825-
(3, my_current_funding_locked_txid, option),
2836+
(5, my_current_funding_locked, option),
2837+
});
2838+
2839+
impl_writeable!(FundingLocked, {
2840+
txid,
2841+
retransmit_flags
28262842
});
28272843

28282844
impl_writeable_msg!(ClosingSigned,
@@ -4295,8 +4311,7 @@ mod tests {
42954311
your_last_per_commitment_secret: [9; 32],
42964312
my_current_per_commitment_point: public_key,
42974313
next_funding_txid: None,
4298-
your_last_funding_locked_txid: None,
4299-
my_current_funding_locked_txid: None,
4314+
my_current_funding_locked: None,
43004315
};
43014316

43024317
let encoded_value = cr.encode();
@@ -4348,8 +4363,7 @@ mod tests {
43484363
])
43494364
.unwrap(),
43504365
)),
4351-
your_last_funding_locked_txid: None,
4352-
my_current_funding_locked_txid: None,
4366+
my_current_funding_locked: None,
43534367
};
43544368

43554369
let encoded_value = cr.encode();
@@ -4399,20 +4413,16 @@ mod tests {
43994413
your_last_per_commitment_secret: [9; 32],
44004414
my_current_per_commitment_point: public_key,
44014415
next_funding_txid: None,
4402-
your_last_funding_locked_txid: Some(Txid::from_raw_hash(
4403-
bitcoin::hashes::Hash::from_slice(&[
4404-
48, 167, 250, 69, 152, 48, 103, 172, 164, 99, 59, 19, 23, 11, 92, 84, 15, 80,
4405-
4, 12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124,
4406-
])
4407-
.unwrap(),
4408-
)),
4409-
my_current_funding_locked_txid: Some(Txid::from_raw_hash(
4410-
bitcoin::hashes::Hash::from_slice(&[
4411-
21, 167, 250, 69, 152, 48, 103, 172, 164, 99, 59, 19, 23, 11, 92, 84, 15, 80,
4412-
4, 12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124,
4413-
])
4414-
.unwrap(),
4415-
)),
4416+
my_current_funding_locked: Some(msgs::FundingLocked {
4417+
txid: Txid::from_raw_hash(
4418+
bitcoin::hashes::Hash::from_slice(&[
4419+
21, 167, 250, 69, 152, 48, 103, 172, 164, 99, 59, 19, 23, 11, 92, 84, 15,
4420+
80, 4, 12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124,
4421+
])
4422+
.unwrap(),
4423+
),
4424+
retransmit_flags: 1,
4425+
}),
44164426
};
44174427

44184428
let encoded_value = cr.encode();
@@ -4428,14 +4438,10 @@ mod tests {
44284438
3, 27, 132, 197, 86, 123, 18, 100, 64, 153, 93, 62, 213, 170, 186, 5, 101, 215, 30,
44294439
24, 52, 96, 72, 25, 255, 156, 23, 245, 233, 213, 221, 7,
44304440
143, // my_current_per_commitment_point
4431-
1, // Type (your_last_funding_locked_txid)
4432-
32, // Length
4433-
48, 167, 250, 69, 152, 48, 103, 172, 164, 99, 59, 19, 23, 11, 92, 84, 15, 80, 4,
4434-
12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124, // Value
4435-
3, // Type (my_current_funding_locked_txid)
4436-
32, // Length
4441+
5, // Type (my_current_funding_locked)
4442+
33, // Length
44374443
21, 167, 250, 69, 152, 48, 103, 172, 164, 99, 59, 19, 23, 11, 92, 84, 15, 80, 4,
4438-
12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124, // Value
4444+
12, 98, 82, 75, 31, 201, 11, 91, 23, 98, 23, 53, 124, 1, // Value
44394445
]
44404446
);
44414447
}

0 commit comments

Comments
 (0)