Skip to content

Commit ebdab41

Browse files
Mateusz FaltynMateusz Faltyn
authored andcommitted
Squashed
1 parent d166044 commit ebdab41

33 files changed

+1390
-749
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl chain::Watch<EnforcingSigner> for TestChainMonitor {
148148
self.chain_monitor.update_channel(funding_txo, update)
149149
}
150150

151-
fn release_pending_monitor_events(&self) -> Vec<MonitorEvent> {
151+
fn release_pending_monitor_events(&self) -> Vec<(OutPoint, Vec<MonitorEvent>)> {
152152
return self.chain_monitor.release_pending_monitor_events();
153153
}
154154
}
@@ -442,7 +442,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
442442
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
443443
}]};
444444
funding_output = OutPoint { txid: tx.txid(), index: 0 };
445-
$source.funding_transaction_generated(&temporary_channel_id, tx.clone()).unwrap();
445+
$source.funding_transaction_generated(&temporary_channel_id, &$dest.get_our_node_id(), tx.clone()).unwrap();
446446
channel_txn.push(tx);
447447
} else { panic!("Wrong event type"); }
448448
}

fuzz/src/full_stack.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
408408
let mut should_forward = false;
409409
let mut payments_received: Vec<PaymentHash> = Vec::new();
410410
let mut payments_sent = 0;
411-
let mut pending_funding_generation: Vec<([u8; 32], u64, Script)> = Vec::new();
411+
let mut pending_funding_generation: Vec<([u8; 32], PublicKey, u64, Script)> = Vec::new();
412412
let mut pending_funding_signatures = HashMap::new();
413413

414414
loop {
@@ -516,7 +516,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
516516
let channel_id = get_slice!(1)[0] as usize;
517517
if channel_id >= channels.len() { return; }
518518
channels.sort_by(|a, b| { a.channel_id.cmp(&b.channel_id) });
519-
if channelmanager.close_channel(&channels[channel_id].channel_id).is_err() { return; }
519+
if channelmanager.close_channel(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id).is_err() { return; }
520520
},
521521
7 => {
522522
if should_forward {
@@ -556,7 +556,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
556556
10 => {
557557
'outer_loop: for funding_generation in pending_funding_generation.drain(..) {
558558
let mut tx = Transaction { version: 0, lock_time: 0, input: Vec::new(), output: vec![TxOut {
559-
value: funding_generation.1, script_pubkey: funding_generation.2,
559+
value: funding_generation.2, script_pubkey: funding_generation.3,
560560
}] };
561561
let funding_output = 'search_loop: loop {
562562
let funding_txid = tx.txid();
@@ -575,7 +575,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
575575
continue 'outer_loop;
576576
}
577577
};
578-
if let Err(e) = channelmanager.funding_transaction_generated(&funding_generation.0, tx.clone()) {
578+
if let Err(e) = channelmanager.funding_transaction_generated(&funding_generation.0, &funding_generation.1, tx.clone()) {
579579
// It's possible the channel has been closed in the mean time, but any other
580580
// failure may be a bug.
581581
if let APIError::ChannelUnavailable { err } = e {
@@ -624,16 +624,16 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
624624
let channel_id = get_slice!(1)[0] as usize;
625625
if channel_id >= channels.len() { return; }
626626
channels.sort_by(|a, b| { a.channel_id.cmp(&b.channel_id) });
627-
channelmanager.force_close_channel(&channels[channel_id].channel_id).unwrap();
627+
channelmanager.force_close_channel(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id).unwrap();
628628
},
629629
// 15 is above
630630
_ => return,
631631
}
632632
loss_detector.handler.process_events();
633633
for event in loss_detector.manager.get_and_clear_pending_events() {
634634
match event {
635-
Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, output_script, .. } => {
636-
pending_funding_generation.push((temporary_channel_id, channel_value_satoshis, output_script));
635+
Event::FundingGenerationReady { temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, .. } => {
636+
pending_funding_generation.push((temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script));
637637
},
638638
Event::PaymentReceived { payment_hash, .. } => {
639639
//TODO: enhance by fetching random amounts from fuzz input?

fuzz/src/peer_crypt.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use lightning::ln::peer_channel_encryptor::PeerChannelEncryptor;
1111

12-
use bitcoin::secp256k1::{PublicKey,SecretKey};
12+
use bitcoin::secp256k1::{Secp256k1, PublicKey, SecretKey};
1313

1414
use utils::test_logger;
1515

@@ -35,6 +35,8 @@ pub fn do_test(data: &[u8]) {
3535
}
3636
}
3737

38+
let secp_ctx = Secp256k1::signing_only();
39+
3840
let our_network_key = match SecretKey::from_slice(get_slice!(32)) {
3941
Ok(key) => key,
4042
Err(_) => return,
@@ -50,16 +52,16 @@ pub fn do_test(data: &[u8]) {
5052
Err(_) => return,
5153
};
5254
let mut crypter = PeerChannelEncryptor::new_outbound(their_pubkey, ephemeral_key);
53-
crypter.get_act_one();
54-
match crypter.process_act_two(get_slice!(50), &our_network_key) {
55+
crypter.get_act_one(&secp_ctx);
56+
match crypter.process_act_two(get_slice!(50), &our_network_key, &secp_ctx) {
5557
Ok(_) => {},
5658
Err(_) => return,
5759
}
5860
assert!(crypter.is_ready_for_encryption());
5961
crypter
6062
} else {
61-
let mut crypter = PeerChannelEncryptor::new_inbound(&our_network_key);
62-
match crypter.process_act_one_with_keys(get_slice!(50), &our_network_key, ephemeral_key) {
63+
let mut crypter = PeerChannelEncryptor::new_inbound(&our_network_key, &secp_ctx);
64+
match crypter.process_act_one_with_keys(get_slice!(50), &our_network_key, ephemeral_key, &secp_ctx) {
6365
Ok(_) => {},
6466
Err(_) => return,
6567
}

lightning-background-processor/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ mod tests {
379379
use lightning::util::ser::Writeable;
380380
use lightning::util::test_utils;
381381
use lightning::util::persist::KVStorePersister;
382-
use lightning_invoice::payment::{InvoicePayer, RetryAttempts};
382+
use lightning_invoice::payment::{InvoicePayer, Retry};
383383
use lightning_invoice::utils::DefaultRouter;
384384
use lightning_persister::FilesystemPersister;
385385
use std::fs;
@@ -540,7 +540,7 @@ mod tests {
540540
macro_rules! handle_funding_generation_ready {
541541
($event: expr, $channel_value: expr) => {{
542542
match $event {
543-
&Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, ref output_script, user_channel_id } => {
543+
&Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, ref output_script, user_channel_id, .. } => {
544544
assert_eq!(channel_value_satoshis, $channel_value);
545545
assert_eq!(user_channel_id, 42);
546546

@@ -556,7 +556,7 @@ mod tests {
556556

557557
macro_rules! end_open_channel {
558558
($node_a: expr, $node_b: expr, $temporary_channel_id: expr, $tx: expr) => {{
559-
$node_a.node.funding_transaction_generated(&$temporary_channel_id, $tx.clone()).unwrap();
559+
$node_a.node.funding_transaction_generated(&$temporary_channel_id, &$node_b.node.get_our_node_id(), $tx.clone()).unwrap();
560560
$node_b.node.handle_funding_created(&$node_a.node.get_our_node_id(), &get_event_msg!($node_a, MessageSendEvent::SendFundingCreated, $node_b.node.get_our_node_id()));
561561
$node_a.node.handle_funding_signed(&$node_b.node.get_our_node_id(), &get_event_msg!($node_b, MessageSendEvent::SendFundingSigned, $node_a.node.get_our_node_id()));
562562
}}
@@ -637,7 +637,7 @@ mod tests {
637637
}
638638

639639
// Force-close the channel.
640-
nodes[0].node.force_close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).unwrap();
640+
nodes[0].node.force_close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id(), &nodes[1].node.get_our_node_id()).unwrap();
641641

642642
// Check that the force-close updates are persisted.
643643
check_persisted_data!(nodes[0].node, filepath.clone());
@@ -776,7 +776,7 @@ mod tests {
776776
let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()));
777777

778778
// Force close the channel and check that the SpendableOutputs event was handled.
779-
nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id).unwrap();
779+
nodes[0].node.force_close_channel(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id()).unwrap();
780780
let commitment_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap();
781781
confirm_transaction_depth(&mut nodes[0], &commitment_tx, BREAKDOWN_TIMEOUT as u32);
782782
let event = receiver
@@ -801,7 +801,7 @@ mod tests {
801801
let data_dir = nodes[0].persister.get_data_dir();
802802
let persister = Arc::new(Persister::new(data_dir));
803803
let router = DefaultRouter::new(Arc::clone(&nodes[0].network_graph), Arc::clone(&nodes[0].logger), random_seed_bytes);
804-
let invoice_payer = Arc::new(InvoicePayer::new(Arc::clone(&nodes[0].node), router, Arc::clone(&nodes[0].scorer), Arc::clone(&nodes[0].logger), |_: &_| {}, RetryAttempts(2)));
804+
let invoice_payer = Arc::new(InvoicePayer::new(Arc::clone(&nodes[0].node), router, Arc::clone(&nodes[0].scorer), Arc::clone(&nodes[0].logger), |_: &_| {}, Retry::Attempts(2)));
805805
let event_handler = Arc::clone(&invoice_payer);
806806
let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), nodes[0].net_graph_msg_handler.clone(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone()));
807807
assert!(bg_processor.stop().is_ok());

lightning-invoice/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
1212

1313
//! This crate provides data structures to represent
14-
//! [lightning BOLT11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md)
14+
//! [lightning BOLT11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md)
1515
//! invoices and functions to create, encode and decode these. If you just want to use the standard
1616
//! en-/decoding functionality this should get you started:
1717
//!
@@ -25,6 +25,8 @@ compile_error!("at least one of the `std` or `no-std` features must be enabled")
2525
pub mod payment;
2626
pub mod utils;
2727

28+
pub(crate) mod time_utils;
29+
2830
extern crate bech32;
2931
extern crate bitcoin_hashes;
3032
#[macro_use] extern crate lightning;

0 commit comments

Comments
 (0)