throw new TypeError('Invalid account')
}
balance ??= account.balance
- previous ??= account.frontier
+ previous ??= account.frontier ?? '00'
representative ??= account.representative
if (typeof balance !== 'bigint' && typeof balance !== 'number' && typeof balance !== 'string') {
throw new TypeError('Account balance is unknown')
return _change(this, representative)
}
+ /**
+ * Alias for `receive()`. Zeros out `previous` as required for initial recieve
+ * blocks.
+ *
+ * @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 (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW"
+ * @returns {Block} This block with balance, link, and subtype configured
+ */
+ open (sendBlock: string | Block, amount: bigint | number | string, unit?: string): Block {
+ this.previous.fill(0)
+ return _receive(this, sendBlock, amount, unit)
+ }
+
/**
* Calculates proof-of-work using NanoPow.
*