nano package

Submodules

nano.accounts module

Accounts module

nano.accounts.KNOWN_ACCOUNT_IDS: dict of account ids => names eg.

>>> KNOWN_ACCOUNT_IDS['xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est']
'Developer Fund'

nano.accounts.KNOWN_ACCOUNT_NAMES: dict of names => account ids

>>> KNOWN_ACCOUNT_NAMES['Burn']
'xrb_1111111111111111111111111111111111111111111111111111hifc8npp'
nano.accounts.generate_account(seed=None, index=0)[source]

Generates an adhoc account and keypair

>>> account = generate_account(seed=unhexlify('0'*64))
{'address': u'xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7',
 'private_key_bytes': 'ŸDLi÷zI½
蝹,8þq> cÊúõq-vW’,
‘private_key_hex’: ‘9f0e444c69f77a49bd0be89db92c38fe713e0963165cca12faf5712d7657120f’, ‘public_key_bytes’: ‘À¸§Òi¡ú<e(±’¢Myyۙ–ÿ¡ÿ5nEU+’, ‘public_key_hex’: ‘c008b814a7d269a1fa3c6528b19201a24d797912db9996ff02a1ff356e45552b’}
param seed:the seed in bytes to use to generate the account, if not provided one is generated randomly
type seed:bytes
param index:the index offset for deterministic account generation
type index:int
return:dict containing the account address and pub/priv keys in hex/bytes
rtype:dict
nano.accounts.public_key_to_xrb_address(public_key)[source]

Convert public_key (bytes) to an xrb address

>>> public_key_to_xrb_address(b'00000000000000000000000000000000')
'xrb_1e3i81r51e3i81r51e3i81r51e3i81r51e3i81r51e3i81r51e3imxssakuq'
Parameters:public_key (bytes) – public key in bytes
Returns:xrb address
Return type:str
nano.accounts.xrb_address_to_public_key(address)[source]

Convert an xrb address to public key in bytes

>>> xrb_address_to_public_key('xrb_1e3i81r51e3i81r51e3i81r51e3i'                                  '81r51e3i81r51e3i81r51e3imxssakuq')
b'00000000000000000000000000000000'
Parameters:address (bytes) – xrb address
Returns:public key in bytes
Return type:bytes
Raises:ValueError

nano.blocks module

nano.blocks.GENESIS_BLOCK_HASH = '991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948'

Genesis block hash

nano.conversion module

Conversion tools for converting xrb

Gxrb = 1000000000000000000000000000000000raw, 10^33

Mxrb = 1000000000000000000000000000000raw, 10^30

kxrb = 1000000000000000000000000000raw, 10^27

xrb = 1000000000000000000000000raw, 10^24

mxrb = 1000000000000000000000raw, 10^21

uxrb = 1000000000000000000raw, 10^18

1 Mxrb used to be also called 1 Mrai 1 xrb is 10^24 raw 1 raw is the smallest possible division

Mrai are XRB 1rai = 1000krai = 1,000,000mrai = 0,000001 XRB

nano.conversion.convert(value, from_unit, to_unit)[source]

Converts a value from from_unit units to to_unit units

Parameters:
  • value (int or str or decimal.Decimal) – value to convert
  • from_unit (str) – unit to convert from
  • to_unit (str) – unit to convert to
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015')

nano.rpc module

class nano.rpc.Client(host='http://localhost:7076', session=None, timeout=3)[source]

Bases: object

Nano (RaiBlocks) node RPC client

Parameters:
  • host – RPC server host, defaults to ‘http://localhost:7076’
  • session – optional requests.Session session to use for this client
>>> from nano.rpc import Client
>>> rpc = Client('http://localhost:7076')
>>> rpc.version()
{
    'rpc_version': 1,
    'store_version': 10,
    'node_vendor': 'RaiBlocks 9.0'
}
account_balance(account)[source]

Returns how many RAW is owned and how many have not yet been received by account

Parameters:account (str) – Account id to return balance of
Raises:nano.rpc.RPCException
>>> rpc.account_balance(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
... )
{
  "balance": 10000,
  "pending": 10000
}
account_block_count(account)[source]

Get number of blocks for a specific account

Parameters:account (str) – Account to get number of blocks for
Raises:nano.rpc.RPCException
>>> rpc.account_block_count(account="xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")
19
account_create(wallet, work=True)[source]

Creates a new account, insert next deterministic key in wallet

Parameters:
  • wallet (str) – Wallet to insert new account into
  • work (bool) – If false, disables work generation after creating account
Raises:

nano.rpc.RPCException

>>> rpc.account_create(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
account_get(key)[source]

Get account number for the public key

Parameters:key (str) – Public key to get account for
Raises:nano.rpc.RPCException
>>> rpc.account_get(
...    key="3068BB1CA04525BB0E416C485FE6A67FD52540227D267CC8B6E8DA958A7FA039"
... )
"xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"
account_history(account, count)[source]

Reports send/receive information for a account

Parameters:
  • account (str) – Account to get send/receive information for
  • count (int) – number of blocks to return
Raises:

nano.rpc.RPCException

>>> rpc.account_history(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     count=1
... )
[
    {
      "hash": "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
      "type": "receive",
      "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
      "amount": 100000000000000000000000000000000
    }
]
account_info(account, representative=False, weight=False, pending=False)[source]

Returns frontier, open block, change representative block, balance, last modified timestamp from local database & block count for account

Parameters:
  • account (str) – Account to return info for
  • representative (bool) – if True, also returns the representative block
  • weight (bool) – if True, also returns the voting weight
  • pending (bool) – if True, also returns the pending balance
Raises:

nano.rpc.RPCException

>>> rpc.account_info(
...     account="xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3"
... )
{
  "frontier": "FF84533A571D953A596EA401FD41743AC85D04F406E76FDE4408EAED50B473C5",
  "open_block": "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948",
  "representative_block": "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948",
  "balance": "235580100176034320859259343606608761791",
  "modified_timestamp": "1501793775",
  "block_count": "33"
}
account_key(account)[source]

Get the public key for account

Parameters:account (str) – Account to get public key for
Raises:nano.rpc.RPCException
>>> rpc.account_key(
...     account="xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"
... )
"3068BB1CA04525BB0E416C485FE6A67FD52540227D267CC8B6E8DA958A7FA039"
account_list(wallet)[source]

Lists all the accounts inside wallet

Parameters:wallet (str) – Wallet to get account list for
Raises:nano.rpc.RPCException
>>> rpc.account_list(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
[
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
]
account_move(source, wallet, accounts)[source]

Moves accounts from source to wallet

Parameters:
  • source (str) – wallet to move accounts from
  • wallet (str) – wallet to move accounts to
  • accounts (list of str) – accounts to move
Raises:

nano.rpc.RPCException

>>> rpc.account_move(
...     source="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     accounts=[
...         "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
...     ]
... )
True
account_remove(wallet, account)[source]

Remove account from wallet

Parameters:
  • wallet (str) – Wallet to remove account from
  • account (str) – Account to remove
Raises:

nano.rpc.RPCException

>>> rpc.account_remove(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi"
... )
True
account_representative(account)[source]

Returns the representative for account

Parameters:account (str) – Account to get representative for
Raises:nano.rpc.RPCException
>>> rpc.account_representative(
...     account="xrb_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi"
)
"xrb_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5"
account_representative_set(wallet, account, representative, work=None)[source]

Sets the representative for account in wallet

Parameters:
  • wallet (str) – Wallet to use for account
  • account (str) – Account to set representative for
  • representative (str) – Representative to set to
  • work (str) – If set, is used as the work for the block
Raises:

nano.rpc.RPCException

>>> rpc.account_representative_set(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_39a73oy5ungrhxy5z5oao1xso4zo7dmgpjd4u74xcrx3r1w6rtazuouw6qfi",
...     representative="xrb_16u1uufyoig8777y6r8iqjtrw8sg8maqrm36zzcm95jmbd9i9aj5i8abr8u5"
... )
"000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
account_weight(account)[source]

Returns the voting weight for account

Parameters:account (str) – Account to get voting weight for
Raises:nano.rpc.RPCException
>>> rpc.account_weight(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
... )
10000
accounts_balances(accounts)[source]

Returns how many RAW is owned and how many have not yet been received by accounts list

Parameters:accounts (list of str) – list of accounts to return balances for
Raises:nano.rpc.RPCException
>>> rpc.accounts_balances(
...     accounts=[
...         "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...         "xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7"
...      ]
... )
{
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000": {
        "balance": 10000,
        "pending": 10000
    },
    "xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7": {
        "balance": 10000000,
        "pending": 0
    }
}
accounts_create(wallet, count, work=True)[source]

Creates new accounts, insert next deterministic keys in wallet up to count

Parameters:
  • wallet (str) – Wallet to create new accounts in
  • count (int) – Number of accounts to create
  • work (bool) – If false, disables work generation after creating account
Raises:

nano.rpc.RPCException

>>> rpc.accounts_create(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     count=2
... )
[
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3s00000000"
]
accounts_frontiers(accounts)[source]

Returns a list of pairs of account and block hash representing the head block for accounts list

Parameters:accounts (list of str) – Accounts to return frontier blocks for
Raises:nano.rpc.RPCException
>>> rpc.accounts_frontiers(
...     accounts=[
...         "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3",
...         "xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7"
...     ]
... )
{
    "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3":
        "791AF413173EEE674A6FCF633B5DFC0F3C33F397F0DA08E987D9E0741D40D81A",
    "xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7":
        "6A32397F4E95AF025DE29D9BF1ACE864D5404362258E06489FABDBA9DCCC046F"
}
accounts_pending(accounts, count=None, threshold=None, source=False)[source]

Returns a list of block hashes which have not yet been received by these accounts

Parameters:
  • accounts (list of str) – Accounts to return list of block hashes for
  • count (int) – Max number of blocks to returns
  • threshold (int) – Minimum amount in raw per block
  • source (bool) – if True returns the source as well
Raises:

nano.rpc.RPCException

>>> rpc.accounts_pending(
...     accounts=[
...         "xrb_1111111111111111111111111111111111111111111111111117353trpda",
...         "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3"
...     ],
...     count=1
... )
{
    "xrb_1111111111111111111111111111111111111111111111111117353trpda": [
        "142A538F36833D1CC78B94E11C766F75818F8B940771335C6C1B8AB880C5BB1D"
    ],
    "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3": [
        "4C1FEEF0BEA7F50BE35489A1233FE002B212DEA554B55B1B470D78BD8F210C74"
    ]
}
available_supply()[source]

Returns how many rai are in the public supply

Raises:nano.rpc.RPCException
>>> rpc.available_supply()
10000
block(hash)[source]

Retrieves a json representation of block

Parameters:hash (str) – Hash of block to return representation for
Raises:nano.rpc.RPCException
>>> rpc.block(
...     hash="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
    "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "work": "0000000000000000",
    "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
    "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "type": "open"
}
block_account(hash)[source]

Returns the account containing block

Parameters:hash (str) – Hash of the block to return account for
Raises:nano.rpc.RPCException
>>> rpc.block_account(
...     hash="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
block_count()[source]

Reports the number of blocks in the ledger and unchecked synchronizing blocks

Raises:nano.rpc.RPCException
>>> rpc.block_count()
{
  "count": 1000,
  "unchecked": 10
}
block_count_type()[source]

Reports the number of blocks in the ledger by type (send, receive, open, change)

Raises:nano.rpc.RPCException
>>> rpc.block_count_type()
{
  "send": 1000,
  "receive": 900,
  "open": 100,
  "change": 50
}
block_create(type, account, wallet=None, representative=None, key=None, destination=None, amount=None, balance=None, previous=None, source=None, work=None)[source]

Creates a json representations of new block based on input data & signed with private key or account in wallet for offline signing

Parameters:
  • type (str) – Type of block to create one of open, receive, change, send
  • account (str) – Account for the signed block
  • wallet (str) – Wallet to use
  • representative (str) – Representative account for open and change blocks
  • key (str) – Private key to use to open account for open blocks
  • destination (str) – Destination account for send blocks
  • amount (int) – Amount in raw for send blocks
  • balance (int) – Balance in raw of account for send blocks
  • previous (str) – Previous block hash for receive, send and change blocks
  • source (str) – Source block for open and receive blocks
  • work (str) – Work value to use for block from external source
Raises:

nano.rpc.RPCException

>>> rpc.block_create(
...     type="open",
...     account="xrb_3kdbxitaj7f6mrir6miiwtw4muhcc58e6tn5st6rfaxsdnb7gr4roudwn951",
...     source="19D3D919475DEED4696B5D13018151D1AF88B2BD3BCFF048B45031C1F36D1858",
...     representative="xrb_1hza3f7wiiqa7ig3jczyxj5yo86yegcmqk3criaz838j91sxcckpfhbhhra1",
...     key="0000000000000000000000000000000000000000000000000000000000000001"
... )
{
    "block": {
        "account": "xrb_3kdbxitaj7f6mrir6miiwtw4muhcc58e6tn5st6rfaxsdnb7gr4roudwn951",
        "representative": "xrb_1hza3f7wiiqa7ig3jczyxj5yo86yegcmqk3criaz838j91sxcckpfhbhhra1",
        "signature": "5974324F8CC42DA56F62FC212A17886BDCB18DE363D04DA84EEDC99CB4A33919D14A2CF9DE9D534FAA6D0B91D01F0622205D898293525E692586C84F2DCF9208",
        "source": "19D3D919475DEED4696B5D13018151D1AF88B2BD3BCFF048B45031C1F36D1858",
        "type": "open",
        "work": "4ec76c9bda2325ed"
    },
    "hash": "F47B23107E5F34B2CE06F562B5C435DF72A533251CB414C51B2B62A8F63A00E4"
}
>>> rpc.block_create(
...     type="receive",
...     account="xrb_3kdbxitaj7f6mrir6miiwtw4muhcc58e6tn5st6rfaxsdnb7gr4roudwn951",
...     previous="F47B23107E5F34B2CE06F562B5C435DF72A533251CB414C51B2B62A8F63A00E4",
...     source="19D3D919475DEED4696B5D13018151D1AF88B2BD3BCFF048B45031C1F36D1858",
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
... )
{
    "block": {
        "previous": "F47B23107E5F34B2CE06F562B5C435DF72A533251CB414C51B2B62A8F63A00E4",
        "signature": "A13FD22527771667D5DFF33D69787D734836A3561D8A490C1F4917A05D77EA09860461D5FBFC99246A4EAB5627F119AD477598E22EE021C4711FACF4F3C80D0E",
        "source": "19D3D919475DEED4696B5D13018151D1AF88B2BD3BCFF048B45031C1F36D1858",
        "type": "receive",
        "work": "6acb5dd43a38d76a"
    },
    "hash": "314BA8D9057678C1F53371C2DB3026C1FAC01EC8E7802FD9A2E8130FC523429E"
}
>>> rpc.block_create(
...     type="send",
...     account="xrb_3kdbxitaj7f6mrir6miiwtw4muhcc58e6tn5st6rfaxsdnb7gr4roudwn951",
...     amount=10000000000000000000000000000000,
...     balance=20000000000000000000000000000000,
...     destination="xrb_18gmu6engqhgtjnppqam181o5nfhj4sdtgyhy36dan3jr9spt84rzwmktafc",
...     previous="314BA8D9057678C1F53371C2DB3026C1FAC01EC8E7802FD9A2E8130FC523429E",
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     work="478563b2d9facfd4",
... )
{
    "block": {
        "balance": "0000007E37BE2022C0914B2680000000",
        "destination": "xrb_18gmu6engqhgtjnppqam181o5nfhj4sdtgyhy36dan3jr9spt84rzwmktafc",
        "previous": "314BA8D9057678C1F53371C2DB3026C1FAC01EC8E7802FD9A2E8130FC523429E",
        "signature": "F19CA177EFA8692C8CBF7478CE3213F56E4A85DF760DA7A9E69141849831F8FD79BA9ED89CEC807B690FB4AA42D5008F9DBA7115E63C935401F1F0EFA547BC00",
        "type": "send",
        "work": "478563b2d9facfd4"
    },
    "hash": "F958305C0FF0551421D4ABEDCCF302079D020A0A3833E33F185E2B0415D4567A"
}
>>> rpc.block_create(
...     type="change",
...     account="xrb_3kdbxitaj7f6mrir6miiwtw4muhcc58e6tn5st6rfaxsdnb7gr4roudwn951",
...     representative="xrb_18gmu6engqhgtjnppqam181o5nfhj4sdtgyhy36dan3jr9spt84rzwmktafc",
...     previous="F958305C0FF0551421D4ABEDCCF302079D020A0A3833E33F185E2B0415D4567A",
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
... )
{
    "block": {
        "previous": "F958305C0FF0551421D4ABEDCCF302079D020A0A3833E33F185E2B0415D4567A",
        "representative": "xrb_18gmu6engqhgtjnppqam181o5nfhj4sdtgyhy36dan3jr9spt84rzwmktafc",
        "signature": "98B4D56881D9A88B170A6B2976AE21900C26A27F0E2C338D93FDED56183B73D19AA5BEB48E43FCBB8FF8293FDD368CEF50600FECEFD490A0855ED702ED209E04",
        "type": "change",
        "work": "55e5b7a83edc3f4f"
    },
    "hash": "654FA425CEBFC9E7726089E4EDE7A105462D93DBC915FFB70B50909920A7D286"
}
blocks(hashes)[source]

Retrieves a json representations of blocks

Parameters:hashes (list of str) – List of block hashes to return
Raises:nano.rpc.RPCException
>>> rpc.blocks(
...     hashes=["000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"]
... )
{
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F": {
        "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
        "work": "0000000000000000",
        "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
        "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
        "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "type": "open"
    }
}
blocks_info(hashes, pending=False, source=False)[source]

Retrieves a json representations of blocks with transaction amount & block account

Parameters:
  • hashes (list of str) – List of block hashes to return info for
  • pending (bool) – If true, returns pending amount as well
  • source (bool) – If true, returns source account as well
Raises:

nano.rpc.RPCException

>>> rpc.blocks_info(hashes=["000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"])
{
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F": {
        "block_account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
        "amount": "1000000000000000000000000000000",
        "contents": {
            "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
            "work": "0000000000000000",
            "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
            "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
            "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "type": "open"
        }
    }
}
bootstrap(address, port)[source]

Initialize bootstrap to specific IP address and port

Parameters:
  • address (str) – Ip address to bootstrap
  • port (int) – Port to bootstrap
Raises:

nano.rpc.RPCException

>>> rpc.bootstrap(address="::ffff:138.201.94.249", port="7075")
True
bootstrap_any()[source]

Initialize multi-connection bootstrap to random peers

Raises:nano.rpc.RPCException
>>> rpc.bootstrap_any()
True
call(action, params=None)[source]

Makes an RPC call to the server and returns the json response

Parameters:
  • action (str) – RPC method to call
  • params (dict) – Dict of arguments to send with RPC call
Raises:

nano.rpc.RPCException

Raises:

requests.exceptions.RequestException

>>> rpc.call(
...     action='account_balance',
...     params={
...         'account': xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3'
...     })
{'balance': '325586539664609129644855132177',
 'pending': '2309370940000000000000000000000000'}
chain(block, count)[source]

Returns a list of block hashes in the account chain starting at block up to count

Parameters:
  • block (str) – Block hash to start at
  • count (int) – Number of blocks to return up to
Raises:

nano.rpc.RPCException

>>> rpc.chain(
...     block="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     count=1
... )
[
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
]
delegators(account)[source]

Returns a list of pairs of delegator names given account a representative and its balance

Parameters:account (str) – Account to return delegators for
Raises:nano.rpc.RPCException
>>> rpc.delegators(
...     account="xrb_1111111111111111111111111111111111111111111111111117353trpda"
... )
{
    "xrb_13bqhi1cdqq8yb9szneoc38qk899d58i5rcrgdk5mkdm86hekpoez3zxw5sd":
        "500000000000000000000000000000000000",
    "xrb_17k6ug685154an8gri9whhe5kb5z1mf5w6y39gokc1657sh95fegm8ht1zpn":
        "961647970820730000000000000000000000"
}
delegators_count(account)[source]

Get number of delegators for a specific representative account

Parameters:account (str) – Account to get number of delegators for
Raises:nano.rpc.RPCException
>>> rpc.delegators_count(
...     account="xrb_1111111111111111111111111111111111111111111111111117353trpda"
... )
2
deterministic_key(seed, index)[source]

Derive deterministic keypair from seed based on index

Parameters:
  • seed (str) – Seed used to get keypair
  • index (int) – Index of the generated keypair
Raises:

nano.rpc.RPCException

>>> rpc.deterministic_key(
...     seed="0000000000000000000000000000000000000000000000000000000000000000",
...     index=0
... )
{
  "private": "9F0E444C69F77A49BD0BE89DB92C38FE713E0963165CCA12FAF5712D7657120F",
  "public": "C008B814A7D269A1FA3C6528B19201A24D797912DB9996FF02A1FF356E45552B",
  "account": "xrb_3i1aq1cchnmbn9x5rsbap8b15akfh7wj7pwskuzi7ahz8oq6cobd99d4r3b7"
}
frontier_count()[source]

Reports the number of accounts in the ledger

Raises:nano.rpc.RPCException
>>> rpc.frontier_count()
1000
frontiers(account, count)[source]

Returns a list of pairs of account and block hash representing the head block starting at account up to count

Parameters:
  • account (str) – Account to get frontier blocks for
  • count (int) – Max amount to return
Raises:

nano.rpc.RPCException

>>> rpc.frontiers(
...     account="xrb_1111111111111111111111111111111111111111111111111111hifc8npp",
...     count=1
... )
{
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000":
        "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
}
history(hash, count)[source]

Reports send/receive information for a chain of blocks

Parameters:
  • hash (str) – Hash of block to receive history for
  • count (int) – Max number of blocks to return
Raises:

nano.rpc.RPCException

>>> rpc.history(
...     hash="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     count=1
... )
[
    {
      "hash": "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
      "type": "receive",
      "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
      "amount": "100000000000000000000000000000000"
    }
]
keepalive(address, port)[source]

Tells the node to send a keepalive packet to address:port

Parameters:
  • address (str) – IP address of node to send keepalive packet to
  • port (int) – Port of node to send keepalive packet to
Raises:

nano.rpc.RPCException

>>> rpc.keepalive(address="::ffff:192.168.1.1", port=1024)
True
key_create()[source]

Generates an adhoc random keypair

Raises:nano.rpc.RPCException
>>> rpc.key_create()
{
  "private": "781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3",
  "public": "3068BB1CA04525BB0E416C485FE6A67FD52540227D267CC8B6E8DA958A7FA039",
  "account": "xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"
}
key_expand(key)[source]

Derive public key and account number from private key

Parameters:key (str) – Private key to generate account and public key of
Raises:nano.rpc.RPCException
>>> rpc.key_expand(
    key="781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3"
)
{
  "private": "781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3",
  "public": "3068BB1CA04525BB0E416C485FE6A67FD52540227D267CC8B6E8DA958A7FA039",
  "account": "xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"
}
krai_from_raw(amount)[source]

Divide a raw amount down by the krai ratio.

Parameters:amount (int) – Amount in raw to convert to krai
Raises:nano.rpc.RPCException
>>> rpc.krai_from_raw(amount=1000000000000000000000000000)
1
krai_to_raw(amount)[source]

Multiply an krai amount by the krai ratio.

Parameters:amount (int) – Amount in krai to convert to raw
Raises:nano.rpc.RPCException
>>> rpc.krai_to_raw(amount=1)
1000000000000000000000000000
ledger(account, count=None, representative=False, weight=False, pending=False, sorting=False)[source]

Returns frontier, open block, change representative block, balance, last modified timestamp from local database & block count starting at account up to count

Parameters:
  • account (str) – Account to return blocks for
  • count (int) – Max number of blocks to return
  • representative (bool) – If true, returns the representative as well
  • weight (bool) – If true, returns the voting weight as well
  • pending (bool) – If true, returns the pending amount as well
  • sorting (bool) – If true, sorts the response by balance
Raises:

nano.rpc.RPCException

>>> rpc.ledger(
...     account="xrb_1111111111111111111111111111111111111111111111111111hifc8npp",
...     count=1
... )
{
    "xrb_11119gbh8hb4hj1duf7fdtfyf5s75okzxdgupgpgm1bj78ex3kgy7frt3s9n": {
        "frontier": "E71AF3E9DD86BBD8B4620EFA63E065B34D358CFC091ACB4E103B965F95783321",
        "open_block": "643B77F1ECEFBDBE1CC909872964C1DBBE23A6149BD3CEF2B50B76044659B60F",
        "representative_block": "643B77F1ECEFBDBE1CC909872964C1DBBE23A6149BD3CEF2B50B76044659B60F",
        "balance": 0,
        "modified_timestamp": 1511476234,
        "block_count": 2
    }
}
mrai_from_raw(amount)[source]

Divide a raw amount down by the Mrai ratio.

Parameters:amount (int) – Amount in raw to convert to Mrai
Raises:nano.rpc.RPCException
>>> rpc.mrai_from_raw(amount=1000000000000000000000000000000)
1
mrai_to_raw(amount)[source]

Multiply an Mrai amount by the Mrai ratio.

Parameters:amount (int) – Amount in Mrai to convert to raw
Raises:nano.rpc.RPCException
>>> rpc.mrai_to_raw(amount=1)
1000000000000000000000000000000
password_change(wallet, password)[source]

Changes the password for wallet to password

Parameters:
  • wallet (str) – Wallet to change password for
  • password (str) – Password to set
Raises:

nano.rpc.RPCException

>>> rpc.password_change(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     password="test"
... )
True
password_enter(wallet, password)[source]

Enters the password in to wallet

Parameters:
  • wallet (str) – Wallet to enter password for
  • password (str) – Password to enter
Raises:

nano.rpc.RPCException

>>> rpc.password_enter(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     password="test"
... )
True
password_valid(wallet)[source]

Checks whether the password entered for wallet is valid

Parameters:wallet (str) – Wallet to check password for
Raises:nano.rpc.RPCException
>>> rpc.password_valid(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
payment_begin(wallet)[source]

Begin a new payment session. Searches wallet for an account that’s marked as available and has a 0 balance. If one is found, the account number is returned and is marked as unavailable. If no account is found, a new account is created, placed in the wallet, and returned.

Parameters:wallet (str) – Wallet to begin payment in
Raises:nano.rpc.RPCException
>>> rpc.payment_begin(
... wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
payment_end(account, wallet)[source]

End a payment session. Marks the account as available for use in a payment session.

Parameters:
  • account (str) – Account to mark available
  • wallet (str) – Wallet to end payment session for
Raises:

nano.rpc.RPCException

>>> rpc.payment_end(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     wallet="FFFD1BAEC8EC20814BBB9059B393051AAA8380F9B5A2E6B2489A277D81789EEE"
... )
True
payment_init(wallet)[source]

Marks all accounts in wallet as available for being used as a payment session.

Parameters:wallet (str) – Wallet to init payment in
Raises:nano.rpc.RPCException
>>> rpc.payment_init(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
payment_wait(account, amount, timeout)[source]

Wait for payment of amount to arrive in account or until timeout milliseconds have elapsed.

Parameters:
  • account (str) – Account to wait for payment
  • amount (int) – Amount in raw of funds to wait for payment to arrive
  • timeout (int) – Timeout in milliseconds to wait for
Raises:

nano.rpc.RPCException

>>> rpc.payment_wait(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     amount=1,
...     timeout=1000
... )
True
peers()[source]

Returns a list of pairs of peer IPv6:port and its node network version

Raises:nano.rpc.RPCException
>>> rpc.peers()
{
    "[::ffff:172.17.0.1]:32841": 3
}
pending(account, count=None, threshold=None, source=False)[source]

Returns a list of pending block hashes with amount more or equal to threshold

Parameters:
  • account (str) – Account to get list of pending block hashes for
  • count (int) – Max blocks to return
  • threshold (int) – Minimum amount in raw for blocks
  • source (bool) – If true, returns source address as well
Raises:

nano.rpc.RPCException

>>> rpc.pending(
...     account="xrb_1111111111111111111111111111111111111111111111111117353trpda"
... )
[
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
]
>>> rpc.pending(
...     account="xrb_1111111111111111111111111111111111111111111111111117353trpda",
...     count=1,
...     threshold=1000000000000000000000000
... )
{
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F": "6000000000000000000000000000000"
}
pending_exists(hash)[source]

Check whether block is pending by hash

Parameters:hash (str) – Hash of block to check if pending
Raises:nano.rpc.RPCException
>>> rpc.pending_exists(
    hash="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
)
True
process(block)[source]

Publish block to the network

Parameters:block (dict or json) – Block to publish
Raises:nano.rpc.RPCException
>>> block = {
    "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "work": "0000000000000000",
    "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
    "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "type": "open"
}
>>> rpc.process(block=block)
"42A723D2B60462BF7C9A003FE9A70057D3A6355CA5F1D0A57581000000000000"
>>> rpc.process(json.dumps(block))
"42A723D2B60462BF7C9A003FE9A70057D3A6355CA5F1D0A57581000000000000"
rai_from_raw(amount)[source]

Divide a raw amount down by the rai ratio.

Parameters:amount (int) – Amount in raw to convert to rai
Raises:nano.rpc.RPCException
>>> rpc.rai_from_raw(amount=1000000000000000000000000)
1
rai_to_raw(amount)[source]

Multiply an rai amount by the rai ratio.

Parameters:amount (int) – Amount in rai to convert to raw
Raises:nano.rpc.RPCException
>>> rpc.rai_to_raw(amount=1)
1000000000000000000000000
receive(wallet, account, block, work=None)[source]

Receive pending block for account in wallet

Parameters:
  • wallet (str) – Wallet of account to receive block for
  • account (str) – Account to receive block for
  • block (str) – Block hash to receive
  • work (str) – If set, uses this work for the receive block
Raises:

nano.rpc.RPCException

>>> rpc.receive(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     block="53EAA25CE28FA0E6D55EA9704B32604A736966255948594D55CBB05267CECD48",
...     work="12041e830ad10de1"
... )
"EE5286AB32F580AB65FD84A69E107C69FBEB571DEC4D99297E19E3FA5529547B"
receive_minimum()[source]

Returns receive minimum for node

Raises:nano.rpc.RPCException
>>> rpc.receive_minimum()
1000000000000000000000000
receive_minimum_set(amount)[source]

Set amount as new receive minimum for node until restart

Parameters:amount (int) – Amount in raw to set as minimum to receive
Raises:nano.rpc.RPCException
>>> rpc.receive_minimum_set(amount=1000000000000000000000000000000)
True
representatives(count=None, sorting=False)[source]

Returns a list of pairs of representative and its voting weight

Parameters:
  • count (int) – Max amount of representatives to return
  • sorting (bool) – If true, sorts by weight
Raises:

nano.rpc.RPCException

>>> rpc.representatives()
{
    "xrb_1111111111111111111111111111111111111111111111111117353trpda":
        3822372327060170000000000000000000000,
    "xrb_1111111111111111111111111111111111111111111111111awsq94gtecn":
        30999999999999999999999999000000,
    "xrb_114nk4rwjctu6n6tr6g6ps61g1w3hdpjxfas4xj1tq6i8jyomc5d858xr1xi":
        0
}
republish(hash, count=None, sources=None, destinations=None)[source]

Rebroadcast blocks starting at hash to the network

Parameters:
  • hash (str) – Hash of block to start rebroadcasting from
  • count (int) – Max number of blocks to rebroadcast
  • sources (int) – If set, additionally rebroadcasts source chain blocks for receive/open up to sources depth
  • destinations (int) – If set, additionally rebroadcasts destination chain blocks for receive/open up to destinations depth
Raises:

nano.rpc.RPCException

>>> rpc.republish(
...     hash="991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948"
... )
[
    "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948",
    "A170D51B94E00371ACE76E35AC81DC9405D5D04D4CEBC399AEACE07AE05DD293"
]
search_pending(wallet)[source]

Tells the node to look for pending blocks for any account in wallet

Parameters:wallet (str) – Wallet to search for pending blocks
Raises:nano.rpc.RPCException
>>> rpc.search_pending(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
search_pending_all()[source]

Tells the node to look for pending blocks for any account in all available wallets

Raises:nano.rpc.RPCException
>>> rpc.search_pending_all()
True
send(wallet, source, destination, amount, work=None, id=None)[source]

Send amount from source in wallet to destination

Parameters:
  • wallet (str) – Wallet of account used to send funds
  • source (str) – Account to send funds from
  • destination (str) – Account to send funds to
  • amount (int) – Amount in raw to send
  • work (str) – If set, uses this work for the block
  • id

    Unique identifier for this request

    You can (and should) specify a unique id for each spend to provide idempotency. That means that if you call send two times with the same id, the second request won’t send any additional Nano, and will return the first block instead. The id can be any string. This may be a required parameter in the future.

    If you accidentally reuse an id, the send will not go through (it will be seen as a duplicate request), so make sure your ids are unique! They must be unique per node, and are not segregated per wallet.

    Using the same id for requests with different parameters (wallet, source, destination, and amount) is undefined behavior and may result in an error in the future.

Raises:

nano.rpc.RPCException

>>> rpc.send(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     source="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     destination="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
...     amount=1000000,
...     work="2bf29ef00786a6bc",
...     id="tx-13258"
... )
"000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
stop()[source]

Stop the node

Raises:nano.rpc.RPCException
>>> rpc.stop()
True
successors(block, count)[source]

Returns a list of block hashes in the account chain ending at block up to count

Parameters:
  • block (str) – Hash of block to start returning successors for
  • count (int) – Max number of successor blocks to return
Raises:

nano.rpc.RPCException

>>> rpc.successors(
...     block="991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948",
...     count=1
... )
[
    "A170D51B94E00371ACE76E35AC81DC9405D5D04D4CEBC399AEACE07AE05DD293"
]
unchecked(count=None)[source]

Returns a list of pairs of unchecked synchronizing block hash and its json representation up to count

Parameters:count (int) – Max amount of unchecked blocks to return
Raises:nano.rpc.RPCException
>>> rpc.unchecked(count=1)
{
    "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F": {
        "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
        "work": "0000000000000000",
        "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
        "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
        "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "type": "open"
    }
}
unchecked_clear()[source]

Clear unchecked synchronizing blocks

Raises:nano.rpc.RPCException
>>> rpc.unchecked_clear()
True
unchecked_get(hash)[source]

Retrieves a json representation of unchecked synchronizing block by hash

Parameters:hash (str) – Hash of unchecked block to get
Raises:nano.rpc.RPCException
>>> rpc.unchecked_get(
...     hash="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
    "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "work": "0000000000000000",
    "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
    "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
    "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "type": "open"
}
unchecked_keys(key=None, count=None)[source]

Retrieves unchecked database keys, blocks hashes & a json representations of unchecked pending blocks starting from key up to count

Parameters:
  • key (str) – Starting key to return unchecked keys for
  • count (int) – Max number of keys/blocks to return
Raises:

nano.rpc.RPCException

>>> rpc.unchecked_keys(
...     key="FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
...     count=1
... )
[
    {
        "key": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
        "hash": "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
        "contents": {
            "account": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
            "work": "0000000000000000",
            "source": "FA5B51D063BADDF345EFD7EF0D3C5FB115C85B1EF4CDE89D8B7DF3EAF60A04A4",
            "representative": "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
            "signature": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "type": "open"
        }
    }
]
validate_account_number(account)[source]

Check whether account is a valid account number

Parameters:account (str) – Account number to check
Raises:nano.rpc.RPCException
>>> rpc.validate_account_number(
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
... )
True
version()[source]

Returns the node’s RPC version

Raises:nano.rpc.RPCException
>>> rpc.version()
{
    "rpc_version": 1,
    "store_version": 10,
    "node_vendor": "RaiBlocks 9.0"
}
wallet_add(wallet, key, work=True)[source]

Add an adhoc private key key to wallet

Parameters:
  • wallet (str) – Wallet to add private key to
  • key (str) – Private key to add
  • work (bool) – If false, disables work generation
Raises:

nano.rpc.RPCException

>>> rpc.wallet_add(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     key="34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4"
... )
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
wallet_balance_total(wallet)[source]

Returns the sum of all accounts balances in wallet

Parameters:wallet (str) – Wallet to return sum of balances for
Raises:nano.rpc.RPCException
>>> rpc.wallet_balance_total(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
  "balance": 10000,
  "pending": 10000
}
wallet_balances(wallet)[source]

Returns how many rai is owned and how many have not yet been received by all accounts in wallet

Parameters:wallet (str) – Wallet to return balances for
Raises:nano.rpc.RPCException
>>> rpc.wallet_balances(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000": {
        "balance": 10000,
        "pending": 10000
    }
}
wallet_change_seed(wallet, seed)[source]

Changes seed for wallet to seed

Parameters:
  • wallet (str) – Wallet to change seed for
  • seed (str) – Seed to change wallet to
Raises:

nano.rpc.RPCException

>>> rpc.wallet_change_seed(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     seed="74F2B37AAD20F4A260F0A5B3CB3D7FB51673212263E58A380BC10474BB039CEE"
... )
True
wallet_contains(wallet, account)[source]

Check whether wallet contains account

Parameters:
  • wallet (str) – Wallet to check contains account
  • account (str) – Account to check exists in wallet
Raises:

nano.rpc.RPCException

>>> rpc.wallet_contains(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
... )
True
wallet_create()[source]

Creates a new random wallet id

Raises:nano.rpc.RPCException
>>> rpc.wallet_create()
"000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
wallet_destroy(wallet)[source]

Destroys wallet and all contained accounts

Parameters:wallet (str) – Wallet to destroy
Raises:nano.rpc.RPCException
>>> rpc.wallet_destroy(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
wallet_export(wallet)[source]

Return a json representation of wallet

Parameters:wallet (str) – Wallet to export
Raises:nano.rpc.RPCException
>>> rpc.wallet_export(wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F")
{
    "0000000000000000000000000000000000000000000000000000000000000000": "0000000000000000000000000000000000000000000000000000000000000001"
}
wallet_frontiers(wallet)[source]

Returns a list of pairs of account and block hash representing the head block starting for accounts from wallet

Parameters:wallet (str) – Wallet to return frontiers for
Raises:nano.rpc.RPCException
>>> rpc.wallet_frontiers(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
    "xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000": "000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
}
wallet_key_valid(wallet)[source]

Returns if a wallet key is valid

Parameters:wallet (str) – Wallet to check key is valid
>>> rpc.wallet_key_valid(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
wallet_lock(wallet)[source]

Locks a wallet

Parameters:wallet (str) – Wallet to lock
Raises:nano.rpc.RPCException
>>> rpc.wallet_lock(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
True
wallet_locked(wallet)[source]

Checks whether wallet is locked

Parameters:wallet (str) – Wallet to check if locked
Raises:nano.rpc.RPCException
>>> rpc.wallet_locked(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
False
wallet_pending(wallet, count=None, threshold=None, source=False)[source]

Returns a list of block hashes which have not yet been received by accounts in this wallet

Parameters:
  • wallet (str) – Wallet to get list of pending block hashes for
  • count (int) – Max amount of blocks to return
  • threshold (int) – Minimum amount in raw per block
  • source (bool) – If true, returns source account as well
Raises:

nano.rpc.RPCException

>>> rpc.wallet_pending(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     count=1
... )
{
    "xrb_1111111111111111111111111111111111111111111111111117353trpda": [
        "142A538F36833D1CC78B94E11C766F75818F8B940771335C6C1B8AB880C5BB1D"
    ],
    "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3": [
        "4C1FEEF0BEA7F50BE35489A1233FE002B212DEA554B55B1B470D78BD8F210C74"
    ]
}
wallet_representative(wallet)[source]

Returns the default representative for wallet

Parameters:wallet (str) – Wallet to get default representative account for
Raises:nano.rpc.RPCException
>>> rpc.wallet_representative(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
wallet_representative_set(wallet, representative)[source]

Sets the default representative for wallet

Parameters:
  • wallet (str) – Wallet to set default representative account for
  • representative (str) – Representative account to set for wallet
Raises:

nano.rpc.RPCException

>>> rpc.wallet_representative_set(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     representative="xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"
... )
True
wallet_republish(wallet, count)[source]

Rebroadcast blocks for accounts from wallet starting at frontier down to count to the network

Parameters:
  • wallet (str) – Wallet to rebroadcast blocks for
  • count (int) – Max amount of blocks to rebroadcast since frontier block
Raises:

nano.rpc.RPCException

>>> rpc.wallet_republish(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     count=2
... )
[
    "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948",
    "A170D51B94E00371ACE76E35AC81DC9405D5D04D4CEBC399AEACE07AE05DD293",
    "90D0C16AC92DD35814E84BFBCC739A039615D0A42A76EF44ADAEF1D99E9F8A35"
]
wallet_unlock(wallet, password)[source]

Unlocks wallet using password

Parameters:
  • wallet (str) – Wallet to unlock
  • password (str) – Password to enter
Raises:

nano.rpc.RPCException

>>> rpc.wallet_unlock(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     password="test"
... )
True
wallet_work_get(wallet)[source]

Returns a list of pairs of account and work from wallet

Parameters:wallet (str) – Wallet to return work for
Raises:nano.rpc.RPCException
>>> rpc.wallet_work_get(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"
... )
{
    "xrb_1111111111111111111111111111111111111111111111111111hifc8npp":
        "432e5cf728c90f4f"
}
work_cancel(hash)[source]

Stop generating work for block

Parameters:hash (str) – Hash to stop generating work for
Raises:nano.rpc.RPCException
>>> rpc.work_cancel(
...     hash="718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
... )
True
work_generate(hash)[source]

Generates work for block

Parameters:hash (str) – Hash to start generating work for
Raises:nano.rpc.RPCException
>>> rpc.work_generate(
...     hash="718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
... )
"2bf29ef00786a6bc"
work_get(wallet, account)[source]

Retrieves work for account in wallet

Parameters:
  • wallet (str) – Wallet to get account work for
  • account (str) – Account to get work for
Raises:

nano.rpc.RPCException

>>> rpc.work_get(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_1111111111111111111111111111111111111111111111111111hifc8npp"
... )
"432e5cf728c90f4f"
work_peer_add(address, port)[source]

Add specific IP address and port as work peer for node until restart

Parameters:
  • address (str) – IP address of work peer to add
  • port (int) – Port work peer to add
Raises:

nano.rpc.RPCException

>>> rpc.work_peer_add(address="::ffff:172.17.0.1", port="7076")
True
work_peers()[source]

Retrieve work peers

Raises:nano.rpc.RPCException
>>> rpc.work_peers()
[
    "::ffff:172.17.0.1:7076"
]
work_peers_clear()[source]

Clear work peers node list until restart

Raises:nano.rpc.RPCException
>>> rpc.work_peers_clear()
True
work_set(wallet, account, work)[source]

Set work for account in wallet

Parameters:
  • wallet (str) – Wallet to set work for account for
  • account (str) – Account to set work for
  • work (str) – Work to set for account in wallet
Raises:

nano.rpc.RPCException

>>> rpc.work_set(
...     wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F",
...     account="xrb_1111111111111111111111111111111111111111111111111111hifc8npp",
...     work="0000000000000000"
... )
True
work_validate(work, hash)[source]

Check whether work is valid for block

Parameters:
  • work (str) – Work to validate
  • hash (str) – Hash of block to validate work for
Raises:

nano.rpc.RPCException

>>> rpc.work_validate(
...     work="2bf29ef00786a6bc",
...     hash="718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
... )
True
nano.rpc.RPCClient

alias of Client

exception nano.rpc.RPCException[source]

Bases: exceptions.Exception

Base class for RPC errors

nano.rpc.doc_metadata(categories)[source]

Decorator to add doc metadata for docs generation