Merge pull request #5 from MutinyWallet/add-js-instructions

This commit is contained in:
Paul Miller
2023-04-21 21:06:56 -05:00
committed by GitHub

View File

@@ -2,6 +2,18 @@
"What am I looking at?" A tool for decoding bitcoin-related strings. "What am I looking at?" A tool for decoding bitcoin-related strings.
## Installing
`bitcoin-waila` is available as a Rust crate and as an npm package.
```
cargo add bitcoin-waila
```
```
npm i @mutinywallet/waila-wasm
```
--- ---
## What is this? ## What is this?
@@ -54,3 +66,20 @@ Lightning Address:
let parsed = bitcoin_waila::PaymentParams::from_str("ben@opreturnbot.com").unwrap(); let parsed = bitcoin_waila::PaymentParams::from_str("ben@opreturnbot.com").unwrap();
assert_eq!(parsed.lnurl(), Some(LnUrl::from_str("lnurl1dp68gurn8ghj7mmswfjhgatjde3x7apwvdhk6tewwajkcmpdddhx7amw9akxuatjd3cz7cn9dc94s6d4").unwrap())); assert_eq!(parsed.lnurl(), Some(LnUrl::from_str("lnurl1dp68gurn8ghj7mmswfjhgatjde3x7apwvdhk6tewwajkcmpdddhx7amw9akxuatjd3cz7cn9dc94s6d4").unwrap()));
``` ```
JavaScript:
```js
// You need to initialize the wasm
// There's also an initSync() if you don't like async
const waila = await init();
const string =
"bitcoin:BC1QYLH3U67J673H6Y6ALV70M0PL2YZ53TZHVXGG7U?amount=0.00001&label=sbddesign%3A%20For%20lunch%20Tuesday&message=For%20lunch%20Tuesday&lightning=LNBC10U1P3PJ257PP5YZTKWJCZ5FTL5LAXKAV23ZMZEKAW37ZK6KMV80PK4XAEV5QHTZ7QDPDWD3XGER9WD5KWM36YPRX7U3QD36KUCMGYP282ETNV3SHJCQZPGXQYZ5VQSP5USYC4LK9CHSFP53KVCNVQ456GANH60D89REYKDNGSMTJ6YW3NHVQ9QYYSSQJCEWM5CJWZ4A6RFJX77C490YCED6PEMK0UPKXHY89CMM7SCT66K8GNEANWYKZGDRWRFJE69H9U5U0W57RRCSYSAS7GADWMZXC8C6T0SPJAZUP6";
const params = new PaymentParams(string);
console.log(params.address);
console.log(params.invoice);
console.log(params.memo);
```