Function
Static Public Summary | ||
public |
checkAddress(address: string): boolean Check if the given address is valid. |
|
public |
checkBalance(balance: string): boolean 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 |
checkSignature(signature: string): boolean 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 |
derivePublicKey(secretKey: string): string Derive a public key from a secret key. |
|
public |
deriveSecretKey(seed: string, index: number): string 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 |
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 |
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:
Name | Type | Attribute | Description |
address | string | The address to check |
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:
Name | Type | Attribute | Description |
balance | string | The balance to check |
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:
Name | Type | Attribute | Description |
hash | string | The hash to check |
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:
Name | Type | Attribute | Description |
key | string | The key to check |
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:
Name | Type | Attribute | Description |
seed | string | The seed to check |
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:
Name | Type | Attribute | Description |
signature | string | The signature to check |
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:
Name | Type | Attribute | Description |
work | string | The work to check |
public createChangeBlock(secretKey: string, data: Object): Object source
import {createChangeBlock} from 'nanocurrency/src/block.js'
Create a change block. Requires initialization.
Params:
Name | Type | Attribute | Description |
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 |
public createOpenBlock(secretKey: string, data: Object): Object source
import {createOpenBlock} from 'nanocurrency/src/block.js'
Create an open block. Requires initialization.
Params:
Name | Type | Attribute | Description |
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 |
public createReceiveBlock(secretKey: string, data: Object): Object source
import {createReceiveBlock} from 'nanocurrency/src/block.js'
Create a receive block. Requires initialization.
Params:
Name | Type | Attribute | Description |
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 |
public createSendBlock(secretKey: string, data: Object): Object source
import {createSendBlock} from 'nanocurrency/src/block.js'
Create a send block. Requires initialization.
Params:
Name | Type | Attribute | Description |
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 |
public deriveAddress(publicKey: string): string source
import {deriveAddress} from 'nanocurrency/src/keys.js'
Derive address from a public key. Requires initialization.
Params:
Name | Type | Attribute | Description |
publicKey | string | The public key to generate the address from, in hexadecimal format |
public derivePublicKey(secretKey: string): string source
import {derivePublicKey} from 'nanocurrency/src/keys.js'
Derive a public key from a secret key. Requires initialization.
Params:
Name | Type | Attribute | Description |
secretKey | string | The secret key to generate the secret key from, 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.
public generateSeed(): Promise<string> source
import {generateSeed} from 'nanocurrency/src/keys.js'
Generate a cryptographically secure seed. Does not require initialization.
public getRandomBytes(count: *): * source
import {getRandomBytes} from 'nanocurrency/src/helpers.js'
Params:
Name | Type | Attribute | Description |
count | * |
Return:
* |
public hashChangeBlock(previous: string, representative: string): string source
import {hashChangeBlock} from 'nanocurrency/src/hash.js'
Hash a change block. Requires initialization.
public hashOpenBlock(source: string, representative: string, account: string): string source
import {hashOpenBlock} from 'nanocurrency/src/hash.js'
Hash an open block. Requires initialization.
public hashReceiveBlock(previous: string, source: string): string source
import {hashReceiveBlock} from 'nanocurrency/src/hash.js'
Hash a receive block. Requires initialization.
public hashSendBlock(previous: string, destination: string, balance: string): string source
import {hashSendBlock} from 'nanocurrency/src/hash.js'
Hash a send block. Requires initialization.
public init(): Promise<undefined> source
import {init} from 'nanocurrency/src/common.js'
Initialize the library.
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).
public signBlock(blockHash: string, secretKey: string): string source
import {signBlock} from 'nanocurrency/src/signature.js'
Sign a block. Requires initialization.
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.
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.