Skip to content

Commit 6592081

Browse files
authored
Merge pull request #1389 from lightning-signer/2022-03-bitcoin
Update bitcoin crate to 0.28.1
2 parents c8c4daa + a650159 commit 6592081

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+381
-368
lines changed

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ stdin_fuzz = []
1919
[dependencies]
2020
afl = { version = "0.4", optional = true }
2121
lightning = { path = "../lightning", features = ["regex"] }
22-
bitcoin = { version = "0.27", features = ["fuzztarget", "secp-lowmemory"] }
22+
bitcoin = { version = "0.28.1", features = ["secp-lowmemory"] }
2323
hex = "0.3"
2424
honggfuzz = { version = "0.5", optional = true }
2525
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git", optional = true }

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use lightning::routing::router::{Route, RouteHop};
5353
use utils::test_logger::{self, Output};
5454
use utils::test_persister::TestPersister;
5555

56-
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
57-
use bitcoin::secp256k1::recovery::RecoverableSignature;
56+
use bitcoin::secp256k1::{PublicKey,SecretKey};
57+
use bitcoin::secp256k1::ecdsa::RecoverableSignature;
5858
use bitcoin::secp256k1::Secp256k1;
5959

6060
use std::mem;

fuzz/src/full_stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ use lightning::util::ser::ReadableArgs;
5050
use utils::test_logger;
5151
use utils::test_persister::TestPersister;
5252

53-
use bitcoin::secp256k1::key::{PublicKey,SecretKey};
54-
use bitcoin::secp256k1::recovery::RecoverableSignature;
53+
use bitcoin::secp256k1::{PublicKey,SecretKey};
54+
use bitcoin::secp256k1::ecdsa::RecoverableSignature;
5555
use bitcoin::secp256k1::Secp256k1;
5656

5757
use std::cell::RefCell;

fuzz/src/peer_crypt.rs

Lines changed: 1 addition & 1 deletion
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::key::{PublicKey,SecretKey};
12+
use bitcoin::secp256k1::{PublicKey,SecretKey};
1313

1414
use utils::test_logger;
1515

fuzz/src/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use lightning::util::ser::Readable;
2323
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
2424

2525
use bitcoin::hashes::Hash;
26-
use bitcoin::secp256k1::key::PublicKey;
26+
use bitcoin::secp256k1::PublicKey;
2727
use bitcoin::network::constants::Network;
2828
use bitcoin::blockdata::constants::genesis_block;
2929

lightning-background-processor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ all-features = true
1414
rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[dependencies]
17-
bitcoin = "0.27"
17+
bitcoin = "0.28.1"
1818
lightning = { version = "0.0.106", path = "../lightning", features = ["std"] }
1919

2020
[dev-dependencies]

lightning-block-sync/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rest-client = [ "serde", "serde_json", "chunked_transfer" ]
1818
rpc-client = [ "serde", "serde_json", "chunked_transfer" ]
1919

2020
[dependencies]
21-
bitcoin = "0.27"
21+
bitcoin = "0.28.1"
2222
lightning = { version = "0.0.106", path = "../lightning" }
2323
futures = { version = "0.3" }
2424
tokio = { version = "1.0", features = [ "io-util", "net", "time" ], optional = true }

lightning-block-sync/src/test_utils.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use bitcoin::blockdata::constants::genesis_block;
66
use bitcoin::hash_types::BlockHash;
77
use bitcoin::network::constants::Network;
88
use bitcoin::util::uint::Uint256;
9+
use bitcoin::util::hash::bitcoin_merkle_root;
10+
use bitcoin::Transaction;
911

1012
use lightning::chain;
1113

@@ -37,16 +39,27 @@ impl Blockchain {
3739
let prev_block = &self.blocks[i - 1];
3840
let prev_blockhash = prev_block.block_hash();
3941
let time = prev_block.header.time + height as u32;
42+
// Must have at least one transaction, because the merkle root is not defined for an empty block
43+
// and we would fail when we later checked, as of bitcoin crate 0.28.0.
44+
// Note that elsewhere in tests we assume that the merkle root of an empty block is all zeros,
45+
// but that's OK because those tests don't trigger the check.
46+
let coinbase = Transaction {
47+
version: 0,
48+
lock_time: 0,
49+
input: vec![],
50+
output: vec![]
51+
};
52+
let merkle_root = bitcoin_merkle_root(vec![coinbase.txid().as_hash()].into_iter()).unwrap();
4053
self.blocks.push(Block {
4154
header: BlockHeader {
4255
version: 0,
4356
prev_blockhash,
44-
merkle_root: Default::default(),
57+
merkle_root: merkle_root.into(),
4558
time,
4659
bits,
4760
nonce: 0,
4861
},
49-
txdata: vec![],
62+
txdata: vec![coinbase],
5063
});
5164
}
5265
self

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ std = ["bitcoin_hashes/std", "num-traits/std", "lightning/std", "bech32/std"]
2020
[dependencies]
2121
bech32 = { version = "0.8", default-features = false }
2222
lightning = { version = "0.0.106", path = "../lightning", default-features = false }
23-
secp256k1 = { version = "0.20", default-features = false, features = ["recovery", "alloc"] }
23+
secp256k1 = { version = "0.22", default-features = false, features = ["recovery", "alloc"] }
2424
num-traits = { version = "0.2.8", default-features = false }
2525
bitcoin_hashes = { version = "0.10", default-features = false }
2626
hashbrown = { version = "0.11", optional = true }

lightning-invoice/src/de.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use lightning::routing::router::{RouteHint, RouteHintHop};
1919
use num_traits::{CheckedAdd, CheckedMul};
2020

2121
use secp256k1;
22-
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
23-
use secp256k1::key::PublicKey;
22+
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
23+
use secp256k1::PublicKey;
2424

2525
use super::{Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiry, Fallback, PayeePubKey, InvoiceSignature, PositiveTimestamp,
2626
SemanticError, PrivateRoute, ParseError, ParseOrSemanticError, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawInvoice,
@@ -967,7 +967,7 @@ mod test {
967967
#[test]
968968
fn test_payment_secret_and_features_de_and_ser() {
969969
use lightning::ln::features::InvoiceFeatures;
970-
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
970+
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
971971
use TaggedField::*;
972972
use {SiPrefix, SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart,
973973
Currency, Sha256, PositiveTimestamp};
@@ -1014,7 +1014,7 @@ mod test {
10141014
#[test]
10151015
fn test_raw_signed_invoice_deserialization() {
10161016
use TaggedField::*;
1017-
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
1017+
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
10181018
use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
10191019
PositiveTimestamp};
10201020

0 commit comments

Comments
 (0)