You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: readme.md
+63-76
Original file line number
Diff line number
Diff line change
@@ -6,102 +6,86 @@ This is the second version of the JSON payment protocol interface. If you have q
6
6
7
7
8
8
### Getting Started with v2
9
-
This is actively being implemented. The plan is to:
10
-
* Update the bitpay side to send the v2 structure
11
-
* Change the json-payment-protocol client code to work with v1 and v2
12
-
13
-
### Getting Started with v1
14
9
15
10
`npm install json-payment-protocol`
16
11
17
-
### v1 Usage
18
-
19
-
We support both callbacks and promises. For promises just add Async to the end of the function name. Be careful to follow the notes about when to broadcast your payment. **Broadcasting a payment before getting a success notification back from the server in most cases will lead to a failed payment for the sender.** The sender will bear the cost of paying transaction fees yet again to get their money back.
12
+
### v2 Usage
20
13
21
-
#### Callbacks
14
+
This library is now using async await structure for all functions. Be careful to follow the notes about when to broadcast your payment.
15
+
Broadcasting a payment before getting a success notification back from the server in most cases will lead to a failed payment for the sender.
16
+
The sender will bear the cost of paying transaction fees yet again to get their money back.
//TODO: Create the rawTransaction and sign it in your wallet instead of this, do NOT broadcast yet
41
-
let currency ='BTC';
42
-
43
-
// Funded unsigned raw transaction
44
-
let unsignedRawTransaction ='02000000016b7bceefa3ff3bf6f3ad39a99cf6def9126a6edf8f49462bd06e4cb74366dab00100000000feffffff0248590095000000001976a9141b4f4e0c5354ce950ea702cc79be34885e7a60af88ac0c430100000000001976a914072053b485736e002f665d5fc65c443fb379256e88ac00000000'
45
-
// Signed version of that transaction
46
-
let signedRawTransaction ='02000000016b7bceefa3ff3bf6f3ad39a99cf6def9126a6edf8f49462bd06e4cb74366dab0010000006b4830450221008d8852576eb8e505832a53569dd756a1d0c304606c27e81d0ac1a83e78250969022058b2bde3f2e1ea7e6a62e69d99f7219e846f04c1c58ff163e2996669a935c31501210206e855c3cfd24a5e154cf94ff7a214d598dfc2d62966011fd83c360cf229777ffeffffff0248590095000000001976a9141b4f4e0c5354ce950ea702cc79be34885e7a60af88ac0c430100000000001976a914072053b485736e002f665d5fc65c443fb379256e88ac00000000';
47
-
// total size of the signed transaction (note the way shown here is incorrect for segwit, see the code in /examples for getting vsize from RPC)
48
-
let signedRawTransactionSize =Buffer.from(signedRawTransaction, 'hex').byteLength;
// The paymentOptions response will contain one or more currency / chain options. If you are a multi-currency wallet then you should
44
+
// display the compatible payment options to the user. If only one option is supported it is
79
45
80
-
//TODO: Create the rawTransaction and sign it in your wallet instead of this example, do NOT broadcast yet
81
-
// Funded unsigned raw transaction
82
-
let unsignedRawTransaction ='02000000016b7bceefa3ff3bf6f3ad39a99cf6def9126a6edf8f49462bd06e4cb74366dab00100000000feffffff0248590095000000001976a9141b4f4e0c5354ce950ea702cc79be34885e7a60af88ac0c430100000000001976a914072053b485736e002f665d5fc65c443fb379256e88ac00000000'
83
-
// Signed version of that transaction
84
-
let signedRawTransaction ='02000000016b7bceefa3ff3bf6f3ad39a99cf6def9126a6edf8f49462bd06e4cb74366dab0010000006b4830450221008d8852576eb8e505832a53569dd756a1d0c304606c27e81d0ac1a83e78250969022058b2bde3f2e1ea7e6a62e69d99f7219e846f04c1c58ff163e2996669a935c31501210206e855c3cfd24a5e154cf94ff7a214d598dfc2d62966011fd83c360cf229777ffeffffff0248590095000000001976a9141b4f4e0c5354ce950ea702cc79be34885e7a60af88ac0c430100000000001976a914072053b485736e002f665d5fc65c443fb379256e88ac00000000';
85
-
// total size of the signed transaction (note the way shown here is incorrect for segwit, see the code in /examples for getting vsize from RPC)
86
-
let signedRawTransactionSize =Buffer.from(signedRawTransaction, 'hex').byteLength;
0 commit comments