ExBitcoin v0.4.0 ExBitcoin.Wallet View Source

wallet related RPC

Link to this section Summary

Functions

abandontransaction “txid”

abortrescan

addmultisigaddress nrequired [“key”,…] ( “account” )

addwitnessaddress “address”

backupwallet “destination”

bumpfee “txid” ( options )

dumpprivkey “address”

dumpwallet “filename”

encryptwallet “passphrase”

getaccount “address”

getaccountaddress “account”

getaddressesbyaccount “account”

getbalance ( “account” minconf include_watchonly )

getnewaddress ( “account” )

getrawchangeaddress

getreceivedbyaccount “account” ( minconf )

getreceivedbyaddress “address” ( minconf )

gettransaction “txid” ( include_watchonly )

getunconfirmedbalance Returns the server’s total unconfirmed balance

getwalletinfo Returns an object containing various wallet state info

importaddress “address” ( “label” rescan p2sh )

importmulti “requests” ( “options” )

importprivkey “privkey” ( “label” ) ( rescan )

importpubkey “pubkey” ( “label” rescan )

importwallet “filename”

keypoolrefill ( newsize )

listaccounts ( minconf include_watchonly)

listaddressgroupings

listlockunspent

listreceivedbyaccount ( minconf include_empty include_watchonly)

listreceivedbyaddress ( minconf include_empty include_watchonly)

listsinceblock ( “blockhash” target_confirmations include_watchonly include_removed )

listtransactions ( “account” count skip include_watchonly)

listunspent ( minconf maxconf [“addresses”,…] [include_unsafe] [query_options])

listwallets Returns a list of currently loaded wallets. For full information on the wallet, use “getwalletinfo”

lockunspent unlock ([{“txid”:”txid”,”vout”:n},…])

move “fromaccount” “toaccount” amount ( minconf “comment” )

removeprunedfunds “txid”

sendfrom “fromaccount” “toaddress” amount ( minconf “comment” “comment_to” )

sendmany “fromaccount” {“address”:amount,…} ( minconf “comment” [“address”,…] replaceable conf_target “estimate_mode”)

sendtoaddress “address” amount ( “comment” “comment_to” subtractfeefromamount replaceable conf_target “estimate_mode”)

setaccount “address” “account”

settxfee amount

signmessage “address” “message”

Link to this section Functions

Link to this function abandontransaction(txid) View Source
abandontransaction(:"String.t") :: any()

abandontransaction “txid”

Mark in-wallet transaction as abandoned This will mark this transaction and all its in-wallet descendants as abandoned which will allow for their inputs to be respent. It can be used to replace “stuck” or evicted transactions. It only works on transactions which are not included in a block and are not currently in the mempool. It has no effect on transactions which are already conflicted or abandoned.

Arguments:

  1. “txid” (string, required) The transaction id

Result:

Examples:

bitcoin-cli abandontransaction “1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “abandontransaction”, “params”: [“1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function abortrescan() View Source
abortrescan() :: any()

abortrescan

Stops current wallet rescan triggered e.g. by an importprivkey call.

Examples:

Import a private key

bitcoin-cli importprivkey “mykey”

Abort the running wallet rescan

bitcoin-cli abortrescan

As a JSON-RPC call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “abortrescan”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function addmultisigaddress(nrequired, keys, account) View Source
addmultisigaddress(:"String.t", :"String.t", :"String.t") :: any()

addmultisigaddress nrequired [“key”,…] ( “account” )

Add a nrequired-to-sign multisignature address to the wallet. Each key is a Bitcoin address or hex-encoded public key. If ‘account’ is specified (DEPRECATED), assign address to that account.

Arguments:

  1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.
  2. “keys” (string, required) A json array of bitcoin addresses or hex-encoded public keys [ “address” (string) bitcoin address or hex-encoded public key …, ]
  3. “account” (string, optional) DEPRECATED. An account to assign the addresses to.

Result: “address” (string) A bitcoin address associated with the keys.

Examples:

Add a multisig address from 2 addresses

bitcoin-cli addmultisigaddress 2 “[\”16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\”,\”171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\”]”

As json rpc call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “addmultisigaddress”, “params”: [2, “[\”16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\”,\”171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\”]”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function addwitnessaddress(address) View Source
addwitnessaddress(:"String.t") :: any()

addwitnessaddress “address”

Add a witness address for a script (with pubkey or redeemscript known). It returns the witness script.

Arguments:

  1. “address” (string, required) An address known to the wallet

Result: “witnessaddress”, (string) The value of the new address (P2SH of witness script). }

Link to this function backupwallet(destination) View Source
backupwallet(:"String.t") :: any()

backupwallet “destination”

Safely copies current wallet file to destination, which can be a directory or a path with filename.

Arguments:

  1. “destination” (string) The destination directory or file

Examples:

bitcoin-cli backupwallet “backup.dat” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “backupwallet”, “params”: [“backup.dat”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function bumpfee(txid, options) View Source
bumpfee(:"String.t", :"String.t") :: any()

bumpfee “txid” ( options )

Bumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B. An opt-in RBF transaction with the given txid must be in the wallet. The command will pay the additional fee by decreasing (or perhaps removing) its change output. If the change output is not big enough to cover the increased fee, the command will currently fail instead of adding new inputs to compensate. (A future implementation could improve this.) The command will fail if the wallet or mempool contains a transaction that spends one of T’s outputs. By default, the new fee will be calculated automatically using estimatefee. The user can specify a confirmation target for estimatefee. Alternatively, the user can specify totalFee, or use RPC settxfee to set a higher fee rate. At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee returned by getnetworkinfo) to enter the node’s mempool.

Arguments:

  1. txid (string, required) The txid to be bumped
  2. options (object, optional) { “confTarget” (numeric, optional) Confirmation target (in blocks) “totalFee” (numeric, optional) Total fee (NOT feerate) to pay, in satoshis.

                     In rare cases, the actual fee paid might be slightly higher than the specified
                     totalFee if the tx change output has to be removed because it is too close to
                     the dust threshold.

    “replaceable” (boolean, optional, default true) Whether the new transaction should still be

                     marked bip-125 replaceable. If true, the sequence numbers in the transaction will
                     be left unchanged from the original. If false, any input sequence numbers in the
                     original transaction that were less than 0xfffffffe will be increased to 0xfffffffe
                     so the new transaction will not be explicitly bip-125 replaceable (though it may
                     still be replaceable in practice, for example if it has unconfirmed ancestors which
                     are replaceable).

    “estimate_mode” (string, optional, default=UNSET) The fee estimate mode, must be one of:

     "UNSET"
     "ECONOMICAL"
     "CONSERVATIVE"

    }

Result: { “txid”: “value”, (string) The id of the new transaction “origfee”: n, (numeric) Fee of the replaced transaction “fee”: n, (numeric) Fee of the new transaction “errors”: [ str… ] (json array of strings) Errors encountered during processing (may be empty) }

Examples:

Bump the fee, get the new transaction’s txid

bitcoin-cli bumpfee

Link to this function dumpprivkey(address) View Source
dumpprivkey(:"String.t") :: any()

dumpprivkey “address”

Reveals the private key corresponding to ‘address’. Then the importprivkey can be used with this output

Arguments:

  1. “address” (string, required) The bitcoin address for the private key

Result: “key” (string) The private key

Examples:

bitcoin-cli dumpprivkey “myaddress” bitcoin-cli importprivkey “mykey” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “dumpprivkey”, “params”: [“myaddress”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function dumpwallet(filename) View Source
dumpwallet(:"String.t") :: any()

dumpwallet “filename”

Dumps all wallet keys in a human-readable format to a server-side file. This does not allow overwriting existing files.

Arguments:

  1. “filename” (string, required) The filename with path (either absolute or relative to bitcoind)

Result: { (json object) “filename” : { (string) The filename with full absolute path }

Examples:

bitcoin-cli dumpwallet “test” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “dumpwallet”, “params”: [“test”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function encryptwallet(passphrase) View Source
encryptwallet(:"String.t") :: any()

encryptwallet “passphrase”

Encrypts the wallet with ‘passphrase’. This is for first time encryption. After this, any calls that interact with private keys such as sending or signing will require the passphrase to be set prior the making these calls. Use the walletpassphrase call for this, and then walletlock call. If the wallet is already encrypted, use the walletpassphrasechange call. Note that this will shutdown the server.

Arguments:

  1. “passphrase” (string) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.

Examples:

Encrypt your wallet

bitcoin-cli encryptwallet “my pass phrase”

Now set the passphrase to use the wallet, such as for signing or sending bitcoin

bitcoin-cli walletpassphrase “my pass phrase”

Now we can do something like sign

bitcoin-cli signmessage “address” “test message”

Now lock the wallet again by removing the passphrase

bitcoin-cli walletlock

As a json rpc call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “encryptwallet”, “params”: [“my pass phrase”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getaccount(address) View Source
getaccount(:"String.t") :: any()

getaccount “address”

DEPRECATED. Returns the account associated with the given address.

Arguments:

  1. “address” (string, required) The bitcoin address for account lookup.

Result: “accountname” (string) the account address

Examples:

bitcoin-cli getaccount “1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getaccount”, “params”: [“1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getaccountaddress(account) View Source
getaccountaddress(:"String.t") :: any()

getaccountaddress “account”

DEPRECATED. Returns the current Bitcoin address for receiving payments to this account.

Arguments:

  1. “account” (string, required) The account name for the address. It can also be set to the empty string “” to represent the default account. The account does not need to exist, it will be created and a new address created if there is no account by the given name.

Result: “address” (string) The account bitcoin address

Examples:

bitcoin-cli getaccountaddress bitcoin-cli getaccountaddress “” bitcoin-cli getaccountaddress “myaccount” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getaccountaddress”, “params”: [“myaccount”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getaddressesbyaccount(account) View Source
getaddressesbyaccount(:"String.t") :: any()

getaddressesbyaccount “account”

DEPRECATED. Returns the list of addresses for the given account.

Arguments:

  1. “account” (string, required) The account name.

Result: [ (json array of string) “address” (string) a bitcoin address associated with the given account ,… ]

Examples:

bitcoin-cli getaddressesbyaccount “tabby” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getaddressesbyaccount”, “params”: [“tabby”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getbalance(account, minconf, include_watchonly) View Source
getbalance(:"String.t", :"String.t", :"String.t") :: any()

getbalance ( “account” minconf include_watchonly )

If account is not specified, returns the server’s total available balance. If account is specified (DEPRECATED), returns the balance in the account. Note that the account “” is not the same as leaving the parameter out. The server total may be different to the balance in the default “” account.

Arguments:

  1. “account” (string, optional) DEPRECATED. The account string may be given as a specific account name to find the balance associated with wallet keys in a named account, or as the empty string (“”) to find the balance associated with wallet keys not in any named account, or as “*” to find the balance associated with all wallet keys regardless of account. When this option is specified, it calculates the balance in a different way than when it is not specified, and which can count spends twice when there are conflicting pending transactions (such as those created by the bumpfee command), temporarily resulting in low or even negative balances. In general, account balance calculation is not considered reliable and has resulted in confusing outcomes, so it is recommended to avoid passing this argument.
  2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.
  3. include_watchonly (bool, optional, default=false) Also include balance in watch-only addresses (see ‘importaddress’)

Result: amount (numeric) The total amount in BTC received for this account.

Examples:

The total amount in the wallet with 1 or more confirmations

bitcoin-cli getbalance

The total amount in the wallet at least 6 blocks confirmed

bitcoin-cli getbalance “*” 6

As a json rpc call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getbalance”, “params”: [“*”, 6] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getnewaddress(account) View Source
getnewaddress(:"String.t") :: any()

getnewaddress ( “account” )

Returns a new Bitcoin address for receiving payments. If ‘account’ is specified (DEPRECATED), it is added to the address book so payments received with the address will be credited to ‘account’.

Arguments:

  1. “account” (string, optional) DEPRECATED. The account name for the address to be linked to. If not provided, the default account “” is used. It can also be set to the empty string “” to represent the default account. The account does not need to exist, it will be created if there is no account by the given name.

Result: “address” (string) The new bitcoin address

Examples:

bitcoin-cli getnewaddress curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getnewaddress”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getrawchangeaddress() View Source
getrawchangeaddress() :: any()

getrawchangeaddress

Returns a new Bitcoin address, for receiving change. This is for use with raw transactions, NOT normal use.

Result: “address” (string) The address

Examples:

bitcoin-cli getrawchangeaddress curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getrawchangeaddress”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getreceivedbyaccount(account, minconf) View Source
getreceivedbyaccount(:"String.t", :"String.t") :: any()

getreceivedbyaccount “account” ( minconf )

DEPRECATED. Returns the total amount received by addresses with in transactions with at least [minconf] confirmations.

Arguments:

  1. “account” (string, required) The selected account, may be the default account using “”.
  2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.

Result: amount (numeric) The total amount in BTC received for this account.

Examples:

Amount received by the default account with at least 1 confirmation

bitcoin-cli getreceivedbyaccount “”

Amount received at the tabby account including unconfirmed amounts with zero confirmations

bitcoin-cli getreceivedbyaccount “tabby” 0

The amount with at least 6 confirmations

bitcoin-cli getreceivedbyaccount “tabby” 6

As a json rpc call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getreceivedbyaccount”, “params”: [“tabby”, 6] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getreceivedbyaddress(address, minconf) View Source
getreceivedbyaddress(:"String.t", :"String.t") :: any()

getreceivedbyaddress “address” ( minconf )

Returns the total amount received by the given address in transactions with at least minconf confirmations.

Arguments:

  1. “address” (string, required) The bitcoin address for transactions.
  2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.

Result: amount (numeric) The total amount in BTC received at this address.

Examples:

The amount from transactions with at least 1 confirmation

bitcoin-cli getreceivedbyaddress “1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX”

The amount including unconfirmed transactions, zero confirmations

bitcoin-cli getreceivedbyaddress “1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX” 0

The amount with at least 6 confirmations

bitcoin-cli getreceivedbyaddress “1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX” 6

As a json rpc call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getreceivedbyaddress”, “params”: [“1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX”, 6] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function gettransaction(txid, include_watchonly) View Source
gettransaction(:"String.t", :"String.t") :: any()

gettransaction “txid” ( include_watchonly )

Get detailed information about in-wallet transaction

Arguments:

  1. “txid” (string, required) The transaction id
  2. “include_watchonly” (bool, optional, default=false) Whether to include watch-only addresses in balance calculation and details[]

Result: { “amount” : x.xxx, (numeric) The transaction amount in BTC “fee”: x.xxx, (numeric) The amount of the fee in BTC. This is negative and only available for the

                          'send' category of transactions.

“confirmations” : n, (numeric) The number of confirmations “blockhash” : “hash”, (string) The block hash “blockindex” : xx, (numeric) The index of the transaction in the block that includes it “blocktime” : ttt, (numeric) The time in seconds since epoch (1 Jan 1970 GMT) “txid” : “transactionid”, (string) The transaction id. “time” : ttt, (numeric) The transaction time in seconds since epoch (1 Jan 1970 GMT) “timereceived” : ttt, (numeric) The time received in seconds since epoch (1 Jan 1970 GMT) “bip125-replaceable”: “yes|no|unknown”, (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);

                                               may be unknown for unconfirmed transactions not in the mempool

“details” : [

{
  "account" : "accountname",      (string) DEPRECATED. The account name involved in the transaction, can be "" for the default account.
  "address" : "address",          (string) The bitcoin address involved in the transaction
  "category" : "send|receive",    (string) The category, either 'send' or 'receive'
  "amount" : x.xxx,                 (numeric) The amount in BTC
  "label" : "label",              (string) A comment for the address/transaction, if any
  "vout" : n,                       (numeric) the vout value
  "fee": x.xxx,                     (numeric) The amount of the fee in BTC. This is negative and only available for the 
                                       'send' category of transactions.
  "abandoned": xxx                  (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the 
                                       'send' category of transactions.
}
,...

], “hex” : “data” (string) Raw data for transaction }

Examples:

bitcoin-cli gettransaction “1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d” bitcoin-cli gettransaction “1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d” true curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “gettransaction”, “params”: [“1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getunconfirmedbalance() View Source
getunconfirmedbalance() :: any()

getunconfirmedbalance Returns the server’s total unconfirmed balance

Link to this function getwalletinfo() View Source
getwalletinfo() :: any()

getwalletinfo Returns an object containing various wallet state info.

Result: { “walletname”: xxxxx, (string) the wallet name “walletversion”: xxxxx, (numeric) the wallet version “balance”: xxxxxxx, (numeric) the total confirmed balance of the wallet in BTC “unconfirmed_balance”: xxx, (numeric) the total unconfirmed balance of the wallet in BTC “immature_balance”: xxxxxx, (numeric) the total immature balance of the wallet in BTC “txcount”: xxxxxxx, (numeric) the total number of transactions in the wallet “keypoololdest”: xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool “keypoolsize”: xxxx, (numeric) how many new keys are pre-generated (only counts external keys) “keypoolsize_hd_internal”: xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used) “unlocked_until”: ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked “paytxfee”: x.xxxx, (numeric) the transaction fee configuration, set in BTC/kB “hdmasterkeyid”: ““ (string) the Hash160 of the HD master pubkey }

Examples:

bitcoin-cli getwalletinfo curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getwalletinfo”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function importaddress(script, label, rescan, p2sh) View Source
importaddress(:"String.t", :"String.t", :"String.t", :"String.t") :: any()

importaddress “address” ( “label” rescan p2sh )

Adds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend.

Arguments:

  1. “script” (string, required) The hex-encoded script (or address)
  2. “label” (string, optional, default=””) An optional label
  3. rescan (boolean, optional, default=true) Rescan the wallet for transactions
  4. p2sh (boolean, optional, default=false) Add the P2SH version of the script as well

Note: This call can take minutes to complete if rescan is true. If you have the full public key, you should call importpubkey instead of this.

Note: If you import a non-standard raw script in hex form, outputs sending to it will be treated as change, and not show up in many RPCs.

Examples:

Import a script with rescan

bitcoin-cli importaddress “myscript”

Import using a label without rescan

bitcoin-cli importaddress “myscript” “testing” false

As a JSON-RPC call

curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “importaddress”, “params”: [“myscript”, “testing”, false] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function importmulti(requests, options) View Source
importmulti(:"String.t", :"String.t") :: any()

importmulti “requests” ( “options” )

Import addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options).

Arguments:

  1. requests (array, required) Data to be imported [ (array of json objects) { “scriptPubKey”: “