From faaf51eada21e8457a6d9664e878b247a13705f4 Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Thu, 23 Apr 2020 17:10:31 +0300 Subject: [PATCH] Add BIP21 bitcoin payment URI support to sendpayment.py --- docs/USAGE.md | 6 +++- jmbitcoin/jmbitcoin/__init__.py | 1 + jmbitcoin/jmbitcoin/bip21.py | 41 ++++++++++++++++++++++ jmbitcoin/setup.py | 2 +- jmbitcoin/test/test_bip21.py | 58 ++++++++++++++++++++++++++++++++ jmclient/jmclient/cli_options.py | 3 +- scripts/sendpayment.py | 28 ++++++++++----- 7 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 jmbitcoin/jmbitcoin/bip21.py create mode 100644 jmbitcoin/test/test_bip21.py diff --git a/docs/USAGE.md b/docs/USAGE.md index 474d74e..d0fe187 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -382,7 +382,11 @@ Here is an example: (jmvenv)$ python sendpayment.py wallet.jmdat 5000000 mprGzBA9rQk82Ly41TsmpQGa8UPpZb2w8c -This sends 5000000 satoshi (0.05btc) to the address *mprGzBA9rQk82Ly41TsmpQGa8UPpZb2w8c* (testnet), with the default 5-7 (randomized) other parties from the default 0-th mixing depth from the wallet contained in the file *wallet.jmdat*. This will take some time, since Joinmarket will connect to remote messaging servers and do end to end encrypted communication with other bots, and also you will be paying some fees (more on this later in this section). +Or you can use BIP21 bitcoin payment URI: + + (jmvenv)$ python sendpayment.py wallet.jmdat bitcoin:mprGzBA9rQk82Ly41TsmpQGa8UPpZb2w8c?amount=0.05 + +These send 5000000 satoshi (0.05btc) to the address *mprGzBA9rQk82Ly41TsmpQGa8UPpZb2w8c* (testnet), with the default 5-7 (randomized) other parties from the default 0-th mixing depth from the wallet contained in the file *wallet.jmdat*. This will take some time, since Joinmarket will connect to remote messaging servers and do end to end encrypted communication with other bots, and also you will be paying some fees (more on this later in this section). diff --git a/jmbitcoin/jmbitcoin/__init__.py b/jmbitcoin/jmbitcoin/__init__.py index 7db6dc1..784673a 100644 --- a/jmbitcoin/jmbitcoin/__init__.py +++ b/jmbitcoin/jmbitcoin/__init__.py @@ -5,4 +5,5 @@ from jmbitcoin.secp256k1_deterministic import * from jmbitcoin.btscript import * from jmbitcoin.bech32 import * from jmbitcoin.amount import * +from jmbitcoin.bip21 import * diff --git a/jmbitcoin/jmbitcoin/bip21.py b/jmbitcoin/jmbitcoin/bip21.py new file mode 100644 index 0000000..58a726d --- /dev/null +++ b/jmbitcoin/jmbitcoin/bip21.py @@ -0,0 +1,41 @@ +# https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki +# bitcoin:
[?amount=][?label=