@@ -22,7 +22,7 @@ use crate::routing::gossip::{NetworkUpdate, RoutingFees};
2222use crate :: routing:: router:: { get_route, PaymentParameters , Route , RouteParameters , RouteHint , RouteHintHop } ;
2323use crate :: ln:: features:: { InitFeatures , Bolt11InvoiceFeatures } ;
2424use crate :: ln:: msgs;
25- use crate :: ln:: msgs:: { ChannelMessageHandler , ChannelUpdate } ;
25+ use crate :: ln:: msgs:: { ChannelMessageHandler , ChannelUpdate , OutboundTrampolinePayload } ;
2626use crate :: ln:: wire:: Encode ;
2727use crate :: util:: ser:: { Writeable , Writer , BigSize } ;
2828use crate :: util:: test_utils;
@@ -35,11 +35,12 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine};
3535use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
3636
3737use bitcoin:: secp256k1;
38- use bitcoin:: secp256k1:: { Secp256k1 , SecretKey } ;
38+ use bitcoin:: secp256k1:: { PublicKey , Secp256k1 , SecretKey } ;
3939
4040use crate :: io;
4141use crate :: prelude:: * ;
4242use core:: default:: Default ;
43+ use bitcoin:: hashes:: hex:: FromHex ;
4344
4445use crate :: ln:: functional_test_utils:: * ;
4546
@@ -966,6 +967,25 @@ fn test_always_create_tlv_format_onion_payloads() {
966967 }
967968}
968969
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+
969989fn do_test_fail_htlc_backwards_with_reason ( failure_code : FailureCode ) {
970990
971991 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments