subtype?: 'send' | 'receive' | 'change'
account: Account
balance: bigint
- previous: string
+ previous: Uint8Array<ArrayBuffer>
representative?: Account
link?: Uint8Array<ArrayBuffer>
signature?: string
* the other parameters instead of passing them into the constructor.
*
* @param {(string|Account)} account - Target of the transaction; can include `balance`, `frontier`, `representative`
- * @param {(bigint|number|string)} [balance] - Current balance of the target account
+ * @param {(bigint|number|string)} [balance] - Current balance of the target account in raw
* @param {string} [previous] - Current frontier block hash of the target account
* @param {(string|Account)} [representative] - Current representative of the target account
*/
*
* @param {(string|Block)} sendBlock - Corresponding send block or its hash
* @param {(bigint|number|string)} amount - Amount to be received from sender
- * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW)
+ * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW"
* @returns {Block} This block with balance, link, and subtype configured
*/
receive (sendBlock: string | Block, amount: bigint | number | string, unit?: string): Block
*
* @param {(string|Account)} account - Account to target or its address or public key
* @param {(bigint|number|string)} amount - Amount to send to recipient
- * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW)
+ * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW"
* @returns {Block} This block with balance, link, and subtype configured
*/
send (account: string | Account, amount: bigint | number | string, unit?: string): Block
.send(NANO_TEST_VECTORS.SEND_BLOCK.link, '0')\r
.pow()\r
\r
- assert.equal(block.previous.length, 64)\r
+ assert.equal(block.previous.byteLength, 32)\r
assert.equal(block.work?.length, 16)\r
\r
const work = block.work\r
?.map(hex => parseInt(hex, 16))\r
.reverse()\r
if (work == null) throw new Error('Work invalid')\r
- const previous = block.previous\r
- ?.match(/.{2}/g)\r
- ?.map(hex => parseInt(hex, 16))\r
- if (previous == null) throw new Error('Previous block hash invalid')\r
\r
- const bytes = new Uint8Array([...work, ...previous])\r
+ const bytes = new Uint8Array([...work, ...block.previous])\r
assert.equal(bytes.byteLength, 40)\r
\r
const hash = new Blake2b(8)\r