Skip to content

Latest commit

 

History

History
873 lines (625 loc) · 37.2 KB

documentation.md

File metadata and controls

873 lines (625 loc) · 37.2 KB

Objects

Main : object
PawUtil : object
DepositUtil : object
PawnodeApi : object

Typedefs

PawParts : Object
AccountValidationInfo : Object

Main : object

Kind: global namespace

Main.setPawnodeApi(_pawnodeApi) ⇒ undefined

Sets the Pawnode Api (useful for overriding some methods)

Kind: static method of Main
Returns: undefined - returns nothing.

Param Type Description
_pawnodeApi string the new pawnodeApi

Main.setAuth(auth) ⇒ undefined

Sets the Pawnode Api Authorization

Kind: static method of Main
Returns: undefined - returns nothing.

Param Type Description
auth string the new authorization

Main.setPawnodeApiUrl(url) ⇒ undefined

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

Kind: static method of Main
Returns: undefined - returns nothing.

Param Type Description
url string the new url

PawUtil : object

Kind: global namespace

PawUtil.getPawPartsFromDecimal(decimalAmount) ⇒ PawParts

converts amount from decimal to pawParts.

Kind: static method of PawUtil
Returns: PawParts - returns the paw parts of the decimal amount.

Param Type Description
decimalAmount string the decimal amount of paws.

PawUtil.getPawPartsAsDecimal(pawParts) ⇒ string

converts amount from pawParts to decimal.

Kind: static method of PawUtil
Returns: string - returns the decimal amount of paws.

Param Type Description
pawParts PawParts the paw parts to describe.

PawUtil.getPawDecimalAmountAsRaw(amount) ⇒ string

converts amount from decimal to raw.

Kind: static method of PawUtil
Returns: string - returns amount in raw.

Param Type Description
amount string the decimal amount.

PawUtil.getPawPartsDescription(pawParts) ⇒ string

describes the paw parts in an english description.

Kind: static method of PawUtil
Returns: string - returns the description of the paw parts.

Param Type Description
pawParts PawParts the paw parts to describe.

PawUtil.sendAmountToPawAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash) ⇒ Promise.<string>

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.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the send.

Param 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).

PawUtil.sendAmountToNanoAccountWithRepresentativeAndPrevious(seed, seedIx, destAccount, amountRaw, representative, previousHash) ⇒ Promise.<string>

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.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the send.

Param 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).

PawUtil.sendAmountToPawAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback) ⇒ Promise.<string>

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

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the send.

Param 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.

PawUtil.sendAmountToNanoAccount(seed, seedIx, destAccount, amountRaw, successCallback, failureCallback) ⇒ Promise.<string>

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

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the send.

Param 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.

PawUtil.changePawRepresentativeForSeed(seed, seedIx, representative) ⇒ Promise.<string>

Sets the rep for an account with a given seed.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the change.

Param 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.

PawUtil.changeNanoRepresentativeForSeed(seed, seedIx, representative) ⇒ Promise.<string>

Sets the rep for an account with a given seed.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the change.

Param 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.

PawUtil.getPawAccountFromSeed(seed, seedIx) ⇒ Promise.<string>

Get the paw account with a given seed and index.

Kind: static method of PawUtil
Returns: Promise.<string> - the account.

Param Type Description
seed string the seed to use to find the account.
seedIx string the index to use with the seed.

PawUtil.getNanoAccountFromSeed(seed, seedIx) ⇒ Promise.<string>

Get the paw account with a given seed and index.

Kind: static method of PawUtil
Returns: Promise.<string> - the account.

Param Type Description
seed string the seed to use to find the account.
seedIx string the index to use with the seed.

PawUtil.openPawAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw) ⇒ Promise.<string>

Open a paw account with a given seed.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the open.

Param 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.

PawUtil.openNanoAccountFromSeed(seed, seedIx, representative, pendingBlockHash, pendingValueRaw) ⇒ Promise.<string>

Open a nano account with a given seed.

Kind: static method of PawUtil
Returns: Promise.<string> - returns the hash returned by the open.

Param 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.

PawUtil.getBlockHash(block) ⇒ string

Get the hash for a given block.

Kind: static method of PawUtil
Returns: string - the block's hash.

Param Type Description
block string the seed to use to find the account.

PawUtil.signHash(privateKey, hash) ⇒ string

signs a hash.

Kind: static method of PawUtil
Returns: string - the block's hash.

Param Type Description
privateKey string the private key to use to sign.
hash string the hash to sign.

PawUtil.verify(hash, signature, publicKey) ⇒ string

verifys a hash.

Kind: static method of PawUtil
Returns: string - true if verification passed.

Param Type Description
hash string the hash to verify.
signature string the signature to verify.
publicKey string the public key to use to sign.

PawUtil.getSignature(privateKey, block) ⇒ string

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

Kind: static method of PawUtil
Returns: string - the block's signature.

Param Type Description
privateKey string the private key used to sign the block.
block string the block to sign.

PawUtil.getBytesFromHex(hex) ⇒ Uint8Array

Converts a hex string to bytes in a Uint8Array.

Kind: static method of PawUtil
Returns: Uint8Array - the bytes in a Uint8Array.

Param Type Description
hex string the hex string to use.

PawUtil.getHexFromBytes(bytes) ⇒ string

Converts bytes in a Uint8Array to a hex string.

Kind: static method of PawUtil
Returns: string - the hex string.

Param Type Description
bytes Uint8Array the bytes to use.

PawUtil.getWorkUsingCpu(hash, workBytes) ⇒ string

gets work bytes using the CPU.

Kind: static method of PawUtil
Returns: string - the work bytes as a hex string.

Param Type Description
hash string the hash to use to calculate work bytes.
workBytes Uint8Array the Uint8Array(8) used to store temporary calculations.

PawUtil.getRawStrFromPawStr(amountStr, amountPrefix) ⇒ string

Converts an amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the amount, as a string.
amountPrefix string the amount, as a string.

PawUtil.getRawStrFromPawoshiStr(amountStr, amountPrefix) ⇒ string

Converts an amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the amount, as a string.
amountPrefix string the amount, as a string.

PawUtil.getRawStrFromNanoStr(amountStr, amountPrefix) ⇒ string

Converts an amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the amount, as a string.
amountPrefix string the amount, as a string.

PawUtil.getRawStrFromNanoshiStr(amountStr, amountPrefix) ⇒ string

Converts an amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the amount, as a string.
amountPrefix string the amount, as a string.

PawUtil.getPawAccount(publicKey) ⇒ string

Get the paw account for a given public key.

Kind: static method of PawUtil
Returns: string - the account.

Param Type Description
publicKey string the public key.

PawUtil.getNanoAccount(publicKey) ⇒ string

Get the paw account for a given public key.

Kind: static method of PawUtil
Returns: string - the account.

Param Type Description
publicKey string the public key.

PawUtil.getPawPartsFromRaw(amountRawStr) ⇒ PawParts

Get the paw parts (paw, pawoshi, raw) for a given raw value.

Kind: static method of PawUtil
Returns: PawParts - the paw parts.

Param Type Description
amountRawStr string the raw amount, as a string.

PawUtil.getNanoPartsFromRaw(amountRawStr) ⇒ PawParts

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

Kind: static method of PawUtil
Returns: PawParts - the paw parts.

Param Type Description
amountRawStr string the raw amount, as a string.

PawUtil.getRawStrFromMajorAmountStr(amountStr, amountPrefix) ⇒ string

Converts an amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the amount, as a string.
amountPrefix string the amount, as a string.

PawUtil.getRawStrFromMinorAmountStr(amountStr, amountPrefix) ⇒ string

Converts a pawoshi amount into a raw amount.

Kind: static method of PawUtil
Returns: string - the paw as a raw value.

Param Type Description
amountStr string the pawoshi, as a string.
amountPrefix string the amount prefix, as a string.

PawUtil.getAmountPartsFromRaw(amountRawStr, amountPrefix) ⇒ PawParts

Get the paw parts (paw, pawoshi, raw) for a given raw value.

Kind: static method of PawUtil
Returns: PawParts - the paw parts.

Param Type Description
amountRawStr string the raw amount, as a string.
amountPrefix string the amount prefix, as a string.

PawUtil.getAccountPublicKey(account) ⇒ string

Get the public key for a given account.

Kind: static method of PawUtil
Returns: string - the public key.

Param Type Description
account string the account.

PawUtil.getAccountSuffix(publicKey) ⇒ string

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

Kind: static method of PawUtil
Returns: string - the account suffix.

Param Type Description
publicKey string the public key.

PawUtil.getAccount(publicKey, accountPrefix) ⇒ string

Get the account for a given public key.

Kind: static method of PawUtil
Returns: string - the account.

Param Type Description
publicKey string the public key.
accountPrefix string the prefix. paw_ or nano_.

PawUtil.isWorkValid(hashBytes, workBytes) ⇒ boolean

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

Kind: static method of PawUtil
Returns: boolean - true if the work is valid for the hash.

Param Type Description
hashBytes string the hash bytes to check.
workBytes string the work bytes to check.

PawUtil.getZeroedWorkBytes() ⇒ Uint8Array

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

Kind: static method of PawUtil
Returns: Uint8Array - the bytes in a Uint8Array.

PawUtil.getPublicKey(privateKey) ⇒ string

Get the public key for a given private key.

Kind: static method of PawUtil
Returns: string - the public key.

Param Type Description
privateKey string the private key.

PawUtil.isSeedValid(seed, seedIx) ⇒ object

validates a seed.

Kind: static method of PawUtil
Returns: object - {valid:[true/false] message:[if false, why]}.

Param Type Description
seed string the seed to use to validate.
seedIx string the index to use with the seed.

PawUtil.getPrivateKey(seed, seedIx) ⇒ string

Get the private key for a given seed.

Kind: static method of PawUtil
Returns: string - the private key.

Param Type Description
seed string the seed to use to find the account.
seedIx string the index to use with the seed.

PawUtil.getPawAccountValidationInfo(account) ⇒ AccountValidationInfo

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

Kind: static method of PawUtil
Returns: AccountValidationInfo - an object saying if the account is valid, and why.

Param Type Description
account string the account.

PawUtil.getNanoAccountValidationInfo(account) ⇒ AccountValidationInfo

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.

Kind: static method of PawUtil
Returns: AccountValidationInfo - an object saying if the account is valid, and why.

Param Type Description
account string the account.

DepositUtil : object

Kind: global namespace

DepositUtil.receiveNanoDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash) ⇒ Promise.<object>

Recieve deposits for a nano account with a given seed.

Kind: static method of DepositUtil
Returns: Promise.<object> - returns the response returned by the receive.

Param 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).

DepositUtil.receivePawDepositsForSeed(seed, seedIx, representative, specificPendingBlockHash) ⇒ Promise.<object>

Recieve deposits for a paw account with a given seed.

Kind: static method of DepositUtil
Returns: Promise.<object> - returns the response returned by the receive.

Param 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).

PawnodeApi : object

Kind: global namespace

PawnodeApi.getAccountBalanceRaw(account) ⇒ Promise.<string>

Get the balance, in raw, for an account.

(use other methods like getPawPartsFromRaw to convert to paw or pawoshi)

Calls https://docs.nano.org/commands/rpc-protocol/#accounts_balances

Kind: static method of PawnodeApi
Returns: Promise.<string> - the account's balance, in raw.

Param Type Description
account string the account to use.

PawnodeApi.getAccountBalanceAndPendingRaw(account) ⇒ Promise.<object>

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 getPawPartsFromRaw to convert to paw or pawoshi)

Calls https://docs.nano.org/commands/rpc-protocol/#accounts_balances

Kind: static method of PawnodeApi
Returns: Promise.<object> - the account's balances, in raw.

Param Type Description
account string the account to use.

PawnodeApi.getAccountsBalances(accounts) ⇒ Promise.<object>

Get the balances and pending values, in raw, as an object for all given account. Returns the Node object without transformation.

(use other methods like getPawPartsFromRaw to convert to paw or pawoshi)

Calls https://docs.nano.org/commands/rpc-protocol/#accounts_balances

Kind: static method of PawnodeApi
Returns: Promise.<object> - the account's balances, in raw.

Param Type Description
accounts string_array the account to use.

PawnodeApi.getAccountHistory(account, count, head, raw) ⇒ Promise.<object>

Get the history for an account.

Calls https://docs.nano.org/commands/rpc-protocol/#account_history

Kind: static method of PawnodeApi
Returns: Promise.<object> - the account's history.

Param 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).

PawnodeApi.getAccountInfo(account, representativeFlag) ⇒ Promise.<object>

Get the account info for an account.

Calls https://docs.nano.org/commands/rpc-protocol/#account_info

Kind: static method of PawnodeApi
Returns: Promise.<object> - the account's info.

Param Type Description
account string the account to use.
representativeFlag boolean the representativeFlag to use (optional).

PawnodeApi.getBlockCount() ⇒ Promise.<object>

Get the network block count.

Calls https://docs.nano.org/commands/rpc-protocol/#block_count

Kind: static method of PawnodeApi
Returns: Promise.<object> - the block count.

PawnodeApi.getAccountsPending(accounts, count, source) ⇒ Promise.<object>

Get the network block count.

Calls https://docs.nano.org/commands/rpc-protocol/#accounts_pending

Kind: static method of PawnodeApi
Returns: Promise.<object> - the account's pending blocks.

Param Type Description
accounts string_array the array of pending accounts.
count number the max count to get.
source string if true, get source.

PawnodeApi.setAuth(authString) ⇒ undefined

Sets an authorization string (http 'Authorization' header), useful if node requires api key.

Kind: static method of PawnodeApi
Returns: undefined - returns nothing.

Param Type Description
authString string api key as a string\

PawParts : Object

Kind: global typedef
Properties

Name Type Description
paw string The amount of paw.
pawoshi string The amount of pawoshi (not counting whole paw).
raw string The amount of raw (not counting whole paw and whole pawoshi).

AccountValidationInfo : Object

Kind: global typedef
Properties

Name Type Description
message string The message describing why the account is valid or not.
valid boolean True if account is valid.