How To Use Bitcoin RPC In Iguana

From Komodo Platform Wiki
Jump to: navigation, search

This Page is Currently Being Developed

Bitcoin RPC calls can be issued using an Iguana instance with BTC active. Currently you can send them either

  • 1.- Submitting the corresponding form in the SuperNET API page at http://localhost:7778
  • 2.- From the command shell, using curl

The curl syntax for every call is described below, and responses are compared to the original Bitcoin RPC calls. For this document, Bitcoin RPC calls have been tested with Bitcoin Core 0.12.0.

For Iguana calls, arguments are highlighted in upper case RED for required arguments and lower case red for optional arguments. The data string with the Iguana API call parameters is sent in JSON format, so every field using " quotes including string arguments requires them to be escaped as \".

1 Blockchain RPCs[edit]

1.1 getbestblockhash[edit]

ZERO_ARGS(bitcoinrpc,getbestblockhash);

  • Returns the header hash of the most recent block on the best block chain.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getbestblockhash\"}"

Example:

Bitcoin RPC Output

bitcoin-cli getbestblockhash
000000000000000005795fb23e17158d23acb4e0312819f297b1b40c909b0d4a

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getbestblockhash\"}"
000000000000000005795fb23e17158d23acb4e0312819f297b1b40c909b0d4a

1.2 getblock[edit]

HASH_AND_TWOINTS(bitcoinrpc,getblock,blockhash,verbose,remoteonly);

  • Gets a block with a particular header hash from the local database.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblock\",\"params\":[HEIGHT, verbose, remoteonly]}"

Example:

Bitcoin RPC Output

./bitcoin-cli getblock 000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f true
{"hash": "000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f", "confirmations":9267, "size":948994, "height":400000, "version":4, "merkleroot":"b0e8f88d4fb7cbc49ab49a3a43c368550e22a8e9e3e04b15e34240306a53aeec", "tx": [TXIDS ARRAY], "time":1456417484, "mediantime":1456415577, "nonce":657220870, "bits":"1806b99f", "difficulty":163491654908.9593, "chainwork":"000000000000000000000000000000000000000000122a24b77c62cd76004cde", "previousblockhash":"0000000000000000030034b661aed920a9bdf6bbfa6d2e7a021f78481882fa39", "nextblockhash":"000000000000000005421b1b2ee6d06d037557d7f5ec96852542413cfed40c22"}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblock\",\"params\":[\"000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f\",true]}"
{"result":"success", "hash":"000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f", "height":400000, "merkleroot":"b0e8f88d4fb7cbc49ab49a3a43c368550e22a8e9e3e04b15e34240306a53aeec", "previousblockhash":"0000000000000000030034b661aed920a9bdf6bbfa6d2e7a021f78481882fa39", "nextblockhash":"000000000000000005421b1b2ee6d06d037557d7f5ec96852542413cfed40c22", "timestamp":1456417484, "utc":"2016-02-25T16:24:44Z", "nonce":657220870, "version":4, "numvouts":0, "numvins":0, "recvlen":0, "hdrsi":200, "PoW":102400256, "bundlei":0, "mainchain":1, "valid":1, "txn_count":1660, "bits":403093919, "nBitshex":"1806b99f", "blockheader":"040000000000000000000000000000000000000000000000000000000000000000000000ecae536a304042e3154be0e3e9a8220e5568c3433a9ab49ac4cbb74f8df8e8b0cc2acf569fb9061806652c2700", "tx":[TXIDS ARRAY], "size":948992, "tag":"10040222761924827016"}

1.3 getblockcount[edit]

ZERO_ARGS(bitcoinrpc,getblockcount);

  • Returns the number of blocks in the local best block chain.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblockcount\"}"

Example:

Bitcoin RPC Output

bitcoin-cli getblockcount
417384

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblockcount\"}"
417384

1.4 getblockhash[edit]

INT_ARG(bitcoinrpc,getblockhash,height);

  • Returns the header hash of a block at the given height in the local best block chain.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblockhash\",\"params\":[HEIGHT]}"

Example: Bitcoin RPC Output

bitcoin-cli getblockhash 400000
000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getblockhash\",\"params\":[400000]}"
000000000000000004ec466ce4732fe6f1ed1cddc2ed4b328fff5224276e3f6f

1.5 gettxout[edit]

HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool);

  • Returns details about a transaction output. Only unspent transaction outputs (UTXOs) are guaranteed to be available.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"gettxout\",\"params\":[\"TXID\",VOUT,mempool]}"

Example:

Bitcoin RPC Output

bitcoin-cli gettxout 4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c 1
{ "bestblock": "00000000000000000061a51e59d936b2bd7757b16a613b42b8c2e65e3cea1c92", "confirmations": 29, "value": 0.01168000, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 8f3638094d04daec3ee63c373ef10f0e114516e5 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs"]}, "version": 1, "coinbase": false }

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"gettxout\",\"params\":[\"4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c\",1]}"
{"bestblock":"000000000000000000c7b3f95ba5aa25331597951fd82e5adb453d36d355bc7c","bestheight":419847,"height":409300,"confirmations":10548,"value":0.01168000,"scriptPubKey":{"asm":"OP_DUP OP_HASH160 8f3638094d04daec3ee63c373ef10f0e114516e5 OP_EQUALVERIFY OP_CHECKSIG // 1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs","iguanatype":2,"scriptlen":25,"reqSigs":1,"addresses":["1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs"],"p2sh":"37P5XYTdaGavRJ9Q7DX1QZCc5i2cFPverD"},"iguana":{"txid":"4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c","vout":1,"address":"37P5XYTdaGavRJ9Q7DX1QZCc5i2cFPverD","scriptPubKey":"76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac","amount":0.01168000,"timestamp":0,"height":409300,"confirmations":10548,"checkind":5339978,"spendable":false,"spent":{"hdrsi":204,"pkind":2674381,"unspentind":5339978,"prevunspentind":5339966,"satoshis":"1168000","txidind":2006374,"vout":1,"type":2,"fileid":0,"scriptpos":0,"scriptlen":25},"spentheight":409781,"dest":{"spentfrom":"2196c07f71f206728301b03ffbffb7fd383744d03c1a3e0a1e03b6fb9ffd4ece","vin":1,"vouts":[{"1DAYGHMuTjQstuNHRH3Kf7RmRDqxVjJya5":0.01224834}, {"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt":0.01000000}],"total":0.02224834,"ratio":0.52498299}},"coinbase":false,"tag":"7061691412814161076"}

2 Control RPCs[edit]

2.1 getinfo[edit]

ZERO_ARGS(bitcoinrpc,getinfo);

  • Prints various information about the node and the network.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getinfo\"}"

Example:

Bitcoin RPC output

bitcoin-cli getinfo
{"version":120000, "protocolversion":70012, "walletversion":60000, "balance":0.00263825, "blocks":409266, "timeoffset":-1, "connections":96, "proxy":"", "difficulty":178659257772.5273, "testnet":false, "keypoololdest": 1457620757, "keypoolsize":101, "paytxfee":0.00000000, "relayfee":0.00001000, "errors": ""}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getinfo\"}"
{"result":"success","protocolversion":70001,"blocks":409266,"longestchain":409267,"port":8333,"connections":20,"difficulty":104772352,"status":"BTC.RT409267 u.204+c.205 b.205 v.204 (0+1267/1267 1st.204).s0 to 204 N[205] h.409267 r.409267 c.408000 s.409267 d.0 E.204 maxB.8 peers.36/24 Q.(0 0) (L.409267 204:1267) M.409266 000000000000000005795fb23e17158d23acb4e0312819f297b1b40c909b0d4a","coin":"BTC","tag":"8590036014127809422"}

3 Raw Transaction RPCs[edit]

3.1 createrawtransaction[edit]

ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime);

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"createrawtransaction\",\"params\":[INPUTS_ARRAY, OUTPUTS, locktime]}"

Example:

Bitcoin RPC Output

bitcoin-cli createrawtransaction '''[{"txid":"2196c07f71f206728301b03ffbffb7fd383744d03c1a3e0a1e03b6fb9ffd4ece","vout":1}]''' '{"1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs":0.009}'
0100000001ce4efd9ffbb6031e0a3e1a3cd0443738fdb7fffb3fb001837206f2717fc096210100000000ffffffff01a0bb0d00000000001976a9148f3638094d04daec3ee63c373ef10f0e114516e588ac00000000

Iguana API Output

curl --url "http://127.0.0.1:7778" --data "{\"method\":\"createrawtransaction\",\"params\":[[{\"txid\":\"2196c07f71f206728301b03ffbffb7fd383744d03c1a3e0a1e03b6fb9ffd4ece\",\"vout\":1}], {\"1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs\":0.009}] }"
0100000001ce4efd9ffbb6031e0a3e1a3cd0443738fdb7fffb3fb001837206f2717fc096210100000000\
ffffffff01a0bb0d00000000001976a9148f3638094d04daec3ee63c373ef10f0e114516e588ac00000000

3.2 decoderawtransaction[edit]

STRING_ARG(bitcoinrpc,decoderawtransaction,rawtx);

  • Decodes a serialized transaction hex string into a JSON object describing the transaction.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"RAW_TX_BYTES\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli decoderawtransaction 0100000001946c4b42dc4c2003cc3f989dbe5e0dfab13470a9119cc1526745dc780818ea180200000000\

ffffffff04f0550000000000001976
a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac80d21100000000001976a9148f3638094d04daec3ee63c373ef10f0e114516e588accaf700000000000017a914ccc8038b2
80d99e6f808fb81a4a55d60c77575ba87a0860100000000001976a9142dcc96a038f269e2218c6d04ab339017f46e356788ac00000000

{"txid": "364eee487736a4353255b8ffe8c0674bb45f35f6a6fe6f4ca894b07452e27142", "size": 185, "version": 1, "locktime": 0, "vin": [{"txid": "18ea180878dc456752c19c11a97034b1fa0d5ebe9d983fcc03204cdc424b6c94", "vout": 2, "scriptSig": {"asm": "", "hex": ""}, "sequence": 4294967295}], "vout": [{"value": 0.00022000, "n": 0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 4ab009889e5b66d2a4341a7f38bcc9428b815bfe OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK"]}}, {"value": 0.01168000, "n": 1, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 8f3638094d04daec3ee63c373ef10f0e114516e5 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs"]}}, {"value": 0.00063434, "n": 2, "scriptPubKey": {"asm": "OP_HASH160 ccc8038b280d99e6f808fb81a4a55d60c77575ba OP_EQUAL", "hex": "a914ccc8038b280d99e6f808fb81a4a55d60c77575ba87", "reqSigs": 1, "type": "scripthash", "addresses": ["3LMoNt98VPKYVji13Lj1oZSVdsgRSMBKmt"]}}, {"value": 0.00100000,"n": 3,"scriptPubKey": {"asm": "OP_DUP OP_HASH160 2dcc96a038f269e2218c6d04ab339017f46e3567 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9142dcc96a038f269e2218c6d04ab339017f46e356788ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": ["15BAVgaX5RxjaMph5WypMXrtkRquYKqpTW"]}} ]}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000001946c4b42dc4c2003cc3f989db
e5e0dfab13470a9119cc1526745dc780818ea180200000000ffffffff04f0550000000000001976a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac80d21100000000001976
a9148f3638094d04daec3ee63c373ef10f0e114516e588accaf700000000000017a914ccc8038b280d99e6f808fb81a4a55d60c77575ba87a0860100000000001976a9142dcc96a038f
269e2218c6d04ab339017f46e356788ac00000000\"]}"
{"version":1, "vin": [{"sequence":4294967295, "txid":"18ea180878dc456752c19c11a97034b1fa0d5ebe9d983fcc03204cdc424b6c94", "vout":2}], "numvins":1, "vout":[{"value":0.00022000, "n":0, "scriptPubKey": {"asm": "OP_DUP OP_HASH160 4ab009889e5b66d2a4341a7f38bcc9428b815bfe OP_EQUALVERIFY OP_CHECKSIG // 17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK", "reqSigs":1, "type":"pubkeyhash", "addresses": ["17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK"], "hex":"76a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac"}}, {"value":0.01168000, "n":1, "scriptPubKey": {"asm":"OP_DUP OP_HASH160 8f3638094d04daec3ee63c373ef10f0e114516e5 OP_EQUALVERIFY OP_CHECKSIG // 1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "reqSigs":1, "type":"pubkeyhash", "addresses": ["1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs"], "hex":"76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac"}}, {"value":0.00063434, "n":2, "scriptPubKey":{"asm":"OP_HASH160 ccc8038b280d99e6f808fb81a4a55d60c77575ba OP_EQUAL // 3LMoNt98VPKYVji13Lj1oZSVdsgRSMBKmt", "addresses":["3LMoNt98VPKYVji13Lj1oZSVdsgRSMBKmt"], "hex":"a914ccc8038b280d99e6f808fb81a4a55d60c77575ba87"}}, {"value":0.00100000, "n":3, "scriptPubKey": {"asm":"OP_DUP OP_HASH160 2dcc96a038f269e2218c6d04ab339017f46e3567 OP_EQUALVERIFY OP_CHECKSIG // 15BAVgaX5RxjaMph5WypMXrtkRquYKqpTW", "reqSigs":1, "type":"pubkeyhash", "addresses": ["15BAVgaX5RxjaMph5WypMXrtkRquYKqpTW"], "hex":"76a9142dcc96a038f269e2218c6d04ab339017f46e356788ac"}}], "numvouts":4, "locktime":0, "size":185, "txid":"364eee487736a4353255b8ffe8c0674bb45f35f6a6fe6f4ca894b07452e27142", "tag":"8408494105757195733"}

3.3 decodescript[edit]

STRING_ARG(bitcoinrpc,decodescript,script);

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"decodescript\",\"params\":[\"P2SH_REDEEM_SCRIPT\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli decodescript 522102a06970d5ea57da41e787f324d7cecbf3d3435d68987ac93c021402253e72d18421039b6dcf1986e2acde75485abbc7253bb42a4e07c60c6b970b8b07a38d1e442c232102525e3c674aa65bed934d08458d28ca40cf0333626eb425f3bf0ba3bb92f87a4353ae
{"asm": "2 02a06970d5ea57da41e787f324d7cecbf3d3435d68987ac93c021402253e72d184 039b6dcf1986e2acde75485abbc7253bb42a4e07c60c6b970b8b07a38d1e442c23 02525e3c674aa65bed934d08458d28ca40cf0333626eb425f3bf0ba3bb92f87a43 3 OP_CHECKMULTISIG", "reqSigs": 2, "type": "multisig", "addresses": ["19ouyC8x15m5EqiESXEeNsgKZHAgZFETsT","1MJ4Ns2VAqq5KEHhAZqLyWE4D1RYCRfVPa","16evaMtCFto8E76b9Xexm6ziNcq9fAhyQT"], "p2sh": "3GWpoCvgY37kvQsZBCUQwTWfpxkhNygsbu"}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"decodescript\",\"params\":[\"522102a06970d5ea57da41e787f324d7cecbf3d3435d68987ac93c021402253e72d18421039b6dcf1986e2acde75485abbc7253bb42a4e07c60c6b970b8b07a38d1e442c232102525e3c674aa65bed934d08458d28ca40cf0333626eb425f3bf0ba3bb92f87a4353ae\"]}"
{"result": {"asm":"2 02a06970d5ea57da41e787f324d7cecbf3d3435d68987ac93c021402253e72d184 3 // M.2 of N.3 [19ouyC8x15m5EqiESXEeNsgKZHAgZFETsT 1MJ4Ns2VAqq5KEHhAZqLyWE4D1RYCRfVPa 16evaMtCFto8E76b9Xexm6ziNcq9fAhyQT]\n", "iguanatype":6, "scriptlen":105, "reqSigs":2, "pubkey":"02a06970d5ea57da41e787f324d7cecbf3d3435d68987ac93c021402253e72d184", "rmd160":"60a05b4e49f89b6d78fcb86070528b3e78eee5a5", "addresses":["19ouyC8x15m5EqiESXEeNsgKZHAgZFETsT", "1MJ4Ns2VAqq5KEHhAZqLyWE4D1RYCRfVPa", "16evaMtCFto8E76b9Xexm6ziNcq9fAhyQT"], "p2sh":"3GWpoCvgY37kvQsZBCUQwTWfpxkhNygsbu"}, "tag":"5467990546816145635"}

3.4 getrawtransaction[edit]

HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose);

  • Gets a hex-encoded serialized transaction or a JSON object describing the transaction.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getrawtransaction\",\"params\":[\"TXID\", verbose]}"

Example:

Bitcoin RPC Output

./bitcoin-cli getrawtransaction 8ecbd9ac0d144d3ae953ddd7aad5db9a3b9bc9d973eb75365f200bd0a5347fce
010000000312a79469371f9e0eec26801779a2f9578a0e2bfbb48b8334783308043dce95fc01000000da004830450...

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getrawtransaction\",\"params\":[\"8ecbd9ac0d144d3ae953ddd7aad5db9a3b9bc9d973eb75365f200bd0a5347fce\"]}"
010000000312a79469371f9e0eec26801779a2f9578a0e2bfbb48b8334783308043dce95fc01000000da004830450...

3.5 sendrawtransaction[edit]

STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees);

  • Validates a transaction and broadcasts it to the peer-to-peer network. Returns transaction ID if successful.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"sendrawtransaction\",\"params\":[\"SIGNED_RAW_TX\"]}"

Bitcoin RPC Output

./bitcoin-cli sendrawtransaction 01000000011da9283b4ddf8d\
89eb996988b89ead56cecdc44041ab38bf787f1206cd90b51e000000006a4730\
4402200ebea9f630f3ee35fa467ffc234592c79538ecd6eb1c9199eb23c4a16a\
0485a20220172ecaf6975902584987d295b8dddf8f46ec32ca19122510e22405\
ba52d1f13201210256d16d76a49e6c8e2edc1c265d600ec1a64a45153d45c29a\
2fd0228c24c3a524ffffffff01405dc600000000001976a9140dfc8bafc84198\
53b34d5e072ad37d1a5159f58488ac00000000
f5a5ce5988cc72b9b90e8d1d6c910cda53c88d2175177357cc2f2cf0899fbaad

Iguana API Output

curl --url "http://127.0.0.1:7778" --data "{\"method\":\"sendrawtransaction\",
\"params\":[\"0100000001801ff0939cd918c8a2f6034b540438d7a29915dd9635da6ba5d9\
94ad670688f4000000006a47304402207be1c232452694acf4eb866bcd9a7d7a4\
7ccb109e43b5286f57dce34b7db20e6022041499fb7424214a7a37966ed179418\
010a07c4a0a93908818c4f229c25bc7eee01210214b7cbd6599c5e020357fbe6c\
9c3f7f69552c6dedaaf67e98e938db5e60a8643ffffffff01a086010000000000\
1976a9148ff22a478565f8b8c7df1b306fdbc44bb99176d288ac00000000\"]}"
{"result":"f5a5ce5988cc72b9b90e8d1d6c910cda53c88d2175177357cc2f2cf0899fbaad","tag":"2934019158496126376"}

3.6 signrawtransaction[edit]

STRING_ARRAY_OBJ_STRING(bitcoinrpc,signrawtransaction,rawtx,vins,privkeys,sighash);

  • Signs a transaction in the serialized transaction format using private keys stored in the wallet or provided in the call.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"signrawtransaction\",\"params\":[\"RAW_TX\", [{\"txid\":\"first_input_tx\",\"vout\":unspent_output_number,\"scriptPubKey\":\"script_pubkey_hex\"},{\"txid\":\"second_input_tx_id\",\"vout\":unspent_output_number,\"scriptPubKey\":\"script_pubkey_hex\"}...], [\"private_key_1\", \"private_key_2\"...], \"ALL\"] }"

Bitcoin RPC Output

./bitcoin-cli signrawtransaction 01000000011da9283b4ddf8d89eb996988b89ead56cecdc44041ab38bf787f1206cd90b51e0000000000ffffffff01405dc600000000001976a9140dfc8bafc8419853b34d5e072ad37d1a5159f58488ac00000000
{"hex" : "01000000011da9283b4ddf8d89eb996988b89ead56cecdc44041ab38bf787f1206cd90b51e000000006a47304402200ebea9f630f3ee35fa467ffc234592c79538ecd6eb1c9199eb23c4a16a0485a20220172ecaf6975902584987d295b8dddf8f46ec32ca19122510e22405ba52d1f13201210256d16d76a49e6c8e2edc1c265d600ec1a64a45153d45c29a2fd0228c24c3a524ffffffff01405dc600000000001976a9140dfc8bafc8419853b34d5e072ad37d1a5159f58488ac00000000", "complete" : true }

Iguana API Output

curl --url "http://127.0.0.1:7778" --data "{\"method\":\"signrawtransaction\", \"params\":[\"0100000001801ff0939cd918c8a2f6034b540438d7a29915dd9635da6ba5d994ad670688f40000000000ffffffff01a0860100000000001976a9148ff22a478565f8b8c7df1b306fdbc44bb99176d288ac00000000\",  [{\"txid\":\"f4880667ad94d9a56bda3596dd1599a2d73804544b03f6a2c818d99c93f01f80\", \"vout\":0, \"scriptPubKey\":\"76a914e553bf79b87ad9eb498bab8a62994294a604ef5c88ac\"}], [\"KeEdGu31Mm1uqhRYCWexYcRZSehkAwoisGr9We8irFA91Ra\"], \"ALL\"] }"
{"result":"0100000001801ff0939cd918c8a2f6034b540438d7a29915dd9635da6ba5d994ad670688f4000000006a47304402207be1c232452694acf4eb866bcd9a7d7a47ccb109e43b5286f57dce34b7db20e6022041499fb7424214a7a37966ed179418010a07c4a0a93908818c4f229c25bc7eee01210214b7cbd6599c5e020357fbe6c9c3f7f69552c6dedaaf67e98e938db5e60a8643ffffffff01a0860100000000001976a9148ff22a478565f8b8c7df1b306fdbc44bb99176d288ac00000000","complete":true,"tag":"2934019158496126376"}

4 Wallet RPCs[edit]

4.1 addmultisig[edit]

INT_ARRAY_STRING(bitcoinrpc,addmultisig,M,pubkeys,account);

  • Adds a M-of-N P2SH multi-signature address to the wallet, where N is the number of addresses/pubkeys in the array. Optionally, an account name can be provided.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"addmultisig\",\"params\":[M, [\"ADDRESS1\",\"ADDRESS2\",\"ADDRESS3\"..],\"account\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli addmultisigaddress 2 '''["1bPAhBpBZ231NxXhDRCYViTKxmKYNAHmN", "135tMW4E9yEd7L55Ru1AqmhvYm8iGhLqvn", "1NkNtcXm6Rv6hfZSgLtMwcyL5CVdNusrK"]''' 'multisigs'
3AaZWMXkXRbUUWdLjtijsjE8XiDoWRw3yR

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\", \"method\":\"addmultisig\", \"params\":[2, [\"02912ecebe3c043636bb470bdf7e9248265ef396b0bf8a02a806ffab6d5177832a\", \"020babfe8cc15718fc55c5cb8c17db9cb345bb5328de5541a5d2937490f2b7ad7b\", \"026a6ded1e06aa65da70affd8fe0dd02291927a822151a75d838b4579c9312ca23\"], \"multisigs\"]}"
3AaZWMXkXRbUUWdLjtijsjE8XiDoWRw3yR

4.2 createmultisig[edit]

INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,pubkeys,ignore);

  • Creates a M-of-N P2SH multi-signature address, where N is the number of addresses/pubkeys in the array.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"createmultisig\",\"params\":[M, [\"ADDRESS1\",\"ADDRESS2\",\"ADDRESS3\"..]]}"

Example:

Bitcoin RPC Output

bitcoin-cli createmultisig 2 '''["1bPAhBpBZ231NxXhDRCYViTKxmKYNAHmN", "135tMW4E9yEd7L55Ru1AqmhvYm8iGhLqvn", "1NkNtcXm6Rv6hfZSgLtMwcyL5CVdNusrK"]'''
{ "address" : "3AaZWMXkXRbUUWdLjtijsjE8XiDoWRw3yR", "redeemScript" : "522102912 ..... ca2353ae" }

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\", \"method\":\"createmultisig\", \"params\":[2, [\"1bPAhBpBZ231NxXhDRCYViTKxmKYNAHmN\", \"135tMW4E9yEd7L55Ru1AqmhvYm8iGhLqvn\", \"1NkNtcXm6Rv6hfZSgLtMwcyL5CVdNusrK\"]]}"
{"result":"success", "address":"3AaZWMXkXRbUUWdLjtijsjE8XiDoWRw3yR", "redeemScript":"522102912 ..... ca2353ae", "M":2, "N":3, "pubkeys":["02912ecebe3c043636bb470bdf7e9248265ef396b0bf8a02a806ffab6d5177832a", "020babfe8cc15718fc55c5cb8c17db9cb345bb5328de5541a5d2937490f2b7ad7b", "026a6ded1e06aa65da70affd8fe0dd02291927a822151a75d838b4579c9312ca23"], "addresses":["1bPAhBpBZ231NxXhDRCYViTKxmKYNAHmN", "135tMW4E9yEd7L55Ru1AqmhvYm8iGhLqvn", "1NkNtcXm6Rv6hfZSgLtMwcyL5CVdNusrK"], "tag":"5669492059337712832"}

4.3 dumpprivkey[edit]

STRING_ARG(bitcoinrpc,dumpprivkey,address);

  • Returns the wallet-import-format (WIF) private key corresponding to an address.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"dumpprivkey\",\"params\":[\"ADDRESS\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli dumpprivkey 1Cags6YwKA1EkF4aahogcwFZGV1cgEtHTB
KzEDPGzGjH6KS3EDbpktij2sgg7BHvY5bzehKn9RaLpNJm1hWJ4a

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"dumpprivkey\",\"params\":[\"1Cags6YwKA1EkF4aahogcwFZGV1cgEtHTB\"]}"
KzEDPGzGjH6KS3EDbpktij2sgg7BHvY5bzehKn9RaLpNJm1hWJ4a

4.4 dumpwallet[edit]

STRING_ARG(bitcoinrpc,dumpwallet);

  • Creates a JSON object with all wallet keys in a human-readable format.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"dumpwallet\"}"

Example:

Bitcoin RPC Output

bitcoin-cli dumpwallet

(no response if successful)

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"dumpwallet\"}"

(JSON object with the wallet parameters in the shell, list of addresses > wif formatted privkeys in Iguana log)


4.5 getaccount[edit]

STRING_ARG(bitcoinrpc,getaccount,address);

  • Returns the name of the account associated with the given address.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaccount\",\"params\":[\"ADDRESS\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli getaccount 1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt
testaccount

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaccount\",\"params\":[\"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt\"]}"
{"address":"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt", "rmd160":"764692cd5473f62ffa8a93e55d876f567623de07", "coin":"BTC", "pubkey":"032d713bae780bb74d651470d887231b36809116928847bd1681e51cb6bc46a280", "account":"testaccount", "result":"success", "tag":"5014441541211727782"}

4.6 getaccountaddress[edit]

STRING_ARG(bitcoinrpc,getaccountaddress,account);

  • Returns the current Bitcoin address for receiving payments to this account. If the account doesn’t exist, it creates both the account and a new address for receiving payment.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaccountaddress\",\"params\":[\"ACCOUNT\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli getaccountaddress testaccount
1KFeuRKQ7utKMZXYCC1KkYQuEwBwqeMcF1

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaccountaddress\",\"params\":[\"testaccount\"]}"
{"address":"1KFeuRKQ7utKMZXYCC1KkYQuEwBwqeMcF1", "rmd160":"c837ba61d88a48d7dca01231b33aa2bfeac5c3dc", "coin":"BTC", "pubkey":"03cb0f540a59ca68f86914906c632ea2dbd723c5bb30debbfc9c976f68877a51da", "account":"testaccount", "result":"success", "tag":"15378356583679161005"}

4.7 getaddressesbyaccount[edit]

STRING_ARG(bitcoinrpc,getaddressesbyaccount,account);

  • description
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaddressesbyaccount\",\"params\":[\"ACCOUNT\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli getaddressesbyaccount testaccount
["1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt"]

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getaddressesbyaccount\",\"params\":[\"testaccount\"]}"
{"result":["1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt"], "tag":"5568427282827502473"}

4.8 getnewaddress[edit]

STRING_ARG(bitcoinrpc,getnewaddress,account);

  • Returns a new Bitcoin address for receiving payments. If an account is specified, payments received with the address will be credited to that account.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getnewaddress\",\"params\":[\"account\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli getnewaddress
16DiWqEnChM5Uh4m7NQBpW3ENwB5rmZCA2

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"getnewaddress\",\"params\":[\"testaccount\"]}"
{"address":"16DiWqEnChM5Uh4m7NQBpW3ENwB5rmZCA2", "pubkey":"028cde4e4404e5077f11699c06b3ca254abde8ef2f1a1f9bde1245ee065c698ebe", "rmd160":"3940465ee82ae8b20476b06d1f29754bdccacca9", "coin":"BTC", "account":"testaccount1", "result":"success", "tag":"5793524690977951568"}

4.9 gettransaction[edit]

HASH_ARG(bitcoinrpc,gettransaction,txid);

  • gets detailed information about an in-wallet transaction. Iguana: Returns detailed information about a transaction, belonging or not to a local Bitcoin address.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"gettransaction\",\"params\":[\"TXID\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli gettransaction 4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c
{"amount": 0.01168000, "confirmations": 1, "blockhash": "0000000000000000008b33dc9621301b8dff595dc145a6aa67c922e2aeea657e", "blockindex": 1366, "blocktime": 1461866725, "txid": "4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c", "walletconflicts": [], "time": 1461859433, "timereceived": 1461859433, "bip125-replaceable": "no", "details": [{"account": "",       "address": "1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "category": "receive", "amount": 0.01168000, "label": "", "vout": 1 }], "hex": "0100000001946c4b42dc4c2003cc3f989dbe5e0dfab13470a9119cc1526745dc780818ea1802000000fdfd000047304402201ee115018538a1a7b62f541f1a18e9cc22d5a6033d1ab5dedd5060ad9276cca20220126b1d07a06d9796478d5c5991f492848ead22cf743e31fe53a499cfc22a1eae0148304502210094fb71d57ac5edf7d33a8b120427004f802a839ed7c4bb54bc57a89e4a09877a02206f1d4d3375e0f4aab291a47c19f39087e6fb51ed65dc14aa42fb203dfd24a234014c6952210234acde0a2cfb53ff3c6af10afb5f70b5ff11a0b356a58686e36752554a3408482102cb9a07d41ed61edb659f443605221b01993a154c4ae456338c2642d55e9f477f21034ae0aadd58677cf8e675dc3bc3723d8ecadfbfa89467a6f2b857eeacbc8e9cf453aeffffffff04f0550000000000001976a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac80d21100000000001976a9148f3638094d04daec3ee63c373ef10f0e114516e588accaf700000000000017a914ccc8038b280d99e6f808fb81a4a55d60c77575ba8700000000000000000d6a0b4d47577a58f0266e8f7d1d00000000"}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"gettransaction\",\"params\":[\"4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c\"]}"
{"version":1, "vin":[{"sequence":4294967295, "txid":"18ea180878dc456752c19c11a97034b1fa0d5ebe9d983fcc03204cdc424b6c94", "vout":2, "scriptSig":{"hex":"0047304402201ee115018538a1a7b62f541f1a18e9cc22d5a6033d1ab5dedd5060ad9276cca20220126b1d07a06d9796478d5c5991f492848ead22cf743e31fe53a499cfc22a1eae0148304502210094fb71d57ac5edf7d33a8b120427004f802a839ed7c4bb54bc57a89e4a09877a02206f1d4d3375e0f4aab291a47c19f39087e6fb51ed65dc14aa42fb203dfd24a234014c6952210234acde0a2cfb53ff3c6af10afb5f70b5ff11a0b356a58686e36752554a3408482102cb9a07d41ed61edb659f443605221b01993a154c4ae456338c2642d55e9f477f21034ae0aadd58677cf8e675dc3bc3723d8ecadfbfa89467a6f2b857eeacbc8e9cf453ae", "asm":"OP_FALSE 304402201ee115018538a1a7b62f541f1a18e9cc22d5a6033d1ab5dedd5060ad9276cca20220126b1d07a06d9796478d5c5991f492848ead22cf743e31fe53a499cfc22a1eae01 304502210094fb71d57ac5edf7d33a8b120427004f802a839ed7c4bb54bc57a89e4a09877a02206f1d4d3375e0f4aab291a47c19f39087e6fb51ed65dc14aa42fb203dfd24a23401 OP_PUSHDATA1 52210234acde0a2cfb53ff3c6af10afb5f70b5ff11a0b356a58686e36752554a3408482102cb9a07d41ed61edb659f443605221b01993a154c4ae456338c2642d55e9f477f21034ae0aadd58677cf8e675dc3bc3723d8ecadfbfa89467a6f2b857eeacbc8e9cf453ae"}}], "numvins":1, "vout":[{"satoshis":"22000", "n":0, "scriptPubKey":{"asm":"OP_DUP OP_HASH160 4ab009889e5b66d2a4341a7f38bcc9428b815bfe OP_EQUALVERIFY OP_CHECKSIG // 17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK", "reqSigs":1, "type":"pubkeyhash", "addresses":["17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK"], "hex":"76a9144ab009889e5b66d2a4341a7f38bcc9428b815bfe88ac"}}, {"satoshis":"1168000", "n":1, "scriptPubKey":{"asm":"OP_DUP OP_HASH160 8f3638094d04daec3ee63c373ef10f0e114516e5 OP_EQUALVERIFY OP_CHECKSIG // 1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "reqSigs":1, "type":"pubkeyhash", "addresses":["1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs"], "hex":"76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac"}}, {"satoshis":"63434", "n":2, "scriptPubKey":{"asm":"OP_HASH160 ccc8038b280d99e6f808fb81a4a55d60c77575ba OP_EQUAL // 3LMoNt98VPKYVji13Lj1oZSVdsgRSMBKmt", "addresses":["3LMoNt98VPKYVji13Lj1oZSVdsgRSMBKmt"], "hex":"a914ccc8038b280d99e6f808fb81a4a55d60c77575ba87"}}, {"satoshis":"0", "n":3, "scriptPubKey":{"asm":"OP_RETURN 6a0b4d47577a58f0266e8f7d1d", "addresses":["3QXCxrJKnHR4J1RcJKWT83UNKzyksVhCaS"], "hex":"6a0b4d47577a58f0266e8f7d1d"}}], "numvouts":4, "locktime":"0", "size":428, "txid":"4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c", "tag":"154485262926559259"}

4.10 importprivkey[edit]

TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan);

  • Adds a private key to your wallet. The key should be formatted in the wallet import format created by the dumpprivkey RPC.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"importprivkey\",\"params\":[\"WIF\",\"account\",rescan]}"

Example:

Bitcoin RPC Output

bitcoin-cli importprivkey KzEDPGzGjH6KS3EDbpktij2sgg7BHvY5bzehKn9RaLpNJm1hWJ4a
(rescan and no response if successful)

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"importprivkey\",\"params\":[\"KzEDPGzGjH6KS3EDbpktij2sgg7BHvY5bzehKn9RaLpNJm1hWJ4a\"]}"
{"address":"1Cags6YwKA1EkF4aahogcwFZGV1cgEtHTB", "pubkey":"035c05d86230bff5987784e49cb717cb80214c5dd3c47c2330dbbb22a08b91caf7", "rmd160":"7f08630d04da0c2d5617c8456d29015837b716a5", "coin":"BTC","account":"default","result":"success","tag":"4496824274640144342"}

4.11 listaccounts[edit]

TWO_INTS(bitcoinrpc,listaccounts,minconf,includewatchonly);

  • Lists accounts and their balances. Iguana: minconf specifies the minimum number of confirmations for unspent transactions to be included in the balances. includewatchonly can be set to 1 to also display watched addresses.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listaccounts\",\"params\":[minconf,includewatchonly]}"

Example:

Bitcoin RPC Output

bitcoin-cli listaccounts
{"testaccount": 0.01000000}

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listaccounts\",\"params\":[1,0]}"
{"result":{"testaccount":0.01000000},"tag":"17806012012067684668"}

4.12 listreceivedbyaddress[edit]

THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag);

  • Lists the total number of bitcoins received by each address.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listreceivedbyaddress\",\"params\":[minconf, includeempty, flag]}"

Example:

Bitcoin RPC Output

bitcoin-cli listreceivedbyaddress
[{ "address": "1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt", "account": "testaccount", "amount": 0.01000000, "confirmations": 1592, "label": "testaccount", "txids": [   "2196c07f71f206728301b03ffbffb7fd383744d03c1a3e0a1e03b6fb9ffd4ece"] }]

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listreceivedbyaddress\",\"params\":[5,1,1]}"
{"result": [{"address":"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt", "amount":0.01000000, "txids":["2196c07f71f206728301b03ffbffb7fd383744d03c1a3e0a1e03b6fb9ffd4ece"], "vouts":[1]}], "tag":"7326332900853546432"}

4.13 listunspent[edit]

TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array);

  • Returns an array of unspent transaction outputs belonging to the specified address/es.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[MINCONF, MAXCONF, ["ADDRESS1","address2"...]]}"

Example:

Bitcoin RPC Output

bitcoin-cli listunspent 1 2000
[{"txid": "4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c", "vout": 1, "address": "1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "account": "", "scriptPubKey": "76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "amount": 0.01168000, "confirmations": 29, "spendable": true}, {"txid": "b157f83eca6f9771f9848ff73f80e8825ff1a2a3578fcdeda619d2a24c9b2fd8", "vout": 1, "address": "1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "account": "", "scriptPubKey": "76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "amount": 0.01068000, "confirmations": 29, "spendable": true}]

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[1,2000,[\"1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs\"]]}"
[{"txid":"4b1cdad59fb5bd6f53a3f884a76c1cdce58d635d8e7d0bbf971f4f2eefd8122c", "vout":1, "address":"1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "scriptPubKey":"76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "amount":0.01168000, "confirmations":29, "checkind":5339978, "spendable":false, "unspent": {"hdrsi":204, "pkind":2674381, "unspentind":5339978, "prevunspentind":5339966, "satoshis":"1168000", "txidind":2006374, "vout":1, "type":2, "fileid":0, "scriptpos":0, "scriptlen":25}}, {"txid":"b157f83eca6f9771f9848ff73f80e8825ff1a2a3578fcdeda619d2a24c9b2fd8", "vout":1, "address":"1E4EadLDvqRWgSPRLqTM5YXefdaxsPPZVs", "scriptPubKey":"76a9148f3638094d04daec3ee63c373ef10f0e114516e588ac", "amount":0.01068000, "confirmations":29, "checkind":5339966, "spendable":false, "unspent": {"hdrsi":204, "pkind":2674381, "unspentind":5339966, "prevunspentind":0, "satoshis":"1068000", "txidind":2006372, "vout":1, "type":2, "fileid":0, "scriptpos":0, "scriptlen":25}}]

4.14 setaccount[edit]

TWO_STRINGS(bitcoinrpc,setaccount,address,account);

  • Puts the specified address in the given account.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"setaccount\",\"params\":[\"ADDRESS\",\"ACCOUNT\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli setaccount 1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt testaccount
(no response if successful)

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"setaccount\",\"params\":[\"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt\",\"testaccount\"]}"
success

4.15 validateaddress[edit]

STRING_ARG(bitcoinrpc,validateaddress,address);

  • Returns information about the given Bitcoin address.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"validateaddress\",\"params\":[\"ADDRESS\"]}"

Example:

Bitcoin RPC Output

bitcoin-cli validateaddress 1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt
{ "isvalid": true, "address": "1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt", "scriptPubKey": "76a914764692cd5473f62ffa8a93e55d876f567623de0788ac", "ismine": true, "iswatchonly": false, "isscript": false, "pubkey": "032d713bae780bb74d651470d887231b36809116928847bd1681e51cb6bc46a280", "iscompressed": true, "account": "testaccount" }

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"validateaddress\",\"params\":[\"1BnPHAZuPvYSgWkRfEu6wHDL8uGRzDcTjt\"]}"
{"result":"success", "addrtype":0, "rmd160":"764692cd5473f62ffa8a93e55d876f567623de07", "scriptPubKey":"76a914764692cd5473f62ffa8a93e55d876f567623de0788ac", "isscript":false, "pubkey":"", "ismine":true, "tag":"8325203187365968829"}

4.16 walletlock[edit]

ZERO_ARGS(bitcoinrpc,walletlock);

  • Eemoves the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"walletlock\"}"

Example:

Bitcoin RPC Output

bitcoin-cli walletlock
(no response if successful)

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"walletlock\"}"
{"tag":"6820864451736957999"}

4.17 walletpassphrase[edit]

TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout);

  • In Iguana, if no wallet has been created or unlocked by the user, this call will create an Iguana BTC wallet file encrypted with PASSPHRASE. Additionally, or if an Iguana BTC wallet file already exists, this call stores the wallet decryption key in memory for TIMEOUT seconds.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"walletpassphrase\",\"params\":[\"PASSPHRASE\",\"permanentfile\",TIMEOUT]}"

Example:

Bitcoin RPC Output

bitcoin-cli walletpassphrase test
(no response if successful)

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"walletpassphrase\",\"params\":[\"test\",100]}"
{"pubkey":"d9d5c57971eefb085e3abaf7a5a4a6cdb8185f30105583cdb09ad8f61886ec65", "RS":"NXT-E8JD-FHKJ-CQ9H-5KGMQ", "NXT":"4273301882745002507", "btcpubkey":"020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2f", "rmd160":"b7128d2ee837cf03e30a2c0e3e0181f7b9669bb6", "BTC":"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE", "BTCD":"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z", "result":"success", "handle":"", "persistent":"d9d5c57971eefb085e3abaf7a5a4a6cdb8185f30105583cdb09ad8f61886ec65", "status":"unlocked", "duration":3600, "tag":"7389958375741113802"}

5 Iguana Additional Methods[edit]

5.1 makekeypair*[edit]

ZERO_ARGS(bitcoinrpc,makekeypair);

  • * Iguana only call: Generates an additional key pair for the current wallet.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"makekeypair\"}"

Example:

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"makekeypair\"}"
{"result":"success", "privkey":"284df7a0a6638de81d0b204b73530fd9cc60702a1b92307b09c5d460b4bfa861", "rosetta":{"pubkey":"8dedf234c27f02e43f50654947faf87bf81fde6e7043867ba7c817338382544a", "RS":"NXT-B6SV-AJE2-D5F3-FG8QG", "NXT":"15517379307961094939", "btcpubkey":"0221aa96689bcf6abd0baf2e4ba2f8854be033ae6cdf70126ff86e8c95ce491ba0", "rmd160":"2661166126153bc7467aa4fe2c641972af1dab9c", "BTC":"14Vvz3RSruwpkzatWeZkRhvPLLrAw7jHj1", "BTCwif":"Kxa4JHTGs9Rwzmw85a6AeTRj1hoVNfqgjfT38SK9sV3fPAnFJpoH", "BTCD":"RCn84ZJjTjkPpzx5ypYsXEFb6cJmXv4doV", "BTCDwif":"UqMtby5FNNQCTpjDG7mkQu6wwmrdTn7JWAprhh6qLCGNH2iDvuhP", "privkey":"284df7a0a6638de81d0b204b73530fd9cc60702a1b92307b09c5d460b4bfa861"}, "tag":"4550786942619247009"}

5.2 validatepubkey*[edit]

STRING_ARG(bitcoinrpc,validatepubkey,pubkey);

  • * Iguana only call: Returns information about the given Bitcoin pubkey.
curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"validatepubkey\",\"params\":[\"PUBKEY\"]}"

Example:

Iguana API Output

curl --url "http://127.0.0.1:7778"  --data "{\"coin\":\"BTC\",\"method\":\"validatepubkey\",\"params\":[\"0214b7cbd6599c5e020357fbe6c9c3f7f69552c6dedaaf67e98e938db5e60a8643\"]}"
{"result":"success","pubkey":"0214b7cbd6599c5e020357fbe6c9c3f7f69552c6dedaaf67e98e938db5e60a8643","address":"1Mua4qenTyJpp4VerWbw5wriXXvGCRELTQ","coin":"BTC","tag":"10739138950273732776"}