Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added prettier and custom BTC RPC host settings #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BITCOIND_RPCHOST=127.0.0.1
BITCOIND_RPCPORT=8332
BITCOIND_RPCUSER=user
BITCOIND_RPCPASSWORD=password
MAX_ADDRESSES_PER_ITERATION=100000
MAX_ADDRESSES_PER_ITERATION=100000
13 changes: 10 additions & 3 deletions modules/bitcoin-client.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
const BitcoinClient = require('bitcoin-core')

const BITCOIND_RPCHOST = process.env.BITCOIND_RPCHOST || ''
const BITCOIND_RPCPORT = process.env.BITCOIND_RPCPORT || ''
const BITCOIND_RPCUSER = process.env.BITCOIND_RPCUSER || ''
const BITCOIND_RPCPASSWORD = process.env.BITCOIND_RPCPASSWORD || ''

const bitcoinClient = new BitcoinClient({username: BITCOIND_RPCUSER, password: BITCOIND_RPCPASSWORD})
const bitcoinClient = new BitcoinClient({
username: BITCOIND_RPCUSER,
password: BITCOIND_RPCPASSWORD,
host: BITCOIND_RPCHOST,
port: BITCOIND_RPCPORT
})

let blockCount

async function getBlockCount () {
async function getBlockCount() {
// freeze it until the scan ends
if (!blockCount) {
blockCount = await bitcoinClient.getBlockCount()
}
return blockCount
}

async function getBlockByHeight (blockHeight) {
async function getBlockByHeight(blockHeight) {
const blockHash = await bitcoinClient.getBlockHash(blockHeight)
const block = await bitcoinClient.getBlock(blockHash, 0)
return block
Expand Down
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
"dotenv": "^8.1.0"
},
"devDependencies": {
"nodemon": "^1.19.2"
"nodemon": "^1.19.2",
"prettier": "^2.2.1"
},
"prettier": {
"semi": false,
"singleQuote": true,
"bracketSpacing": true,
"trailingComma": "none",
"arrowParens": "avoid",
"printWidth": 120,
"proseWrap": "always",
"importSort": {
".js, .jsx, .ts, .tsx": {
"style": "module"
}
}
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,11 @@ prepend-http@^1.0.1:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=

prettier@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
Expand Down