Skip to content

Commit

Permalink
Add getDifficulty rpc (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
izzycsy authored May 25, 2021
1 parent 241f390 commit 454cd1f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ describe('masternode', () => {
})
})

describe('getdifficulty', () => {
it('should getDifficulty', async () => {
const difficulty = await client.blockchain.getDifficulty()
expect(difficulty).toBeGreaterThanOrEqual(0)
})
})

describe('getRawMempool', () => {
beforeAll(async () => {
await client.wallet.setWalletFlag(wallet.WalletFlag.AVOID_REUSE)
Expand Down
9 changes: 9 additions & 0 deletions packages/jellyfish-api-core/src/category/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ export class Blockchain {
return await this.client.call('getchaintips', [], 'number')
}

/**
* Get the proof-of-work difficulty as a multiple of the minimum difficulty.
*
* @return {Promise<number>}
*/
async getDifficulty (): Promise<number> {
return await this.client.call('getdifficulty', [], 'number')
}

/**
* Get details of unspent transaction output (UTXO).
*
Expand Down
10 changes: 10 additions & 0 deletions website/docs/jellyfish/api/blockchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ interface ChainTip {
}
```

## getDifficulty

Return the proof-of-work difficulty as a multiple of the minimum difficulty.

```ts tile="client.blockchain.getDifficulty()"
interface blockchain {
getDifficulty (): Promise<number>
}
```

## getTxOut

Get details of unspent transaction output (UTXO).
Expand Down

0 comments on commit 454cd1f

Please sign in to comment.