Home Reference Source

Function

Static Public Summary
public

Check if the given address is valid.

public

Check if the given balance is valid.

public

Check if the given hash is valid.

public

Check if the given public or secret key is valid.

public
public

Check if the given seed is valid.

public

Check if the given signature is valid.

public

Check if the given work is valid.

public

createChangeBlock(secretKey: string, data: Object): Object

Create a change block.

public

createOpenBlock(secretKey: string, data: Object): Object

Create an open block.

public

createReceiveBlock(secretKey: string, data: Object): Object

Create a receive block.

public

createSendBlock(secretKey: string, data: Object): Object

Create a send block.

public

deriveAddress(publicKey: string): string

Derive address from a public key.

public

Derive a public key from a secret key.

public

Derive a secret key from a seed, given an index.

public

Generate a cryptographically secure seed.

public

getRandomBytes(count: *): *

public

hashChangeBlock(previous: string, representative: string): string

Hash a change block.

public

hashOpenBlock(source: string, representative: string, account: string): string

Hash an open block.

public

hashReceiveBlock(previous: string, source: string): string

Hash a receive block.

public

hashSendBlock(previous: string, destination: string, balance: string): string

Hash a send block.

public

Initialize the library.

public

Get whether or not the library is ready to be used (#module_NanoCurrency.init has been called).

public

signBlock(blockHash: string, secretKey: string): string

Sign a block.

public

validateWork(blockHash: string, work: string): boolean

Validate whether or not the work value meets the difficulty for the given hash.

public

verifyBlock(blockHash: string, signature: string, publicKey: string): boolean

Verify a block against a public key.

public

work(blockHash: string, workerIndex: number, workerCount: number): string

Find a work value that meets the difficulty for the given hash.

Static Public

public checkAddress(address: string): boolean source

import {checkAddress} from 'nanocurrency/src/common.js'

Check if the given address is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
address string

The address to check

Return:

boolean

Valid

public checkBalance(balance: string): boolean source

import {checkBalance} from 'nanocurrency/src/common.js'

Check if the given balance is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
balance string

The balance to check

Return:

boolean

Valid

public checkHash(hash: string): boolean source

import {checkHash} from 'nanocurrency/src/common.js'

Check if the given hash is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
hash string

The hash to check

Return:

boolean

Valid

public checkKey(key: string): boolean source

import {checkKey} from 'nanocurrency/src/common.js'

Check if the given public or secret key is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
key string

The key to check

Return:

boolean

Valid

public checkNotInitialized() source

import {checkNotInitialized} from 'nanocurrency/src/common.js'

public checkSeed(seed: string): boolean source

import {checkSeed} from 'nanocurrency/src/common.js'

Check if the given seed is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
seed string

The seed to check

Return:

boolean

Valid

public checkSignature(signature: string): boolean source

import {checkSignature} from 'nanocurrency/src/common.js'

Check if the given signature is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
signature string

The signature to check

Return:

boolean

Valid

public checkWork(work: string): boolean source

import {checkWork} from 'nanocurrency/src/common.js'

Check if the given work is valid. Does not require initialization.

Params:

NameTypeAttributeDescription
work string

The work to check

Return:

boolean

Valid

public createChangeBlock(secretKey: string, data: Object): Object source

import {createChangeBlock} from 'nanocurrency/src/block.js'

Create a change block. Requires initialization.

Params:

NameTypeAttributeDescription
secretKey string

The secret key to create the block from, in hexadecimal format

data Object

Block data

data.work string

The PoW

data.previous string

The hash of the previous block on the account chain, in hexadecimal format

data.representative string

The representative address

Return:

Object

Block

public createOpenBlock(secretKey: string, data: Object): Object source

import {createOpenBlock} from 'nanocurrency/src/block.js'

Create an open block. Requires initialization.

Params:

NameTypeAttributeDescription
secretKey string

The secret key to create the block from, in hexadecimal format

data Object

Block data

data.work string

The PoW

data.source string

The hash of the send block that is being received, in hexadecimal format

data.representative string

The representative address

Return:

Object

Block

public createReceiveBlock(secretKey: string, data: Object): Object source

import {createReceiveBlock} from 'nanocurrency/src/block.js'

Create a receive block. Requires initialization.

Params:

NameTypeAttributeDescription
secretKey string

The secret key to create the block from, in hexadecimal format

data Object

Block data

data.work string

The PoW

data.previous string

The hash of the previous block on the account chain, in hexadecimal format

data.source string

The hash of the send block that is being received, in hexadecimal format

Return:

Object

Block

public createSendBlock(secretKey: string, data: Object): Object source

import {createSendBlock} from 'nanocurrency/src/block.js'

Create a send block. Requires initialization.

Params:

NameTypeAttributeDescription
secretKey string

The secret key to create the block from, in hexadecimal format

data Object

Block data

data.work string

The PoW

data.previous string

The hash of the previous block on the account chain, in hexadecimal format

data.destination string

The destination address

data.balance string

The balance, in raw

Return:

Object

Block

public deriveAddress(publicKey: string): string source

import {deriveAddress} from 'nanocurrency/src/keys.js'

Derive address from a public key. Requires initialization.

Params:

NameTypeAttributeDescription
publicKey string

The public key to generate the address from, in hexadecimal format

Return:

string

Address

public derivePublicKey(secretKey: string): string source

import {derivePublicKey} from 'nanocurrency/src/keys.js'

Derive a public key from a secret key. Requires initialization.

Params:

NameTypeAttributeDescription
secretKey string

The secret key to generate the secret key from, in hexadecimal format

Return:

string

Public key, in hexadecimal format

public deriveSecretKey(seed: string, index: number): string source

import {deriveSecretKey} from 'nanocurrency/src/keys.js'

Derive a secret key from a seed, given an index. Requires initialization.

Params:

NameTypeAttributeDescription
seed string

The seed to generate the secret key from, in hexadecimal format

index number

The index to generate the secret key from

Return:

string

Secret key, in hexadecimal format

public generateSeed(): Promise<string> source

import {generateSeed} from 'nanocurrency/src/keys.js'

Generate a cryptographically secure seed. Does not require initialization.

Return:

Promise<string>

Seed, in hexadecimal format

public getRandomBytes(count: *): * source

import {getRandomBytes} from 'nanocurrency/src/helpers.js'

Params:

NameTypeAttributeDescription
count *

Return:

*

public hashChangeBlock(previous: string, representative: string): string source

import {hashChangeBlock} from 'nanocurrency/src/hash.js'

Hash a change block. Requires initialization.

Params:

NameTypeAttributeDescription
previous string

The hash of the previous block on the account chain, in hexadecimal format

representative string

The representative address

Return:

string

Hash, in hexadecimal format

public hashOpenBlock(source: string, representative: string, account: string): string source

import {hashOpenBlock} from 'nanocurrency/src/hash.js'

Hash an open block. Requires initialization.

Params:

NameTypeAttributeDescription
source string

The hash of the send block that is being received, in hexadecimal format

representative string

The representative address

account string

The account address

Return:

string

Hash, in hexadecimal format

public hashReceiveBlock(previous: string, source: string): string source

import {hashReceiveBlock} from 'nanocurrency/src/hash.js'

Hash a receive block. Requires initialization.

Params:

NameTypeAttributeDescription
previous string

The hash of the previous block on the account chain, in hexadecimal format

source string

The hash of the send block that is being received, in hexadecimal format

Return:

string

Hash, in hexadecimal format

public hashSendBlock(previous: string, destination: string, balance: string): string source

import {hashSendBlock} from 'nanocurrency/src/hash.js'

Hash a send block. Requires initialization.

Params:

NameTypeAttributeDescription
previous string

The hash of the previous block on the account chain, in hexadecimal format

destination string

The destination address

balance string

The balance, in raw

Return:

string

Hash, in hexadecimal format

public init(): Promise<undefined> source

import {init} from 'nanocurrency/src/common.js'

Initialize the library.

Return:

Promise<undefined>

public isReady(): boolean source

import {isReady} from 'nanocurrency/src/common.js'

Get whether or not the library is ready to be used (#module_NanoCurrency.init has been called).

Return:

boolean

public signBlock(blockHash: string, secretKey: string): string source

import {signBlock} from 'nanocurrency/src/signature.js'

Sign a block. Requires initialization.

Params:

NameTypeAttributeDescription
blockHash string

The hash of the block to sign

secretKey string

The secret key to sign the block with, in hexadecimal format

Return:

string

Signature, in hexadecimal format

public validateWork(blockHash: string, work: string): boolean source

import {validateWork} from 'nanocurrency/src/work.js'

Validate whether or not the work value meets the difficulty for the given hash. Requires initialization.

Params:

NameTypeAttributeDescription
blockHash string

The hash to validate the work against

work string

The work to validate

Return:

boolean

Valid

public verifyBlock(blockHash: string, signature: string, publicKey: string): boolean source

import {verifyBlock} from 'nanocurrency/src/signature.js'

Verify a block against a public key. Requires initialization.

Params:

NameTypeAttributeDescription
blockHash string

The hash of the block to verify

signature string

The signature of the block to verify, in hexadecimal format

publicKey string

The public key to verify the block against, in hexadecimal format

Return:

boolean

Valid

public work(blockHash: string, workerIndex: number, workerCount: number): string source

import {work} from 'nanocurrency/src/work.js'

Find a work value that meets the difficulty for the given hash. Requires initialization.

Params:

NameTypeAttributeDescription
blockHash string

The hash to find a work for

workerIndex number
  • optional
  • default: 0

The current worker index, starting at 0

workerCount number
  • optional
  • default: 1

The count of worker

Return:

string

Work, in hexadecimal format