-
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
bf3e07d
commit bb5da5c
Showing
6 changed files
with
182 additions
and
20 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,35 @@ | ||
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(_) => { | ||
println!("ERROR provided offer argument is invalid") | ||
} | ||
} | ||
} | ||
} | ||
} |
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,2 @@ | ||
#[allow(dead_code)] | ||
pub mod lndk_offers; |
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>() | ||
} |