dogecoinrpc.connection — Connect to Dogecoin server via JSON-RPC

Connect to Dogecoin server via JSON-RPC.

class dogecoinrpc.connection.DogecoinConnection(user, password, host='localhost', port=22555, use_https=False)

Bases: builtins.object

A DogecoinConnection object defines a connection to a dogecoin server. It is a thin wrapper around a JSON-RPC API connection.

Arguments to constructor:

  • user – Authenticate as user.
  • password – Authentication password.
  • host – Dogecoin JSON-RPC host.
  • port – Dogecoin JSON-RPC port.
backupwallet(destination)

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

Arguments: - destination – directory or path with filename to backup wallet to.

createrawtransaction(inputs, outputs)

Creates a raw transaction spending given inputs (a list of dictionaries, each containing a transaction id and an output number), sending to given address(es).

Returns hex-encoded raw transaction.

Example usage: >>> conn.createrawtransaction(

[{“txid”: “a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c”,
“vout”: 0}],

{“mkZBYBiq6DNoQEKakpMJegyDbw2YiNQnHT”:50})

Arguments:

  • inputs – A list of {“txid”: txid, “vout”: n} dictionaries.

  • outputs – A dictionary mapping (public) addresses to the amount

    they are to be paid.

decoderawtransaction(hexstring)

Produces a human-readable JSON object for a raw transaction.

Arguments:

  • hexstring – A hex string of the transaction to be decoded.
dumpprivkey(address)

Returns the private key belonging to <address>.

Arguments:

  • address – Dogecoin address whose private key should be returned.
getaccount(dogecoinaddress)

Returns the account associated with the given address.

Arguments:

  • dogecoinaddress – Dogecoin address to get account for.
getaccountaddress(account)

Returns the current dogecoin address for receiving payments to an account.

Arguments:

  • account – Account for which the address should be returned.
getaddressesbyaccount(account)

Returns the list of addresses for the given account.

Arguments:

  • account – Account to get list of addresses for.
getbalance(account=None, minconf=None)

Get the current balance, either for an account or the total server balance.

Arguments: - account – If this parameter is specified, returns the balance in the account. - minconf – Minimum number of confirmations required for transferred balance.

getblock(hash)

Returns information about the given block hash.

getblockcount()

Returns the number of blocks in the longest block chain.

getblockhash(index)

Returns hash of block in best-block-chain at index.

Parameters:index – index ob the block
getblocknumber()

Returns the block number of the latest block in the longest block chain. Deprecated. Use getblockcount instead.

getconnectioncount()

Returns the number of connections to other nodes.

getdifficulty()

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

getgenerate()

Returns True or False, depending on whether generation is enabled.

gethashespersec()

Returns a recent hashes per second performance measurement while generating.

getinfo()

Returns an ServerInfo object containing various state info.

getmininginfo()

Returns an MiningInfo object containing various mining state info.

getnewaddress(account=None)

Returns a new dogecoin address for receiving payments.

Arguments:

  • account – If account is specified (recommended), it is added to the address book so that payments received with the address will be credited to it.
getrawtransaction(txid, verbose=True)

Get transaction raw info

Arguments:

  • txid – Transactiond id for which the info should be returned.
  • verbose – If False, return only the “hex” of the transaction.
getreceivedbyaccount(account, minconf=1)

Returns the total amount received by addresses with an account in transactions with at least a certain number of confirmations.

Arguments:

  • account – Account to query for total amount.
  • minconf – Number of confirmations to require, defaults to 1.
getreceivedbyaddress(dogecoinaddress, minconf=1)

Returns the total amount received by a dogecoin address in transactions with at least a certain number of confirmations.

Arguments:

  • dogecoinaddress – Address to query for total amount.
  • minconf – Number of confirmations to require, defaults to 1.
gettransaction(txid)

Get detailed information about transaction

Arguments:

  • txid – Transactiond id for which the info should be returned
gettxout(txid, index, mempool=True)

Returns details about an unspent transaction output (UTXO)

Arguments:

  • txid – Transactiond id for which the info should be returned.
  • index – The output index.
  • mempool – Add memory pool transactions.
getwork(data=None)

Get work for remote mining, or submit result. If data is specified, the server tries to solve the block using the provided data and returns True if it was successful. If not, the function returns formatted hash data (WorkItem) to work on.

Arguments:

  • data – Result from remote mining.
importprivkey(privkey, acct='', rescan=True)

import private key <privkey> to account [acct], optionally rescanning blockchain .

Arguments:

  • privkey – private key to import.
  • [acct] – name of account to associate with private key
  • [rescan] – rescan blockchain for transcations containing altcoin address associated with privkey
keypoolrefill()

Fills the keypool, requires wallet passphrase to be set.

listaccounts(minconf=1, as_dict=False)

Returns a list of account names.

Arguments:

  • minconf – Minimum number of confirmations before payments are included.
  • as_dict – Returns a dictionary of account names, with their balance as values.
listreceivedbyaccount(minconf=1, includeempty=False)

Returns a list of accounts.

Each account is represented with a AccountInfo object.

Arguments:

  • minconf – Minimum number of confirmations before payments are included.
  • includeempty – Whether to include addresses that haven’t received any payments.
listreceivedbyaddress(minconf=1, includeempty=False)

Returns a list of addresses.

Each address is represented with a AddressInfo object.

Arguments:

  • minconf – Minimum number of confirmations before payments are included.
  • includeempty – Whether to include addresses that haven’t received any payments.
listtransactions(account=None, count=10, from_=0, address=None)

Returns a list of the last transactions for an account.

Each transaction is represented with a TransactionInfo object.

Arguments:

  • account – Account to list transactions from. Return transactions from

    all accounts if None.

  • count – Number of transactions to return.

  • from_ – Skip the first <from_> transactions.

  • address – Receive address to consider

listunspent(minconf=1, maxconf=999999)

Returns a list of unspent transaction inputs in the wallet.

Arguments:

  • minconf – Minimum number of confirmations required to be listed.
  • maxconf – Maximal number of confirmations allowed to be listed.
move(fromaccount, toaccount, amount, minconf=1, comment=None)

Move from one account in your wallet to another.

Arguments:

  • fromaccount – Source account name.
  • toaccount – Destination account name.
  • amount – Amount to transfer.
  • minconf – Minimum number of confirmations required for transferred balance.
  • comment – Comment to add to transaction log.
sendfrom(fromaccount, todogecoinaddress, amount, minconf=1, comment=None, comment_to=None)

Sends amount from account’s balance to dogecoinaddress. This method will fail if there is less than amount dogecoins with minconf confirmations in the account’s balance (unless account is the empty-string-named default account; it behaves like the sendtoaddress method). Returns transaction ID on success.

Arguments:

  • fromaccount – Account to send from.
  • todogecoinaddress – Dogecoin address to send to.
  • amount – Amount to send (float, rounded to the nearest 0.01).
  • minconf – Minimum number of confirmations required for transferred balance.
  • comment – Comment for transaction.
  • comment_to – Comment for to-address.
sendmany(fromaccount, todict, minconf=1, comment=None)

Sends specified amounts from account’s balance to dogecoinaddresses. This method will fail if there is less than total amount dogecoins with minconf confirmations in the account’s balance (unless account is the empty-string-named default account; Returns transaction ID on success.

Arguments:

  • fromaccount – Account to send from.
  • todict – Dictionary with Dogecoin addresses as keys and amounts as values.
  • minconf – Minimum number of confirmations required for transferred balance.
  • comment – Comment for transaction.
sendtoaddress(dogecoinaddress, amount, comment=None, comment_to=None)

Sends amount from the server’s available balance to dogecoinaddress.

Arguments:

  • dogecoinaddress – Dogecoin address to send to.
  • amount – Amount to send (float, rounded to the nearest 0.00000001).
  • minconf – Minimum number of confirmations required for transferred balance.
  • comment – Comment for transaction.
  • comment_to – Comment for to-address.
setaccount(dogecoinaddress, account)

Sets the account associated with the given address.

Arguments:

  • dogecoinaddress – Dogecoin address to associate.
  • account – Account to associate the address to.
setgenerate(generate, genproclimit=None)

Enable or disable generation (mining) of coins.

Arguments:

  • generate – is True or False to turn generation on or off.
  • genproclimit – Number of processors that are used for generation, -1 is unlimited.
signmessage(address, message)

Sign messages, returns the signature

Parameters:
  • address (str or unicode) – Dogecoin address used to sign a message
  • message (str or unicode) – The message to sign
Return type:

unicode

signrawtransaction(hexstring, previous_transactions=None, private_keys=None)

Sign inputs for raw transaction (serialized, hex-encoded).

Returns a dictionary with the keys:
“hex”: raw transaction with signature(s) (hex-encoded string) “complete”: 1 if transaction has a complete set of signature(s), 0 if not

Arguments:

  • hexstring – A hex string of the transaction to sign.

  • previous_transactions – A (possibly empty) list of dictionaries of the form:

    {“txid”: txid, “vout”: n, “scriptPubKey”: hex, “redeemScript”: hex}, representing previous transaction outputs that this transaction depends on but may not yet be in the block chain.

  • private_keys – A (possibly empty) list of base58-encoded private

    keys that, if given, will be the only keys used to sign the transaction.

stop()

Stop dogecoin server.

validateaddress(validateaddress)

Validate a dogecoin address and return information for it.

The information is represented by a AddressValidation object.

Arguments: – Address to validate.

  • validateaddress
verifymessage(address, signature, message)

Verify a signed message

Parameters:
  • address (str or unicode) – Dogecoin address used to sign a message
  • signature (unicode) – The signature
  • message (str or unicode) – The message to sign
Return type:

bool

walletlock()

Removes 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.

walletpassphrase(passphrase, timeout, dont_raise=False)

Stores the wallet decryption key in memory for <timeout> seconds.

  • passphrase – The wallet passphrase.

  • timeout – Time in seconds to keep the wallet unlocked

    (by keeping the passphrase in memory).

  • dont_raise – instead of raising ~dogecoinrpc.exceptions.WalletPassphraseIncorrect

    return False.

walletpassphrasechange(oldpassphrase, newpassphrase, dont_raise=False)

Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.

Arguments:

  • dont_raise – instead of raising ~dogecoinrpc.exceptions.WalletPassphraseIncorrect

    return False.

Previous topic

dogecoinrpc — Convenience functions

Next topic

dogecoinrpc.exceptions — Exception definitions

This Page