RaiEx v0.2.0 RaiEx.Tools View Source

This module provides convenience functions for working with a RaiBlocks node.

Link to this section Summary

Functions

Converts a raiblocks address to a public key

Same as address_to_public except leaves untrimmied 5 bytes at end of binary

Calculates and compares the checksum on an address, returns a boolean

Changes the password for the wallet

Creates an address from the given public key. The address is encoded in base32 as defined in RaiEx.Tools.Base32 and appended with a checksum

Derives the public key from the private key

Locks the given wallet

Generates a wallet seed

Generates the public and private keys for a given wallet

Unlocks the given wallet with its password

Inserts a new adhoc key into wallet

Creates a new encrypted wallet. Locks it with password

Link to this section Functions

Link to this function address_to_public(address) View Source

Converts a raiblocks address to a public key.

Link to this function address_to_public_without_trim(address) View Source

Same as address_to_public except leaves untrimmied 5 bytes at end of binary.

Calculates and compares the checksum on an address, returns a boolean.

Examples

iex> address_valid("xrb_34bmpi65zr967cdzy4uy4twu7mqs9nrm53r1penffmuex6ruqy8nxp7ms1h1")
true

iex> address_valid("clearly not valid")
false
Link to this function change_password(wallet, current_pwd, password) View Source

Changes the password for the wallet.

Examples

iex> change_password(wallet, current_pwd, new_pwd)
{:ok, wallet}

iex> change_password(wallet, invalid_pwd, new_pwd)
{:error, reason}
Link to this function create_account!(pub_key) View Source

Creates an address from the given public key. The address is encoded in base32 as defined in RaiEx.Tools.Base32 and appended with a checksum.

Examples

iex> create_account!(<<125, 169, 163, 231, 136, 75, 168, 59, 83, 105, 128, 71, 82, 149, 53, 87, 90, 35, 149, 51, 106, 243, 76, 13, 250, 28, 59, 128, 5, 181, 81, 116>>)
"xrb_1zfbnhmrikxa9fbpm149cccmcott6gcm8tqmbi8zn93ui14ucndn93mtijeg"

iex> create_address!("7DA9A3E7884BA83B53698047529535575A2395336AF34C0DFA1C3B8005B55174")
"xrb_1zfbnhmrikxa9fbpm149cccmcott6gcm8tqmbi8zn93ui14ucndn93mtijeg"

Derives the public key from the private key.

Examples

iex> derive_public(<<84, 151, 51, 84, 136, 206, 7, 211, 66, 222, 10, 240, 159, 113, 36, 98, 93, 238, 29, 96, 95, 8, 33, 62, 53, 162, 139, 52, 75, 123, 38, 144>>)
<<125, 169, 163, 231, 136, 75, 168, 59, 83, 105, 128, 71, 82, 149, 53, 87, 90, 35, 149, 51, 106, 243, 76, 13, 250, 28, 59, 128, 5, 181, 81, 116>>

iex> derive_public("5497335488CE07D342DE0AF09F7124625DEE1D605F08213E35A28B344B7B2690")
<<125, 169, 163, 231, 136, 75, 168, 59, 83, 105, 128, 71, 82, 149, 53, 87, 90, 35, 149, 51, 106, 243, 76, 13, 250, 28, 59, 128, 5, 181, 81, 116>>

Locks the given wallet.

Generates a wallet seed.

Link to this function seed_account(seed, nonce) View Source

Generates the public and private keys for a given wallet.

Examples

iex> seed_account("8208BD79655E7141DCFE792084AB6A8FDFFFB56F37CE30ADC4C2CC940E276A8B", 0)
{pub, priv}
Link to this function unlock_wallet(wallet, password) View Source

Unlocks the given wallet with its password.

Link to this function wallet_add_adhoc(wallet) View Source

Inserts a new adhoc key into wallet.

Link to this function wallet_create_encrypted(password) View Source

Creates a new encrypted wallet. Locks it with password.