-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1ecfad
commit 97de626
Showing
6 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use clap::{Parser, Subcommand}; | ||
use lndk::lndk_offers::decode; | ||
|
||
/// A cli for interacting with lndk. | ||
#[derive(Debug, Parser)] | ||
#[command(name = "lndk-cli")] | ||
#[command(about = "A cli for interacting with lndk", long_about = None)] | ||
struct Cli { | ||
#[command(subcommand)] | ||
command: Commands, | ||
} | ||
|
||
#[derive(Debug, Subcommand)] | ||
enum Commands { | ||
/// Decodes a bech32-encoded offer string into a BOLT 12 offer. | ||
Decode { | ||
/// The offer string to decode. | ||
offer_string: String, | ||
}, | ||
} | ||
|
||
fn main() { | ||
let args = Cli::parse(); | ||
match args.command { | ||
Commands::Decode { offer_string } => { | ||
println!("Decoding offer: {offer_string}."); | ||
match decode(offer_string) { | ||
Ok(offer) => println!("Decoded offer: {:?}.", offer), | ||
Err(e) => { | ||
println!( | ||
"ERROR please provide offer starting with lno. Provided offer is \ | ||
invalid, failed to decode with error: {:?}.", | ||
e | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod clock; | ||
pub mod lnd; | ||
#[allow(dead_code)] | ||
pub mod lndk_offers; | ||
mod onion_messenger; | ||
mod rate_limit; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use lightning::offers::offer::Offer; | ||
use lightning::offers::parse::Bolt12ParseError; | ||
|
||
// Decodes a bech32 string into an LDK offer. | ||
pub fn decode(offer_str: String) -> Result<Offer, Bolt12ParseError> { | ||
offer_str.parse::<Offer>() | ||
} |