subtype?: 'send' | 'receive' | 'change'
account: Account
balance: bigint
- previous: string
+ previous: Uint8Array<ArrayBuffer>
representative?: Account
link?: Uint8Array<ArrayBuffer>
signature?: string
}
this.account = account
this.balance = convert(balance, 'raw', 'raw', 'bigint')
- this.previous = previous
+ this.previous = hex.toBytes(previous, 32)
if (representative instanceof Account) {
this.representative = representative
}
const data = [
PREAMBLE,
this.account.publicKey,
- this.previous.padStart(64, '0'),
+ this.previous,
this.representative.publicKey,
dec.toHex(this.balance, 32),
this.link
return {
"type": "state",
"account": this.account.address,
- "previous": this.previous,
+ "previous": bytes.toHex(this.previous),
"representative": this.representative.address ?? '',
"balance": this.balance.toString(),
"link": bytes.toHex(this.link),
const difficulty: bigint = (this.subtype === 'send' || this.subtype === 'change')
? DIFFICULTY_SEND
: DIFFICULTY_RECEIVE
- const hash = +this.previous === 0 ? this.account.publicKey : this.previous
+ const hash = this.previous.every(b => b === 0) ? this.account.publicKey : bytes.toHex(this.previous)
if (work == null) {
const result = await NanoPow.work_generate(hash, { difficulty })
if ('error' in result) {
const purpose = dec.toBytes(BIP44_PURPOSE + HARDENED_OFFSET, 4)\r
const coin = dec.toBytes(BIP44_COIN_NANO + HARDENED_OFFSET, 4)\r
const account = dec.toBytes(index + HARDENED_OFFSET, 4)\r
- const previous = hex.toBytes(block.previous === block.account.publicKey ? '0' : block.previous, 32)\r
+ const previous = block.previous\r
const link = block.link\r
const representative = hex.toBytes(block.representative.publicKey, 32)\r
const balance = hex.toBytes(block.balance.toString(16), 16)\r
}\r
\r
const account = dec.toBytes(index + HARDENED_OFFSET, 4)\r
- const previous = hex.toBytes(block.previous, 32)\r
+ const previous = block.previous\r
const link = block.link\r
const representative = hex.toBytes(block.representative.publicKey, 32)\r
const balance = hex.toBytes(BigInt(block.balance).toString(16), 16)\r