send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000);
send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000);
- let (our_payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
- let (our_payment_preimage_2, _payment_hash_2, _payment_secret_2) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+ let (our_payment_preimage, payment_hash_1, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+ let (our_payment_preimage_2, payment_hash_2, _payment_secret_2) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
// Broadcast legit commitment tx from C on B's chain
// Broadcast HTLC Success transaction by C on received output from C's commitment tx on B's chain
let mut first_claimed = false;
for event in events {
match event {
- Event::PaymentSent { payment_preimage } => {
- if payment_preimage == our_payment_preimage {
+ Event::PaymentSent { payment_preimage, payment_hash } => {
+ if payment_preimage == our_payment_preimage && payment_hash == payment_hash_1 {
assert!(!first_claimed);
first_claimed = true;
} else {
assert_eq!(payment_preimage, our_payment_preimage_2);
+ assert_eq!(payment_hash, payment_hash_2);
}
},
Event::ChannelClosed { reason: ClosureReason::CommitmentTxConfirmed, .. } => {},
nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
reconnect_nodes(&nodes[0], &nodes[1], (false, false), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (false, false));
- let payment_preimage_3 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).0;
+ let (payment_preimage_3, payment_hash_3, _) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000);
let payment_preimage_4 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).0;
let payment_hash_5 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).1;
let payment_hash_6 = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 1000000).1;
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 2);
match events[0] {
- Event::PaymentSent { payment_preimage } => {
+ Event::PaymentSent { payment_preimage, payment_hash } => {
assert_eq!(payment_preimage, payment_preimage_3);
+ assert_eq!(payment_hash, payment_hash_3);
},
_ => panic!("Unexpected event"),
}
let events_4 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_4.len(), 1);
match events_4[0] {
- Event::PaymentSent { ref payment_preimage } => {
+ Event::PaymentSent { ref payment_preimage, ref payment_hash } => {
assert_eq!(payment_preimage_1, *payment_preimage);
+ assert_eq!(payment_hash_1, *payment_hash);
},
_ => panic!("Unexpected event"),
}
let events_4 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_4.len(), 1);
match events_4[0] {
- Event::PaymentSent { ref payment_preimage } => {
+ Event::PaymentSent { ref payment_preimage, ref payment_hash } => {
assert_eq!(payment_preimage_1, *payment_preimage);
+ assert_eq!(payment_hash_1, *payment_hash);
},
_ => panic!("Unexpected event"),
}
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
let logger = test_utils::TestLogger::new();
- let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+ let (payment_preimage_1, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
// Now try to send a second payment which will fail to send
let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
let events_3 = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events_3.len(), 1);
match events_3[0] {
- Event::PaymentSent { ref payment_preimage } => {
+ Event::PaymentSent { ref payment_preimage, ref payment_hash } => {
assert_eq!(*payment_preimage, payment_preimage_1);
+ assert_eq!(*payment_hash, payment_hash_1);
},
_ => panic!("Unexpected event"),
}
let events = nodes[0].node.get_and_clear_pending_events();
match events[0] {
- Event::PaymentSent { ref payment_preimage } => {
+ Event::PaymentSent { ref payment_preimage, ref payment_hash } => {
assert_eq!(*payment_preimage, our_payment_preimage);
+ assert_eq!(*payment_hash, duplicate_payment_hash);
}
_ => panic!("Unexpected event"),
}
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
- let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], if use_dust { 50000 } else { 3000000 });
+ let (our_payment_preimage, our_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], if use_dust { 50000 } else { 3000000 });
// Claim the payment, but don't deliver A's commitment_signed, resulting in the HTLC only being
// present in B's local commitment transaction, but none of A's commitment transactions.
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::PaymentSent { payment_preimage } => {
+ Event::PaymentSent { payment_preimage, payment_hash } => {
assert_eq!(payment_preimage, our_payment_preimage);
+ assert_eq!(payment_hash, our_payment_hash);
},
_ => panic!("Unexpected event"),
}
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match &events[0] {
- &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed, path: _ } => {
+ &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, path: _, ref short_channel_id, ref error_code, ref error_data } => {
assert_eq!(our_payment_hash.clone(), *payment_hash);
assert_eq!(*rejected_by_dest, false);
assert_eq!(*all_paths_failed, true);
assert_eq!(*network_update, None);
+ assert_eq!(*short_channel_id, None);
assert_eq!(*error_code, None);
assert_eq!(*error_data, None);
},
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match &events[0] {
- &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref error_code, ref error_data, ref all_paths_failed, path: _ } => {
+ &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, path: _, ref short_channel_id, ref error_code, ref error_data } => {
assert_eq!(payment_hash_2.clone(), *payment_hash);
assert_eq!(*rejected_by_dest, false);
assert_eq!(*all_paths_failed, true);
assert_eq!(*network_update, None);
+ assert_eq!(*short_channel_id, None);
assert_eq!(*error_code, None);
assert_eq!(*error_data, None);
},
let events = nodes[0].node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::PaymentSent { ref payment_preimage } => {
+ Event::PaymentSent { ref payment_preimage, ref payment_hash } => {
assert_eq!(*payment_preimage, payment_preimage_1);
+ assert_eq!(*payment_hash, payment_hash_1);
}
_ => panic!("Unexpected event"),
}
let channel_id = ::chain::transaction::OutPoint { txid: funding_created_msg.funding_txid, index: funding_created_msg.funding_output_index }.to_channel_id();
nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &msgs::ErrorMessage { channel_id, data: "Hi".to_owned() });
assert!(nodes[0].chain_monitor.added_monitors.lock().unwrap().is_empty());
- check_closed_event!(nodes[0], 1, ClosureReason::CounterpartyForceClosed { peer_msg: "Hi".to_string() });
+ check_closed_event!(nodes[0], 2, ClosureReason::CounterpartyForceClosed { peer_msg: "Hi".to_string() }, true);
}
#[test]