bitcoin-waila

"What am I looking at?" A tool for decoding bitcoin-related strings.


What is this?

This is a tool for decoding bitcoin-related strings. The goal is to be able to give it any string, and it will decode it for you while giving you all the relevant payment information.

Currently supported:

Examples

Bitcoin Address:

```rust let string = "1andreas3batLhQa2FawWjeyjCqyBzypd";

let decoded = bitcoinwaila::PaymentParams::fromstr(string).unwrap();

asserteq!(decoded.address, Some(Address::fromstr("1andreas3batLhQa2FawWjeyjCqyBzypd").unwrap())); assert_eq!(parsed.network(), Some(Network::Bitcoin)); ```

BIP 21:

```rust let string = "bitcoin:BC1QYLH3U67J673H6Y6ALV70M0PL2YZ53TZHVXGG7U?amount=0.00001&label=sbddesign%3A%20For%20lunch%20Tuesday&message=For%20lunch%20Tuesday&lightning=LNBC10U1P3PJ257PP5YZTKWJCZ5FTL5LAXKAV23ZMZEKAW37ZK6KMV80PK4XAEV5QHTZ7QDPDWD3XGER9WD5KWM36YPRX7U3QD36KUCMGYP282ETNV3SHJCQZPGXQYZ5VQSP5USYC4LK9CHSFP53KVCNVQ456GANH60D89REYKDNGSMTJ6YW3NHVQ9QYYSSQJCEWM5CJWZ4A6RFJX77C490YCED6PEMK0UPKXHY89CMM7SCT66K8GNEANWYKZGDRWRFJE69H9U5U0W57RRCSYSAS7GADWMZXC8C6T0SPJAZUP6";

let decoded = bitcoinwaila::PaymentParams::fromstr(string).unwrap();

asserteq!(parsed.amount(), Some(Amount::frombtc(0.00001).unwrap())); asserteq!(parsed.address(), Some(Address::fromstr("BC1QYLH3U67J673H6Y6ALV70M0PL2YZ53TZHVXGG7U").unwrap())); asserteq!(parsed.memo(), Some("For lunch Tuesday".tostring())); asserteq!(parsed.network(), Some(Network::Bitcoin)); asserteq!(parsed.invoice(), Some(Invoice::fromstr("LNBC10U1P3PJ257PP5YZTKWJCZ5FTL5LAXKAV23ZMZEKAW37ZK6KMV80PK4XAEV5QHTZ7QDPDWD3XGER9WD5KWM36YPRX7U3QD36KUCMGYP282ETNV3SHJCQZPGXQYZ5VQSP5USYC4LK9CHSFP53KVCNVQ456GANH60D89REYKDNGSMTJ6YW3NHVQ9QYYSSQJCEWM5CJWZ4A6RFJX77C490YCED6PEMK0UPKXHY89CMM7SCT66K8GNEANWYKZGDRWRFJE69H9U5U0W57RRCSYSAS7GADWMZXC8C6T0SPJAZUP6").unwrap())); asserteq!(parsed.nodepubkey(), Some(PublicKey::fromstr("037cc5f9f1da20ac0d60e83989729a204a33cc2d8e80438969fadf35c1c5f1233b").unwrap())); ```

Lightning Address:

rust let parsed = bitcoin_waila::PaymentParams::from_str("ben@opreturnbot.com").unwrap(); assert_eq!(parsed.lnurl(), Some(LnUrl::from_str("lnurl1dp68gurn8ghj7mmswfjhgatjde3x7apwvdhk6tewwajkcmpdddhx7amw9akxuatjd3cz7cn9dc94s6d4").unwrap()));