@@ -928,6 +928,16 @@ pub struct ChannelReestablish {
928
928
/// * `channel_reestablish`-sending node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
929
929
/// * `channel_reestablish`-receiving node: https:///github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
930
930
pub next_funding_txid : Option < Txid > ,
931
+ /// The last funding txid received by the sending node, which may be:
932
+ /// - the txid of the last `splice_locked` it received, otherwise
933
+ /// - the txid of the funding transaction if it received `channel_ready`, or else
934
+ /// - `None` if it has never received `channel_ready` or `splice_locked`
935
+ pub your_last_funding_locked_txid : Option < Txid > ,
936
+ /// The last funding txid sent by the sending node, which may be:
937
+ /// - the txid of the last `splice_locked` it sent, otherwise
938
+ /// - the txid of the funding transaction if it sent `channel_ready`, or else
939
+ /// - `None` if it has never sent `channel_ready` or `splice_locked`
940
+ pub my_current_funding_locked_txid : Option < Txid > ,
931
941
}
932
942
933
943
/// An [`announcement_signatures`] message to be sent to or received from a peer.
@@ -2805,6 +2815,8 @@ impl_writeable_msg!(ChannelReestablish, {
2805
2815
my_current_per_commitment_point,
2806
2816
} , {
2807
2817
( 0 , next_funding_txid, option) ,
2818
+ ( 1 , your_last_funding_locked_txid, option) ,
2819
+ ( 3 , my_current_funding_locked_txid, option) ,
2808
2820
} ) ;
2809
2821
2810
2822
impl_writeable_msg ! ( ClosingSigned ,
@@ -4275,6 +4287,8 @@ mod tests {
4275
4287
your_last_per_commitment_secret : [ 9 ; 32 ] ,
4276
4288
my_current_per_commitment_point : public_key,
4277
4289
next_funding_txid : None ,
4290
+ your_last_funding_locked_txid : None ,
4291
+ my_current_funding_locked_txid : None ,
4278
4292
} ;
4279
4293
4280
4294
let encoded_value = cr. encode ( ) ;
@@ -4326,6 +4340,8 @@ mod tests {
4326
4340
] )
4327
4341
. unwrap ( ) ,
4328
4342
) ) ,
4343
+ your_last_funding_locked_txid : None ,
4344
+ my_current_funding_locked_txid : None ,
4329
4345
} ;
4330
4346
4331
4347
let encoded_value = cr. encode ( ) ;
@@ -4349,6 +4365,73 @@ mod tests {
4349
4365
) ;
4350
4366
}
4351
4367
4368
+ #[ test]
4369
+ fn encoding_channel_reestablish_with_funding_locked_txid ( ) {
4370
+ let public_key = {
4371
+ let secp_ctx = Secp256k1 :: new ( ) ;
4372
+ PublicKey :: from_secret_key (
4373
+ & secp_ctx,
4374
+ & SecretKey :: from_slice (
4375
+ & <Vec < u8 > >:: from_hex (
4376
+ "0101010101010101010101010101010101010101010101010101010101010101" ,
4377
+ )
4378
+ . unwrap ( ) [ ..] ,
4379
+ )
4380
+ . unwrap ( ) ,
4381
+ )
4382
+ } ;
4383
+
4384
+ let cr = msgs:: ChannelReestablish {
4385
+ channel_id : ChannelId :: from_bytes ( [
4386
+ 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 ,
4387
+ 0 , 0 , 0 , 0 ,
4388
+ ] ) ,
4389
+ next_local_commitment_number : 3 ,
4390
+ next_remote_commitment_number : 4 ,
4391
+ your_last_per_commitment_secret : [ 9 ; 32 ] ,
4392
+ my_current_per_commitment_point : public_key,
4393
+ next_funding_txid : None ,
4394
+ your_last_funding_locked_txid : Some ( Txid :: from_raw_hash (
4395
+ bitcoin:: hashes:: Hash :: from_slice ( & [
4396
+ 48 , 167 , 250 , 69 , 152 , 48 , 103 , 172 , 164 , 99 , 59 , 19 , 23 , 11 , 92 , 84 , 15 , 80 ,
4397
+ 4 , 12 , 98 , 82 , 75 , 31 , 201 , 11 , 91 , 23 , 98 , 23 , 53 , 124 ,
4398
+ ] )
4399
+ . unwrap ( ) ,
4400
+ ) ) ,
4401
+ my_current_funding_locked_txid : Some ( Txid :: from_raw_hash (
4402
+ bitcoin:: hashes:: Hash :: from_slice ( & [
4403
+ 21 , 167 , 250 , 69 , 152 , 48 , 103 , 172 , 164 , 99 , 59 , 19 , 23 , 11 , 92 , 84 , 15 , 80 ,
4404
+ 4 , 12 , 98 , 82 , 75 , 31 , 201 , 11 , 91 , 23 , 98 , 23 , 53 , 124 ,
4405
+ ] )
4406
+ . unwrap ( ) ,
4407
+ ) ) ,
4408
+ } ;
4409
+
4410
+ let encoded_value = cr. encode ( ) ;
4411
+ assert_eq ! (
4412
+ encoded_value,
4413
+ vec![
4414
+ 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 ,
4415
+ 0 , 0 , 0 , 0 , // channel_id
4416
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , // next_local_commitment_number
4417
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 4 , // next_remote_commitment_number
4418
+ 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 ,
4419
+ 9 , 9 , 9 , 9 , // your_last_per_commitment_secret
4420
+ 3 , 27 , 132 , 197 , 86 , 123 , 18 , 100 , 64 , 153 , 93 , 62 , 213 , 170 , 186 , 5 , 101 , 215 , 30 ,
4421
+ 24 , 52 , 96 , 72 , 25 , 255 , 156 , 23 , 245 , 233 , 213 , 221 , 7 ,
4422
+ 143 , // my_current_per_commitment_point
4423
+ 1 , // Type (your_last_funding_locked_txid)
4424
+ 32 , // Length
4425
+ 48 , 167 , 250 , 69 , 152 , 48 , 103 , 172 , 164 , 99 , 59 , 19 , 23 , 11 , 92 , 84 , 15 , 80 , 4 ,
4426
+ 12 , 98 , 82 , 75 , 31 , 201 , 11 , 91 , 23 , 98 , 23 , 53 , 124 , // Value
4427
+ 3 , // Type (my_current_funding_locked_txid)
4428
+ 32 , // Length
4429
+ 21 , 167 , 250 , 69 , 152 , 48 , 103 , 172 , 164 , 99 , 59 , 19 , 23 , 11 , 92 , 84 , 15 , 80 , 4 ,
4430
+ 12 , 98 , 82 , 75 , 31 , 201 , 11 , 91 , 23 , 98 , 23 , 53 , 124 , // Value
4431
+ ]
4432
+ ) ;
4433
+ }
4434
+
4352
4435
macro_rules! get_keys_from {
4353
4436
( $slice: expr, $secp_ctx: expr) => { {
4354
4437
let privkey = SecretKey :: from_slice( & <Vec <u8 >>:: from_hex( $slice) . unwrap( ) [ ..] ) . unwrap( ) ;
0 commit comments