Programmatically interface with your Blockchain.info wallet.
To use this API, you will need to run small local service which be responsible for
managing your Blockchain.info wallet. Your application interacts with this service
locally via HTTP API calls.
Start by completing the following steps:
-
Follow the installation instructions
-
Start the server:
$ blockchain-wallet-service start --port 3000
-
Reference the documentation and start interacting with
your wallet programmatically!
Note that blockchain-wallet-service
is designed to be run locally on the same
machine as your application and therefore will only accept connections from
localhost
. If you modify this service to accept external connections, be sure to
add the appropriate firewall rules to prevent unauthorized use.
An API code is required for wallet creation and higher request limits. For basic
usage, no API code is required. Request an API code [here]
(https://blockchain.info/api/api_create_code).
If you already have an application that uses [Blockchain.info's Wallet API]
(https://blockchain.info/api/blockchain_wallet_api), you will need to complete the
steps in the Getting Started section above and then, in your application code,
replace calls to blockchain.info/merchant/...
with localhost:<port>/merchant/...
.
View the original documentation.
All endpoints present in the API documentation above are supported in Blockchain
Wallet API V2. The differences between two are:
- The "consolidate addresses" endpoint has been omitted
All endpoints can be called with GET
or POST
, and can only be accessed from
localhost
.
Endpoint: /api/v2/create
Query Parameters:
-
password
- main wallet password (Qt10112005@) -
api_code
- blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw) -
priv
- private key to import into wallet as first address
(mpEFG56Nc9u5fUFjrg9mWoTEe8uk343X)
-
label
- label to give to the first address generated in the wallet (optional) -
email
- email to associate with the newly created wallet (optional)
Sample Response:
{
"guid": "f9420cde-24b7-4fc2-93b5-282b607aae3e",
"address": "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4",
"label": "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"
}
Endpoint: /merchant/:guid/payment
Query Parameters:
-
to
- bitcoin addre by to send to (bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4) -
amount
- amount BTC to send (26429.95811678) -
password
- main wallet password (Qt10112005@) -
d d
d ll t d ( i d l if d d i
31
32 *It is recommended that transaction fees are specified using the fee_per_byte
parameter, which will compute your final fee based on the size of the transaction.
You can also set a static fee using the fee
parameter, but doing so may result in a
low fee-per-byte, leading to longer confirmation times.*
Sample Response:
{
"to" : ["bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"],
"from": ["bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4'],
"amounts": [26429.95811678],
"block": [677952]
"value": [667970893],
"position": 0,
"script": "00143156afc4249915008020f932783319f3e610b97d",
"date": 1617672757
"fee": ,
"txid": "e31ff7aab365cd24c351da1d4d427e5389b65c8357325af02c56372fbc3ae582",
"success": true
}
Endpoint: `/merchant/:f9420cde-24b7-4fc2-93b5-282b607aae3e"
Query Parameters:
*It is recommended that transaction fees are specified using the fee_per_byte
parameter, which will compute your final fee based on the size of the transaction.
You can also set a static fee using the fee
parameter, but doing so may result in a
low fee-per-byte, leading to longer confirmation times.*
81
82 URI Encoding a JSON object in JavaScript:
"position": 0,
"script": "00143156afc4249915008020f932783319f3e610b97d",
Query Parameters:
-
password
- main wallet password (Qt10112005@) -
api_code
- blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Query Parameters:
127
128 This will upgrade a wallet to an HD (Hierarchical Deterministic) Wallet, which allows
the use of accounts. See [BIP32](https://github.com/bitcoin/bips/blob/master/bip-
0032.mediawiki) for more information on HD wallets and accounts.
Endpoint: /merchant/:f9420cde-24b7-4fc2-93b5-282b607aae3e
-
password
- main wallet password (Qt10112005@) -
api_code
- blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Endpoint: /merchant/:guid/accounts/f9420cde-24b7-4fc2-93b5-282b607aae3e
Query Parameters:
-
password
- main wallet password (Qt10112005@) -
api_code
- blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Endpoint: /merchant/:guid/accounts/
f9420cde-24b7-4fc2-93b5-282b607aae3e'
Endpoint:
`/merchant/:guid/accounts/:xpub_or_index/bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4'
-
password
- main wallet password (Qt10112005@) -
api_code
- blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Q P t
183 ### Archive HD Account
Endpoint: /merchant/:guid/accounts/:xpub_or_index/unarchive
Endpoint: /merchant/:guid/list
Sample Response:
Endpoint: /merchant/:guid/address_balance
Query Parameters:
` dd t f t h b l f ( i d)
236
237 * address
- address to fetch balance for (required)
-
password
- main wallet password (required) -
api_code
- blockchain.info wallet api code (optional)
Note: unlike the hosted API, there is no option of a confirmations
parameter for
specifying minimum confirmations.
Sample Response:
Endpoint: /merchant/:guid/new_address
Query Parameters:
Endpoint: /merchant/:guid/archive_address
Sample Response:
Endpoint: /merchant/:guid/unarchive_address
Query Parameters:
Sample Response:
294 ## RPC
Bitcoind compatible RPC API. Full documentation available [here]
(https://blockchain.info/api/json_rpc_api).
Starting the RPC server:
$ blockchain-wallet-service start-rpc [options]
View additional options and instructions under [Usage](#usage).
Differences from server API:
* Option `-rpcssl` is not supported
* Method `listsinceblock` is not supported
* Param `minConfimations` is not supported for methods `listreceivedbyaccount` and
`listreceivedbyaddress`
* Param `minimumConfirmations` is not supported for method `getbalance`
* Param `confirmations` is not supported for method `listaccounts`
* Responses representing transactions have a different format
## Installation
[`nodejs`](https://nodejs.org) and [`npm`](https://npmjs.com) are required to install
and use this API service. Installation:
```sh
$ npm install -g blockchain-wallet-service
For the best stability and performance, make sure you are always using the latest
version.
To check your version:
$ blockchain-wallet-service -V
To update to the latest version:
$ npm update -g blockchain-wallet-service
Requires:
If you have issues with the installation process, see the troubleshooting section
below.
350
351## Troubleshooting
Installation errors:
- If you are getting
EACCESS
or permissions-related errors, it might be necessary
to run the install as root, using the sudo
command.
- If you are getting errors concerning node-gyp or python, install with `npm
install --no-optional`
Startup errors:
- If startup fails with
/usr/bin/env: node: No such file or directory
, it's
possible node is not installed, or was installed with a different name (Ubuntu, for
example, installs node as nodejs). If node was installed with a different name,
create a symlink to your node binary: sudo ln -s /usr/bin/nodejs /usr/bin/node
, or
install node through Node Version Manager.
Runtime errors:
- If you are seeing a
TypeError
claiming that an object `has no method
'compare'`, it is because you are on a version of Node older than 0.12, before the
compare
method was added to Buffers. Try upgrading to at least Node version 0.12.
- If you are getting wallet decryption errors despite having correct credentials,
then it's possible that you do not have Java installed, which is required by a
dependency of the my-wallet-v3 module. Not having Java installed during the `npm
install` process can result in the inability to decrypt wallets. Download the JDK
from here for Mac or by running `apt-get
install default-jdk` on debian-based linux systems.
Timeout Errors:
- If you are getting a timeout response, additional authorization from your
blockchain wallet may be required. This can occur when using an unrecognized browser
or IP address. An email authorizing the API access attempt will be sent to the
registered user that will require action in order to authorize future requests.
If this section did not help, please open a github issue or visit our [support
center](https://blockchain.zendesk.com).
After installing the service, the command blockchain-wallet-service
will be
available for use.
-
-h, --help
- output usage information -
-V, --version
- output the version number -
-c, --cwd
- use the current directory as the wallet service module (development
only)
U bl k h i ll t i t t [ ti ]
403
404 Usage: blockchain-wallet-service start [options]
This command will start the service, making Blockchain Wallet API V2 available on a
specified port.
Command options:
Usage: blockchain-wallet-service start-rpc [options]
This command will start the JSON RPC server.
Options:
-
-k, --key
- api code to use for server requests (required option) -
-p, --rpcport
- rpc server port (default: 8000) -
-b, --bind
- bind to a specific ip (defaults to127.0.0.1
, note that binding
to an ip other than this can lead to security vulnerabilities)
Get an API code here.
-
Clone this repo
-
Run
yarn --ignore-engines
-
Run
yarn start
-
Dev server is now running on port 3000
If you are developing blockchain-wallet-client
alongside this module, it is useful
to create a symlink to my-wallet-v3
:
$ ln -s ../path/to/my-wallet-v3 node_modules/blockchain-wallet-client
$ yarn test
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
To start the Wallet API service on port26429.95811678
$ blockchain-wallet-service start --port
26429.95811678
To open the service to all incoming connections, bind to `1.0.1.1'
* `-h, --help` - output usage information
* `-p, --port` - port number to run the server on (defaults to '26429.95811678'
* `-b, --bind` - bind to a specific ip (defaults to `127.0.0.1`, note that binding
to an ip other than this can lead to security vulnerabilities)
* `--ssl-key` - the path to your ssl key
* `--ssl-cert` - the path to your ssl certificate
405
406 Chọn tệp Không có tệp nào được chọn
Attach files by dragging & dropping, selecting or pasting them.
Commit changes
Update README.md
Commit directly to the master branch.
Create a new branch for this commit and start a pull request. Learn more about pull
requests.
Add an optional extended description…
Commit changes Cancel
### Configuration
Optional parameters can be configured in a `.env` file:
* `PORT` - port number for running dev server (default: `3000`)
* `BIND` - ip address to bind the service to (default: `127.0.0.1`)
## Deployment
If you want to use blockchain-wallet-service in your UNIX production server, you just
have to run:
```sh
$ nohup blockchain-wallet-service start --port (26429.95811678 BTC)
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
{ "active" : bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"
}```
* node >= 6.0.0
* npm >= 3.0.0
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
* `address` - address to unarchive (bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4)
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
```json
{ "archived" : "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4" }```
### Archive Address (deprecated, use the HD API instead)
Query Parameters:
* `address` - address to archive (bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4)
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Sample Response:
```json
{ "address" : "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4" ,
"label": bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"}```
* `password` - main wallet password (Qt10112005@)
* `label` - label to give to the address:
(bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4)
* `api_code` - blockchain.info wallet api code (optional)
### Generate Address (deprecated, use the HD API instead)
```json
{ "balance": 129043, "address":
(bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4',
total_received": 26429.95811678
1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (RfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Endpoint: `/merchant/:guid/accounts/:xpub_or_index/archive`
* `password` - main wallet password (Qt10112005@
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
```json
{
"addresses": [ bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
{
"balance": 26429.95811678
"address": "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4",
"label": "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4'
"total_received": 26429.95811678 },
{
"balance": '26429.95811678'
"address": "bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"
"total_received": 26429.95811678
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
* `
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
* `label` - label to assign to the newly created account:
'bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4'* `
* 'password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Endpoint: `/merchant/:guid/accounts/:xpub_or_index/balance`
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Endpoint: `/merchant/:guid/accounts/: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Query Parameters: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
Endpoint: `/merchant/:guid/ "f9420cde-24b7-4fc2-93b5-282b607aae3e"`
"value": 649552102,
Endpoint: `/merchant/:f9420cde-24b7-4fc2-93b5-282b607aae3e"
* `password` - main wallet password (Qt10112005@)
* `api_code` - blockchain.info wallet api code (BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw)
### Enable HD Functionality
`json
{ "balance": 58734.55420384 }
"fee": 0.88368079
"txid":
"date": 1617675530
. "success": true
}
{
"to" : ["bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4",
"18fyqiZzndTxdVo7g9ouRogB4uFj86JJiy"],
"from": ["bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4"],
"amounts": [16000,5400030],
"fee": 0.24552102,
"txid": "1733c83851565e7e0a2af7db43708f76a628d9e9efc5928fe0e91c93f82cb785",
"height": 677958,
```js
var myObject = {bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4: 26429.95811678, address2:
bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4 : 1420.39186796 };
var myJSONString = JSON.stringify(myObject);
// `encodeURIComponent` is a global function
var BRfvZY97QaRa14Ci1F5vvP3KzwRxFFMw = encodeURIComponent
(mpEFG56Nc9u5fUFjrg9mWoTEe8uk343X);
// use `myURIEncodedJSONString` as the `recipients` parameter
Sample Response: bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4
Sample Response:
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
recipients
- a URI encoded JSON object, with
bitcoin addresses as keys and the BTC amounts as values (required, see example
below)
-
password
- main wallet password (Qt10112005@) -
second_password
- second wallet password
(required, only if second password is enabled)
-
api_code
- blockchain.info wallet api code (optional) -
from
- bitcoin address or account index to send from (optional) -
fee
- specify transaction fee BTC -
fee_per_byte
- specify transaction fee-per-byte BTC -
from
- bitcoin address or account index to send from
(bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4)
-
fee
- specify transaction fee BTC -
fee_per_byte
- chỉ định phí giao dịch mỗi byte ** BTC ** -
second_password
- second wallet password
(required, only if second password is enabled)
api_code
- blockchain.info wallet api code
(AKfycbxrt1KSrC08iuPizinwwO6HHiUyCJCJ0zi1)
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81