Skip to content

Commit

Permalink
make getBlockTempalte return an object istead of JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric ogire committed Jan 27, 2023
1 parent e30e663 commit d8dab77
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions packages/jellyfish-api-core/src/category/mining.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Transaction } from '@defichain/jellyfish-transaction/dist/tx'
import { ApiClient } from '../.'

export enum EstimateMode {
Expand Down Expand Up @@ -58,9 +59,9 @@ export class Mining {
* @param {string} mode This must be set to 'template', 'proposal' (see BIP 23), or omitted
* @param {string[]} capabilities client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'
* @param {string[]} rules A list of strings
* @returns {Promise<void>}
* @returns {Promise<BlockTemplate>}
*/
async getBlockTemplate (templateRequest: TemplateRequest): Promise<JSON> {
async getBlockTemplate (templateRequest: TemplateRequest): Promise<BlockTemplate> {
return await this.client.call('getblocktemplate', [templateRequest], 'number')
}
}
Expand Down Expand Up @@ -125,3 +126,27 @@ export interface TemplateRequest {
capabilities?: string[]
rules: string[]
}

export interface BlockTemplate {
capabilities: string[]
version: number
rules: string[]
vbavailable: JSON
vbrequired: number
previousblockhash: string
transactions: Transaction[]
coinbaseaux: JSON
coinbasevalue: number
longpollid: string
target: string
mintime: number
mutable: string[]
noncerange: string
sigoplimit: number
sizelimit: number
weightlimit: number
curtime: number
bits: string
height: number
default_witness_commitment: string
}

0 comments on commit d8dab77

Please sign in to comment.