use lightning::chain::chainmonitor;
use lightning::chain::transaction::OutPoint;
use lightning::chain::keysinterface::{InMemorySigner, KeysInterface};
-use lightning::ln::channelmanager::{BestBlock, ChainParameters, ChannelManager, PaymentHash, PaymentPreimage, PaymentSecret};
+use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
+use lightning::ln::channelmanager::{BestBlock, ChainParameters, ChannelManager};
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor};
use lightning::ln::msgs::DecodeError;
use lightning::routing::router::get_route;
use utils::test_persister::TestPersister;
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
+use bitcoin::secp256k1::recovery::RecoverableSignature;
use bitcoin::secp256k1::Secp256k1;
use std::cell::RefCell;
fn read_chan_signer(&self, data: &[u8]) -> Result<EnforcingSigner, DecodeError> {
EnforcingSigner::read(&mut std::io::Cursor::new(data))
}
+
+ fn sign_invoice(&self, _invoice_preimage: Vec<u8>) -> Result<RecoverableSignature, ()> {
+ unreachable!()
+ }
}
#[inline]
}, our_network_key, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0], Arc::clone(&logger)));
let mut should_forward = false;
- let mut payments_received: Vec<(PaymentHash, Option<PaymentSecret>, u64)> = Vec::new();
+ let mut payments_received: Vec<PaymentHash> = Vec::new();
let mut payments_sent = 0;
let mut pending_funding_generation: Vec<([u8; 32], u64, Script)> = Vec::new();
let mut pending_funding_signatures = HashMap::new();
}
},
8 => {
- for (payment, payment_secret, amt) in payments_received.drain(..) {
+ for payment in payments_received.drain(..) {
// SHA256 is defined as XOR of all input bytes placed in the first byte, and 0s
// for the remaining bytes. Thus, if not all remaining bytes are 0s we cannot
// fulfill this HTLC, but if they are, we can just take the first byte and
// place that anywhere in our preimage.
if &payment.0[1..] != &[0; 31] {
- channelmanager.fail_htlc_backwards(&payment, &payment_secret);
+ channelmanager.fail_htlc_backwards(&payment);
} else {
let mut payment_preimage = PaymentPreimage([0; 32]);
payment_preimage.0[0] = payment.0[0];
- channelmanager.claim_funds(payment_preimage, &payment_secret, amt);
+ channelmanager.claim_funds(payment_preimage);
}
}
},
+ 16 => {
+ let payment_preimage = PaymentPreimage(keys_manager.get_secure_random_bytes());
+ let mut sha = Sha256::engine();
+ sha.input(&payment_preimage.0[..]);
+ let payment_hash = PaymentHash(Sha256::from_engine(sha).into_inner());
+ // Note that this may fail - our hashes may collide and we'll end up trying to
+ // double-register the same payment_hash.
+ let _ = channelmanager.create_inbound_payment_for_hash(payment_hash, None, 1, 0);
+ },
9 => {
- for (payment, payment_secret, _) in payments_received.drain(..) {
- channelmanager.fail_htlc_backwards(&payment, &payment_secret);
+ for payment in payments_received.drain(..) {
+ channelmanager.fail_htlc_backwards(&payment);
}
},
10 => {
Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, output_script, .. } => {
pending_funding_generation.push((temporary_channel_id, channel_value_satoshis, output_script));
},
- Event::PaymentReceived { payment_hash, payment_secret, amt } => {
+ Event::PaymentReceived { payment_hash, .. } => {
//TODO: enhance by fetching random amounts from fuzz input?
- payments_received.push((payment_hash, payment_secret, amt));
+ payments_received.push(payment_hash);
},
Event::PaymentSent {..} => {},
Event::PaymentFailed {..} => {},