]> zoso.dev Git - nano-pow.git/commitdiff
Fix incorrect difficulty regexp.
authorChris Duncan <chris@zoso.dev>
Tue, 22 Apr 2025 03:21:25 +0000 (20:21 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 22 Apr 2025 03:21:25 +0000 (20:21 -0700)
src/bin/server.ts

index 0d9a2f03e558af1fcd518346e4e234a7255700d2..58b97e7f768a799935012753be8d3818dceded12 100755 (executable)
@@ -109,7 +109,7 @@ async function respond (res: http.ServerResponse, data: Buffer[]): Promise<void>
                if (!/^[0-9A-Fa-f]{64}$/.test(hash ?? '')) {
                        throw new Error('Invalid hash. Must be a 64-character hex string.')
                }
-               if (difficulty && !/^[1-9A-Fa-f][0-9A-Fa-f]{0,15}$/.test(difficulty)) {
+               if (difficulty && !/^[1-9A-Fa-f]{1}[0-9A-Fa-f]{0,15}$/.test(difficulty)) {
                        throw new Error('Invalid difficulty. Must be a hexadecimal string between 1-FFFFFFFFFFFFFFFF.')
                }
                if (action === 'work_validate' && !/^[0-9A-Fa-f]{16}$/.test(work ?? '')) {