From c7d87d35d2b2ba661a7c33c25162ad44853ca3b1 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 12 Apr 2026 23:09:55 -0700 Subject: [PATCH] Generate PoW automatically during networking processing if work value is not present at broadcast. --- src/lib/block.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/block.ts b/src/lib/block.ts index 17f5bc3..5402446 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -251,7 +251,8 @@ export class Block { * Sends the block to a node for processing on the network. * * The block must already be signed (see `sign()` for more information). - * The block must also have a `work` value. + * + * If the block has no `work` value, `pow()` will be called automatically. * * @param {Rpc} rpc - RPC node information required to call `process` * @returns {Promise} Hash of the processed block @@ -262,9 +263,7 @@ export class Block { if (this.signature == null) { throw new Error('Block is missing signature. Use sign() and try again.') } - if (this.work == null) { - throw new Error('Block is missing proof-of-work. Use pow() and try again.') - } + if (this.work == null) await this.pow() const data = { subtype: this.subtype, json_block: true, -- 2.47.3