def sendtoaddress(address='', amount=0.0, comment='', comment_to='', subtractFeeFromAmt=False): ''' The sendtoaddress method sends an amount to a given address. The amount is real and is rounded to the nearest 0.00000001 :param address: (string, required) the receiving address :param amount: (numeric, required) the amount to send (json requires all decimals values less than 1 begin with the characters '0.') :param comment: (string, optional) a comment used to store what the transaction is for; this is not part of the transaction, just kept in your wallet :param comment_to: (string, optional) a comment to store the name of the person or organization to which you're sending the transaction; this is stored in your local wallet file only :param subtractFeeFromAmt: (boolean, optional, default=false) when true, the fee will be deducted from the amount being sent :return: "transaction_id" (JSON string) the transaction id ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "sendtoaddress", ' \ '"params": ["' + str(address) + '", ' + str(amount) +\ ', "' + str(comment) + '", "' + str(comment_to) +\ '", ' + str(subtractFeeFromAmt).lower() + '] }' return rpc.rpc_request(data)
def getsnapshot(top=0): ''' The getsnapshot method returns a snapshot of addresses and their amounts at the asset chain's current height. The method requires addressindex to be enabled. :param top: (number, optional) Only return this many addresses, i.e. top N rich lis :return: JSON string containing: "addresses" (array of jsons) the array containing the address and amount details "addr" (string) an address "amount" (number) the amount of coins in the above address "total" (numeric) the total amount in snapshot "average" (numeric) the average amount in each address "utxos" (number) the total number of UTXOs in snapshot "total_addresses" (number) the total number of addresses in snapshot. "start_height" (number) the block height snapshot began "ending_height" (number) the block height snapshot finished, "start_time" (number) the unix epoch time snapshot started "end_time" (number) the unix epoch time snapshot finished ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getsnapshot", ' \ '"params": ["' + str(top) + '"] }' return rpc.rpc_request(data)
def listreceivedbyaddress(minconf=1, includeEmpty=False, includeWatchOnly=False): ''' The listreceivedbyaddress method lists balances by receiving address :param minconf:(numeric, optional, default=1) the minimum number of confirmations before payments are included :param includeEmpty:(numeric, optional, default=false) whether to include addresses that haven't received any payments :param includeWatchOnly:(bool, optional, default=false) whether to include watchonly addresses (see 'importaddress') :return:JSON string: "involvesWatchonly" (bool) only returned if imported addresses were involved in transaction "address" (string) the receiving address "account" (string) DEPRECATED the account of the receiving address; the default account is "" "amount" (numeric) the total amount received by the address "confirmations" (numeric) a confirmation number that is dPoW aware; "rawconfirmations" (numeric) the raw confirmations of the most recent transaction included (number of blocks on top of this transaction's block) ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "listreceivedbyaddress", ' \ '"params": [' + str(minconf) + ', ' +\ str(includeEmpty).lower() + ', ' +\ str(includeWatchOnly).lower() + '] }' return rpc.rpc_request(data)
def z_shieldcoinbase(fromaddress='', toaddress='', fee=0.0001, limit=50): ''' The z_shieldcoinbase method shields transparent coinbase funds by sending the funds to a shielded z address. :param fromaddress: (string, required) the address is a t address or "*" for all t address belonging to the wallet :param toaddress: (string, required) the address is a z address :param fee: (numeric, optional, default=0.0001) the fee amount to attach to this transaction :param limit: (numeric, optional, default=50) limit on the maximum number of utxos to shield; set to 0 to use node option mempooltxinputlimit :return: JSON string: "remainingUTXOs" (numeric) the number of coinbase utxos still available for shielding "remainingValue" (numeric) the value of coinbase utxos still available for shielding "shieldingUTXOs" (numeric) the number of coinbase utxos being shielded "shieldingValue" (numeric) the value of coinbase utxos being shielded "opid" (string) an operationid to pass to z_getoperationstatus to get the result of the operation ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "z_shieldcoinbase", ' \ '"params": ["'+str(fromaddress)+'", "'+\ str(toaddress)+(', '+str(fee) if fee != 0.0001 else '')+\ (', '+str(limit) if limit != 50 else '')+\ '"] }' return rpc.rpc_request(data)
def z_listunspent(minconf=1, maxconf=9999999, includeWatchOnly=False, addresses=['']): ''' The z_listunspent method returns an array of unspent shielded notes :param minconf: (numeric, optional, default=1) the minimum confirmations to filter :param maxconf: (numeric, optional, default=9999999) the maximum confirmations to filter :param includeWatchOnly: (bool, optional, default=false) whether to also include watchonly addresses :param addresses: [string] a list of z addresses (both Sprout and Sapling) to act as a filter; duplicate addresses are not allowed :return: JSON string ''' addr_list = "[" for addr in addresses: addr_list += "\"" + str(addr) + "\"," if (len(addresses) > 0): addr_list = addr_list[:-1] addr_list += "]" data = '{'+rpc.get_request_metadata()+', ' \ '"method": "z_listunspent", ' \ '"params": ['+str(minconf)+', '+str(maxconf)+\ ', '+str(includeWatchOnly).lower()+', '+addr_list+'] }' return rpc.rpc_request(data)
def z_listreceivedbyaddress(address='', minconf=1): ''' The z_listreceivedbyaddress method returns a list of amounts received by a z address belonging to the node’s wallet. :param address: (string) the private address. :param minconf: (numeric, optional, default=1) only include transactions confirmed at least this many times :return: JSON string: txid (string) the transaction id amount (numeric) the amount of value in the note memo (string ) hexadecimal string representation of memo field "confirmations" (numeric) a confirmation number that is dPoW aware; "rawconfirmations" (numeric) the raw confirmations (number of blocks on top of this transaction's block) jsindex (sprout) (numeric, received only by sprout addresses) the joinsplit index jsoutindex (numeric, received only by sprout addresses) the output index of the joinsplit outindex (numeric, sapling) the output index change (boolean) true if the address that received the note is also one of the sending addresses ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "z_listreceivedbyaddress", ' \ '"params": ["'+str(address)+'", '+str(minconf)+'] }' return rpc.rpc_request(data)
def z_getoperationresult(operationid=['']): ''' The z_getoperationresult method retrieves the result and status of an operation which has finished, and then removes the operation from memory :param operationid: [string, optional] a list of operation ids to query; if not provided, the method examines all operations known to the node :return: JSON String "id" (string) the operation id "status" (string) the result of the operation; can be success "creation_time" (numeric) the creation time, in seconds since epoch (Jan 1 1970 GMT) "result": { ... } (array of json objects) "txid": (string) the transaction id "execution_secs" (numeric) the length of time to calculate the transaction "method" (string) the name of the method used in the operation "params": { ... } (json) "fromaddress" (string) the address from which funds are drawn "amounts": [ ... ] (array of json objects) "address" (string) the receiving address "amount" (numeric) the amount to receive "minconf" (numeric) the minimum number of confirmations required "fee" (numeric) the transaction fee ''' oppid_list = "[" for oppid in operationid: oppid_list += "\"" + str(oppid) + "\"," if (len(operationid) > 0): oppid_list = oppid_list[:-1] oppid_list += "]" data = '{' + rpc.get_request_metadata( ) + ', "method": "z_getoperationresult", "params": [' + oppid_list + '] }' return rpc.rpc_request(data)
def getblocktemplate(mode='', capabilities=[''], support=''): ''' The getblocktemplate method returns data that is necessary to construct a block. :param mode: (string, optional) this must be set to "template" or omitted :param capabilities: [string, optional] a list of capability strings :param support: (string) client side supported features: "longpoll", "coinbasetxn", "coinbasevalue", "proposal", "serverlist", "workid" :return: JSON string with details necessary to construct a block. ''' cap_list = '[' for cap in capabilities: cap_list += '"' + cap + '",' if (len(capabilities) > 0): cap_list = cap_list[:-1] cap_list += ']' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getblocktemplate", ' \ '"params": [{' +\ ('"mode":"'+str(mode)+'",' if mode != '' else '')+\ ('"capabilities:"'+cap_list if (len(capabilities) > 0 and capabilities[0] != '') else '') +\ ('"support":"'+support+'"' if support != '' else '') +\ '}] }' return rpc.rpc_request(data)
def getwalletinfo(): ''' The getwalletinfo method returns an object containing various information about the wallet state. :return: JSON string: "walletversion" (numeric) the wallet version "balance" (numeric) the total confirmed balance of the wallet "unconfirmed_balance" (numeric) the total unconfirmed balance of the wallet "immature_balance" (numeric) the total immature balance of the wallet "txcount" (numeric) the total number of transactions in the wallet "keypoololdest" (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool "keypoolsize" (numeric) how many new keys are pre-generated "unlocked_until" (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" (numeric) the transaction fee configuration, given as the relevant COIN per KB ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getwalletinfo", ' \ '"params": [] }' return rpc.rpc_request(data)
def getaddressdeltas(addresses=[""], start=0, end=0, chainInfo=False): ''' The getaddressdeltas method returns all confirmed balance changes of an address. :param addresses: [string] a list of addresses :param start: (number) the start block height :param end: (number) the end block height :param chainInfo:(boolean) include chain info in results (only applies if start and end specified) :return: JSON string containing: "satoshis" (number) the difference in satoshis "txid" (string) the related transaction id "index" (number) the related input or output index "height" (number) the block height "address" (string) the address ''' addr_list = "[" for addr in addresses: addr_list += "\"" + str(addr) + "\"," if (len(addresses) > 0): addr_list = addr_list[:-1] addr_list += "]" data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getaddressdeltas", ' \ '"params": [{"addresses": ' + str(addr_list) +\ ',"start":' + str(start) + ',"end":' + str(end) +\ ',"chainInfo":' + str(chainInfo).lower() + '}]}' return rpc.rpc_request(data)
def notaries(height=0, timestamp=0): ''' The notaries method returns the public key, BTC address, and KMD address for each Komodo notary node. Either or both of the height and timestamp parameters will suffice. :param height: (number) the block height desired for the query :param timestamp: (number) the timestamp of the block desired for the query :return: JSON string containing: "notaries": [ ... ] (array) "pubkey" (string) the public signing key of the indicated notary node, used on the KMD network to create notary-node authorized transactions "BTCaddress" (string) the public BTC address the notary node uses on the BTC blockchain to create notarizations "KMDaddress" (string) the public KMD address the notary node uses on the KMD blockchain to create notarizations "numnotaries" (number) the number of notary nodes; typically this value is 64, but the value may vary on rare circumstances, such as during election seasons "height" (number) the block height number at which the notary-node information applies "timestamp" (number) the timestamp at which the notary-node information applies ''' options = ('"' + str(height) + '", "' + str(timestamp) + '"' if (height != 0 and timestamp != 0) else ('"' + str(height) + '"' if height > 0 else (('"' + str(timestamp) + '"' if timestamp > 0 else '')))) data = '{'+rpc.get_request_metadata()+', ' \ '"method": "notaries", ' \ '"params": ['+options+'] ' \ '}' return rpc.rpc_request(data)
def getblock(block_id=1, verbose=True): ''' The getblock method returns the block's relevant state information :param block_id: (string OR number) block_id can be block-hash (string) OR block-height (number) :param verbose: (boolean, optional, default=true) true returns a json object, false returns hex-encoded data :return: JSON string containing: "hash" (string) the block hash (same as provided hash) "confirmations" (numeric) a confirmation num that is dPoW aware "rawconfirmations" (numeric) the raw confirmations (number of blocks on top of this block); the returned value is -1 if the block is not on the main chain "size" (numeric) the block size "height" (numeric) the block height or index (same as provided height) "version" (numeric) the block version "merkleroot" (string) the merkle root "tx" ["tx_id",...] array of strings "time" (numeric) the block time in seconds since epoch "nonce" (numeric) the nonce "bits" (string) the bits "difficulty" (numeric) the difficulty "previousblockhash" (string) the hash of the previous block "nextblockhash" (string) the hash of the next block ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getblock", ' \ '"params": ["'+str(block_id)+'", '+str(verbose).lower()+']' \ ' }' return rpc.rpc_request(data)
def getaddressmempool(addresses=[""]): ''' The getaddressmempool method returns all mempool deltas for an address, or addresses. It requires addressindex to be enabled. :param addresses: [string] a list of addresses :return: JSON string containing: "address" (string) the address "txid" (string) the related txid "index" (number) the related input or output index "satoshis" (number) the difference in satoshis "timestamp" (number) the time the transaction entered the mempool (seconds) "prevtxid" (string) the previous txid (if spending) "prevout" (string) the previous transaction output index (if spending) ''' addr_list = "[" for addr in addresses: addr_list += "\"" + str(addr) + "\"," if (len(addresses) > 0): addr_list = addr_list[:-1] addr_list += "]" data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getaddressmempool", ' \ '"params": [{"addresses": ' + str(addr_list) + '}] }' return rpc.rpc_request(data)
def getchaintxstats(nblocks=1, blockhash=''): ''' The method getchaintxstats returns statistics about the total number and rate of transactions in the chain. :param nblocks: (numeric, optional) the number of blocks in the averaging window. :param blockhash: (string, optional) the hash of the block which ends the window :return: JSON string containing: "time" (numeric) the timestamp for the final block in the window "txcount" (numeric) the total number of transactions in the chain up to this point "window_final_block_hash" (string) the hash of the final block in the window "window_block_count" (numeric) the size of the window in the number of blocks "window_tx_count" (numeric) the number of transactions in the window; this value is only returned if window_block_count is > 0. "window_interval" (numeric) the elapsed time in the window in seconds; this value is only returned if window_block_count is > 0. "txrate" (numeric) the average rate of transactions per second in the window; this value is only returned if window_interval is > 0 ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getchaintxstats", ' \ '"params": ['+str(nblocks)+', "'+str(blockhash)+'"] ' \ '}' return rpc.rpc_request(data)
def createrawtransaction(transactions={'': 0}, amounts={'', 0.0}): ''' The createrawtransaction method creates a transaction, spending the given inputs and sending to the given addresses. :param transactions: {string, number} a dictinary of txid (string) as key and vout (number) as value. :param amounts: {string, number} a dictinary of address (string) as key and amount (number) as value. :return: "transaction" (JSON string) a hex string of the transaction ''' tx_list = '[' for tx_id in transactions: tx_list += '{"txid":"' + tx_id + '", "vout": ' +\ str(transactions[tx_id]) + '},' if (len(transactions) > 0): tx_list = tx_list[:-1] tx_list += ']' amount_list = '{' for addr in amounts: amount_list += '"' + addr + '":' + str(amounts[addr]) + ',' if (len(amounts) > 0): amount_list = amount_list[:-1] amount_list += '}' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "createrawtransaction", ' \ '"params": ['+tx_list+', '+amount_list+'] }' return rpc.rpc_request(data)
def getaddressutxos(addresses=[""], chainInfo=False): ''' The getaddressutxos method returns all unspent outputs for an address. It requires addressindex to be enabled. :param addresses: [string] a list of addreses :param chainInfo: (boolean) include chain info with results :return: JSON string containing: "address" (string) the address "txid" (string) the output txid "height" (number) the block height "outputIndex" (number) the output index "script" (string) the script hex encoded "satoshis" (number) the number of satoshis of the output ''' addr_list = "[" for addr in addresses: addr_list += "\"" + str(addr) + "\"," if (len(addresses) > 0): addr_list = addr_list[:-1] addr_list += "]" data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getaddressutxos", ' \ '"params": [{"addresses": ' + str(addr_list) +\ ', "chainInfo": ' + str(chainInfo).lower() + '}] }' return rpc.rpc_request(data)
def kvupdate(key='', value='', days=1, passphrase=''): ''' The kvupdate method stores a key/value pair via OP_RETURN. :param key: (string, required) key (should be unique) :param value: (string, required) value :param days: (numeric, required) amount of days before the key expires (1440 blocks/day); minimum 1 day :param passphrase: (string, optional) passphrase required to update this key :return: JSON string containing: "coin" (string) the chain on which the key is stored "height" (numeric) the height at which the key was stored "expiration" (numeric) the height at which the key will expire "flags" (string the amount of days the key will be stored "key" (numeric) the stored key "keylen" (numeric) the length of the key "value" (numeric) the stored value "valuesize" (string) the length of the stored value "fee" (string) the transaction fee paid to store the key "txid" (string) the transaction id ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "kvupdate", ' \ '"params": ["'+str(key)+'","'+str(value)+'","'+str(days)+\ '", "'+str(passphrase)+'"] ' \ '}' return rpc.rpc_request(data)
def getrawmempool(verbose=False): ''' The getrawmempool method returns all transaction ids in the memory pool as a json array of transaction ids. :param verbose: (boolean, optional, default=false) true for a json object, false for a json array of transaction ids :return: JSON string, if verbose=False: "transaction_id" (string) the transaction id, if verbose=True: "transaction_id": { .... } (json object) "size" (numeric) the transaction size in bytes "fee" (numeric) the transaction fee "time" (numeric) the local time transaction entered pool in seconds since 1 Jan 1970 GMT "height" (numeric) the block height wherein the transaction entered the mempool "startingpriority" (numeric) the priority when the transaction entered the mempool "currentpriority" (numeric) the transaction priority at the current height "depends": { ... } (array) unconfirmed transactions used as inputs for this transaction "transaction_id" (string) the parent transaction id ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getrawmempool", ' \ '"params": ['+str(verbose).lower()+'] ' \ '}' return rpc.rpc_request(data)
def clearbanned(): ''' The clearbanned method clears all banned IPs :return: JSON string ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "clearbanned", "params": [] }' return rpc.rpc_request(data)
def getinfo(): ''' The getinfo method returns an object containing various state info :return: JSON string conataining wallet state and network state info ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getinfo", ' \ '"params": [] }' return rpc.rpc_request(data)
def stop(): ''' The stop method instructs the coin daemon to shut down. :return: JSON string: Komodo server stopping ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "stop", ' \ '"params": [] }' return rpc.rpc_request(data)
def getconnectioncount(): ''' The getconnectioncount method returns the number of connections to other nodes. :return: n (numeric) the connection count ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getconnectioncount", "params": [] }' return rpc.rpc_request(data)
def getnetworkinfo(): ''' The getnetworkinfo method returns an object containing various state info regarding p2p networking. :return: JSON string with various state info regarding p2p networking. ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getnetworkinfo", "params": [] }' return rpc.rpc_request(data)
def getlocalsolps(): ''' The getlocalsolps method returns the average local solutions per second since this node was started. :return: "data" (numeric) the solutions-per-second average ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getlocalsolps", ' \ '"params": [] }' return rpc.rpc_request(data)
def disconnectnode(node=''): ''' The disconnectnode method instructs the daemon to immediately disconnect from the specified node. :param node: (string, required) node_ip:port :return: JSON string ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "disconnectnode", "params": ["' + str(node) + '"] }' return rpc.rpc_request(data)
def z_getnewaddress(): ''' The z_getnewaddress method returns a new z_address for receiving payments :return: "z_address" (JSON string) the new z_address ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "z_getnewaddress", ' \ '"params": [] }' return rpc.rpc_request(data)
def ping(): ''' The ping method requests that a ping be sent to all other nodes, to measure ping time. :return: JSON string ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "ping", ' \ '"params": [] }' return rpc.rpc_request(data)
def getmininginfo(): ''' The getmininginfo method returns a json object containing mining-related information. :return: JSON string with mining-related information. ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "getmininginfo", ' \ '"params": [] }' return rpc.rpc_request(data)
def jumblr_resume(): ''' The jumblr_resume method instructs Jumblr to resume the privacy-shielding process. :return: JSON string ''' data = '{'+rpc.get_request_metadata()+', ' \ '"method": "jumblr_resume", ' \ '"params": [] }' return rpc.rpc_request(data)
def walletlock(): ''' The walletlock method re-locks a wallet that has a passphrase enabled via encryptwallet. :return: JSON string ''' data = '{' + rpc.get_request_metadata() + ', ' \ '"method": "walletlock", ' \ '"params": [] }' return rpc.rpc_request(data)