Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interop with another LN implementations #77

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 108 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ required-features = ["server"]

[dependencies]
# LNP/BP crates
amplify = "3.14.1"
amplify = "3.13.0"
strict_encoding = { version = "0.9.0-rc.2", features = ["miniscript"] }
bitcoin_scripts = "0.9.0"
bitcoin_blockchain = "0.9.0"
descriptor-wallet = { version = "0.9.0", features = ["keygen", "miniscript", "electrum", "sign", "construct"] }
lnpbp = "0.9.0"
lnpbp-invoice = { version = "0.9.0", features = ["serde", "bolt11"] }
lnp-core = "0.9.1"
lnp_rpc = { version = "0.9.1", path = "./rpc" }
internet2 = { version = "0.9.0", features = ["keygen"] }
Expand Down Expand Up @@ -119,4 +120,16 @@ embedded = ["microservices/embedded"]
tor = ["microservices/tor", "internet2/tor"]

[package.metadata.configure_me]
spec = "config_spec.toml"
spec = "config_spec.toml"

[patch.crates-io]
# TODO: Remove after merge and release:
# - https://github.com/LNP-WG/lnp-core/pull/29
# - https://github.com/LNP-WG/lnp-core/pull/27
lnp-core = { git = "https://github.com/crisdut/lnp-core", branch="exp/ln-interop" }
# TODO: Remove after merge and release:
# - https://github.com/LNP-WG/lightning_encoding/pull/4
lightning_encoding = { git = "https://github.com/crisdut/lightning_encoding", branch="fix/script-decode" }
# TODO: Remove after merge and release:
# - https://github.com/LNP-BP/invoices/pull/9
lnpbp-invoice = { git = "https://github.com/crisdut/invoices", branch="feat/bolt11" }
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ microservices = { version = "0.9.0", default-features = false, features = ["cli"
shellexpand = "2.1"
clap = { version = "~3.2.23", features = ["derive", "env"] }
log = "0.4.14"
colored = "2.0.0"

[build-dependencies]
amplify = "3.13.0"
Expand Down
29 changes: 27 additions & 2 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

use std::str::FromStr;

use colored::Colorize;
use internet2::addr::NodeId;
use lnp::p2p::bolt::{ChannelId, LNP2P_BOLT_PORT};
use lnp_rpc::{self, Client, CreateChannel, Error, ListenAddr, PayInvoice, RpcMsg, ServiceId};
use lnp_rpc::{
self, Client, CreateChannel, CreateInvoice, Error, ListenAddr, PayInvoice, RpcMsg, ServiceId,
};
use microservices::shell::Exec;

use crate::{Command, Opts};
Expand Down Expand Up @@ -152,7 +155,29 @@ impl Exec for Opts {
)?;
runtime.report_progress()?;
}
Command::Invoice { .. } => todo!("Implement invoice generation"),
Command::Invoice { amount, description, bolt, .. } => {
if bolt {
runtime.request(
ServiceId::LnpBroker,
RpcMsg::CreateInvoice(CreateInvoice {
amount_msat: (amount * 1000),
description,
}),
)?;
runtime.report_response()?;
eprintln!(
"{} {}",
"Warning:".bright_yellow(),
"This is a experimental feature!".yellow()
);
} else {
eprintln!(
"{} {}",
"Error:".bright_red(),
"Bifrost invoice does not implemented yet!".red()
);
}
}

Command::Pay { invoice, channel: channel_id, amount_msat } => {
runtime.request(
Expand Down
11 changes: 11 additions & 0 deletions cli/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,24 @@ pub enum Command {

/// Create an invoice
Invoice {
/// Invoice Description and/or Propouse
description: String,

/// Asset amount to invoice, in atomic unit (satoshis or smallest asset
/// unit type)
amount: u64,

/// Asset ticker in which the invoice should be issued
#[clap(default_value = "btc")]
asset: String,

/// Use BOLT lightning network protocol.
#[clap(long, conflicts_with = "bifrost")]
bolt: bool,

/// Use Bifrost lightning network protocol.
#[clap(long, required_unless_present = "bolt")]
bifrost: bool,
},

/// Pay the invoice
Expand Down
1 change: 1 addition & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ strict_encoding = "0.9.0"
bitcoin_scripts = "0.9.0"
lnp-core = { version = "0.9.0", default-features = false }
lnpbp = "0.9.0"
lnpbp-invoice = { version = "0.9.0", features = ["serde", "bolt11"] }
bitcoin = { version = "0.29.2", features = ["rand"] }
lightning-invoice = { version = "0.21.0", optional = true }
internet2 = "0.9.0"
Expand Down
Loading