You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// BOLT 2 Requirements for the Sender when constructing and sending an update_add_htlc message.
6606
+
// BOLT 2 Requirements for the Sender when constructing and sending an update_add_htlc message.
6607
+
// BOLT 2 Requirement: MUST NOT offer amount_msat it cannot pay for in the remote commitment transaction at the current feerate_per_kw (see "Updating Fees") while maintaining its channel reserve.
6608
+
//TODO: I don't believe this is explicitly enforced when sending an HTLC but as the Fee aspect of the BOLT specs is in flux leaving this as a TODO.
6616
6609
6617
-
// BOLT 2 Requirement: MUST NOT offer amount_msat it cannot pay for in the remote commitment transaction at the current feerate_per_kw (see "Updating Fees") while maintaining its channel reserve.
6618
-
//TODO: I don't believe this is explicitly enforced when sending an HTLC but as the Fee aspect of the BOLT specs is in flux leaving this as a TODO.
6619
-
6620
-
// BOLT2 Requirement: MUST offer amount_msat greater than 0.
6621
-
// BOLT2 Requirement: MUST NOT offer amount_msat below the receiving node's htlc_minimum_msat (same validation check catches both of these)
let onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys,&our_payment_hash);
6621
+
let err = nodes[0].node.send_payment(route, our_payment_hash);
6637
6622
6638
-
let err = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2).unwrap().send_htlc(0, our_payment_hash,TEST_FINAL_CLTV,HTLCSource::OutboundRoute{
6639
-
route: route.clone(),
6640
-
session_priv: session_priv.clone(),
6641
-
first_hop_htlc_msat:0,
6642
-
}, onion_packet);
6643
-
6644
-
ifletErr(ChannelError::Ignore(msg)) = err {
6645
-
assert_eq!(msg,"Cannot send less than their minimum HTLC value");
//BOLT 2 Requirement: MUST set cltv_expiry less than 500000000.
6651
6633
//TODO: This is not currently explicitly checked when sending an HTLC and exists as TODO in the channel::send_htlc(...) function
6652
6634
//It is enforced when constructing a route.
6653
-
6654
-
// BOLT 2 Requirement: if result would be offering more than the remote's max_accepted_htlcs HTLCs, in the remote commitment transaction: MUST NOT add an HTLC.
let onion_packet = onion_utils::construct_onion_packet(onion_payloads, onion_keys,&our_payment_hash);
6670
-
6671
-
let max_accepted_htlcs = nodes[1].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().their_max_accepted_htlcs;
6672
-
6673
-
for _i in0..max_accepted_htlcs {
6674
-
let _ = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2).unwrap().send_htlc(10000, our_payment_hash,TEST_FINAL_CLTV,HTLCSource::OutboundRoute{
6675
-
route: route.clone(),
6676
-
session_priv: session_priv.clone(),
6677
-
first_hop_htlc_msat:0,
6678
-
}, onion_packet.clone());
6679
-
}
6680
-
6681
-
let err = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2).unwrap().send_htlc(10000, our_payment_hash,TEST_FINAL_CLTV,HTLCSource::OutboundRoute{
6682
-
route: route.clone(),
6683
-
session_priv: session_priv.clone(),
6684
-
first_hop_htlc_msat:0,
6685
-
}, onion_packet);
6686
-
6687
-
ifletErr(ChannelError::Ignore(msg)) = err {
6688
-
assert_eq!(msg,"Cannot push more than their max accepted HTLCs");
6642
+
ifletErr(APIError::RouteError{err}) = err {
6643
+
assert_eq!(err,"Channel CLTV overflowed?!");
6689
6644
}else{
6690
6645
assert!(false);
6691
6646
}
6647
+
}
6692
6648
6693
-
// BOLT 2 Requirement: if the sum of total offered HTLCs would exceed the remote's max_htlc_value_in_flight_msat: MUST NOT add an HTLC.
6694
-
let chan = create_announced_chan_between_nodes_with_value(&nodes,0,1,100000,0);
6695
-
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(),None,&[],100000,TEST_FINAL_CLTV).unwrap();
//BOLT 2 Requirement: if result would be offering more than the remote's max_accepted_htlcs HTLCs, in the remote commitment transaction: MUST NOT add an HTLC.
6652
+
//BOLT 2 Requirement: for the first HTLC it offers MUST set id to 0.
6653
+
//BOLT 2 Requirement: MUST increase the value of id by 1 for each successive offer.
6654
+
letmut nodes = create_network(2);
6655
+
let chan = create_announced_chan_between_nodes_with_value(&nodes,0,1,1000000,0);
6656
+
let max_accepted_htlcs = nodes[1].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().their_max_accepted_htlcsasu64;
6697
6657
6698
-
let session_priv = SecretKey::from_slice(&secp_ctx,&{
let err = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2).unwrap().send_htlc(10000001, our_payment_hash,TEST_FINAL_CLTV,HTLCSource::OutboundRoute{
//BOLT 2 Requirement: if the sum of total offered HTLCs would exceed the remote's max_htlc_value_in_flight_msat: MUST NOT add an HTLC.
6696
+
letmut nodes = create_network(2);
6697
+
let _chan = create_announced_chan_between_nodes_with_value(&nodes,0,1,100000,0);
6737
6698
6738
-
for expected_id in0..2{
6739
-
let res = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2).unwrap().send_htlc(100000, our_payment_hash,TEST_FINAL_CLTV,HTLCSource::OutboundRoute{
6740
-
route: route.clone(),
6741
-
session_priv: session_priv.clone(),
6742
-
first_hop_htlc_msat:0,
6743
-
}, onion_packet.clone());
6699
+
let route = nodes[0].router.get_route(&nodes[1].node.get_our_node_id(),None,&[],100000000,TEST_FINAL_CLTV).unwrap();
0 commit comments