use lightning_types::payment::PaymentSecret;
use lightning_types::routing::{RoutingFees, RouteHint, RouteHintHop};
-use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
-use secp256k1::PublicKey;
+use bitcoin::secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
+use bitcoin::secp256k1::PublicKey;
use super::{Bolt11Invoice, Sha256, TaggedField, ExpiryTime, MinFinalCltvExpiryDelta, Fallback, PayeePubKey, Bolt11InvoiceSignature, PositiveTimestamp,
Bolt11SemanticError, PrivateRoute, Bolt11ParseError, ParseOrSemanticError, Description, RawTaggedField, Currency, RawHrp, SiPrefix, RawBolt11Invoice,
}
}
-from_error!(Bolt11ParseError::MalformedSignature, secp256k1::Error);
+from_error!(Bolt11ParseError::MalformedSignature, bitcoin::secp256k1::Error);
from_error!(Bolt11ParseError::ParseAmountError, ParseIntError);
from_error!(Bolt11ParseError::DescriptionDecodeError, str::Utf8Error);
#[cfg(test)]
mod test {
use crate::de::Bolt11ParseError;
- use secp256k1::PublicKey;
+ use bitcoin::secp256k1::PublicKey;
use bech32::u5;
use bitcoin::hashes::sha256;
use std::str::FromStr;
#[test]
fn test_payment_secret_and_features_de_and_ser() {
use lightning_types::features::Bolt11InvoiceFeatures;
- use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
+ use bitcoin::secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
use crate::TaggedField::*;
use crate::{SiPrefix, SignedRawBolt11Invoice, Bolt11InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart,
Currency, Sha256, PositiveTimestamp};
#[test]
fn test_raw_signed_invoice_deserialization() {
use crate::TaggedField::*;
- use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
+ use bitcoin::secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
use crate::{SignedRawBolt11Invoice, Bolt11InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256,
PositiveTimestamp};
extern crate bech32;
extern crate lightning_types;
-extern crate secp256k1;
extern crate alloc;
#[cfg(any(test, feature = "std"))]
extern crate core;
use bitcoin::hashes::{Hash, sha256};
use lightning_types::features::Bolt11InvoiceFeatures;
-use secp256k1::PublicKey;
-use secp256k1::{Message, Secp256k1};
-use secp256k1::ecdsa::RecoverableSignature;
+use bitcoin::secp256k1::PublicKey;
+use bitcoin::secp256k1::{Message, Secp256k1};
+use bitcoin::secp256k1::ecdsa::RecoverableSignature;
use core::cmp::Ordering;
use core::fmt::{Display, Formatter, self};
pub enum Bolt11ParseError {
Bech32Error(bech32::Error),
ParseAmountError(ParseIntError),
- MalformedSignature(secp256k1::Error),
+ MalformedSignature(bitcoin::secp256k1::Error),
BadPrefix,
UnknownCurrency,
UnknownSiPrefix,
/// ensures that only a semantically and syntactically correct invoice can be built using it.
///
/// ```
-/// extern crate secp256k1;
/// extern crate lightning_invoice;
/// extern crate bitcoin;
///
/// use bitcoin::hashes::Hash;
/// use bitcoin::hashes::sha256;
///
-/// use secp256k1::Secp256k1;
-/// use secp256k1::SecretKey;
+/// use bitcoin::secp256k1::Secp256k1;
+/// use bitcoin::secp256k1::SecretKey;
///
/// use lightning_types::payment::PaymentSecret;
///
}
/// Recovers the public key used for signing the invoice from the recoverable signature.
- pub fn recover_payee_pub_key(&self) -> Result<PayeePubKey, secp256k1::Error> {
+ pub fn recover_payee_pub_key(&self) -> Result<PayeePubKey, bitcoin::secp256k1::Error> {
let hash = Message::from_digest(self.hash);
Ok(PayeePubKey(Secp256k1::new().recover_ecdsa(
/// Check that the invoice is signed correctly and that key recovery works
pub fn check_signature(&self) -> Result<(), Bolt11SemanticError> {
match self.signed_invoice.recover_payee_pub_key() {
- Err(secp256k1::Error::InvalidRecoveryId) =>
+ Err(bitcoin::secp256k1::Error::InvalidRecoveryId) =>
return Err(Bolt11SemanticError::InvalidRecoveryId),
- Err(secp256k1::Error::InvalidSignature) =>
+ Err(bitcoin::secp256k1::Error::InvalidSignature) =>
return Err(Bolt11SemanticError::InvalidSignature),
Err(e) => panic!("no other error may occur, got {:?}", e),
Ok(_) => {},
#[test]
fn test_check_signature() {
use crate::TaggedField::*;
- use secp256k1::Secp256k1;
- use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
- use secp256k1::{SecretKey, PublicKey};
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
+ use bitcoin::secp256k1::{SecretKey, PublicKey};
use crate::{SignedRawBolt11Invoice, Bolt11InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256,
PositiveTimestamp};
fn test_check_feature_bits() {
use crate::TaggedField::*;
use lightning_types::features::Bolt11InvoiceFeatures;
- use secp256k1::Secp256k1;
- use secp256k1::SecretKey;
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::SecretKey;
use crate::{Bolt11Invoice, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp,
Bolt11SemanticError};
use crate::*;
use lightning_types::routing::RouteHintHop;
use std::iter::FromIterator;
- use secp256k1::PublicKey;
+ use bitcoin::secp256k1::PublicKey;
let builder = InvoiceBuilder::new(Currency::Bitcoin)
.payment_hash(sha256::Hash::from_slice(&[0;32][..]).unwrap())
fn test_builder_ok() {
use crate::*;
use lightning_types::routing::RouteHintHop;
- use secp256k1::Secp256k1;
- use secp256k1::{SecretKey, PublicKey};
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::{SecretKey, PublicKey};
use std::time::Duration;
let secp_ctx = Secp256k1::new();
#[test]
fn test_default_values() {
use crate::*;
- use secp256k1::Secp256k1;
- use secp256k1::SecretKey;
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::SecretKey;
let signed_invoice = InvoiceBuilder::new(Currency::Bitcoin)
.description("Test".into())
#[test]
fn test_expiration() {
use crate::*;
- use secp256k1::Secp256k1;
- use secp256k1::SecretKey;
+ use bitcoin::secp256k1::Secp256k1;
+ use bitcoin::secp256k1::SecretKey;
let signed_invoice = InvoiceBuilder::new(Currency::Bitcoin)
.description("Test".into())