@@ -927,6 +927,16 @@ pub struct ChannelReestablish {
927
927
/// * `channel_reestablish`-sending node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
928
928
/// * `channel_reestablish`-receiving node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
929
929
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 > ,
935
+ /// The last funding txid sent by the sending node, which may be:
936
+ /// - the txid of the last `splice_locked` it sent, otherwise
937
+ /// - the txid of the funding transaction if it sent `channel_ready`, or else
938
+ /// - `None` if it has never sent `channel_ready` or `splice_locked`
939
+ pub my_current_funding_locked_txid : Option < Txid > ,
930
940
}
931
941
932
942
/// An [`announcement_signatures`] message to be sent to or received from a peer.
@@ -2811,6 +2821,8 @@ impl_writeable_msg!(ChannelReestablish, {
2811
2821
my_current_per_commitment_point,
2812
2822
} , {
2813
2823
( 0 , next_funding_txid, option) ,
2824
+ ( 1 , your_last_funding_locked_txid, option) ,
2825
+ ( 3 , my_current_funding_locked_txid, option) ,
2814
2826
} ) ;
2815
2827
2816
2828
impl_writeable_msg ! ( ClosingSigned ,
@@ -4283,6 +4295,8 @@ mod tests {
4283
4295
your_last_per_commitment_secret : [ 9 ; 32 ] ,
4284
4296
my_current_per_commitment_point : public_key,
4285
4297
next_funding_txid : None ,
4298
+ your_last_funding_locked_txid : None ,
4299
+ my_current_funding_locked_txid : None ,
4286
4300
} ;
4287
4301
4288
4302
let encoded_value = cr. encode ( ) ;
@@ -4334,6 +4348,8 @@ mod tests {
4334
4348
] )
4335
4349
. unwrap ( ) ,
4336
4350
) ) ,
4351
+ your_last_funding_locked_txid : None ,
4352
+ my_current_funding_locked_txid : None ,
4337
4353
} ;
4338
4354
4339
4355
let encoded_value = cr. encode ( ) ;
@@ -4357,6 +4373,73 @@ mod tests {
4357
4373
) ;
4358
4374
}
4359
4375
4376
+ #[ test]
4377
+ fn encoding_channel_reestablish_with_funding_locked_txid ( ) {
4378
+ let public_key = {
4379
+ let secp_ctx = Secp256k1 :: new ( ) ;
4380
+ PublicKey :: from_secret_key (
4381
+ & secp_ctx,
4382
+ & SecretKey :: from_slice (
4383
+ & <Vec < u8 > >:: from_hex (
4384
+ "0101010101010101010101010101010101010101010101010101010101010101" ,
4385
+ )
4386
+ . unwrap ( ) [ ..] ,
4387
+ )
4388
+ . unwrap ( ) ,
4389
+ )
4390
+ } ;
4391
+
4392
+ let cr = msgs:: ChannelReestablish {
4393
+ channel_id : ChannelId :: from_bytes ( [
4394
+ 4 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 6 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 0 , 0 , 0 ,
4395
+ 0 , 0 , 0 , 0 ,
4396
+ ] ) ,
4397
+ next_local_commitment_number : 3 ,
4398
+ next_remote_commitment_number : 4 ,
4399
+ your_last_per_commitment_secret : [ 9 ; 32 ] ,
4400
+ my_current_per_commitment_point : public_key,
4401
+ 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
+ } ;
4417
+
4418
+ let encoded_value = cr. encode ( ) ;
4419
+ assert_eq ! (
4420
+ encoded_value,
4421
+ vec![
4422
+ 4 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 6 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 0 , 0 , 0 ,
4423
+ 0 , 0 , 0 , 0 , // channel_id
4424
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , // next_local_commitment_number
4425
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 4 , // next_remote_commitment_number
4426
+ 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ,
4427
+ 9 , 9 , 9 , 9 , // your_last_per_commitment_secret
4428
+ 3 , 27 , 132 , 197 , 86 , 123 , 18 , 100 , 64 , 153 , 93 , 62 , 213 , 170 , 186 , 5 , 101 , 215 , 30 ,
4429
+ 24 , 52 , 96 , 72 , 25 , 255 , 156 , 23 , 245 , 233 , 213 , 221 , 7 ,
4430
+ 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
4437
+ 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
4439
+ ]
4440
+ ) ;
4441
+ }
4442
+
4360
4443
macro_rules! get_keys_from {
4361
4444
( $slice: expr, $secp_ctx: expr) => { {
4362
4445
let privkey = SecretKey :: from_slice( & <Vec <u8 >>:: from_hex( $slice) . unwrap( ) [ ..] ) . unwrap( ) ;
0 commit comments