From ecc4b47dffeea7a4459aa28e1b518d2c3d4027f9 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sun, 26 Jan 2025 12:15:52 +1100 Subject: [PATCH] Delete ** * This script finds an address given an account extended public key * Usage: edit these fields below and run it like `node find-address.js` */ const assert = require('node:assert/strict'); const HDPublicKey = require('hsd/lib/hd/find-address.js --- .../lib/hd/find-address.js | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 ** * This script finds an address given an account extended public key * Usage: edit these fields below and run it like `node find-address.js` */ const assert = require('node:assert/strict'); const HDPublicKey = require('hsd/lib/hd/find-address.js diff --git a/** * This script finds an address given an account extended public key * Usage: edit these fields below and run it like `node find-address.js` */ const assert = require('node:assert/strict'); const HDPublicKey = require('hsd/lib/hd/find-address.js b/** * This script finds an address given an account extended public key * Usage: edit these fields below and run it like `node find-address.js` */ const assert = require('node:assert/strict'); const HDPublicKey = require('hsd/lib/hd/find-address.js deleted file mode 100644 index 000c2c4..0000000 --- a/** * This script finds an address given an account extended public key * Usage: edit these fields below and run it like `node find-address.js` */ const assert = require('node:assert/strict'); const HDPublicKey = require('hsd/lib/hd/find-address.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * This script finds an address given an account extended public key - * Usage: edit these fields below and run it like `node find-address.js` - */ - -const assert = require('node:assert/strict'); -const HDPublicKey = require('hsd/lib/hd/public'); -const Address = require('hsd/lib/primitives/address'); - -// ********** -// FILL THESE -// ********** -const NETWORK = 'main'; -const ACCOUNT_XPUB = 'xpub6BvF6DnLZRV6my62FuQ8nw5TRebL8qr9Wa7u2tE1aEedHWBt4XAfSaNTmP1SM2nXErGWSzxRAHVwqstPzRrsXtA2vn1a4KzLwAVEgLNmfca'; // should start with: xpub, rpub, etc. -const SEARCH_ADDRESS = 'hs1q3tlnmk9sp2luxdvkdcyvtj8ucj5pa4hwvr8ql6'; - -const [START, END] = [0, 0x7fffffff]; -// const [START, END] = [0, 100]; - -(() => { - const account = HDPublicKey.fromBase58(ACCOUNT_XPUB, NETWORK); - console.log('[*] Using account public key:', account.xpubkey(NETWORK)); - - const expectedAddr = new Address(SEARCH_ADDRESS, NETWORK); - console.log('[*] Searching for address:', expectedAddr.toString(NETWORK)); - - const len = END - START; - assert((len >>> 0) > 0); - - for (let i = START; i <= END; i++) { - if (i % 1e3 === 0) { - console.log(`[${i}/${len}] searching...`); - } - - /** @type {Buffer[]} */ - const keys = [ - account.derive(0).derive(i).publicKey, // receive - account.derive(1).derive(i).publicKey, // change - ]; - - for (const [branch, key] of keys.entries()) { - const addr = Address.fromPubkey(key); - if (expectedAddr.equals(addr)) { - console.log('Found address', { - address: addr, - branch: branch, - index: i, - publicKey: key.toString('hex'), - }); - return; - } - } - } - - console.log(`Searched index from ${START} to ${END}. Address not found.`); -})(); \ No newline at end of file