mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 15:02:20 +01:00
Add a lightning-types
dependency to lightning-invoice
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This takes tees us up for the final step, adding a `lightning-types` dependency to `lightning-invoice` and using it for imports rather than the `lightning` crate.
This commit is contained in:
parent
1f01f2ef67
commit
1eba737f44
3 changed files with 15 additions and 17 deletions
|
@ -21,6 +21,7 @@ std = ["bitcoin/std", "lightning/std", "bech32/std"]
|
|||
|
||||
[dependencies]
|
||||
bech32 = { version = "0.9.1", default-features = false }
|
||||
lightning-types = { version = "0.1", path = "../lightning-types", default-features = false }
|
||||
lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false }
|
||||
secp256k1 = { version = "0.28.0", default-features = false, features = ["recovery", "alloc"] }
|
||||
serde = { version = "1.0.118", optional = true }
|
||||
|
|
|
@ -14,9 +14,8 @@ use bitcoin::{PubkeyHash, ScriptHash, WitnessVersion};
|
|||
use bitcoin::hashes::Hash;
|
||||
use bitcoin::hashes::sha256;
|
||||
use crate::prelude::*;
|
||||
use lightning::ln::types::PaymentSecret;
|
||||
use lightning::routing::gossip::RoutingFees;
|
||||
use lightning::routing::router::{RouteHint, RouteHintHop};
|
||||
use lightning_types::payment::PaymentSecret;
|
||||
use lightning_types::routing::{RoutingFees, RouteHint, RouteHintHop};
|
||||
|
||||
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
|
||||
use secp256k1::PublicKey;
|
||||
|
@ -918,8 +917,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_parse_route() {
|
||||
use lightning::routing::gossip::RoutingFees;
|
||||
use lightning::routing::router::{RouteHint, RouteHintHop};
|
||||
use lightning_types::routing::{RoutingFees, RouteHint, RouteHintHop};
|
||||
use crate::PrivateRoute;
|
||||
use bech32::FromBase32;
|
||||
|
||||
|
@ -974,7 +972,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_payment_secret_and_features_de_and_ser() {
|
||||
use lightning::ln::features::Bolt11InvoiceFeatures;
|
||||
use lightning_types::features::Bolt11InvoiceFeatures;
|
||||
use secp256k1::ecdsa::{RecoveryId, RecoverableSignature};
|
||||
use crate::TaggedField::*;
|
||||
use crate::{SiPrefix, SignedRawBolt11Invoice, Bolt11InvoiceSignature, RawBolt11Invoice, RawHrp, RawDataPart,
|
||||
|
|
|
@ -30,6 +30,7 @@ pub mod utils;
|
|||
|
||||
extern crate bech32;
|
||||
#[macro_use] extern crate lightning;
|
||||
extern crate lightning_types;
|
||||
extern crate secp256k1;
|
||||
extern crate alloc;
|
||||
#[cfg(any(test, feature = "std"))]
|
||||
|
@ -44,7 +45,7 @@ use bech32::u5;
|
|||
use bitcoin::{Address, Network, PubkeyHash, ScriptHash, WitnessProgram, WitnessVersion};
|
||||
use bitcoin::address::Payload;
|
||||
use bitcoin::hashes::{Hash, sha256};
|
||||
use lightning::ln::features::Bolt11InvoiceFeatures;
|
||||
use lightning_types::features::Bolt11InvoiceFeatures;
|
||||
use lightning::util::invoice::construct_invoice_preimage;
|
||||
|
||||
use secp256k1::PublicKey;
|
||||
|
@ -64,12 +65,10 @@ use core::str;
|
|||
use serde::{Deserialize, Deserializer,Serialize, Serializer, de::Error};
|
||||
|
||||
#[doc(no_inline)]
|
||||
pub use lightning::ln::types::PaymentSecret;
|
||||
pub use lightning_types::payment::PaymentSecret;
|
||||
#[doc(no_inline)]
|
||||
pub use lightning::routing::router::{RouteHint, RouteHintHop};
|
||||
#[doc(no_inline)]
|
||||
pub use lightning::routing::gossip::RoutingFees;
|
||||
use lightning::util::string::UntrustedString;
|
||||
pub use lightning_types::routing::{RoutingFees, RouteHint, RouteHintHop};
|
||||
use lightning_types::string::UntrustedString;
|
||||
|
||||
mod de;
|
||||
mod ser;
|
||||
|
@ -161,7 +160,7 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = 18;
|
|||
/// use secp256k1::Secp256k1;
|
||||
/// use secp256k1::SecretKey;
|
||||
///
|
||||
/// use lightning::ln::types::PaymentSecret;
|
||||
/// use lightning_types::payment::PaymentSecret;
|
||||
///
|
||||
/// use lightning_invoice::{Currency, InvoiceBuilder};
|
||||
///
|
||||
|
@ -1877,14 +1876,14 @@ mod test {
|
|||
#[test]
|
||||
fn test_check_feature_bits() {
|
||||
use crate::TaggedField::*;
|
||||
use lightning::ln::features::Bolt11InvoiceFeatures;
|
||||
use lightning_types::features::Bolt11InvoiceFeatures;
|
||||
use secp256k1::Secp256k1;
|
||||
use secp256k1::SecretKey;
|
||||
use crate::{Bolt11Invoice, RawBolt11Invoice, RawHrp, RawDataPart, Currency, Sha256, PositiveTimestamp,
|
||||
Bolt11SemanticError};
|
||||
|
||||
let private_key = SecretKey::from_slice(&[42; 32]).unwrap();
|
||||
let payment_secret = lightning::ln::types::PaymentSecret([21; 32]);
|
||||
let payment_secret = lightning_types::payment::PaymentSecret([21; 32]);
|
||||
let invoice_template = RawBolt11Invoice {
|
||||
hrp: RawHrp {
|
||||
currency: Currency::Bitcoin,
|
||||
|
@ -1998,7 +1997,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_builder_fail() {
|
||||
use crate::*;
|
||||
use lightning::routing::router::RouteHintHop;
|
||||
use lightning_types::routing::RouteHintHop;
|
||||
use std::iter::FromIterator;
|
||||
use secp256k1::PublicKey;
|
||||
|
||||
|
@ -2052,7 +2051,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_builder_ok() {
|
||||
use crate::*;
|
||||
use lightning::routing::router::RouteHintHop;
|
||||
use lightning_types::routing::RouteHintHop;
|
||||
use secp256k1::Secp256k1;
|
||||
use secp256k1::{SecretKey, PublicKey};
|
||||
use std::time::Duration;
|
||||
|
|
Loading…
Add table
Reference in a new issue