Back to Top

@bananocoin/bananojs master

JavaScript utilities for the banano cryptocurrency.

getRawStrFromMajorAmountStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromMinorAmountStr(amountStr, amountPrefix)

Converts a banoshi amount into a raw amount.

Parameters

Name Type Description
amountStr string

the banoshi, as a string.

amountPrefix string

the amount prefix, as a string.

Returns

string

the banano as a raw value.

getAmountPartsFromRaw(amountRawStr, amountPrefix)

Get the banano parts (banano, banoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

amountPrefix string

the amount prefix, as a string.

Returns

BananoParts

the banano parts.

getAccountPublicKey(account)

Get the public key for a given account.

Parameters

Name Type Description
account string

the account.

Returns

string

the public key.

getAccountSuffix(publicKey)

Get the account suffix for a given public key (everything but ban_ or camo_ or nano_).

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account suffix.

getAccount(publicKey, accountPrefix)

Get the account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

accountPrefix string

the prefix. ban_ or nano_.

Returns

string

the account.

isWorkValid(hashBytes, workBytes)

returns true if the work (in bytes) for the hash (in bytes) is valid.

Parameters

Name Type Description
hashBytes string

the hash bytes to check.

workBytes string

the work bytes to check.

Returns

boolean

true if the work is valid for the hash.

getZeroedWorkBytes()

creates a new Uint8Array(8) to calculate work bytes.

Returns

Uint8Array

the bytes in a Uint8Array.

getPublicKey(privateKey)

Get the public key for a given private key.

Parameters

Name Type Description
privateKey string

the private key.

Returns

string

the public key.

isSeedValid(seed, seedIx)

validates a seed.

Parameters

Name Type Description
seed string

the seed to use to validate.

seedIx string

the index to use with the seed.

Returns

object

{valid:[true/false] message:[if false, why]}.

getPrivateKey(seed, seedIx)

Get the private key for a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the private key.

getBananoAccountValidationInfo(account)

Returns an object saying if the banano account is valid or not.

If the account is not valid, the message describes why it is not valid.

Parameters

Name Type Description
account string

the account.

Returns

AccountValidationInfo

an object saying if the account is valid, and why.

getNanoAccountValidationInfo(account)

Returns an object saying if the nano account is valid or not. If the account is not valid, the message describes why it is not valid.

Parameters

Name Type Description
account string

the account.

Returns

AccountValidationInfo

an object saying if the account is valid, and why.

getCamoPublicKey(privateKey)

Gets the camo public key from a private key.

a normal banano public key is used in ECDSA.

a camo public key is used in ECDH.

this is why the derivation is different for the two keys.

Parameters

Name Type Description
privateKey string

the private key.

Returns

string

the camo public key.

getSharedSecret(privateKey, publicKey)

Gets the shared secret from a camo public key and a private key.

Parameters

Name Type Description
privateKey string

the private key.

publicKey string

the public key.

Returns

string

the shared secret.

getCamoAccount(camoPublicKey)

Get the camo account for a given camo public key.

Parameters

Name Type Description
camoPublicKey string

the camo public key.

Returns

string

the camo account.

isCamoAccountValid(camoAccount)

Parameters

Name Type Description
camoAccount string

the camo account.

Returns

boolean

true if the camo account is valid.

getRawStrFromMajorAmountStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromMinorAmountStr(amountStr, amountPrefix)

Converts a banoshi amount into a raw amount.

Parameters

Name Type Description
amountStr string

the banoshi, as a string.

amountPrefix string

the amount prefix, as a string.

Returns

string

the banano as a raw value.

getAmountPartsFromRaw(amountRawStr, amountPrefix)

Get the banano parts (banano, banoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

amountPrefix string

the amount prefix, as a string.

Returns

BananoParts

the banano parts.

getAccountPublicKey(account)

Get the public key for a given account.

Parameters

Name Type Description
account string

the account.

Returns

string

the public key.

getAccountSuffix(publicKey)

Get the account suffix for a given public key (everything but ban_ or camo_ or nano_).

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account suffix.

getAccount(publicKey, accountPrefix)

Get the account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

accountPrefix string

the prefix. ban_ or nano_.

Returns

string

the account.

isWorkValid(hashBytes, workBytes)

returns true if the work (in bytes) for the hash (in bytes) is valid.

Parameters

Name Type Description
hashBytes string

the hash bytes to check.

workBytes string

the work bytes to check.

Returns

boolean

true if the work is valid for the hash.

getZeroedWorkBytes()

creates a new Uint8Array(8) to calculate work bytes.

Returns

Uint8Array

the bytes in a Uint8Array.

getPublicKey(privateKey)

Get the public key for a given private key.

Parameters

Name Type Description
privateKey string

the private key.

Returns

string

the public key.

isSeedValid(seed, seedIx)

validates a seed.

Parameters

Name Type Description
seed string

the seed to use to validate.

seedIx string

the index to use with the seed.

Returns

object

{valid:[true/false] message:[if false, why]}.

getPrivateKey(seed, seedIx)

Get the private key for a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the private key.

getBananoAccountValidationInfo(account)

Returns an object saying if the banano account is valid or not.

If the account is not valid, the message describes why it is not valid.

Parameters

Name Type Description
account string

the account.

Returns

AccountValidationInfo

an object saying if the account is valid, and why.

getNanoAccountValidationInfo(account)

Returns an object saying if the nano account is valid or not. If the account is not valid, the message describes why it is not valid.

Parameters

Name Type Description
account string

the account.

Returns

AccountValidationInfo

an object saying if the account is valid, and why.

getCamoPublicKey(privateKey)

Gets the camo public key from a private key.

a normal banano public key is used in ECDSA.

a camo public key is used in ECDH.

this is why the derivation is different for the two keys.

Parameters

Name Type Description
privateKey string

the private key.

Returns

string

the camo public key.

getSharedSecret(privateKey, publicKey)

Gets the shared secret from a camo public key and a private key.

Parameters

Name Type Description
privateKey string

the private key.

publicKey string

the public key.

Returns

string

the shared secret.

getCamoAccount(camoPublicKey)

Get the camo account for a given camo public key.

Parameters

Name Type Description
camoPublicKey string

the camo public key.

Returns

string

the camo account.

isCamoAccountValid(camoAccount)

Parameters

Name Type Description
camoAccount string

the camo account.

Returns

boolean

true if the camo account is valid.

setBananodeApi(_bananodeApi)

Sets the Bananode Api (useful for overriding some methods)

Parameters

Name Type Description
_bananodeApi string

the new bananodeApi

Returns

returns nothing.

getBananoPartsFromDecimal(decimalAmount)

converts amount from decimal to bananoParts.

Parameters

Name Type Description
decimalAmount string

the decimal amount of bananos.

Returns

BananoParts

returns the banano parts of the decimal amount.

getBananoPartsAsDecimal(bananoParts)

converts amount from bananoParts to decimal.

Parameters

Name Type Description
bananoParts BananoParts

the banano parts to describe.

Returns

string

returns the decimal amount of bananos.

getBananoDecimalAmountAsRaw(amount)

converts amount from decimal to raw.

Parameters

Name Type Description
amount string

the decimal amount.

Returns

string

returns amount in raw.

getBananoPartsDescription(bananoParts)

describes the banano parts in an english description.

Parameters

Name Type Description
bananoParts BananoParts

the banano parts to describe.

Returns

string

returns the description of the banano parts.

sendAmountToBananoAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash)

Sends the amount to the account with an optional representative and previous block hash. If the representative is not sent, it will be pulled from the api. If the previous is not sent, it will be pulled from the api. Be very careful with previous, as setting it incorrectly can cause an incorrect amount of funds to be sent.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

representative string

the representative (optional).

previousHash string

the previous hash (optional).

Returns

string

returns the hash returned by the send.

sendAmountToNanoAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash)

Sends the amount to the account with an optional representative and previous block hash. If the representative is not sent, it will be pulled from the api. If the previous is not sent, it will be pulled from the api. Be very careful with previous, as setting it incorrectly can cause an incorrect amount of funds to be sent.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

representative string

the representative (optional).

previousHash string

the previous hash (optional).

Returns

string

returns the hash returned by the send.

sendAmountToBananoAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback)

Sends the amount to the banano account with a callback for success and failure.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

successCallback string

the callback to call upon success.

failureCallback string

the callback to call upon failure.

Returns

string

returns the hash returned by the send.

sendAmountToNanoAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback)

Sends the amount to the nano account with a callback for success and failure.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

successCallback string

the callback to call upon success.

failureCallback string

the callback to call upon failure.

Returns

string

returns the hash returned by the send.

changeBananoRepresentativeForSeed(seed, seedIx, representative)

Sets the rep for an account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

Returns

string

returns the hash returned by the change.

changeNanoRepresentativeForSeed(seed, seedIx, representative)

Sets the rep for an account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

Returns

string

returns the hash returned by the change.

receiveNanoDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash)

Recieve deposits for a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

specificPendingBlockHash string

a specific block hash to receive (optional).

Returns

object

returns the response returned by the receive.

receiveBananoDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash)

Recieve deposits for a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

specificPendingBlockHash string

a specific block hash to receive (optional).

Returns

object

returns the response returned by the receive.

sendBananoWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

Send a withdrawal from a banano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

object

returns the response returned by the withdraw.

sendNanoWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

Send a withdrawal from a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

object

returns the response returned by the withdraw.

getAccountBalanceRaw(account)

Get the balance, in raw, for an account.

(use other methods like getBananoPartsFromRaw to convert to banano or banoshi)

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_balances}

Parameters

Name Type Description
account string

the account to use.

Returns

string

the account's balance, in raw.

getAccountBalanceAndPendingRaw(account)

Get the balance and pending values, in raw, as an object like this one: { balance: '123', pending: '123' } for an account.

(use other methods like getBananoPartsFromRaw to convert to banano or banoshi)

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_balances}

Parameters

Name Type Description
account string

the account to use.

Returns

object

the account's balances, in raw.

getAccountHistory(account, count, head, raw)

Get the history for an account.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#account_history}

Parameters

Name Type Description
account string

the account to use.

count string

the count to use (use -1 for all).

head string

the head to start at (optional).

raw string

if true, return raw history (optional).

Returns

object

the account's history.

getBananoAccountFromSeed(seed, seedIx)

Get the banano account with a given seed and index.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the account.

getNanoAccountFromSeed(seed, seedIx)

Get the banano account with a given seed and index.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the account.

setBananodeApiUrl(url)

Sets the URL to use for the node behind the Bananode Api

Parameters

Name Type Description
url string

the new url

Returns

returns nothing.

getAccountInfo(account, representativeFlag)

Get the account info for an account.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#account_info}

Parameters

Name Type Description
account string

the account to use.

representativeFlag boolean

the representativeFlag to use (optional).

Returns

object

the account's info.

getBlockCount()

Get the network block count.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#block_count}

Returns

object

the block count.

openBananoAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw)

Open a banano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

pendingBlockHash string

the pending block hash.

pendingValueRaw string

the pending block hash.

Returns

string

returns the hash returned by the open.

openNanoAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw)

Open a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

pendingBlockHash string

the pending block hash.

pendingValueRaw string

the pending block hash.

Returns

string

returns the hash returned by the open.

getBlockHash(block)

Get the hash for a given block.

Parameters

Name Type Description
block string

the seed to use to find the account.

Returns

string

the block's hash.

signHash(privateKey, hash)

signs a hash.

Parameters

Name Type Description
privateKey string

the private key to use to sign.

hash string

the hash to sign.

Returns

string

the block's hash.

verify(hash, signature, publicKey)

verifys a hash.

Parameters

Name Type Description
hash string

the hash to verify.

signature string

the signature to verify.

publicKey string

the public key to use to sign.

Returns

string

true if verification passed.

getSignature(privateKey, block)

Get the signature for a given block (gets the hash of the block, and signs the hash).

Parameters

Name Type Description
privateKey string

the private key used to sign the block.

block string

the block to sign.

Returns

string

the block's signature.

getBytesFromHex(hex)

Converts a hex string to bytes in a Uint8Array.

Parameters

Name Type Description
hex string

the hex string to use.

Returns

Uint8Array

the bytes in a Uint8Array.

getWorkUsingCpu(hash, workBytes)

gets work bytes using the CPU.

Parameters

Name Type Description
hash string

the hash to use to calculate work bytes.

workBytes Uint8Array

the Uint8Array(8) used to store temporary calculations.

Returns

string

the work bytes as a hex string.

camoBananoReceive(toPrivateKey, fromPublicKey)

receives banano funds at a camo address.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string_array

the received hashes in an array.

camoNanoReceive(toPrivateKey, fromPublicKey)

receives nano funds at a camo address.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string_array

the received hashes in an array.

getCamoBananoNextPrivateKeyForReceive(seed)

finds a new private key to recieve more banano funds. the key would have no history.

Parameters

Name Type Description
seed string

the seed to use to find the account.

Returns

string

the private key to use.

getCamoNanoNextPrivateKeyForReceive(seed)

finds a new private key to recieve more banano funds. the key would have no history.

Parameters

Name Type Description
seed string

the seed to use to find the account.

Returns

string

the private key to use.

camoBananoSend(fundingPrivateKey, fromCamoPrivateKey, toCamoPublicKey, amountBananos)

sends banano funds to a camo address.

Parameters

Name Type Description
fundingPrivateKey string

the private key that sends the funds.

fromCamoPrivateKey string

the private key used to generate the shared seed.

toCamoPublicKey string

the public key that receives the funds.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoNanoSend(fundingPrivateKey, fromCamoPrivateKey, toCamoPublicKey, amountBananos)

sends camo funds to a camo address.

Parameters

Name Type Description
fundingPrivateKey string

the private key that sends the funds.

fromCamoPrivateKey string

the private key used to generate the shared seed.

toCamoPublicKey string

the public key that receives the funds.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoBananoSendWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

sends banano funds to a camo account. This function uses seed index 0 to generate the shared secret, and seed index "seedIx" to get the private key that contains funds to send.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoNanoSendWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

sends nano funds to a camo account. This function uses seed index 0 to generate the shared secret, and seed index "seedIx" to get the private key that contains funds to send.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoBananoGetAccountsPending(seed, seedIx, fromAccount, sharedSeedIx, count)

get the pending blocks for the camo banano account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

fromAccount string

the account to recieve from.

sharedSeedIx number

the index to use with the shared seed.

count number

the max count to get.

Returns

string_array

the pending hashes in an array.

camoNanoGetAccountsPending(seed, seedIx, fromAccount, sharedSeedIx, count)

get the pending blocks for the camo nano account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

fromAccount string

the account to recieve from.

sharedSeedIx number

the index to use with the shared seed.

count number

the max count to get.

Returns

string_array

the pending hashes in an array.

getCamoAccountValidationInfo(account)

returns data on whether a camo account is valid or not, and why.

Parameters

Name Type Description
account string

the account to check.

Returns

object

the account validity data.

getCamoBananoSharedAccountData(seed, seedIx, account, sharedSeedIx)

get the banano shared account, used as an intermediary to send finds between the seed and the camo account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

Returns

string

the shared account.

getCamoNanoSharedAccountData(seed, seedIx, account, sharedSeedIx)

get the nano shared account, used as an intermediary to send finds between the seed and the camo account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

Returns

string

the shared account.

receiveCamoBananoDepositsForSeed(seed, seedIx, account, sharedSeedIx, specificPendingBlockHash)

Recieve banano deposits for a camo account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

specificPendingBlockHash string

the pending block to recieve.

Returns

string

the response from receiving the block.

receiveCamoNanoDepositsForSeed(seed, seedIx, account, sharedSeedIx, specificPendingBlockHash)

Recieve nano deposits for a camo account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

specificPendingBlockHash string

the pending block to recieve.

Returns

string

the response from receiving the block.

getCamoBananoAccountBalanceRaw(toPrivateKey, fromPublicKey)

gets the total banano account balance, in raw.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string

the account balance, in raw.

getCamoNanoAccountBalanceRaw(toPrivateKey, fromPublicKey)

gets the total nano account balance, in raw.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string

the account balance, in raw.

getAccountsPending(accounts, count, source)

Get the network block count.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_pending}

Parameters

Name Type Description
accounts string_array

the array of pending accounts.

count number

the max count to get.

source string

if true, get source.

Returns

object

the account's pending blocks.

getRawStrFromBananoStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromBanoshiStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromNanoStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromNanoshiStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getBananoAccount(publicKey)

Get the banano account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account.

getNanoAccount(publicKey)

Get the banano account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account.

getBananoPartsFromRaw(amountRawStr)

Get the banano parts (banano, banoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

Returns

BananoParts

the banano parts.

getNanoPartsFromRaw(amountRawStr)

Get the nano parts nano, nanoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

Returns

BananoParts

the banano parts.

index()

Returns

Void

setBananodeApi(_bananodeApi)

Sets the Bananode Api (useful for overriding some methods)

Parameters

Name Type Description
_bananodeApi string

the new bananodeApi

Returns

returns nothing.

getBananoPartsFromDecimal(decimalAmount)

converts amount from decimal to bananoParts.

Parameters

Name Type Description
decimalAmount string

the decimal amount of bananos.

Returns

BananoParts

returns the banano parts of the decimal amount.

getBananoPartsAsDecimal(bananoParts)

converts amount from bananoParts to decimal.

Parameters

Name Type Description
bananoParts BananoParts

the banano parts to describe.

Returns

string

returns the decimal amount of bananos.

getBananoDecimalAmountAsRaw(amount)

converts amount from decimal to raw.

Parameters

Name Type Description
amount string

the decimal amount.

Returns

string

returns amount in raw.

getBananoPartsDescription(bananoParts)

describes the banano parts in an english description.

Parameters

Name Type Description
bananoParts BananoParts

the banano parts to describe.

Returns

string

returns the description of the banano parts.

sendAmountToBananoAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash)

Sends the amount to the account with an optional representative and previous block hash. If the representative is not sent, it will be pulled from the api. If the previous is not sent, it will be pulled from the api. Be very careful with previous, as setting it incorrectly can cause an incorrect amount of funds to be sent.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

representative string

the representative (optional).

previousHash string

the previous hash (optional).

Returns

string

returns the hash returned by the send.

sendAmountToNanoAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash)

Sends the amount to the account with an optional representative and previous block hash. If the representative is not sent, it will be pulled from the api. If the previous is not sent, it will be pulled from the api. Be very careful with previous, as setting it incorrectly can cause an incorrect amount of funds to be sent.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

representative string

the representative (optional).

previousHash string

the previous hash (optional).

Returns

string

returns the hash returned by the send.

sendAmountToBananoAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback)

Sends the amount to the banano account with a callback for success and failure.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

successCallback string

the callback to call upon success.

failureCallback string

the callback to call upon failure.

Returns

string

returns the hash returned by the send.

sendAmountToNanoAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback)

Sends the amount to the nano account with a callback for success and failure.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

destAccount string

the destination account.

amountRaw string

the amount to send, in raw.

successCallback string

the callback to call upon success.

failureCallback string

the callback to call upon failure.

Returns

string

returns the hash returned by the send.

changeBananoRepresentativeForSeed(seed, seedIx, representative)

Sets the rep for an account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

Returns

string

returns the hash returned by the change.

changeNanoRepresentativeForSeed(seed, seedIx, representative)

Sets the rep for an account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

Returns

string

returns the hash returned by the change.

receiveNanoDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash)

Recieve deposits for a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

specificPendingBlockHash string

a specific block hash to receive (optional).

Returns

object

returns the response returned by the receive.

receiveBananoDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash)

Recieve deposits for a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

specificPendingBlockHash string

a specific block hash to receive (optional).

Returns

object

returns the response returned by the receive.

sendBananoWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

Send a withdrawal from a banano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

object

returns the response returned by the withdraw.

sendNanoWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

Send a withdrawal from a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

object

returns the response returned by the withdraw.

getAccountBalanceRaw(account)

Get the balance, in raw, for an account.

(use other methods like getBananoPartsFromRaw to convert to banano or banoshi)

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_balances}

Parameters

Name Type Description
account string

the account to use.

Returns

string

the account's balance, in raw.

getAccountBalanceAndPendingRaw(account)

Get the balance and pending values, in raw, as an object like this one: { balance: '123', pending: '123' } for an account.

(use other methods like getBananoPartsFromRaw to convert to banano or banoshi)

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_balances}

Parameters

Name Type Description
account string

the account to use.

Returns

object

the account's balances, in raw.

getAccountHistory(account, count, head, raw)

Get the history for an account.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#account_history}

Parameters

Name Type Description
account string

the account to use.

count string

the count to use (use -1 for all).

head string

the head to start at (optional).

raw string

if true, return raw history (optional).

Returns

object

the account's history.

getBananoAccountFromSeed(seed, seedIx)

Get the banano account with a given seed and index.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the account.

getNanoAccountFromSeed(seed, seedIx)

Get the banano account with a given seed and index.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

Returns

string

the account.

setBananodeApiUrl(url)

Sets the URL to use for the node behind the Bananode Api

Parameters

Name Type Description
url string

the new url

Returns

returns nothing.

getAccountInfo(account, representativeFlag)

Get the account info for an account.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#account_info}

Parameters

Name Type Description
account string

the account to use.

representativeFlag boolean

the representativeFlag to use (optional).

Returns

object

the account's info.

getBlockCount()

Get the network block count.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#block_count}

Returns

object

the block count.

openBananoAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw)

Open a banano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

pendingBlockHash string

the pending block hash.

pendingValueRaw string

the pending block hash.

Returns

string

returns the hash returned by the open.

openNanoAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw)

Open a nano account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

representative string

the representative.

pendingBlockHash string

the pending block hash.

pendingValueRaw string

the pending block hash.

Returns

string

returns the hash returned by the open.

getBlockHash(block)

Get the hash for a given block.

Parameters

Name Type Description
block string

the seed to use to find the account.

Returns

string

the block's hash.

signHash(privateKey, hash)

signs a hash.

Parameters

Name Type Description
privateKey string

the private key to use to sign.

hash string

the hash to sign.

Returns

string

the block's hash.

verify(hash, signature, publicKey)

verifys a hash.

Parameters

Name Type Description
hash string

the hash to verify.

signature string

the signature to verify.

publicKey string

the public key to use to sign.

Returns

string

true if verification passed.

getSignature(privateKey, block)

Get the signature for a given block (gets the hash of the block, and signs the hash).

Parameters

Name Type Description
privateKey string

the private key used to sign the block.

block string

the block to sign.

Returns

string

the block's signature.

getBytesFromHex(hex)

Converts a hex string to bytes in a Uint8Array.

Parameters

Name Type Description
hex string

the hex string to use.

Returns

Uint8Array

the bytes in a Uint8Array.

getWorkUsingCpu(hash, workBytes)

gets work bytes using the CPU.

Parameters

Name Type Description
hash string

the hash to use to calculate work bytes.

workBytes Uint8Array

the Uint8Array(8) used to store temporary calculations.

Returns

string

the work bytes as a hex string.

camoBananoReceive(toPrivateKey, fromPublicKey)

receives banano funds at a camo address.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string_array

the received hashes in an array.

camoNanoReceive(toPrivateKey, fromPublicKey)

receives nano funds at a camo address.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string_array

the received hashes in an array.

getCamoBananoNextPrivateKeyForReceive(seed)

finds a new private key to recieve more banano funds. the key would have no history.

Parameters

Name Type Description
seed string

the seed to use to find the account.

Returns

string

the private key to use.

getCamoNanoNextPrivateKeyForReceive(seed)

finds a new private key to recieve more banano funds. the key would have no history.

Parameters

Name Type Description
seed string

the seed to use to find the account.

Returns

string

the private key to use.

camoBananoSend(fundingPrivateKey, fromCamoPrivateKey, toCamoPublicKey, amountBananos)

sends banano funds to a camo address.

Parameters

Name Type Description
fundingPrivateKey string

the private key that sends the funds.

fromCamoPrivateKey string

the private key used to generate the shared seed.

toCamoPublicKey string

the public key that receives the funds.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoNanoSend(fundingPrivateKey, fromCamoPrivateKey, toCamoPublicKey, amountBananos)

sends camo funds to a camo address.

Parameters

Name Type Description
fundingPrivateKey string

the private key that sends the funds.

fromCamoPrivateKey string

the private key used to generate the shared seed.

toCamoPublicKey string

the public key that receives the funds.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoBananoSendWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

sends banano funds to a camo account. This function uses seed index 0 to generate the shared secret, and seed index "seedIx" to get the private key that contains funds to send.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoNanoSendWithdrawalFromSeed(seed, seedIx, toAccount, amountBananos)

sends nano funds to a camo account. This function uses seed index 0 to generate the shared secret, and seed index "seedIx" to get the private key that contains funds to send.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

toAccount string

the account to send to.

amountBananos string

the amount of bananos.

Returns

string_array

the sent hashes in an array.

camoBananoGetAccountsPending(seed, seedIx, fromAccount, sharedSeedIx, count)

get the pending blocks for the camo banano account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

fromAccount string

the account to recieve from.

sharedSeedIx number

the index to use with the shared seed.

count number

the max count to get.

Returns

string_array

the pending hashes in an array.

camoNanoGetAccountsPending(seed, seedIx, fromAccount, sharedSeedIx, count)

get the pending blocks for the camo nano account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

fromAccount string

the account to recieve from.

sharedSeedIx number

the index to use with the shared seed.

count number

the max count to get.

Returns

string_array

the pending hashes in an array.

getCamoAccountValidationInfo(account)

returns data on whether a camo account is valid or not, and why.

Parameters

Name Type Description
account string

the account to check.

Returns

object

the account validity data.

getCamoBananoSharedAccountData(seed, seedIx, account, sharedSeedIx)

get the banano shared account, used as an intermediary to send finds between the seed and the camo account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

Returns

string

the shared account.

getCamoNanoSharedAccountData(seed, seedIx, account, sharedSeedIx)

get the nano shared account, used as an intermediary to send finds between the seed and the camo account.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

Returns

string

the shared account.

receiveCamoBananoDepositsForSeed(seed, seedIx, account, sharedSeedIx, specificPendingBlockHash)

Recieve banano deposits for a camo account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

specificPendingBlockHash string

the pending block to recieve.

Returns

string

the response from receiving the block.

receiveCamoNanoDepositsForSeed(seed, seedIx, account, sharedSeedIx, specificPendingBlockHash)

Recieve nano deposits for a camo account with a given seed.

Parameters

Name Type Description
seed string

the seed to use to find the account.

seedIx string

the index to use with the seed.

account string

the camo account to send or recieve from.

sharedSeedIx string

the index to use with the shared seed.

specificPendingBlockHash string

the pending block to recieve.

Returns

string

the response from receiving the block.

getCamoBananoAccountBalanceRaw(toPrivateKey, fromPublicKey)

gets the total banano account balance, in raw.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string

the account balance, in raw.

getCamoNanoAccountBalanceRaw(toPrivateKey, fromPublicKey)

gets the total nano account balance, in raw.

Parameters

Name Type Description
toPrivateKey string

the private key that receives the funds.

fromPublicKey string

the public key that sent the funds.

Returns

string

the account balance, in raw.

getAccountsPending(accounts, count, source)

Get the network block count.

Calls {@link https://docs.nano.org/commands/rpc-protocol/#accounts_pending}

Parameters

Name Type Description
accounts string_array

the array of pending accounts.

count number

the max count to get.

source string

if true, get source.

Returns

object

the account's pending blocks.

getRawStrFromBananoStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromBanoshiStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromNanoStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getRawStrFromNanoshiStr(amountStr, amountPrefix)

Converts an amount into a raw amount.

Parameters

Name Type Description
amountStr string

the amount, as a string.

amountPrefix string

the amount, as a string.

Returns

string

the banano as a raw value.

getBananoAccount(publicKey)

Get the banano account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account.

getNanoAccount(publicKey)

Get the banano account for a given public key.

Parameters

Name Type Description
publicKey string

the public key.

Returns

string

the account.

getBananoPartsFromRaw(amountRawStr)

Get the banano parts (banano, banoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

Returns

BananoParts

the banano parts.

getNanoPartsFromRaw(amountRawStr)

Get the nano parts nano, nanoshi, raw) for a given raw value.

Parameters

Name Type Description
amountRawStr string

the raw amount, as a string.

Returns

BananoParts

the banano parts.