Skip to content

Commit 2bffd46

Browse files
committed
bitcoin 0.28.1
1 parent e3a305c commit 2bffd46

Some content is hidden

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

45 files changed

+374
-343
lines changed

fuzz/Cargo.toml

+1-1
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

+2-2
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+15-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use lightning::chain;
1111

1212
use std::cell::RefCell;
1313
use std::collections::VecDeque;
14+
use bitcoin::Transaction;
15+
use bitcoin::util::hash::bitcoin_merkle_root;
1416

1517
#[derive(Default)]
1618
pub struct Blockchain {
@@ -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 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

+1-1
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

+4-4
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

lightning-invoice/src/lib.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ use lightning::routing::network_graph::RoutingFees;
4747
use lightning::routing::router::RouteHint;
4848
use lightning::util::invoice::construct_invoice_preimage;
4949

50-
use secp256k1::key::PublicKey;
50+
use secp256k1::PublicKey;
5151
use secp256k1::{Message, Secp256k1};
52-
use secp256k1::recovery::RecoverableSignature;
52+
use secp256k1::ecdsa::RecoverableSignature;
5353

5454
use core::fmt::{Display, Formatter, self};
5555
use core::iter::FilterMap;
@@ -163,7 +163,7 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = 18;
163163
/// use bitcoin_hashes::sha256;
164164
///
165165
/// use secp256k1::Secp256k1;
166-
/// use secp256k1::key::SecretKey;
166+
/// use secp256k1::SecretKey;
167167
///
168168
/// use lightning::ln::PaymentSecret;
169169
///
@@ -191,7 +191,7 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY: u64 = 18;
191191
/// .current_timestamp()
192192
/// .min_final_cltv_expiry(144)
193193
/// .build_signed(|hash| {
194-
/// Secp256k1::new().sign_recoverable(hash, &private_key)
194+
/// Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)
195195
/// })
196196
/// .unwrap();
197197
///
@@ -749,7 +749,7 @@ impl SignedRawInvoice {
749749
let hash = Message::from_slice(&self.hash[..])
750750
.expect("Hash is 32 bytes long, same as MESSAGE_SIZE");
751751

752-
Ok(PayeePubKey(Secp256k1::new().recover(
752+
Ok(PayeePubKey(Secp256k1::new().recover_ecdsa(
753753
&hash,
754754
&self.signature
755755
)?))
@@ -776,7 +776,7 @@ impl SignedRawInvoice {
776776
.expect("Hash is 32 bytes long, same as MESSAGE_SIZE");
777777

778778
let secp_context = Secp256k1::new();
779-
let verification_result = secp_context.verify(
779+
let verification_result = secp_context.verify_ecdsa(
780780
&hash,
781781
&self.signature.to_standard(),
782782
pub_key
@@ -1576,8 +1576,8 @@ mod test {
15761576
fn test_check_signature() {
15771577
use TaggedField::*;
15781578
use secp256k1::Secp256k1;
1579-
use secp256k1::recovery::{RecoveryId, RecoverableSignature};
1580-
use secp256k1::key::{SecretKey, PublicKey};
1579+
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
1580+
use secp256k1::{SecretKey, PublicKey};
15811581
use {SignedRawInvoice, InvoiceSignature, RawInvoice, RawHrp, RawDataPart, Currency, Sha256,
15821582
PositiveTimestamp};
15831583

@@ -1635,7 +1635,7 @@ mod test {
16351635

16361636
let (raw_invoice, _, _) = invoice.into_parts();
16371637
let new_signed = raw_invoice.sign::<_, ()>(|hash| {
1638-
Ok(Secp256k1::new().sign_recoverable(hash, &private_key))
1638+
Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key))
16391639
}).unwrap();
16401640

16411641
assert!(new_signed.check_signature());
@@ -1646,7 +1646,7 @@ mod test {
16461646
use TaggedField::*;
16471647
use lightning::ln::features::InvoiceFeatures;
16481648
use secp256k1::Secp256k1;
1649-
use secp256k1::key::SecretKey;
1649+
use secp256k1::SecretKey;
16501650
use {RawInvoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp, Invoice,
16511651
SemanticError};
16521652

@@ -1677,7 +1677,7 @@ mod test {
16771677
let invoice = {
16781678
let mut invoice = invoice_template.clone();
16791679
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
1680-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1680+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
16811681
}.unwrap();
16821682
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::InvalidFeatures));
16831683

@@ -1686,7 +1686,7 @@ mod test {
16861686
let mut invoice = invoice_template.clone();
16871687
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
16881688
invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
1689-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1689+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
16901690
}.unwrap();
16911691
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::InvalidFeatures));
16921692

@@ -1695,30 +1695,30 @@ mod test {
16951695
let mut invoice = invoice_template.clone();
16961696
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
16971697
invoice.data.tagged_fields.push(Features(InvoiceFeatures::known()).into());
1698-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1698+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
16991699
}.unwrap();
17001700
assert!(Invoice::from_signed(invoice).is_ok());
17011701

17021702
// No payment secret or features
17031703
let invoice = {
17041704
let invoice = invoice_template.clone();
1705-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1705+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
17061706
}.unwrap();
17071707
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::NoPaymentSecret));
17081708

17091709
// No payment secret or feature bits
17101710
let invoice = {
17111711
let mut invoice = invoice_template.clone();
17121712
invoice.data.tagged_fields.push(Features(InvoiceFeatures::empty()).into());
1713-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1713+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
17141714
}.unwrap();
17151715
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::NoPaymentSecret));
17161716

17171717
// Missing payment secret
17181718
let invoice = {
17191719
let mut invoice = invoice_template.clone();
17201720
invoice.data.tagged_fields.push(Features(InvoiceFeatures::known()).into());
1721-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1721+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
17221722
}.unwrap();
17231723
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::NoPaymentSecret));
17241724

@@ -1727,7 +1727,7 @@ mod test {
17271727
let mut invoice = invoice_template.clone();
17281728
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
17291729
invoice.data.tagged_fields.push(PaymentSecret(payment_secret).into());
1730-
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_recoverable(hash, &private_key)))
1730+
invoice.sign::<_, ()>(|hash| Ok(Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)))
17311731
}.unwrap();
17321732
assert_eq!(Invoice::from_signed(invoice), Err(SemanticError::MultiplePaymentSecrets));
17331733
}
@@ -1764,7 +1764,7 @@ mod test {
17641764
use ::*;
17651765
use lightning::routing::router::RouteHintHop;
17661766
use std::iter::FromIterator;
1767-
use secp256k1::key::PublicKey;
1767+
use secp256k1::PublicKey;
17681768

17691769
let builder = InvoiceBuilder::new(Currency::Bitcoin)
17701770
.payment_hash(sha256::Hash::from_slice(&[0;32][..]).unwrap())
@@ -1818,7 +1818,7 @@ mod test {
18181818
use ::*;
18191819
use lightning::routing::router::RouteHintHop;
18201820
use secp256k1::Secp256k1;
1821-
use secp256k1::key::{SecretKey, PublicKey};
1821+
use secp256k1::{SecretKey, PublicKey};
18221822
use std::time::{UNIX_EPOCH, Duration};
18231823

18241824
let secp_ctx = Secp256k1::new();
@@ -1897,7 +1897,7 @@ mod test {
18971897
.basic_mpp();
18981898

18991899
let invoice = builder.clone().build_signed(|hash| {
1900-
secp_ctx.sign_recoverable(hash, &private_key)
1900+
secp_ctx.sign_ecdsa_recoverable(hash, &private_key)
19011901
}).unwrap();
19021902

19031903
assert!(invoice.check_signature().is_ok());
@@ -1932,7 +1932,7 @@ mod test {
19321932
fn test_default_values() {
19331933
use ::*;
19341934
use secp256k1::Secp256k1;
1935-
use secp256k1::key::SecretKey;
1935+
use secp256k1::SecretKey;
19361936

19371937
let signed_invoice = InvoiceBuilder::new(Currency::Bitcoin)
19381938
.description("Test".into())
@@ -1944,7 +1944,7 @@ mod test {
19441944
.sign::<_, ()>(|hash| {
19451945
let privkey = SecretKey::from_slice(&[41; 32]).unwrap();
19461946
let secp_ctx = Secp256k1::new();
1947-
Ok(secp_ctx.sign_recoverable(hash, &privkey))
1947+
Ok(secp_ctx.sign_ecdsa_recoverable(hash, &privkey))
19481948
})
19491949
.unwrap();
19501950
let invoice = Invoice::from_signed(signed_invoice).unwrap();
@@ -1958,7 +1958,7 @@ mod test {
19581958
fn test_expiration() {
19591959
use ::*;
19601960
use secp256k1::Secp256k1;
1961-
use secp256k1::key::SecretKey;
1961+
use secp256k1::SecretKey;
19621962

19631963
let signed_invoice = InvoiceBuilder::new(Currency::Bitcoin)
19641964
.description("Test".into())
@@ -1970,7 +1970,7 @@ mod test {
19701970
.sign::<_, ()>(|hash| {
19711971
let privkey = SecretKey::from_slice(&[41; 32]).unwrap();
19721972
let secp_ctx = Secp256k1::new();
1973-
Ok(secp_ctx.sign_recoverable(hash, &privkey))
1973+
Ok(secp_ctx.sign_ecdsa_recoverable(hash, &privkey))
19741974
})
19751975
.unwrap();
19761976
let invoice = Invoice::from_signed(signed_invoice).unwrap();

lightning-invoice/src/payment.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
//! # use lightning::util::ser::{Writeable, Writer};
4747
//! # use lightning_invoice::Invoice;
4848
//! # use lightning_invoice::payment::{InvoicePayer, Payer, RetryAttempts, Router};
49-
//! # use secp256k1::key::PublicKey;
49+
//! # use secp256k1::PublicKey;
5050
//! # use std::cell::RefCell;
5151
//! # use std::ops::Deref;
5252
//! #
@@ -148,7 +148,7 @@ use lightning::util::events::{Event, EventHandler};
148148
use lightning::util::logger::Logger;
149149
use crate::sync::Mutex;
150150

151-
use secp256k1::key::PublicKey;
151+
use secp256k1::PublicKey;
152152

153153
use core::ops::Deref;
154154
use core::time::Duration;
@@ -555,7 +555,7 @@ mod tests {
555555
.min_final_cltv_expiry(144)
556556
.amount_milli_satoshis(128)
557557
.build_signed(|hash| {
558-
Secp256k1::new().sign_recoverable(hash, &private_key)
558+
Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)
559559
})
560560
.unwrap()
561561
}
@@ -580,7 +580,7 @@ mod tests {
580580
.duration_since_epoch(duration_since_epoch())
581581
.min_final_cltv_expiry(144)
582582
.build_signed(|hash| {
583-
Secp256k1::new().sign_recoverable(hash, &private_key)
583+
Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)
584584
})
585585
.unwrap()
586586
}
@@ -600,7 +600,7 @@ mod tests {
600600
.min_final_cltv_expiry(144)
601601
.amount_milli_satoshis(128)
602602
.build_signed(|hash| {
603-
Secp256k1::new().sign_recoverable(hash, &private_key)
603+
Secp256k1::new().sign_ecdsa_recoverable(hash, &private_key)
604604
})
605605
.unwrap()
606606
}

lightning-invoice/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use lightning::routing::scoring::Score;
1919
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
2020
use lightning::routing::router::{Route, RouteHint, RouteHintHop, RouteParameters, find_route};
2121
use lightning::util::logger::Logger;
22-
use secp256k1::key::PublicKey;
22+
use secp256k1::PublicKey;
2323
use core::convert::TryInto;
2424
use core::ops::Deref;
2525
use core::time::Duration;

0 commit comments

Comments
 (0)