|
18 | 18 | //! send-side handling is correct, other peers. We consider it a failure if any action results in a
|
19 | 19 | //! channel being force-closed.
|
20 | 20 |
|
| 21 | +use bitcoin::TxMerkleNode; |
21 | 22 | use bitcoin::blockdata::block::BlockHeader;
|
22 | 23 | use bitcoin::blockdata::constants::genesis_block;
|
23 | 24 | use bitcoin::blockdata::transaction::{Transaction, TxOut};
|
24 | 25 | use bitcoin::blockdata::script::{Builder, Script};
|
25 | 26 | use bitcoin::blockdata::opcodes;
|
| 27 | +use bitcoin::blockdata::locktime::PackedLockTime; |
26 | 28 | use bitcoin::network::constants::Network;
|
27 | 29 |
|
28 | 30 | use bitcoin::hashes::Hash as TraitImport;
|
@@ -53,7 +55,7 @@ use lightning::routing::router::{Route, RouteHop};
|
53 | 55 | use utils::test_logger::{self, Output};
|
54 | 56 | use utils::test_persister::TestPersister;
|
55 | 57 |
|
56 |
| -use bitcoin::secp256k1::{PublicKey,SecretKey}; |
| 58 | +use bitcoin::secp256k1::{PublicKey, SecretKey, Scalar}; |
57 | 59 | use bitcoin::secp256k1::ecdh::SharedSecret;
|
58 | 60 | use bitcoin::secp256k1::ecdsa::RecoverableSignature;
|
59 | 61 | use bitcoin::secp256k1::Secp256k1;
|
@@ -166,10 +168,10 @@ impl KeysInterface for KeyProvider {
|
166 | 168 | Ok(SecretKey::from_slice(&[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, 1, self.node_id]).unwrap())
|
167 | 169 | }
|
168 | 170 |
|
169 |
| - fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&[u8; 32]>) -> Result<SharedSecret, ()> { |
| 171 | + fn ecdh(&self, recipient: Recipient, other_key: &PublicKey, tweak: Option<&Scalar>) -> Result<SharedSecret, ()> { |
170 | 172 | let mut node_secret = self.get_node_secret(recipient)?;
|
171 | 173 | if let Some(tweak) = tweak {
|
172 |
| - node_secret.mul_assign(tweak).map_err(|_| ())?; |
| 174 | + node_secret = node_secret.mul_tweak(tweak).unwrap(); |
173 | 175 | }
|
174 | 176 | Ok(SharedSecret::new(other_key, &node_secret))
|
175 | 177 | }
|
@@ -447,7 +449,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
447 | 449 | let events = $source.get_and_clear_pending_events();
|
448 | 450 | assert_eq!(events.len(), 1);
|
449 | 451 | if let events::Event::FundingGenerationReady { ref temporary_channel_id, ref channel_value_satoshis, ref output_script, .. } = events[0] {
|
450 |
| - let tx = Transaction { version: $chan_id, lock_time: 0, input: Vec::new(), output: vec![TxOut { |
| 452 | + let tx = Transaction { version: $chan_id, lock_time: PackedLockTime::ZERO, input: Vec::new(), output: vec![TxOut { |
451 | 453 | value: *channel_value_satoshis, script_pubkey: output_script.clone(),
|
452 | 454 | }]};
|
453 | 455 | funding_output = OutPoint { txid: tx.txid(), index: 0 };
|
@@ -481,11 +483,11 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
|
481 | 483 | macro_rules! confirm_txn {
|
482 | 484 | ($node: expr) => { {
|
483 | 485 | let chain_hash = genesis_block(Network::Bitcoin).block_hash();
|
484 |
| - let mut header = BlockHeader { version: 0x20000000, prev_blockhash: chain_hash, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; |
| 486 | + let mut header = BlockHeader { version: 0x20000000, prev_blockhash: chain_hash, merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 }; |
485 | 487 | let txdata: Vec<_> = channel_txn.iter().enumerate().map(|(i, tx)| (i + 1, tx)).collect();
|
486 | 488 | $node.transactions_confirmed(&header, &txdata, 1);
|
487 | 489 | for _ in 2..100 {
|
488 |
| - header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; |
| 490 | + header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: TxMerkleNode::all_zeros(), time: 42, bits: 42, nonce: 42 }; |
489 | 491 | }
|
490 | 492 | $node.best_block_updated(&header, 99);
|
491 | 493 | } }
|
|
0 commit comments