.with_payment_secret(payment_secret)
.with_custom_tlvs(recipient_onion_fields.custom_tlvs.clone());
do_pass_along_path(args);
- claim_payment(&nodes[0], &[&nodes[1]], payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
+ .with_custom_tlvs(recipient_onion_fields.custom_tlvs.clone())
+ );
}
pub expected_min_htlc_overpay: Vec<u32>,
pub skip_last: bool,
pub payment_preimage: PaymentPreimage,
+ pub custom_tlvs: Vec<(u64, Vec<u8>)>,
// Allow forwarding nodes to have taken 1 msat more fee than expected based on the downstream
// fulfill amount.
//
Self {
origin_node, expected_paths, expected_extra_fees: vec![0; expected_paths.len()],
expected_min_htlc_overpay: vec![0; expected_paths.len()], skip_last: false, payment_preimage,
- allow_1_msat_fee_overpay: false,
+ allow_1_msat_fee_overpay: false, custom_tlvs: vec![],
}
}
pub fn skip_last(mut self, skip_last: bool) -> Self {
self.allow_1_msat_fee_overpay = true;
self
}
+ pub fn with_custom_tlvs(mut self, custom_tlvs: Vec<(u64, Vec<u8>)>) -> Self {
+ self.custom_tlvs = custom_tlvs;
+ self
+ }
}
-pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArgs) -> u64 {
+pub fn pass_claimed_payment_along_route(args: ClaimAlongRouteArgs) -> u64 {
let ClaimAlongRouteArgs {
origin_node, expected_paths, expected_extra_fees, expected_min_htlc_overpay, skip_last,
- payment_preimage: our_payment_preimage, allow_1_msat_fee_overpay,
+ payment_preimage: our_payment_preimage, allow_1_msat_fee_overpay, custom_tlvs,
} = args;
let claim_event = expected_paths[0].last().unwrap().node.get_and_clear_pending_events();
assert_eq!(claim_event.len(), 1);
| PaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(preimage), .. },
amount_msat,
ref htlcs,
+ ref onion_fields,
..
} => {
assert_eq!(preimage, our_payment_preimage);
assert_eq!(htlcs.len(), expected_paths.len()); // One per path.
assert_eq!(htlcs.iter().map(|h| h.value_msat).sum::<u64>(), amount_msat);
+ assert_eq!(onion_fields.as_ref().unwrap().custom_tlvs, custom_tlvs);
expected_paths.iter().zip(htlcs).for_each(|(path, htlc)| check_claimed_htlc_channel(origin_node, path, htlc));
fwd_amt_msat = amount_msat;
},
payment_hash,
amount_msat,
ref htlcs,
+ ref onion_fields,
..
} => {
assert_eq!(&payment_hash.0, &Sha256::hash(&our_payment_preimage.0)[..]);
assert_eq!(htlcs.len(), expected_paths.len()); // One per path.
assert_eq!(htlcs.iter().map(|h| h.value_msat).sum::<u64>(), amount_msat);
+ assert_eq!(onion_fields.as_ref().unwrap().custom_tlvs, custom_tlvs);
expected_paths.iter().zip(htlcs).for_each(|(path, htlc)| check_claimed_htlc_channel(origin_node, path, htlc));
fwd_amt_msat = amount_msat;
}
do_pass_along_path(args);
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[1], &[&[&nodes[2]]], payment_preimage)
+ .with_custom_tlvs(recipient_onion_max_custom_tlv_size.custom_tlvs.clone())
);
// If 1 byte is added to the custom TLV value, we'll fail to send prior to pathfinding.
let path = &[&nodes[1], &nodes[2]];
let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, events.pop().unwrap())
.with_payment_secret(payment_secret)
- .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs);
+ .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs.clone());
do_pass_along_path(args);
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs)
);
}
do_pass_along_path(args);
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[1], &[&[&nodes[2], &nodes[3]]], payment_preimage)
+ .with_custom_tlvs(recipient_onion_max_custom_tlv_size.custom_tlvs.clone())
);
// If 1 byte is added to the custom TLV value, we'll fail to send prior to pathfinding.
let path = &[&nodes[1], &nodes[2], &nodes[3]];
let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, events.pop().unwrap())
.with_payment_secret(payment_secret)
- .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs);
+ .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs.clone());
do_pass_along_path(args);
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2], &nodes[3]]], payment_preimage)
+ .with_custom_tlvs(recipient_onion_allows_2_hops.custom_tlvs)
);
}
match (known_tlvs, even_tlvs) {
(true, _) => {
nodes[1].node.claim_funds_with_known_custom_tlvs(our_payment_preimage);
- let expected_total_fee_msat = pass_claimed_payment_along_route(ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], our_payment_preimage));
+ let expected_total_fee_msat = pass_claimed_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], our_payment_preimage)
+ .with_custom_tlvs(custom_tlvs)
+ );
expect_payment_sent!(&nodes[0], our_payment_preimage, Some(expected_total_fee_msat));
},
(false, false) => {
- claim_payment(&nodes[0], &[&nodes[1]], our_payment_preimage);
+ claim_payment_along_route(
+ ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], our_payment_preimage)
+ .with_custom_tlvs(custom_tlvs)
+ );
},
(false, true) => {
nodes[1].node.claim_funds(our_payment_preimage);
let path = &[&nodes[1], &nodes[2]];
let args = PassAlongPathArgs::new(&nodes[0], path, 1_000_000, payment_hash, events.pop().unwrap())
.with_payment_secret(payment_secret)
- .with_custom_tlvs(custom_tlvs);
+ .with_custom_tlvs(custom_tlvs.clone());
do_pass_along_path(args);
claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
+ .with_custom_tlvs(custom_tlvs)
);
}
do_claim_payment_along_route(
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], our_payment_preimage)
+ .with_custom_tlvs(expected_tlvs)
);
expect_payment_sent(&nodes[0], our_payment_preimage, Some(Some(2000)), true, true);
} else {