Skip to content

Commit

Permalink
bcoin-cli: add get block header command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Tyneway committed Sep 26, 2019
1 parent ec82181 commit 40dac00
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bin/bcoin-cli
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ class CLI {
this.log(block);
}

async getBlockHeader() {
let hash = this.config.str(0, '');

if (hash.length !== 64)
hash = parseInt(hash, 10);

const header = await this.client.getBlockHeader(hash);

if (!header) {
this.log('Header not found.');
return;
}

this.log(header);
}

async getFilter() {
let hash = this.config.str(0, '');

Expand Down Expand Up @@ -204,6 +220,9 @@ class CLI {
case 'block':
await this.getBlock();
break;
case 'header':
await this.getBlockHeader();
break;
case 'filter':
await this.getFilter();
break;
Expand All @@ -222,6 +241,7 @@ class CLI {
this.log(' $ tx [hash/address]: View transactions.');
this.log(' $ coin [hash+index/address]: View coins.');
this.log(' $ block [hash/height]: View block.');
this.log(' $ header [hash/height]: View block header.');
this.log(' $ filter [hash/height]: View filter');
this.log(' $ reset [height/hash]: Reset chain to desired block.');
this.log(' $ rpc [command] [args]: Execute RPC command.' +
Expand Down

0 comments on commit 40dac00

Please sign in to comment.