{"_id":"@bitcoin-computer/nakamotojs-client","_rev":"3-9411d57c71a014c5a0b9cd4a68089935","name":"@bitcoin-computer/nakamotojs-client","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.1":{"name":"@bitcoin-computer/nakamotojs-client","version":"0.2.1","keywords":["bitcoin","litecoin","regtest","client"],"author":{"name":"Jonathan Underwood"},"license":"MIT","_id":"@bitcoin-computer/nakamotojs-client@0.2.1","maintainers":[{"name":"clemensley","email":"ley.clemens@gmail.com"}],"contributors":[{"name":"Bitcoin Computer Devs"}],"dist":{"shasum":"3d88984633d0a5ad016868616dea973d8e656c56","tarball":"https://registry.npmjs.org/@bitcoin-computer/nakamotojs-client/-/nakamotojs-client-0.2.1.tgz","fileCount":5,"integrity":"sha512-YzjTkKRLRuCEL9YjSn+IXTFujxoYXLtl37yN+LS1VcRW+n9t6slufjdnErm2iEveT0bXPauBKr75QNRoElmHgA==","signatures":[{"sig":"MEUCIDjbXRdgeMw8WfIuqZ6nIQ0fBP7k6rVn9bCc63HyB1ApAiEApUUBC7+BsqcVC4Lura6JlwIMmw8+BD57CzVGebzFXbc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12976,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkQWbEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrnkQ/8DMRXQ7ii0Ww0xxFmtdV57RxjREPbUneutsHgDu+gVwBP75vt\r\nv9YJjnHprDih/HNwnIc6ReSyuB2H41hivCszxBz5Xc8GHNIMe5Vmousca+Vu\r\nWPEwg+r47Z21ipgzKHzkXjQ5h8TlQUMvmh5EUZceIkeDIpmKLHkrKK00C7wI\r\neEaKEwpUZdaEBY52hicTiBJdHzdhvvTmlVuVpr+38T4QvceCsRqrXL/2r6Sj\r\nLBGJWuaHJ6gWdn9UTtvOhq9QsjEvOHDG/Mn3K+ArCksAlSI7zAqBaQS+wg5O\r\nJykJs68sIYh5cl5YTfpq1ACGkIcEQ8DnmV5T+NuWueO+mECiTAKP2gec4R6D\r\n9aVbSgl+xAMv/Ru1JaP/yZWMFFIvKpQUUV1a7mP2FlUwhPZZEiWaGyFe23Tb\r\nSGyB2H0+GJGpMdVwTaHyBIAlkRLTZ8NoE2y/QcDQT3HanrXSQfOsgFFmzcbo\r\nSQ2bAwVl5RFkqZgU3UbI6phXAwLm9Gh9Hga6fBj4AET3MeeDbDYau/eEnh3t\r\ncGOE4dolh2Wfde0tFeAd8tMALS46lMV3BGIMkBLDcTJx1zsj0Co9Zm9ncO3n\r\nV6CBraRrb18x/iIIMsOhPJAVAhroFq1QU6C2KIi4vzEDKNX/ckhf4dmgsEzs\r\n1/T3hBIpuroaXTsVWe4MpptHRuSM6nqk0fY=\r\n=/ND2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/index.js","types":"types/index.d.ts","gitHead":"67097d892a2bc151956a09de96db409782618293","scripts":{"lint":"tslint -p tsconfig.json -c tslint.json","test":"npm run build && npm run format:ci && npm run lint && npm run nobuild:unit","unit":"npm run build && npm run nobuild:unit","build":"npm run clean && tsc -p ./tsconfig.json && npm run formatjs","clean":"rimraf src/ types/","format":"npm run prettier -- --write","formatjs":"npm run prettierjs -- --write","prettier":"prettier 'ts_src/**/*.ts' --ignore-path ./.prettierignore","format:ci":"npm run prettier -- --check","gitdiff:ci":"npm run build && git diff --exit-code","prettierjs":"prettier 'src/**/*.js' --ignore-path ./.prettierignore","formatjs:ci":"npm run prettierjs -- --check","nobuild:unit":"mocha --timeout 50000","nobuild:gitdiff:ci":"git diff --exit-code"},"_npmUser":{"name":"clemensley","email":"ley.clemens@gmail.com"},"_npmVersion":"9.4.0","description":"A client for regtest bitcoin or litecoin usage. Requires nakamotojs-server from github.","directories":{},"_nodeVersion":"16.14.0","dependencies":{"dhttp":"^3.0.3","ecpair":"^2.1.0","bs58check":"^2.1.2","randombytes":"^2.1.0","tiny-secp256k1":"^2.2.1"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^6.1.4","rimraf":"^2.6.3","tslint":"^5.15.0","prettier":"^1.16.4","typescript":"^3.4.2","@types/node":"^11.13.0","@types/randombytes":"^2.0.0","@bitcoin-computer/nakamotojs-lib":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/nakamotojs-client_0.2.1_1682007748353_0.6059176919010458","host":"s3://npm-registry-packages"}},"0.2.2":{"name":"@bitcoin-computer/nakamotojs-client","version":"0.2.2","keywords":["bitcoin","litecoin","regtest","client"],"author":{"name":"Jonathan Underwood"},"license":"MIT","_id":"@bitcoin-computer/nakamotojs-client@0.2.2","maintainers":[{"name":"clemensley","email":"ley.clemens@gmail.com"}],"contributors":[{"name":"Bitcoin Computer Devs"}],"dist":{"shasum":"259e256acc3c967c3a9f6236ea0d3bcfee50a939","tarball":"https://registry.npmjs.org/@bitcoin-computer/nakamotojs-client/-/nakamotojs-client-0.2.2.tgz","fileCount":5,"integrity":"sha512-UZglFCQn1ipfmYeRywyMRDxooSWGyuiKs4UzXqYNjR6PQ2YuR9IVUq2WPmw12PMSFBdCp7hIlYlPk+zjlTYdDQ==","signatures":[{"sig":"MEUCICgpC+aYRmaVdCLvvXaMEGcEczp4vPbN7xJMf7954WQtAiEA1R4W4P1j/SIhOlKfK6kyZEbwW6xRDOHbXUhqkMDznzk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13056},"main":"src/index.js","types":"types/index.d.ts","gitHead":"b0a5828585916ecd8d876facb35bf109de0d96ee","scripts":{"lint":"tslint -p tsconfig.json -c tslint.json","test":"npm run build && npm run format:ci && npm run lint && npm run nobuild:unit","unit":"npm run build && npm run nobuild:unit","build":"npm run clean && tsc -p ./tsconfig.json && npm run formatjs","clean":"rimraf src/ types/","format":"npm run prettier -- --write","formatjs":"npm run prettierjs -- --write","prettier":"prettier 'ts_src/**/*.ts' --ignore-path ./.prettierignore","format:ci":"npm run prettier -- --check","gitdiff:ci":"npm run build && git diff --exit-code","prettierjs":"prettier 'src/**/*.js' --ignore-path ./.prettierignore","formatjs:ci":"npm run prettierjs -- --check","nobuild:unit":"mocha --timeout 50000","prepublishOnly":"npm run test && npm run nobuild:gitdiff:ci","nobuild:gitdiff:ci":"git diff --exit-code"},"_npmUser":{"name":"clemensley","email":"ley.clemens@gmail.com"},"_npmVersion":"9.4.0","description":"A client for regtest bitcoin or litecoin usage. Requires nakamotojs-server from github.","directories":{},"_nodeVersion":"16.14.0","dependencies":{"dhttp":"^3.0.3","ecpair":"^2.1.0","bs58check":"^2.1.2","randombytes":"^2.1.0","tiny-secp256k1":"^2.2.1"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^6.1.4","rimraf":"^2.6.3","tslint":"^5.15.0","prettier":"^1.16.4","typescript":"^3.4.2","@types/node":"^11.13.0","@types/randombytes":"^2.0.0","@bitcoin-computer/nakamotojs-lib":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/nakamotojs-client_0.2.2_1684864712271_0.1721727051716082","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-04-20T16:22:28.300Z","modified":"2026-09-16T03:25:49.789Z","0.2.1":"2023-04-20T16:22:28.541Z","0.2.2":"2023-05-23T17:58:32.448Z"},"author":{"name":"Jonathan Underwood"},"license":"MIT","keywords":["bitcoin","litecoin","regtest","client"],"description":"A client for regtest bitcoin or litecoin usage. Requires nakamotojs-server from github.","contributors":[{"name":"Bitcoin Computer Devs"}],"maintainers":[{"email":"ley.clemens@gmail.com","name":"clemensley"},{"email":"lauratardivo@gmail.com","name":"ltardivo"}],"readme":"# NakamotoJS Client\n\nA library for managing integration test on NakamotoJS server\n\nThis repo is a clone from the original [regtest-client](https://github.com/bitcoinjs/regtest-client.git) repository, with the addition of support other UTXOs based blockchains.\nCurrently supports Bitcoin and Litecoin.\n\n## You must specify a server\n\nDefault URL is `http://127.0.0.1:3000/1`, and the recommended way to set up a server\nis to run a docker container locally.\n\nYou can override the URL with `APIURL` environment variable or by using the\noptional second arg `new RegtestUtils(bitcoin, { APIURL: 'xxx' })` at runtime.\n\nYou can also override the API password (set on the server side) with `APIPASS`\nenv variable, or `new RegtestUtils(bitcoin, { APIURL: 'xxx', APIPASS: 'yyy' })`\n\nThe optional second arg can have either, both, or none of the two overrides.\n\nYou can provide a network configuration\n\n```\nexport const regtestUtils = new RegtestUtils({\n  APIPASS,\n  APIURL,\n  network: litecoin.networks.regtest,\n});\n```\n\n## Docker\n\nCheck the docker folder on [@bitocin-computer/nakamotojs-server](https://github.com/bitcoin-computer/nakamotojs-server)\nto run a server locally.\n\n## TypeScript support\n\nTypes are automatically generated. Develop in TypeScript, commit JS and types.\nPull requests must all contain TS, JS, and types where needed.\n\n## Usage\n\n```js\n// inside an async function to use await\n\nconst bitcoin = require('@bitcoin-computer/nakamotojs-lib');\nconst { ECPairFactory } = require('ecpair');\nconst tinysecp = require('tiny-secp256k1');\nconst { RegtestUtils } = require('@bitcoin-computer/nakamotojs-client');\nconst regtestUtils = new RegtestUtils(bitcoin);\n\nconst ECPair = ECPairFactory(tinysecp);\n\nconst network = regtestUtils.network; // regtest network params\n\nconst keyPair = ECPair.makeRandom({ network });\nconst p2pkh = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network });\n\n// Tell the server to send you coins (satoshis)\n// Can pass address\nconst unspent = await regtestUtils.faucet(p2pkh.address, 2e4);\n\n// Tell the server to send you coins (satoshis)\n// Can pass Buffer of the scriptPubkey (in case address can not be parsed by bitcoinjs-lib)\n// Non-standard outputs will be rejected, though.\nconst unspentComplex = await regtestUtils.faucetComplex(p2pkh.output, 1e4);\n\n// Get all current unspents of the address.\nconst unspents = await regtestUtils.unspents(p2pkh.address);\n\n// Get data of a certain transaction\nconst fetchedTx = await regtestUtils.fetch(unspent.txId);\nconst fetchedTxComplex = await regtestUtils.fetch(unspentComplex.txId);\n\n// Mine 6 blocks, returns an Array of the block hashes\n// All of the above faucet payments will confirm\nconst results = await regtestUtils.mine(6);\n\n// Send our own transaction\nconst txb = new bitcoin.Psbt({ network });\ntxb.addInput({\n  hash: unspent.txId,\n  index: unspent.vout,\n  nonWitnessUtxo: Buffer.from(fetchedTx.txHex, 'hex'),\n});\ntxb.addInput({\n  hash: unspentComplex.txId,\n  index: unspentComplex.vout,\n  nonWitnessUtxo: Buffer.from(fetchedTxComplex.txHex, 'hex'),\n});\n\n// regtestUtils.RANDOM_ADDRESS is created on first load.\n// regtestUtils.randomAddress() will return a new random address every time.\n// (You won't have the private key though.)\ntxb.addOutput({ address: regtestUtils.RANDOM_ADDRESS, value: 1e4 });\n\ntxb.signInput(0, keyPair);\ntxb.signInput(1, keyPair);\n\ntxb.finalizeAllInputs();\n\nconst tx = txb.extractTransaction();\n\n// build and broadcast to the Bitcoin Local RegTest server\nawait regtestUtils.broadcast(tx.toHex());\n\n// This verifies that the vout output of txId transaction is actually for value\n// in satoshis and is locked for the address given.\n// The utxo can be unconfirmed. We are just verifying it was at least placed in\n// the mempool.\nawait regtestUtils.verify({\n  txId: tx.getId(),\n  address: regtestUtils.RANDOM_ADDRESS,\n  vout: 0,\n  value: 1e4,\n});\n```\n","readmeFilename":"README.md"}