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

Bits in hex for rpc block methods #921

Merged
merged 2 commits into from
Dec 23, 2019
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ that have many transactions.
which coins have been spent and are currently available.
- `GET /` has new fields `.indexes.{addr,tx}` for the status of indexers.

#### RPC

- Both `getblock` and `getblockheader` return `bits` in base 16 as a string
instead of base 10 and a number.

### Network changes

- Regtest params have been updated to correspond with other bitcoin
Expand Down
4 changes: 2 additions & 2 deletions lib/node/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2723,7 +2723,7 @@ class RPC extends RPCBase {
time: entry.time,
mediantime: mtp,
nonce: entry.nonce,
bits: entry.bits,
bits: hex32(entry.bits),
difficulty: toDifficulty(entry.bits),
chainwork: entry.chainwork.toString('hex', 64),
previousblockhash: !entry.prevBlock.equals(consensus.ZERO_HASH)
Expand Down Expand Up @@ -2767,7 +2767,7 @@ class RPC extends RPCBase {
time: entry.time,
mediantime: mtp,
nonce: entry.nonce,
bits: entry.bits,
bits: hex32(entry.bits),
difficulty: toDifficulty(entry.bits),
chainwork: entry.chainwork.toString('hex', 64),
nTx: txs.length,
Expand Down
1 change: 1 addition & 0 deletions test/node-rpc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('RPC', function() {

assert.deepEqual(chain.height, info.height);
assert.deepEqual(chain.tip, info.hash);
assert.equal(info.bits, '207fffff');
});

it('should return correct height', async () => {
Expand Down