nanopy¶
- nanopy.account_get(key)¶
Get account number for the public key
- Parameters:
key (str) – 64 hex-char public key
- Returns:
account number
- Return type:
- Raises:
AssertionError – for invalid key
- nanopy.account_key(account)¶
Get the public key for account
- Parameters:
account (str) – account number
- Returns:
64 hex-char public key
- Return type:
- Raises:
AssertionError – for invalid account
- nanopy.block_create(key, previous, representative, balance, link, work=None, difficulty=None)¶
Create a block
- Parameters:
key (str) – 64 hex-char private key
previous (str) – 64 hex-char previous hash
representative (str) – representative address
balance (str) – balance in raw
link (str) – 64 hex-char link
work (str) – 16 hex-char work
difficulty (str) – 16 hex-char difficulty: send/change require a minimum #fffffff800000000 and receive requires #fffffe0000000000. Default is #ffffffc000000000.
- Returns:
a block with work and signature
- Return type:
- nanopy.block_hash(block)¶
Compute block hash
- nanopy.deterministic_key(seed, index=0)¶
Derive deterministic keypair from seed based on index
- Parameters:
- Returns:
(private key, public key, account number)
- Return type:
- Raises:
AssertionError – for invalid seed
- nanopy.from_multiplier(multiplier)¶
Get difficulty from multiplier
- nanopy.from_raw(amount, exp=0)¶
Divide amount by 10^exp
- nanopy.generate_mnemonic(strength=256, language='english')¶
Generate a BIP39 type mnemonic. Requires mnemonic
- nanopy.key_expand(key)¶
Derive public key and account number from private key
- Parameters:
key (str) – 64 hex-char private key
- Returns:
(private key, public key, account number)
- Return type:
- Raises:
AssertionError – for invalid key
- nanopy.mnemonic_key(words, index=0, passphrase='', language='english')¶
Derive deterministic keypair from mnemonic based on index. Requires mnemonic
- Parameters:
words (str) – word list
- Returns:
(private key, public key, account number)
- Return type:
- Raises:
AssertionError – for invalid key
- nanopy.nano_to_raw(amount)¶
Multiply a nano amount by the raw-nano ratio (10^30)
- nanopy.raw_to_nano(amount)¶
Divide a raw amount down by the raw-nano ratio (10^30)
- nanopy.sign(key, block=None, _hash=None, msg=None, account=None, pk=None)¶
Sign a block, hash, or message
- Parameters:
key (str) – 64 hex-char private key
block (dict) – “account”, “previous”, “representative”, “balance”, and “link” are the required entries
_hash (str) – 64 hex-char hash. Overrides
block
.msg (str) – message to sign. Overrides
_hash
andblock
.account (str) – account
pk (str) – 64 hex-char public key
- Returns:
128 hex-char signature
- Return type:
- nanopy.to_multiplier(difficulty)¶
Get multiplier from difficulty
- nanopy.to_raw(amount, exp=0)¶
Multiply amount by 10^exp
- nanopy.validate_account_number(account)¶
Check whether account is a valid account number using checksum
- nanopy.verify_signature(msg, sig, pk)¶
Verify signature for message with public key
- nanopy.work_generate(_hash, difficulty=None, multiplier=0)¶
Check whether work is valid for _hash.
- nanopy.work_validate(work, _hash, difficulty=None, multiplier=0)¶
Check whether work is valid for _hash.