From d4ef861ea222c45e37b243f12a0d4637fe868873 Mon Sep 17 00:00:00 2001 From: stjet <49297268+stjet@users.noreply.github.com> Date: Fri, 28 Jun 2024 03:46:43 +0000 Subject: [PATCH] more tests, finish readme --- README.md | 56 ++++++++++-- browser_test/index.html | 2 +- docs/CNAME | 1 - docs/assets/highlight.css | 85 ++++++++++++++++++- docs/classes/RPC.html | 40 ++++----- docs/classes/RPCWithBackup.html | 40 ++++----- docs/classes/RPCWorkProvider.html | 6 +- docs/classes/Wallet.html | 18 ++-- docs/functions/base32_to_uint8array.html | 2 +- .../get_address_from_public_key.html | 2 +- docs/functions/get_private_key_from_seed.html | 2 +- .../get_public_key_from_address.html | 2 +- .../get_public_key_from_private_key.html | 2 +- docs/functions/hash_block.html | 2 +- docs/functions/hex_to_uint8array.html | 2 +- docs/functions/int_to_uint8array.html | 2 +- docs/functions/raw_to_whole.html | 2 +- docs/functions/sign_block_hash.html | 2 +- docs/functions/sign_message.html | 2 +- docs/functions/uint8array_to_base32.html | 2 +- docs/functions/uint8array_to_hex.html | 2 +- docs/functions/utf8_to_uint8array.html | 2 +- docs/functions/verify_block_hash.html | 2 +- docs/functions/whole_to_raw.html | 2 +- docs/index.html | 26 ++++-- docs/interfaces/AccountBalanceRPC.html | 4 +- docs/interfaces/AccountHistoryBlock.html | 4 +- docs/interfaces/AccountHistoryRPC.html | 4 +- docs/interfaces/AccountHistoryRawBlock.html | 4 +- docs/interfaces/AccountHistoryRawRPC.html | 4 +- docs/interfaces/AccountInfoRPC.html | 4 +- docs/interfaces/AccountReceivableRPC.html | 4 +- .../AccountReceivableSourceRPC.html | 4 +- .../AccountReceivableThresholdRPC.html | 4 +- docs/interfaces/AccountRepresentativeRPC.html | 4 +- docs/interfaces/AccountWeightRPC.html | 4 +- docs/interfaces/AccountsBalancesRPC.html | 4 +- .../AccountsRepresentativesRPC.html | 4 +- docs/interfaces/Block.html | 4 +- docs/interfaces/BlockCountRPC.html | 4 +- docs/interfaces/BlockInfoRPC.html | 4 +- docs/interfaces/BlockNoSignature.html | 4 +- docs/interfaces/BlocksInfoRPC.html | 4 +- docs/interfaces/BlocksRPC.html | 4 +- docs/interfaces/DelegatorsCountRPC.html | 4 +- docs/interfaces/DelegatorsRPC.html | 4 +- docs/interfaces/RPCInterface.html | 4 +- docs/interfaces/RepresentativesOnlineRPC.html | 4 +- .../RepresentativesOnlineWeightRPC.html | 4 +- docs/interfaces/RepresentativesRPC.html | 4 +- docs/interfaces/WorkProvider.html | 4 +- docs/types/Address.html | 2 +- docs/types/AddressPrefix.html | 2 +- docs/types/BlockAllTypes.html | 2 +- docs/types/BlockBasicTypes.html | 2 +- docs/types/BlockHash.html | 2 +- docs/types/BlockLegacyTypes.html | 2 +- docs/types/BlockStateChangeTypes.html | 2 +- docs/types/BlockSubtype.html | 2 +- docs/types/Whole.html | 2 +- docs/types/WorkFunction.html | 2 +- node_test/index.js | 9 +- package.json | 2 +- wallet.ts | 2 +- 64 files changed, 294 insertions(+), 149 deletions(-) delete mode 100644 docs/CNAME diff --git a/README.md b/README.md index 5257089..6ad881d 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,64 @@ > ~~how to buy banani from beatrice~~ > how to install banani on react.js -Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from [bananopie](https://github.com/stjet/bananopie) (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js. +Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from the Python [bananopie](https://github.com/stjet/bananopie) (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js. -The docs are hosted at https://banani.prussia.dev. +**Please report any bugs or request features by opening an Github issue.** You can ask for help or ask questions in the #frankensteins-lab channel of the Banano discord and people will be typically be eager to assist if they can. -Currently being written, and heavy work in progress. +## Installing -## Examples +``` +npm install banani +``` + +Embedding in the browser is easy to - just download and add `banani-browser.js` to your website: +```html + +``` + +Take a look in `browser_test/index.html` for an example. ## Documentation +The docs are hosted at https://banani.prussia.dev (can also be accessed at https://stjet.github.io/banani/). + +## Examples +Banani allows you to send, receive, and change representative. If you are using Banani on the web, replace `banani` with `window.banani`. + +```js +let rpc = new banani.RPC("https://kaliumapi.appditto.com/api"); + +console.log(await rpc.get_block_count()); + +let wallet = new banani.Wallet(rpc, process.env.seed); + +let zero_index_address = wallet.address; + +wallet.index = 1; + +let send_hash = await wallet.send(zero_index_address, "1"); //send 1 banano + +wallet.index = 0; + +await wallet.receive(send_hash); //receive the bananos we just send (can also do `await wallet.receive_all()`) + +await wallet.change_rep("placeholder"); +``` + +Banani also comes with some useful utilities, and message signing: +```js +let rpc = new banani.RPC("https://kaliumapi.appditto.com/api"); +let random_wallet = banani.Wallet.gen_random_wallet(rpc); + +console.log(banani.whole_to_raw("4.20069") === 420069000000000000000000000000n); +console.log(random_wallet.sign_message("test message\ntest test")); +``` ## Contributing ``` git clone https://github.com/stjet/banani.git cd banani ... - + ... npm run build ``` @@ -46,3 +88,7 @@ Tweetnacl is not listed as a dependency in the package.json because it has been Banani also has many dev dependencies for contributing/developing the package (see the "Contributing" section), but they are not needed for regular users of the package. +## Todo +- More extensive testing +- Example work generating function + diff --git a/browser_test/index.html b/browser_test/index.html index cef47fa..0544f6f 100644 --- a/browser_test/index.html +++ b/browser_test/index.html @@ -22,7 +22,7 @@ const raw = window.banani.whole_to_raw(event.target.value) document.getElementById("units").textContent = raw + "\n" + window.banani.raw_to_whole(raw); } - let random_wallet = window.banani.Wallet.gen_random_wallet(); + let random_wallet = window.banani.Wallet.gen_random_wallet(rpc); console.log("seed", random_wallet.seed); let prk = window.banani.get_private_key_from_seed(random_wallet.seed, 0); console.log("privkey", prk); diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index fc2ba68..0000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -banani.prussia.dev \ No newline at end of file diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index aabe26d..ad81803 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -3,10 +3,32 @@ --dark-hl-0: #9CDCFE; --light-hl-1: #000000; --dark-hl-1: #D4D4D4; - --light-hl-2: #000000; - --dark-hl-2: #C8C8C8; - --light-hl-3: #008000; - --dark-hl-3: #6A9955; + --light-hl-2: #800000; + --dark-hl-2: #808080; + --light-hl-3: #800000; + --dark-hl-3: #569CD6; + --light-hl-4: #000000FF; + --dark-hl-4: #D4D4D4; + --light-hl-5: #E50000; + --dark-hl-5: #9CDCFE; + --light-hl-6: #0000FF; + --dark-hl-6: #CE9178; + --light-hl-7: #0000FF; + --dark-hl-7: #569CD6; + --light-hl-8: #795E26; + --dark-hl-8: #DCDCAA; + --light-hl-9: #A31515; + --dark-hl-9: #CE9178; + --light-hl-10: #AF00DB; + --dark-hl-10: #C586C0; + --light-hl-11: #098658; + --dark-hl-11: #B5CEA8; + --light-hl-12: #008000; + --dark-hl-12: #6A9955; + --light-hl-13: #EE0000; + --dark-hl-13: #D7BA7D; + --light-hl-14: #000000; + --dark-hl-14: #C8C8C8; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -16,6 +38,17 @@ --hl-1: var(--light-hl-1); --hl-2: var(--light-hl-2); --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); + --hl-14: var(--light-hl-14); --code-background: var(--light-code-background); } } @@ -24,6 +57,17 @@ --hl-1: var(--dark-hl-1); --hl-2: var(--dark-hl-2); --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); + --hl-14: var(--dark-hl-14); --code-background: var(--dark-code-background); } } @@ -32,6 +76,17 @@ --hl-1: var(--light-hl-1); --hl-2: var(--light-hl-2); --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); + --hl-11: var(--light-hl-11); + --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); + --hl-14: var(--light-hl-14); --code-background: var(--light-code-background); } @@ -40,6 +95,17 @@ --hl-1: var(--dark-hl-1); --hl-2: var(--dark-hl-2); --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); + --hl-11: var(--dark-hl-11); + --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); + --hl-14: var(--dark-hl-14); --code-background: var(--dark-code-background); } @@ -47,4 +113,15 @@ .hl-1 { color: var(--hl-1); } .hl-2 { color: var(--hl-2); } .hl-3 { color: var(--hl-3); } +.hl-4 { color: var(--hl-4); } +.hl-5 { color: var(--hl-5); } +.hl-6 { color: var(--hl-6); } +.hl-7 { color: var(--hl-7); } +.hl-8 { color: var(--hl-8); } +.hl-9 { color: var(--hl-9); } +.hl-10 { color: var(--hl-10); } +.hl-11 { color: var(--hl-11); } +.hl-12 { color: var(--hl-12); } +.hl-13 { color: var(--hl-13); } +.hl-14 { color: var(--hl-14); } pre, code { background: var(--code-background); } diff --git a/docs/classes/RPC.html b/docs/classes/RPC.html index 5f6850c..07e7838 100644 --- a/docs/classes/RPC.html +++ b/docs/classes/RPC.html @@ -1,5 +1,5 @@ RPC | banani

Class RPC

Sends RPC requests to the RPC node, also has wrappers for actions that only read the network (write actions are handled by the Wallet class)

-

Hierarchy (view full)

Implements

Constructors

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • rpc_url: string
    • Optional use_pending: boolean = false

      If true, uses "pending" instead of "receivable" in RPC action names, for compatibility with older versions of the node

      -

    Returns RPC

Properties

DECIMALS: any = undefined
debug: boolean = false
headers: Record<string, string>

HTTP headers to send with any RPC requests, defaults to { "Content-Type": "application/json" }

-
rpc_url: string
use_pending: boolean

Methods

  • The function that sends the RPC POST request

    -

    Parameters

    • payload: Record<string, any>

    Returns Promise<Record<string, any>>

\ No newline at end of file +

Returns RPC

Properties

DECIMALS: any = undefined
debug: boolean = false
headers: Record<string, string>

HTTP headers to send with any RPC requests, defaults to { "Content-Type": "application/json" }

+
rpc_url: string
use_pending: boolean

Methods

  • The function that sends the RPC POST request

    +

    Parameters

    • payload: Record<string, any>

    Returns Promise<Record<string, any>>

\ No newline at end of file diff --git a/docs/classes/RPCWithBackup.html b/docs/classes/RPCWithBackup.html index 4e0dd2c..fb27ac6 100644 --- a/docs/classes/RPCWithBackup.html +++ b/docs/classes/RPCWithBackup.html @@ -1,5 +1,5 @@ RPCWithBackup | banani

Class RPCWithBackup

Sends RPC requests to the RPC node, also has wrappers for actions that only read the network (write actions are handled by the Wallet class)

-

Hierarchy (view full)

  • RPC
    • RPCWithBackup

Constructors

Hierarchy (view full)

  • RPC
    • RPCWithBackup

Constructors

  • Parameters

    • rpc_urls: string[]
    • Optional timeout: number

      Request to RPC timeout, in milliseconds. If RPC request fails or timeouts, tries the next RPC

      -
    • use_pending: boolean = false

    Returns RPCWithBackup

Properties

DECIMALS: any = undefined
debug: boolean = false
headers: Record<string, string>

HTTP headers to send with any RPC requests, defaults to { "Content-Type": "application/json" }

-
rpc_url: string
rpc_urls: string[]
timeout: number
use_pending: boolean

Methods

  • The function that sends the RPC POST request

    -

    Parameters

    • payload: Record<string, any>

    Returns Promise<Record<string, any>>

\ No newline at end of file +
  • use_pending: boolean = false
  • Returns RPCWithBackup

    Properties

    DECIMALS: any = undefined
    debug: boolean = false
    headers: Record<string, string>

    HTTP headers to send with any RPC requests, defaults to { "Content-Type": "application/json" }

    +
    rpc_url: string
    rpc_urls: string[]
    timeout: number
    use_pending: boolean

    Methods

    • The function that sends the RPC POST request

      +

      Parameters

      • payload: Record<string, any>

      Returns Promise<Record<string, any>>

    \ No newline at end of file diff --git a/docs/classes/RPCWorkProvider.html b/docs/classes/RPCWorkProvider.html index 8d36030..38ad68b 100644 --- a/docs/classes/RPCWorkProvider.html +++ b/docs/classes/RPCWorkProvider.html @@ -1,6 +1,6 @@ -RPCWorkProvider | banani

    Class RPCWorkProvider

    Constructors

    constructor +RPCWorkProvider | banani

    Class RPCWorkProvider

    Constructors

    Properties

    Methods

    Constructors

    Properties

    extra_payload: Record<string, any> = {}

    Extra json to send with the rpc payload. Needed for rpc.nano.to's work_generate, unfortunately

    -
    rpc: RPC

    Methods

    • Parameters

      • block_hash: string

      Returns Promise<string>

    \ No newline at end of file +

    Constructors

    Properties

    extra_payload: Record<string, any> = {}

    Extra json to send with the rpc payload. Needed for rpc.nano.to's work_generate, unfortunately

    +
    rpc: RPC

    Methods

    • Parameters

      • block_hash: string

      Returns Promise<string>

    \ No newline at end of file diff --git a/docs/classes/Wallet.html b/docs/classes/Wallet.html index 7fb5cca..3b60b11 100644 --- a/docs/classes/Wallet.html +++ b/docs/classes/Wallet.html @@ -1,5 +1,5 @@ Wallet | banani

    Class Wallet

    Wallets are created from seeds, so they can have multiple addresses by changing the index. Use Wallets to "write" (send, receive, change rep) to the network

    -

    Constructors

    Constructors

    Properties

    Constructors

    • Parameters

      • rpc: RPCInterface
      • Optional seed: string

        Seed for the wallet from which private keys are derived. 64 character hex string (32 bytes)

        -
      • index: number = 0
      • try_work: boolean = false
      • Optional work_function: WorkFunction

      Returns Wallet

    Properties

    add_do_work: boolean = true
    index: number

    Seed index. Seeds can have multiple private keys and addresses

    -
    seed: string
    try_work: boolean
    work_function?: WorkFunction

    Accessors

    • get address(): `ban_${string}` | `nano_${string}`
    • Returns `ban_${string}` | `nano_${string}`

    • get private_key(): string
    • Returns string

    • get public_key(): string
    • Returns string

    Methods

    • Parameters

      • new_representative: `ban_${string}` | `nano_${string}`
      • Optional work: boolean

      Returns Promise<string>

    • Parameters

      • Optional new_representative: `ban_${string}` | `nano_${string}`

        banano address to change representative to

        +
      • index: number = 0
      • try_work: boolean = false
      • Optional work_function: WorkFunction

      Returns Wallet

    Properties

    add_do_work: boolean = true
    index: number

    Seed index. Seeds can have multiple private keys and addresses

    +
    seed: string
    try_work: boolean
    work_function?: WorkFunction

    Accessors

    • get address(): `ban_${string}` | `nano_${string}`
    • Returns `ban_${string}` | `nano_${string}`

    • get private_key(): string
    • Returns string

    • get public_key(): string
    • Returns string

    Methods

    • Parameters

      • new_representative: `ban_${string}` | `nano_${string}`
      • Optional work: boolean

      Returns Promise<string>

    • Parameters

      • Optional new_representative: `ban_${string}` | `nano_${string}`

        banano address to change representative to

      • Optional gen_work: boolean

        whether or not to call work function to generate work

        -

      Returns Promise<string>

    • Parameters

      • Optional include_confirmed: boolean
      • Optional representative: boolean
      • Optional weight: boolean
      • Optional pending: boolean

      Returns Promise<AccountInfoRPC>

    • Parameters

      • Optional block_hash: string

        send block to receive

        +

      Returns Promise<string>

    • Parameters

      • Optional include_confirmed: boolean
      • Optional representative: boolean
      • Optional weight: boolean
      • Optional pending: boolean

      Returns Promise<AccountInfoRPC>

    • Parameters

      • Optional block_hash: string

        send block to receive

      • Optional gen_work: boolean

        whether or not to call work function to generate work

      • Optional representative: `ban_${string}` | `nano_${string}`

        optionally provide a representative if you do not want to use the current representative receive bananos from a specific send block

        -

      Returns Promise<string>

    • Parameters

      • Optional count: number = 20

        Max amount of blocks to receive +

      Returns Promise<string>

    • Parameters

      • Optional count: number = 20

        Max amount of blocks to receive receive all (up to count and exceeding threshold if applicable) receivable blocks

      • Optional threshold: `${number}`

        Min amount of Banano to receive in whole

      • Optional gen_work: boolean

        whether or not to call work function to generate work Receive all receivable transactions (up to count, and over threshold

        -

      Returns Promise<string[]>

    • Parameters

      • Optional to: `ban_${string}` | `nano_${string}`

        address to send to

        +

      Returns Promise<string[]>

    • Parameters

      • Optional to: `ban_${string}` | `nano_${string}`

        address to send to

      • Optional amount: `${number}`

        amount in whole bananos to send

      • Optional gen_work: boolean

        whether or not to call work function to generate work

      • Optional representative: `ban_${string}` | `nano_${string}`

        optionally provide a representative if you do not want to use the current representative

        -
      • Optional cached_account_info: AccountInfoRPC

        can save one rpc call in some cases. mostly for internal use. Make sure that in the RPC call, "representative" is "true" +

      • Optional cached_account_info: AccountInfoRPC

        can save one rpc call in some cases. Mostly for internal use. Make sure that in the RPC call, "representative" is "true" Send Bananos

        -

      Returns Promise<string>

    • Parameters

      • to: `ban_${string}` | `nano_${string}`
      • Optional work: boolean
      • Optional representative: `ban_${string}` | `nano_${string}`

      Returns Promise<string>

    • Parameters

      • message: string

      Returns string

    \ No newline at end of file +

    Returns Promise<string>

    • Parameters

      • to: `ban_${string}` | `nano_${string}`
      • Optional work: boolean
      • Optional representative: `ban_${string}` | `nano_${string}`

      Returns Promise<string>

    • Parameters

      • message: string

      Returns string

    \ No newline at end of file diff --git a/docs/functions/base32_to_uint8array.html b/docs/functions/base32_to_uint8array.html index b4cfebf..4ace6ad 100644 --- a/docs/functions/base32_to_uint8array.html +++ b/docs/functions/base32_to_uint8array.html @@ -1 +1 @@ -base32_to_uint8array | banani

    Function base32_to_uint8array

    • Parameters

      • base32: string

      Returns Uint8Array

    \ No newline at end of file +base32_to_uint8array | banani

    Function base32_to_uint8array

    • Parameters

      • base32: string

      Returns Uint8Array

    \ No newline at end of file diff --git a/docs/functions/get_address_from_public_key.html b/docs/functions/get_address_from_public_key.html index 4447e6c..df4923c 100644 --- a/docs/functions/get_address_from_public_key.html +++ b/docs/functions/get_address_from_public_key.html @@ -1 +1 @@ -get_address_from_public_key | banani

    Function get_address_from_public_key

    \ No newline at end of file +get_address_from_public_key | banani

    Function get_address_from_public_key

    \ No newline at end of file diff --git a/docs/functions/get_private_key_from_seed.html b/docs/functions/get_private_key_from_seed.html index fb0415e..1e75e77 100644 --- a/docs/functions/get_private_key_from_seed.html +++ b/docs/functions/get_private_key_from_seed.html @@ -1 +1 @@ -get_private_key_from_seed | banani

    Function get_private_key_from_seed

    • Parameters

      • seed: string
      • index: number

      Returns string

    \ No newline at end of file +get_private_key_from_seed | banani

    Function get_private_key_from_seed

    • Parameters

      • seed: string
      • index: number

      Returns string

    \ No newline at end of file diff --git a/docs/functions/get_public_key_from_address.html b/docs/functions/get_public_key_from_address.html index 0f33fa7..6f5ef1c 100644 --- a/docs/functions/get_public_key_from_address.html +++ b/docs/functions/get_public_key_from_address.html @@ -1 +1 @@ -get_public_key_from_address | banani

    Function get_public_key_from_address

    • Parameters

      • address: `ban_${string}` | `nano_${string}`

      Returns string

    \ No newline at end of file +get_public_key_from_address | banani

    Function get_public_key_from_address

    • Parameters

      • address: `ban_${string}` | `nano_${string}`

      Returns string

    \ No newline at end of file diff --git a/docs/functions/get_public_key_from_private_key.html b/docs/functions/get_public_key_from_private_key.html index 74ba826..5157bcb 100644 --- a/docs/functions/get_public_key_from_private_key.html +++ b/docs/functions/get_public_key_from_private_key.html @@ -1 +1 @@ -get_public_key_from_private_key | banani

    Function get_public_key_from_private_key

    • Parameters

      • private_key: string

      Returns string

    \ No newline at end of file +get_public_key_from_private_key | banani

    Function get_public_key_from_private_key

    • Parameters

      • private_key: string

      Returns string

    \ No newline at end of file diff --git a/docs/functions/hash_block.html b/docs/functions/hash_block.html index 47f967a..3b5e8d7 100644 --- a/docs/functions/hash_block.html +++ b/docs/functions/hash_block.html @@ -1 +1 @@ -hash_block | banani

    Function hash_block

    \ No newline at end of file +hash_block | banani

    Function hash_block

    \ No newline at end of file diff --git a/docs/functions/hex_to_uint8array.html b/docs/functions/hex_to_uint8array.html index 447591d..ee0b2c3 100644 --- a/docs/functions/hex_to_uint8array.html +++ b/docs/functions/hex_to_uint8array.html @@ -1 +1 @@ -hex_to_uint8array | banani

    Function hex_to_uint8array

    • Parameters

      • hex: string

      Returns Uint8Array

    \ No newline at end of file +hex_to_uint8array | banani

    Function hex_to_uint8array

    • Parameters

      • hex: string

      Returns Uint8Array

    \ No newline at end of file diff --git a/docs/functions/int_to_uint8array.html b/docs/functions/int_to_uint8array.html index fc79229..1fb41a7 100644 --- a/docs/functions/int_to_uint8array.html +++ b/docs/functions/int_to_uint8array.html @@ -1 +1 @@ -int_to_uint8array | banani

    Function int_to_uint8array

    • Parameters

      • int: number
      • len: number

      Returns Uint8Array

    \ No newline at end of file +int_to_uint8array | banani

    Function int_to_uint8array

    • Parameters

      • int: number
      • len: number

      Returns Uint8Array

    \ No newline at end of file diff --git a/docs/functions/raw_to_whole.html b/docs/functions/raw_to_whole.html index e07951f..5879dec 100644 --- a/docs/functions/raw_to_whole.html +++ b/docs/functions/raw_to_whole.html @@ -1,2 +1,2 @@ raw_to_whole | banani

    Function raw_to_whole

    • Turn raw Bananos (bigint) into whole Bananos (string)

      -

      Parameters

      • raw: bigint
      • decimals: number = BANANO_DECIMALS

      Returns Whole

    \ No newline at end of file +

    Parameters

    • raw: bigint
    • decimals: number = BANANO_DECIMALS

    Returns Whole

    \ No newline at end of file diff --git a/docs/functions/sign_block_hash.html b/docs/functions/sign_block_hash.html index a7fa21e..873a15a 100644 --- a/docs/functions/sign_block_hash.html +++ b/docs/functions/sign_block_hash.html @@ -1 +1 @@ -sign_block_hash | banani

    Function sign_block_hash

    • Parameters

      • private_key: string
      • block_hash: string

      Returns string

    \ No newline at end of file +sign_block_hash | banani

    Function sign_block_hash

    • Parameters

      • private_key: string
      • block_hash: string

      Returns string

    \ No newline at end of file diff --git a/docs/functions/sign_message.html b/docs/functions/sign_message.html index 88348ec..9a7e64e 100644 --- a/docs/functions/sign_message.html +++ b/docs/functions/sign_message.html @@ -1,3 +1,3 @@ sign_message | banani

    Function sign_message

    • sign message by constructing a dummy block with the message (why not just sign the message itself instead of putting it in a dummy block? ledger support). This is already the standard across Banano services and wallets which support signing so please don't invent your own scheme

      Parameters

      • private_key: string
      • message: string
      • preamble: string = MESSAGE_PREAMBLE

      Returns string

      The signature in hex

      -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/docs/functions/uint8array_to_base32.html b/docs/functions/uint8array_to_base32.html index f2202ac..2eff9e2 100644 --- a/docs/functions/uint8array_to_base32.html +++ b/docs/functions/uint8array_to_base32.html @@ -1 +1 @@ -uint8array_to_base32 | banani

    Function uint8array_to_base32

    • Parameters

      • uint8array: Uint8Array

      Returns string

    \ No newline at end of file +uint8array_to_base32 | banani

    Function uint8array_to_base32

    • Parameters

      • uint8array: Uint8Array

      Returns string

    \ No newline at end of file diff --git a/docs/functions/uint8array_to_hex.html b/docs/functions/uint8array_to_hex.html index 38e0e35..aadf419 100644 --- a/docs/functions/uint8array_to_hex.html +++ b/docs/functions/uint8array_to_hex.html @@ -1 +1 @@ -uint8array_to_hex | banani

    Function uint8array_to_hex

    • Parameters

      • uint8array: Uint8Array

      Returns string

    \ No newline at end of file +uint8array_to_hex | banani

    Function uint8array_to_hex

    • Parameters

      • uint8array: Uint8Array

      Returns string

    \ No newline at end of file diff --git a/docs/functions/utf8_to_uint8array.html b/docs/functions/utf8_to_uint8array.html index c410dda..ccd6b38 100644 --- a/docs/functions/utf8_to_uint8array.html +++ b/docs/functions/utf8_to_uint8array.html @@ -1 +1 @@ -utf8_to_uint8array | banani

    Function utf8_to_uint8array

    • Parameters

      • utf8: string

      Returns Uint8Array

    \ No newline at end of file +utf8_to_uint8array | banani

    Function utf8_to_uint8array

    • Parameters

      • utf8: string

      Returns Uint8Array

    \ No newline at end of file diff --git a/docs/functions/verify_block_hash.html b/docs/functions/verify_block_hash.html index baab98a..384de13 100644 --- a/docs/functions/verify_block_hash.html +++ b/docs/functions/verify_block_hash.html @@ -1,2 +1,2 @@ verify_block_hash | banani

    Function verify_block_hash

    • Make sure the alleged signature for a block hash is valid

      -

      Parameters

      • public_key: string
      • signature: string
      • block_hash: string

      Returns boolean

    \ No newline at end of file +

    Parameters

    • public_key: string
    • signature: string
    • block_hash: string

    Returns boolean

    \ No newline at end of file diff --git a/docs/functions/whole_to_raw.html b/docs/functions/whole_to_raw.html index bd3a72f..748a380 100644 --- a/docs/functions/whole_to_raw.html +++ b/docs/functions/whole_to_raw.html @@ -1,2 +1,2 @@ whole_to_raw | banani

    Function whole_to_raw

    • Turn whole Bananos (string) into raw Bananos (bigint)

      -

      Parameters

      • whole: `${number}`
      • decimals: number = BANANO_DECIMALS

      Returns bigint

    \ No newline at end of file +

    Parameters

    • whole: `${number}`
    • decimals: number = BANANO_DECIMALS

    Returns bigint

    \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 035e5a4..6ef02a8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,10 +2,22 @@

    how to buy banani from beatrice how to install banani on react.js

    -

    Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from bananopie (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js.

    -

    The docs are hosted at https://banani.prussia.dev.

    -

    Currently being written, and heavy work in progress.

    -

    Examples

    Documentation

    Contributing

    git clone https://github.com/stjet/banani.git
    cd banani
    ...
    <make your changes>
    ...
    npm run build +

    Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from the Python bananopie (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js.

    +

    Please report any bugs or request features by opening an Github issue. You can ask for help or ask questions in the #frankensteins-lab channel of the Banano discord and people will be typically be eager to assist if they can.

    +

    Installing

    npm install banani
    +
    +

    Embedding in the browser is easy to - just download and add banani-browser.js to your website:

    +
    <script src="/path/to/banani-browser.js"></script>
    +
    +

    Take a look in browser_test/index.html for an example.

    +

    Documentation

    The docs are hosted at https://banani.prussia.dev (can also be accessed at https://stjet.github.io/banani/).

    +

    Examples

    Banani allows you to send, receive, and change representative. If you are using Banani on the web, replace banani with window.banani.

    +
    let rpc = new banani.RPC("https://kaliumapi.appditto.com/api");

    console.log(await rpc.get_block_count());

    let wallet = new banani.Wallet(rpc, process.env.seed);

    let zero_index_address = wallet.address;

    wallet.index = 1;

    let send_hash = await wallet.send(zero_index_address, "1"); //send 1 banano

    wallet.index = 0;

    await wallet.receive(send_hash); //receive the bananos we just send (can also do `await wallet.receive_all()`)

    await wallet.change_rep("placeholder"); +
    +

    Banani also comes with some useful utilities, and message signing:

    +
    let rpc = new banani.RPC("https://kaliumapi.appditto.com/api");
    let random_wallet = banani.Wallet.gen_random_wallet(rpc);

    console.log(banani.whole_to_raw("4.20069") === 420069000000000000000000000000n);
    console.log(random_wallet.sign_message("test message\ntest test")); +
    +

    Contributing

    git clone https://github.com/stjet/banani.git
    cd banani
    ...
    <make your changes with your favourite editor>
    ...
    npm run build

    Then commit and push your changes.

    In most cases, you will only need to touch the typescript (.ts) files.

    @@ -20,4 +32,8 @@ how to install banani on react.js

    Dependencies

    Banani has two external dependencies, tweetnacl and blake2b. Blake2b probably has its own dependencies, but I haven't checked.

    Tweetnacl is not listed as a dependency in the package.json because it has been modified to use blake2b for the hashing algorithm. So, a modified version of it is distributed directly along with the package (see tweetnacl_mod.js). Clone the repo and run npm run cryptodiff to see the changes made from regular tweetnacl.

    Banani also has many dev dependencies for contributing/developing the package (see the "Contributing" section), but they are not needed for regular users of the package.

    -
    \ No newline at end of file +

    Todo

      +
    • More extensive testing
    • +
    • Example work generating function
    • +
    +
    \ No newline at end of file diff --git a/docs/interfaces/AccountBalanceRPC.html b/docs/interfaces/AccountBalanceRPC.html index b768a16..a6f366e 100644 --- a/docs/interfaces/AccountBalanceRPC.html +++ b/docs/interfaces/AccountBalanceRPC.html @@ -1,4 +1,4 @@ -AccountBalanceRPC | banani

    Interface AccountBalanceRPC

    interface AccountBalanceRPC {
        balance: `${number}`;
        pending: `${number}`;
        receivable?: `${number}`;
    }

    Properties

    balance +AccountBalanceRPC | banani

    Interface AccountBalanceRPC

    interface AccountBalanceRPC {
        balance: `${number}`;
        pending: `${number}`;
        receivable?: `${number}`;
    }

    Properties

    balance: `${number}`
    pending: `${number}`
    receivable?: `${number}`
    \ No newline at end of file +

    Properties

    balance: `${number}`
    pending: `${number}`
    receivable?: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountHistoryBlock.html b/docs/interfaces/AccountHistoryBlock.html index 4b5f3d8..4f48ae3 100644 --- a/docs/interfaces/AccountHistoryBlock.html +++ b/docs/interfaces/AccountHistoryBlock.html @@ -1,8 +1,8 @@ -AccountHistoryBlock | banani

    Interface AccountHistoryBlock

    interface AccountHistoryBlock {
        account: `ban_${string}` | `nano_${string}`;
        amount: `${number}`;
        confirmed: boolean;
        hash: string;
        height: `${number}`;
        local_timestamp: `${number}`;
        type: BlockStateChangeTypes;
    }

    Properties

    account +AccountHistoryBlock | banani

    Interface AccountHistoryBlock

    interface AccountHistoryBlock {
        account: `ban_${string}` | `nano_${string}`;
        amount: `${number}`;
        confirmed: boolean;
        hash: string;
        height: `${number}`;
        local_timestamp: `${number}`;
        type: BlockStateChangeTypes;
    }

    Properties

    account: `ban_${string}` | `nano_${string}`
    amount: `${number}`
    confirmed: boolean
    hash: string
    height: `${number}`
    local_timestamp: `${number}`
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    amount: `${number}`
    confirmed: boolean
    hash: string
    height: `${number}`
    local_timestamp: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountHistoryRPC.html b/docs/interfaces/AccountHistoryRPC.html index cd71103..cc96b5c 100644 --- a/docs/interfaces/AccountHistoryRPC.html +++ b/docs/interfaces/AccountHistoryRPC.html @@ -1,4 +1,4 @@ -AccountHistoryRPC | banani

    Interface AccountHistoryRPC

    interface AccountHistoryRPC {
        account: `ban_${string}` | `nano_${string}`;
        history: AccountHistoryBlock[];
        previous?: string;
    }

    Properties

    account +AccountHistoryRPC | banani

    Interface AccountHistoryRPC

    interface AccountHistoryRPC {
        account: `ban_${string}` | `nano_${string}`;
        history: AccountHistoryBlock[];
        previous?: string;
    }

    Properties

    account: `ban_${string}` | `nano_${string}`
    previous?: string
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    previous?: string
    \ No newline at end of file diff --git a/docs/interfaces/AccountHistoryRawBlock.html b/docs/interfaces/AccountHistoryRawBlock.html index 77e3d1c..12bda02 100644 --- a/docs/interfaces/AccountHistoryRawBlock.html +++ b/docs/interfaces/AccountHistoryRawBlock.html @@ -1,4 +1,4 @@ -AccountHistoryRawBlock | banani

    Interface AccountHistoryRawBlock

    interface AccountHistoryRawBlock {
        account: `ban_${string}` | `nano_${string}`;
        amount: `${number}`;
        amount_decimal: `${number}`;
        balance: `${number}`;
        balance_decimal: `${number}`;
        confirmed: "false" | "true";
        hash: string;
        height: `${number}`;
        link: string;
        local_timestamp: `${number}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        signature: string;
        subtype: BlockSubtype;
        type: BlockAllTypes;
        work: string;
    }

    Properties

    account +AccountHistoryRawBlock | banani

    Interface AccountHistoryRawBlock

    interface AccountHistoryRawBlock {
        account: `ban_${string}` | `nano_${string}`;
        amount: `${number}`;
        amount_decimal: `${number}`;
        balance: `${number}`;
        balance_decimal: `${number}`;
        confirmed: "false" | "true";
        hash: string;
        height: `${number}`;
        link: string;
        local_timestamp: `${number}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        signature: string;
        subtype: BlockSubtype;
        type: BlockAllTypes;
        work: string;
    }

    Properties

    Properties

    account: `ban_${string}` | `nano_${string}`
    amount: `${number}`
    amount_decimal: `${number}`
    balance: `${number}`
    balance_decimal: `${number}`
    confirmed: "false" | "true"
    hash: string
    height: `${number}`
    link: string
    local_timestamp: `${number}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    signature: string
    subtype: BlockSubtype
    work: string
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    amount: `${number}`
    amount_decimal: `${number}`
    balance: `${number}`
    balance_decimal: `${number}`
    confirmed: "false" | "true"
    hash: string
    height: `${number}`
    link: string
    local_timestamp: `${number}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    signature: string
    subtype: BlockSubtype
    work: string
    \ No newline at end of file diff --git a/docs/interfaces/AccountHistoryRawRPC.html b/docs/interfaces/AccountHistoryRawRPC.html index 9301965..4645c21 100644 --- a/docs/interfaces/AccountHistoryRawRPC.html +++ b/docs/interfaces/AccountHistoryRawRPC.html @@ -1,4 +1,4 @@ -AccountHistoryRawRPC | banani

    Interface AccountHistoryRawRPC

    interface AccountHistoryRawRPC {
        account: `ban_${string}` | `nano_${string}`;
        history: AccountHistoryRawBlock[];
        previous?: string;
    }

    Properties

    account +AccountHistoryRawRPC | banani

    Interface AccountHistoryRawRPC

    interface AccountHistoryRawRPC {
        account: `ban_${string}` | `nano_${string}`;
        history: AccountHistoryRawBlock[];
        previous?: string;
    }

    Properties

    account: `ban_${string}` | `nano_${string}`
    previous?: string
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    previous?: string
    \ No newline at end of file diff --git a/docs/interfaces/AccountInfoRPC.html b/docs/interfaces/AccountInfoRPC.html index 01f1550..a693f73 100644 --- a/docs/interfaces/AccountInfoRPC.html +++ b/docs/interfaces/AccountInfoRPC.html @@ -1,4 +1,4 @@ -AccountInfoRPC | banani

    Interface AccountInfoRPC

    interface AccountInfoRPC {
        account_version: `${number}`;
        balance: `${number}`;
        block_count: `${number}`;
        confirmation_height?: `${number}`;
        confirmation_height_frontier?: string;
        confirmed_balance?: `${number}`;
        confirmed_frontier?: string;
        confirmed_height?: `${number}`;
        confirmed_pending?: `${number}`;
        confirmed_receivable?: `${number}`;
        confirmed_representative?: `ban_${string}` | `nano_${string}`;
        frontier: string;
        modified_timestamp: `${number}`;
        open_block: string;
        pending?: `${number}`;
        receivable?: `${number}`;
        representative?: `ban_${string}` | `nano_${string}`;
        representative_block: string;
        weight?: `${number}`;
    }

    Properties

    account_version +AccountInfoRPC | banani

    Interface AccountInfoRPC

    interface AccountInfoRPC {
        account_version: `${number}`;
        balance: `${number}`;
        block_count: `${number}`;
        confirmation_height?: `${number}`;
        confirmation_height_frontier?: string;
        confirmed_balance?: `${number}`;
        confirmed_frontier?: string;
        confirmed_height?: `${number}`;
        confirmed_pending?: `${number}`;
        confirmed_receivable?: `${number}`;
        confirmed_representative?: `ban_${string}` | `nano_${string}`;
        frontier: string;
        modified_timestamp: `${number}`;
        open_block: string;
        pending?: `${number}`;
        receivable?: `${number}`;
        representative?: `ban_${string}` | `nano_${string}`;
        representative_block: string;
        weight?: `${number}`;
    }

    Properties

    account_version: `${number}`
    balance: `${number}`
    block_count: `${number}`
    confirmation_height?: `${number}`
    confirmation_height_frontier?: string
    confirmed_balance?: `${number}`
    confirmed_frontier?: string
    confirmed_height?: `${number}`
    confirmed_pending?: `${number}`
    confirmed_receivable?: `${number}`
    confirmed_representative?: `ban_${string}` | `nano_${string}`
    frontier: string
    modified_timestamp: `${number}`
    open_block: string
    pending?: `${number}`
    receivable?: `${number}`
    representative?: `ban_${string}` | `nano_${string}`
    representative_block: string
    weight?: `${number}`
    \ No newline at end of file +

    Properties

    account_version: `${number}`
    balance: `${number}`
    block_count: `${number}`
    confirmation_height?: `${number}`
    confirmation_height_frontier?: string
    confirmed_balance?: `${number}`
    confirmed_frontier?: string
    confirmed_height?: `${number}`
    confirmed_pending?: `${number}`
    confirmed_receivable?: `${number}`
    confirmed_representative?: `ban_${string}` | `nano_${string}`
    frontier: string
    modified_timestamp: `${number}`
    open_block: string
    pending?: `${number}`
    receivable?: `${number}`
    representative?: `ban_${string}` | `nano_${string}`
    representative_block: string
    weight?: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountReceivableRPC.html b/docs/interfaces/AccountReceivableRPC.html index b759df5..6342660 100644 --- a/docs/interfaces/AccountReceivableRPC.html +++ b/docs/interfaces/AccountReceivableRPC.html @@ -1,2 +1,2 @@ -AccountReceivableRPC | banani

    Interface AccountReceivableRPC

    interface AccountReceivableRPC {
        blocks: string[];
    }

    Properties

    Properties

    blocks: string[]
    \ No newline at end of file +AccountReceivableRPC | banani

    Interface AccountReceivableRPC

    interface AccountReceivableRPC {
        blocks: string[];
    }

    Properties

    Properties

    blocks: string[]
    \ No newline at end of file diff --git a/docs/interfaces/AccountReceivableSourceRPC.html b/docs/interfaces/AccountReceivableSourceRPC.html index d2f155c..6d86b1b 100644 --- a/docs/interfaces/AccountReceivableSourceRPC.html +++ b/docs/interfaces/AccountReceivableSourceRPC.html @@ -1,2 +1,2 @@ -AccountReceivableSourceRPC | banani

    Interface AccountReceivableSourceRPC

    interface AccountReceivableSourceRPC {
        blocks: Record<string, {
            amount: `${number}`;
            source: `ban_${string}` | `nano_${string}`;
        }>;
    }

    Properties

    Properties

    blocks: Record<string, {
        amount: `${number}`;
        source: `ban_${string}` | `nano_${string}`;
    }>

    Type declaration

    • amount: `${number}`
    • source: `ban_${string}` | `nano_${string}`
    \ No newline at end of file +AccountReceivableSourceRPC | banani

    Interface AccountReceivableSourceRPC

    interface AccountReceivableSourceRPC {
        blocks: Record<string, {
            amount: `${number}`;
            source: `ban_${string}` | `nano_${string}`;
        }>;
    }

    Properties

    Properties

    blocks: Record<string, {
        amount: `${number}`;
        source: `ban_${string}` | `nano_${string}`;
    }>

    Type declaration

    • amount: `${number}`
    • source: `ban_${string}` | `nano_${string}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountReceivableThresholdRPC.html b/docs/interfaces/AccountReceivableThresholdRPC.html index 3480f4c..6109004 100644 --- a/docs/interfaces/AccountReceivableThresholdRPC.html +++ b/docs/interfaces/AccountReceivableThresholdRPC.html @@ -1,2 +1,2 @@ -AccountReceivableThresholdRPC | banani

    Interface AccountReceivableThresholdRPC

    interface AccountReceivableThresholdRPC {
        blocks: Record<string, `${number}`>;
    }

    Properties

    Properties

    blocks: Record<string, `${number}`>
    \ No newline at end of file +AccountReceivableThresholdRPC | banani

    Interface AccountReceivableThresholdRPC

    interface AccountReceivableThresholdRPC {
        blocks: Record<string, `${number}`>;
    }

    Properties

    Properties

    blocks: Record<string, `${number}`>
    \ No newline at end of file diff --git a/docs/interfaces/AccountRepresentativeRPC.html b/docs/interfaces/AccountRepresentativeRPC.html index f257773..711a518 100644 --- a/docs/interfaces/AccountRepresentativeRPC.html +++ b/docs/interfaces/AccountRepresentativeRPC.html @@ -1,2 +1,2 @@ -AccountRepresentativeRPC | banani

    Interface AccountRepresentativeRPC

    interface AccountRepresentativeRPC {
        representative: `ban_${string}` | `nano_${string}`;
    }

    Properties

    Properties

    representative: `ban_${string}` | `nano_${string}`
    \ No newline at end of file +AccountRepresentativeRPC | banani

    Interface AccountRepresentativeRPC

    interface AccountRepresentativeRPC {
        representative: `ban_${string}` | `nano_${string}`;
    }

    Properties

    Properties

    representative: `ban_${string}` | `nano_${string}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountWeightRPC.html b/docs/interfaces/AccountWeightRPC.html index 7a8ce16..9f1eab6 100644 --- a/docs/interfaces/AccountWeightRPC.html +++ b/docs/interfaces/AccountWeightRPC.html @@ -1,2 +1,2 @@ -AccountWeightRPC | banani

    Interface AccountWeightRPC

    interface AccountWeightRPC {
        weight: `${number}`;
    }

    Properties

    Properties

    weight: `${number}`
    \ No newline at end of file +AccountWeightRPC | banani

    Interface AccountWeightRPC

    interface AccountWeightRPC {
        weight: `${number}`;
    }

    Properties

    Properties

    weight: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/AccountsBalancesRPC.html b/docs/interfaces/AccountsBalancesRPC.html index 1615ee7..6190022 100644 --- a/docs/interfaces/AccountsBalancesRPC.html +++ b/docs/interfaces/AccountsBalancesRPC.html @@ -1,2 +1,2 @@ -AccountsBalancesRPC | banani

    Interface AccountsBalancesRPC

    interface AccountsBalancesRPC {
        balances: Record<`ban_${string}` | `nano_${string}`, AccountBalanceRPC>;
    }

    Properties

    Properties

    balances: Record<`ban_${string}` | `nano_${string}`, AccountBalanceRPC>
    \ No newline at end of file +AccountsBalancesRPC | banani

    Interface AccountsBalancesRPC

    interface AccountsBalancesRPC {
        balances: Record<`ban_${string}` | `nano_${string}`, AccountBalanceRPC>;
    }

    Properties

    Properties

    balances: Record<`ban_${string}` | `nano_${string}`, AccountBalanceRPC>
    \ No newline at end of file diff --git a/docs/interfaces/AccountsRepresentativesRPC.html b/docs/interfaces/AccountsRepresentativesRPC.html index 3a4919c..ea7eda1 100644 --- a/docs/interfaces/AccountsRepresentativesRPC.html +++ b/docs/interfaces/AccountsRepresentativesRPC.html @@ -1,2 +1,2 @@ -AccountsRepresentativesRPC | banani

    Interface AccountsRepresentativesRPC

    interface AccountsRepresentativesRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, `ban_${string}` | `nano_${string}`>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, `ban_${string}` | `nano_${string}`>
    \ No newline at end of file +AccountsRepresentativesRPC | banani

    Interface AccountsRepresentativesRPC

    interface AccountsRepresentativesRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, `ban_${string}` | `nano_${string}`>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, `ban_${string}` | `nano_${string}`>
    \ No newline at end of file diff --git a/docs/interfaces/Block.html b/docs/interfaces/Block.html index db0c180..122c301 100644 --- a/docs/interfaces/Block.html +++ b/docs/interfaces/Block.html @@ -1,4 +1,4 @@ -Block | banani

    Interface Block

    interface Block {
        account: `ban_${string}` | `nano_${string}`;
        balance: `${number}`;
        link: string;
        link_as_account?: `ban_${string}` | `nano_${string}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        signature: string;
        type: BlockAllTypes;
        work?: string;
    }

    Hierarchy (view full)

    Properties

    account +Block | banani

    Interface Block

    interface Block {
        account: `ban_${string}` | `nano_${string}`;
        balance: `${number}`;
        link: string;
        link_as_account?: `ban_${string}` | `nano_${string}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        signature: string;
        type: BlockAllTypes;
        work?: string;
    }

    Hierarchy (view full)

    Properties

    account: `ban_${string}` | `nano_${string}`
    balance: `${number}`
    link: string
    link_as_account?: `ban_${string}` | `nano_${string}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    signature: string
    work?: string
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    balance: `${number}`
    link: string
    link_as_account?: `ban_${string}` | `nano_${string}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    signature: string
    work?: string
    \ No newline at end of file diff --git a/docs/interfaces/BlockCountRPC.html b/docs/interfaces/BlockCountRPC.html index bed36f5..4e8b8f5 100644 --- a/docs/interfaces/BlockCountRPC.html +++ b/docs/interfaces/BlockCountRPC.html @@ -1,4 +1,4 @@ -BlockCountRPC | banani

    Interface BlockCountRPC

    interface BlockCountRPC {
        cemented?: `${number}`;
        count: `${number}`;
        unchecked: `${number}`;
    }

    Properties

    cemented? +BlockCountRPC | banani

    Interface BlockCountRPC

    interface BlockCountRPC {
        cemented?: `${number}`;
        count: `${number}`;
        unchecked: `${number}`;
    }

    Properties

    cemented?: `${number}`
    count: `${number}`
    unchecked: `${number}`
    \ No newline at end of file +

    Properties

    cemented?: `${number}`
    count: `${number}`
    unchecked: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/BlockInfoRPC.html b/docs/interfaces/BlockInfoRPC.html index a63d40e..605db41 100644 --- a/docs/interfaces/BlockInfoRPC.html +++ b/docs/interfaces/BlockInfoRPC.html @@ -1,4 +1,4 @@ -BlockInfoRPC | banani

    Interface BlockInfoRPC

    interface BlockInfoRPC {
        amount: `${number}`;
        balance: `${number}`;
        block_account: `ban_${string}` | `nano_${string}`;
        confirmed?: "false" | "true";
        contents: Block;
        height: `${number}`;
        subtype?: BlockSubtype;
        successor?: string;
        timestamp: `${number}`;
    }

    Properties

    amount +BlockInfoRPC | banani

    Interface BlockInfoRPC

    interface BlockInfoRPC {
        amount: `${number}`;
        balance: `${number}`;
        block_account: `ban_${string}` | `nano_${string}`;
        confirmed?: "false" | "true";
        contents: Block;
        height: `${number}`;
        subtype?: BlockSubtype;
        successor?: string;
        timestamp: `${number}`;
    }

    Properties

    amount: `${number}`
    balance: `${number}`
    block_account: `ban_${string}` | `nano_${string}`
    confirmed?: "false" | "true"
    contents: Block
    height: `${number}`
    subtype?: BlockSubtype
    successor?: string
    timestamp: `${number}`
    \ No newline at end of file +

    Properties

    amount: `${number}`
    balance: `${number}`
    block_account: `ban_${string}` | `nano_${string}`
    confirmed?: "false" | "true"
    contents: Block
    height: `${number}`
    subtype?: BlockSubtype
    successor?: string
    timestamp: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/BlockNoSignature.html b/docs/interfaces/BlockNoSignature.html index 455b54d..35bbb07 100644 --- a/docs/interfaces/BlockNoSignature.html +++ b/docs/interfaces/BlockNoSignature.html @@ -1,8 +1,8 @@ -BlockNoSignature | banani

    Interface BlockNoSignature

    interface BlockNoSignature {
        account: `ban_${string}` | `nano_${string}`;
        balance: `${number}`;
        link: string;
        link_as_account?: `ban_${string}` | `nano_${string}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        type: BlockAllTypes;
    }

    Hierarchy (view full)

    Properties

    account +BlockNoSignature | banani

    Interface BlockNoSignature

    interface BlockNoSignature {
        account: `ban_${string}` | `nano_${string}`;
        balance: `${number}`;
        link: string;
        link_as_account?: `ban_${string}` | `nano_${string}`;
        previous: string;
        representative: `ban_${string}` | `nano_${string}`;
        type: BlockAllTypes;
    }

    Hierarchy (view full)

    Properties

    account: `ban_${string}` | `nano_${string}`
    balance: `${number}`
    link: string
    link_as_account?: `ban_${string}` | `nano_${string}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    \ No newline at end of file +

    Properties

    account: `ban_${string}` | `nano_${string}`
    balance: `${number}`
    link: string
    link_as_account?: `ban_${string}` | `nano_${string}`
    previous: string
    representative: `ban_${string}` | `nano_${string}`
    \ No newline at end of file diff --git a/docs/interfaces/BlocksInfoRPC.html b/docs/interfaces/BlocksInfoRPC.html index 0a82cf4..d987f65 100644 --- a/docs/interfaces/BlocksInfoRPC.html +++ b/docs/interfaces/BlocksInfoRPC.html @@ -1,2 +1,2 @@ -BlocksInfoRPC | banani

    Interface BlocksInfoRPC

    interface BlocksInfoRPC {
        blocks: Record<string, BlockInfoRPC>;
    }

    Properties

    Properties

    blocks: Record<string, BlockInfoRPC>
    \ No newline at end of file +BlocksInfoRPC | banani

    Interface BlocksInfoRPC

    interface BlocksInfoRPC {
        blocks: Record<string, BlockInfoRPC>;
    }

    Properties

    Properties

    blocks: Record<string, BlockInfoRPC>
    \ No newline at end of file diff --git a/docs/interfaces/BlocksRPC.html b/docs/interfaces/BlocksRPC.html index f5c9f64..6c200ec 100644 --- a/docs/interfaces/BlocksRPC.html +++ b/docs/interfaces/BlocksRPC.html @@ -1,2 +1,2 @@ -BlocksRPC | banani

    Interface BlocksRPC

    interface BlocksRPC {
        blocks: Record<string, Block>;
    }

    Properties

    Properties

    blocks: Record<string, Block>
    \ No newline at end of file +BlocksRPC | banani

    Interface BlocksRPC

    interface BlocksRPC {
        blocks: Record<string, Block>;
    }

    Properties

    Properties

    blocks: Record<string, Block>
    \ No newline at end of file diff --git a/docs/interfaces/DelegatorsCountRPC.html b/docs/interfaces/DelegatorsCountRPC.html index 7fabb30..358b82d 100644 --- a/docs/interfaces/DelegatorsCountRPC.html +++ b/docs/interfaces/DelegatorsCountRPC.html @@ -1,2 +1,2 @@ -DelegatorsCountRPC | banani

    Interface DelegatorsCountRPC

    interface DelegatorsCountRPC {
        count: `${number}`;
    }

    Properties

    Properties

    count: `${number}`
    \ No newline at end of file +DelegatorsCountRPC | banani

    Interface DelegatorsCountRPC

    interface DelegatorsCountRPC {
        count: `${number}`;
    }

    Properties

    Properties

    count: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/DelegatorsRPC.html b/docs/interfaces/DelegatorsRPC.html index 7c435fd..93a6a09 100644 --- a/docs/interfaces/DelegatorsRPC.html +++ b/docs/interfaces/DelegatorsRPC.html @@ -1,2 +1,2 @@ -DelegatorsRPC | banani

    Interface DelegatorsRPC

    interface DelegatorsRPC {
        delegators: Record<`ban_${string}` | `nano_${string}`, `${number}`>;
    }

    Properties

    Properties

    delegators: Record<`ban_${string}` | `nano_${string}`, `${number}`>
    \ No newline at end of file +DelegatorsRPC | banani

    Interface DelegatorsRPC

    interface DelegatorsRPC {
        delegators: Record<`ban_${string}` | `nano_${string}`, `${number}`>;
    }

    Properties

    Properties

    delegators: Record<`ban_${string}` | `nano_${string}`, `${number}`>
    \ No newline at end of file diff --git a/docs/interfaces/RPCInterface.html b/docs/interfaces/RPCInterface.html index 53b17c5..a32b48b 100644 --- a/docs/interfaces/RPCInterface.html +++ b/docs/interfaces/RPCInterface.html @@ -1,9 +1,9 @@ RPCInterface | banani

    Interface RPCInterface

    Implement this interface if the built-in RPC class does not fit your needs. The easiest way to do this is by just extending the built-in RPC class

    -
    interface RPCInterface {
        DECIMALS?: number;
        rpc_url: string;
        use_pending: boolean;
        call(payload): Promise<Record<string, string>>;
        get_account_info(account, include_confirmed?, representative?, weight?, pending?): Promise<AccountInfoRPC>;
        get_account_receivable(account, count?, threshold?, source?): Promise<AccountReceivableRPC | AccountReceivableThresholdRPC | AccountReceivableSourceRPC>;
        get_block_info(block_hash): Promise<BlockInfoRPC>;
    }

    Implemented by

    Properties

    interface RPCInterface {
        DECIMALS?: number;
        rpc_url: string;
        use_pending: boolean;
        call(payload): Promise<Record<string, string>>;
        get_account_info(account, include_confirmed?, representative?, weight?, pending?): Promise<AccountInfoRPC>;
        get_account_receivable(account, count?, threshold?, source?): Promise<AccountReceivableRPC | AccountReceivableThresholdRPC | AccountReceivableSourceRPC>;
        get_block_info(block_hash): Promise<BlockInfoRPC>;
    }

    Implemented by

    Properties

    DECIMALS?: number
    rpc_url: string
    use_pending: boolean

    Methods

    • Parameters

      • payload: Record<string, any>

      Returns Promise<Record<string, string>>

    • Parameters

      • account: `ban_${string}` | `nano_${string}`
      • Optional include_confirmed: boolean
      • Optional representative: boolean
      • Optional weight: boolean
      • Optional pending: boolean

      Returns Promise<AccountInfoRPC>

    \ No newline at end of file +

    Properties

    DECIMALS?: number
    rpc_url: string
    use_pending: boolean

    Methods

    • Parameters

      • payload: Record<string, any>

      Returns Promise<Record<string, string>>

    • Parameters

      • account: `ban_${string}` | `nano_${string}`
      • Optional include_confirmed: boolean
      • Optional representative: boolean
      • Optional weight: boolean
      • Optional pending: boolean

      Returns Promise<AccountInfoRPC>

    \ No newline at end of file diff --git a/docs/interfaces/RepresentativesOnlineRPC.html b/docs/interfaces/RepresentativesOnlineRPC.html index 74b6dfd..2e6107c 100644 --- a/docs/interfaces/RepresentativesOnlineRPC.html +++ b/docs/interfaces/RepresentativesOnlineRPC.html @@ -1,2 +1,2 @@ -RepresentativesOnlineRPC | banani

    Interface RepresentativesOnlineRPC

    interface RepresentativesOnlineRPC {
        representatives: (`ban_${string}` | `nano_${string}`)[];
    }

    Properties

    Properties

    representatives: (`ban_${string}` | `nano_${string}`)[]
    \ No newline at end of file +RepresentativesOnlineRPC | banani

    Interface RepresentativesOnlineRPC

    interface RepresentativesOnlineRPC {
        representatives: (`ban_${string}` | `nano_${string}`)[];
    }

    Properties

    Properties

    representatives: (`ban_${string}` | `nano_${string}`)[]
    \ No newline at end of file diff --git a/docs/interfaces/RepresentativesOnlineWeightRPC.html b/docs/interfaces/RepresentativesOnlineWeightRPC.html index c973578..2424355 100644 --- a/docs/interfaces/RepresentativesOnlineWeightRPC.html +++ b/docs/interfaces/RepresentativesOnlineWeightRPC.html @@ -1,2 +1,2 @@ -RepresentativesOnlineWeightRPC | banani

    Interface RepresentativesOnlineWeightRPC

    interface RepresentativesOnlineWeightRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, {
            weight: `${number}`;
        }>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, {
        weight: `${number}`;
    }>

    Type declaration

    • weight: `${number}`
    \ No newline at end of file +RepresentativesOnlineWeightRPC | banani

    Interface RepresentativesOnlineWeightRPC

    interface RepresentativesOnlineWeightRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, {
            weight: `${number}`;
        }>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, {
        weight: `${number}`;
    }>

    Type declaration

    • weight: `${number}`
    \ No newline at end of file diff --git a/docs/interfaces/RepresentativesRPC.html b/docs/interfaces/RepresentativesRPC.html index 81f4002..8c0c6d7 100644 --- a/docs/interfaces/RepresentativesRPC.html +++ b/docs/interfaces/RepresentativesRPC.html @@ -1,2 +1,2 @@ -RepresentativesRPC | banani

    Interface RepresentativesRPC

    interface RepresentativesRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, `${number}`>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, `${number}`>
    \ No newline at end of file +RepresentativesRPC | banani

    Interface RepresentativesRPC

    interface RepresentativesRPC {
        representatives: Record<`ban_${string}` | `nano_${string}`, `${number}`>;
    }

    Properties

    Properties

    representatives: Record<`ban_${string}` | `nano_${string}`, `${number}`>
    \ No newline at end of file diff --git a/docs/interfaces/WorkProvider.html b/docs/interfaces/WorkProvider.html index deff080..400e804 100644 --- a/docs/interfaces/WorkProvider.html +++ b/docs/interfaces/WorkProvider.html @@ -1,2 +1,2 @@ -WorkProvider | banani

    Interface WorkProvider

    interface WorkProvider {
        request_work(block_hash): Promise<string>;
    }

    Methods

    Methods

    • Parameters

      • block_hash: string

      Returns Promise<string>

    \ No newline at end of file +WorkProvider | banani

    Interface WorkProvider

    interface WorkProvider {
        request_work(block_hash): Promise<string>;
    }

    Methods

    Methods

    • Parameters

      • block_hash: string

      Returns Promise<string>

    \ No newline at end of file diff --git a/docs/types/Address.html b/docs/types/Address.html index 344147d..6eeae9d 100644 --- a/docs/types/Address.html +++ b/docs/types/Address.html @@ -1 +1 @@ -Address | banani

    Type alias Address

    Address: `${AddressPrefix}${string}`
    \ No newline at end of file +Address | banani

    Type alias Address

    Address: `${AddressPrefix}${string}`
    \ No newline at end of file diff --git a/docs/types/AddressPrefix.html b/docs/types/AddressPrefix.html index 3257878..973ca01 100644 --- a/docs/types/AddressPrefix.html +++ b/docs/types/AddressPrefix.html @@ -1 +1 @@ -AddressPrefix | banani

    Type alias AddressPrefix

    AddressPrefix: "ban_" | "nano_"
    \ No newline at end of file +AddressPrefix | banani

    Type alias AddressPrefix

    AddressPrefix: "ban_" | "nano_"
    \ No newline at end of file diff --git a/docs/types/BlockAllTypes.html b/docs/types/BlockAllTypes.html index 408958a..240a31e 100644 --- a/docs/types/BlockAllTypes.html +++ b/docs/types/BlockAllTypes.html @@ -1 +1 @@ -BlockAllTypes | banani

    Type alias BlockAllTypes

    BlockAllTypes: BlockLegacyTypes | "state"
    \ No newline at end of file +BlockAllTypes | banani

    Type alias BlockAllTypes

    BlockAllTypes: BlockLegacyTypes | "state"
    \ No newline at end of file diff --git a/docs/types/BlockBasicTypes.html b/docs/types/BlockBasicTypes.html index bdccaab..3bc7b69 100644 --- a/docs/types/BlockBasicTypes.html +++ b/docs/types/BlockBasicTypes.html @@ -1 +1 @@ -BlockBasicTypes | banani

    Type alias BlockBasicTypes

    BlockBasicTypes: BlockStateChangeTypes | "change"
    \ No newline at end of file +BlockBasicTypes | banani

    Type alias BlockBasicTypes

    BlockBasicTypes: BlockStateChangeTypes | "change"
    \ No newline at end of file diff --git a/docs/types/BlockHash.html b/docs/types/BlockHash.html index c751c01..4fe34e7 100644 --- a/docs/types/BlockHash.html +++ b/docs/types/BlockHash.html @@ -1,2 +1,2 @@ BlockHash | banani

    Type alias BlockHash

    BlockHash: string

    32 byte block hash represented as 64 char hexadecimal

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/docs/types/BlockLegacyTypes.html b/docs/types/BlockLegacyTypes.html index ffeae2b..3a61ebf 100644 --- a/docs/types/BlockLegacyTypes.html +++ b/docs/types/BlockLegacyTypes.html @@ -1 +1 @@ -BlockLegacyTypes | banani

    Type alias BlockLegacyTypes

    BlockLegacyTypes: BlockBasicTypes | "open"
    \ No newline at end of file +BlockLegacyTypes | banani

    Type alias BlockLegacyTypes

    BlockLegacyTypes: BlockBasicTypes | "open"
    \ No newline at end of file diff --git a/docs/types/BlockStateChangeTypes.html b/docs/types/BlockStateChangeTypes.html index 9516295..e65d30d 100644 --- a/docs/types/BlockStateChangeTypes.html +++ b/docs/types/BlockStateChangeTypes.html @@ -1 +1 @@ -BlockStateChangeTypes | banani

    Type alias BlockStateChangeTypes

    BlockStateChangeTypes: "send" | "receive"
    \ No newline at end of file +BlockStateChangeTypes | banani

    Type alias BlockStateChangeTypes

    BlockStateChangeTypes: "send" | "receive"
    \ No newline at end of file diff --git a/docs/types/BlockSubtype.html b/docs/types/BlockSubtype.html index 86d9ae9..d915201 100644 --- a/docs/types/BlockSubtype.html +++ b/docs/types/BlockSubtype.html @@ -1 +1 @@ -BlockSubtype | banani

    Type alias BlockSubtype

    BlockSubtype: BlockBasicTypes | "epoch"
    \ No newline at end of file +BlockSubtype | banani

    Type alias BlockSubtype

    BlockSubtype: BlockBasicTypes | "epoch"
    \ No newline at end of file diff --git a/docs/types/Whole.html b/docs/types/Whole.html index 3f534b4..15dcc8f 100644 --- a/docs/types/Whole.html +++ b/docs/types/Whole.html @@ -1,2 +1,2 @@ Whole | banani

    Type alias Whole

    Whole: `${number}`

    Does NOT mean whole number, can be decimal like "4.2001". Use instead of regular number since those lose precision when decimal

    -
    \ No newline at end of file +
    \ No newline at end of file diff --git a/docs/types/WorkFunction.html b/docs/types/WorkFunction.html index 095fc82..b68d218 100644 --- a/docs/types/WorkFunction.html +++ b/docs/types/WorkFunction.html @@ -1 +1 @@ -WorkFunction | banani

    Type alias WorkFunction

    WorkFunction: ((block_hash) => Promise<string>)

    Type declaration

      • (block_hash): Promise<string>
      • Parameters

        Returns Promise<string>

    \ No newline at end of file +WorkFunction | banani

    Type alias WorkFunction

    WorkFunction: ((block_hash) => Promise<string>)

    Type declaration

      • (block_hash): Promise<string>
      • Parameters

        Returns Promise<string>

    \ No newline at end of file diff --git a/node_test/index.js b/node_test/index.js index f67fd5b..098ce6b 100644 --- a/node_test/index.js +++ b/node_test/index.js @@ -1,4 +1,4 @@ -import * as banani from "../main.js"//"banani"; +import * as banani from "../main.js";//"banani"; import * as fs from "fs"; let rpc = new banani.RPC("https://kaliumapi.appditto.com/api"); @@ -7,12 +7,19 @@ console.log(rpc.rpc_url); console.log(await rpc.get_block_count()) +let random_wallet = banani.Wallet.gen_random_wallet(rpc); + +console.log("random", random_wallet.address); +console.log("sig", random_wallet.sign_message("test message\ntest test")); + let test_seed = fs.readFileSync("./.secret", "utf-8").trim(); let wallet = new banani.Wallet(rpc, test_seed); let z_address = wallet.address; //0 index +console.log("hist len", (await rpc.get_account_history(z_address, -1)).history.length); + wallet.index = 2; //3rd account let t_address = wallet.address; console.log(wallet.address); diff --git a/package.json b/package.json index e71c177..2825b39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "banani", - "version": "0.9.0-testing", + "version": "1.0.0", "description": "JS/TS library for the Banano cryptocurrency in the style of bananopie", "main": "main.js", "scripts": { diff --git a/wallet.ts b/wallet.ts index cd434c8..436a8b9 100644 --- a/wallet.ts +++ b/wallet.ts @@ -60,7 +60,7 @@ export class Wallet { * @param {util.Whole} [amount] amount in whole bananos to send * @param {boolean?} [gen_work] whether or not to call work function to generate work * @param {string?} [representative] optionally provide a representative if you do not want to use the current representative - * @param {AccountInfoRPC?} [cached_account_info] can save one rpc call in some cases. mostly for internal use. Make sure that in the RPC call, "representative" is "true" + * @param {AccountInfoRPC?} [cached_account_info] can save one rpc call in some cases. Mostly for internal use. Make sure that in the RPC call, "representative" is "true" Send Bananos */ async send(to: Address, amount: util.Whole, gen_work?: boolean, representative?: Address, cached_account_info?: AccountInfoRPC): Promise {