@@ -22,7 +22,7 @@ use crate::routing::gossip::{NetworkUpdate, RoutingFees};
22
22
use crate :: routing:: router:: { get_route, PaymentParameters , Route , RouteParameters , RouteHint , RouteHintHop } ;
23
23
use crate :: ln:: features:: { InitFeatures , Bolt11InvoiceFeatures } ;
24
24
use crate :: ln:: msgs;
25
- use crate :: ln:: msgs:: { ChannelMessageHandler , ChannelUpdate } ;
25
+ use crate :: ln:: msgs:: { ChannelMessageHandler , ChannelUpdate , OutboundTrampolinePayload } ;
26
26
use crate :: ln:: wire:: Encode ;
27
27
use crate :: util:: ser:: { Writeable , Writer , BigSize } ;
28
28
use crate :: util:: test_utils;
@@ -35,11 +35,12 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine};
35
35
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
36
36
37
37
use bitcoin:: secp256k1;
38
- use bitcoin:: secp256k1:: { Secp256k1 , SecretKey } ;
38
+ use bitcoin:: secp256k1:: { PublicKey , Secp256k1 , SecretKey } ;
39
39
40
40
use crate :: io;
41
41
use crate :: prelude:: * ;
42
42
use core:: default:: Default ;
43
+ use bitcoin:: hashes:: hex:: FromHex ;
43
44
44
45
use crate :: ln:: functional_test_utils:: * ;
45
46
@@ -966,6 +967,25 @@ fn test_always_create_tlv_format_onion_payloads() {
966
967
}
967
968
}
968
969
970
+ #[ test]
971
+ fn test_trampoline_onion_payload_serialization ( ) {
972
+ // As per https://github.com/lightning/bolts/blob/c01d2e6267d4a8d1095f0f1188970055a9a22d29/bolt04/trampoline-payment-onion-test.json#L3
973
+ let trampoline_payload = OutboundTrampolinePayload :: Forward {
974
+ amt_to_forward : 100000000 ,
975
+ outgoing_cltv_value : 800000 ,
976
+ outgoing_node_id : PublicKey :: from_slice ( & <Vec < u8 > >:: from_hex ( "02edabbd16b41c8371b92ef2f04c1185b4f03b6dcd52ba9b78d9d7c89c8f221145" ) . unwrap ( ) ) . unwrap ( ) ,
977
+ } ;
978
+
979
+ let slice_to_hex = |slice : & [ u8 ] | {
980
+ slice. iter ( )
981
+ . map ( |b| format ! ( "{:02x}" , b) . to_string ( ) )
982
+ . collect :: < String > ( )
983
+ } ;
984
+
985
+ let carol_payload_hex = slice_to_hex ( & trampoline_payload. encode ( ) ) ;
986
+ assert_eq ! ( carol_payload_hex, "2e020405f5e10004030c35000e2102edabbd16b41c8371b92ef2f04c1185b4f03b6dcd52ba9b78d9d7c89c8f221145" ) ;
987
+ }
988
+
969
989
fn do_test_fail_htlc_backwards_with_reason ( failure_code : FailureCode ) {
970
990
971
991
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments