keys_manager: Arc<KeysManager>, network_graph: Arc<NetworkGraph>,
onion_messenger: Arc<OnionMessenger>, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
outbound_payments: Arc<Mutex<PaymentInfoStorage>>, ldk_data_dir: String, network: Network,
- logger: Arc<disk::FilesystemLogger>, persister: Arc<FilesystemStore>,
+ logger: Arc<disk::FilesystemLogger>, fs_store: Arc<FilesystemStore>,
) {
println!(
"LDK startup successful. Enter \"help\" to view available commands. Press Ctrl-D to quit."
&channel_manager,
&invoice,
&mut outbound_payments.lock().unwrap(),
- persister.clone(),
+ Arc::clone(&fs_store),
);
}
"keysend" => {
amt_msat,
&*keys_manager,
&mut outbound_payments.lock().unwrap(),
- persister.clone(),
+ Arc::clone(&fs_store),
);
}
"getinvoice" => {
expiry_secs.unwrap(),
Arc::clone(&logger),
);
- persister
+ fs_store
.write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode())
.unwrap();
}
fn send_payment(
channel_manager: &ChannelManager, invoice: &Bolt11Invoice,
- outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
+ outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
) {
let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner());
let payment_secret = Some(*invoice.payment_secret());
amt_msat: MillisatAmount(invoice.amount_milli_satoshis()),
},
);
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
match pay_invoice(invoice, Retry::Timeout(Duration::from_secs(10)), channel_manager) {
Ok(_payment_id) => {
let payee_pubkey = invoice.recover_payee_pub_key();
println!("ERROR: failed to send payment: {:?}", e);
print!("> ");
outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
}
};
}
fn keysend<E: EntropySource>(
channel_manager: &ChannelManager, payee_pubkey: PublicKey, amt_msat: u64, entropy_source: &E,
- outbound_payments: &mut PaymentInfoStorage, persister: Arc<FilesystemStore>,
+ outbound_payments: &mut PaymentInfoStorage, fs_store: Arc<FilesystemStore>,
) {
let payment_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes());
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
amt_msat: MillisatAmount(Some(amt_msat)),
},
);
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
match channel_manager.send_spontaneous_payment_with_retry(
Some(payment_preimage),
RecipientOnionFields::spontaneous_empty(),
println!("ERROR: failed to send payment: {:?}", e);
print!("> ");
outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed;
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap();
}
};
}
channel_manager: &Arc<ChannelManager>, bitcoind_client: &BitcoindClient,
network_graph: &NetworkGraph, keys_manager: &KeysManager,
bump_tx_event_handler: &BumpTxEventHandler, inbound_payments: Arc<Mutex<PaymentInfoStorage>>,
- outbound_payments: Arc<Mutex<PaymentInfoStorage>>, persister: &Arc<FilesystemStore>,
+ outbound_payments: Arc<Mutex<PaymentInfoStorage>>, fs_store: &Arc<FilesystemStore>,
network: Network, event: Event,
) {
match event {
});
}
}
- persister.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
+ fs_store.write("", "", INBOUND_PAYMENTS_FNAME, &inbound.encode()).unwrap();
}
Event::PaymentSent { payment_preimage, payment_hash, fee_paid_msat, .. } => {
let mut outbound = outbound_payments.lock().unwrap();
io::stdout().flush().unwrap();
}
}
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
}
Event::OpenChannelRequest {
ref temporary_channel_id, ref counterparty_node_id, ..
let payment = outbound.payments.get_mut(&payment_hash).unwrap();
payment.status = HTLCStatus::Failed;
}
- persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
+ fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound.encode()).unwrap();
}
Event::PaymentForwarded {
prev_channel_id,
let key = hex_utils::hex_str(&keys_manager.get_secure_random_bytes());
// Note that if the type here changes our read code needs to change as well.
let output: SpendableOutputDescriptor = output;
- persister.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
+ fs_store.write(PENDING_SPENDABLE_OUTPUT_DIR, "", &key, &output.encode()).unwrap();
}
}
Event::ChannelPending { channel_id, counterparty_node_id, .. } => {