-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/all 4863 doge getblock (#1067)
* ALL-4863: doge getblock verbose param is boolean * ALL-4863: removed unused const * ALL-4863: version bump and changelog update * ALL-4863: avoid copying, inherit common rpc methods * ALL-4863: abstract doge rpc, test fix * ALL-4863: changelog update (after merge) --------- Co-authored-by: Rostislav Jadavan <[email protected]>
- Loading branch information
1 parent
cab56da
commit 8d422df
Showing
14 changed files
with
270 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
||
import { JsonRpcResponse } from '../JsonRpcResponse.dto' | ||
import { AbstractRpcInterface } from './AbstractJsonRpcInterface' | ||
import { UtxoBasedCommonRpcInterface } from './UtxoBasedRpcSuite' | ||
|
||
export interface DogeRpcSuite extends DogeRpcInterface, AbstractRpcInterface {} | ||
|
||
export interface DogeRpcInterface extends UtxoBasedCommonRpcInterface{ | ||
getBlock(hashOrHeight: string, verbose?: boolean): Promise<JsonRpcResponse<any>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { JsonRpcResponse, UtxoBasedCommonRpcInterface } from '../../../dto' | ||
|
||
export abstract class AbstractCommonUtxoRpc implements UtxoBasedCommonRpcInterface { | ||
protected abstract rpcCall<T>(method: string, params?: unknown[]): Promise<T> | ||
|
||
async createRawTransaction( | ||
inputs: any[], | ||
outputs: any, | ||
locktime: number, | ||
replaceable: boolean, | ||
): Promise<JsonRpcResponse<string>> { | ||
const params: unknown[] = [inputs, outputs] | ||
if (locktime) { | ||
params.push(locktime) | ||
} | ||
if (replaceable) { | ||
params.push(replaceable) | ||
} | ||
return this.rpcCall<JsonRpcResponse<string>>('createrawtransaction', params) | ||
} | ||
|
||
async decodeRawTransaction(hexstring: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('decoderawtransaction', [hexstring]) | ||
} | ||
|
||
async decodeScript(hexstring: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('decodescript', [hexstring]) | ||
} | ||
|
||
async estimateSmartFee(blocks: number, estimateMode?: string): Promise<JsonRpcResponse<any>> { | ||
const params: unknown[] = [blocks] | ||
if (estimateMode) { | ||
params.push(estimateMode) | ||
} | ||
return this.rpcCall<JsonRpcResponse<any>>('estimatesmartfee', params) | ||
} | ||
|
||
async getBestBlockHash(): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('getbestblockhash') | ||
} | ||
|
||
async getBlockChainInfo(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockchaininfo') | ||
} | ||
|
||
async getBlockCount(): Promise<JsonRpcResponse<number>> { | ||
return this.rpcCall<JsonRpcResponse<number>>('getblockcount') | ||
} | ||
|
||
async getBlockHash(height: number): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('getblockhash', [height]) | ||
} | ||
|
||
async getBlockHeader(hash: string, verbose = true): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockheader', [hash, verbose]) | ||
} | ||
|
||
async getBlockStats(hash: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblockstats', [hash]) | ||
} | ||
|
||
async getChainTips(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getchaintips') | ||
} | ||
|
||
async getDifficulty(): Promise<JsonRpcResponse<number>> { | ||
return this.rpcCall<JsonRpcResponse<number>>('getdifficulty') | ||
} | ||
|
||
async getMempoolAncestors(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolancestors', [txId, verbose]) | ||
} | ||
|
||
async getMempoolDescendants(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempooldescendants', [txId, verbose]) | ||
} | ||
|
||
async getMempoolEntry(txId: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolentry', [txId]) | ||
} | ||
|
||
async getMempoolInfo(): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getmempoolinfo') | ||
} | ||
|
||
async getRawMemPool(verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getrawmempool', [verbose]) | ||
} | ||
|
||
async getRawTransaction(txId: string, verbose = false): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getrawtransaction', [txId, verbose]) | ||
} | ||
|
||
async getTxOut(txId: string, index: number, includeMempool = true): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('gettxout', [txId, index, includeMempool]) | ||
} | ||
|
||
async getTxOutProof(txIds: string[], blockhash?: string): Promise<JsonRpcResponse<any>> { | ||
const params: unknown[] = [txIds] | ||
if (blockhash) { | ||
params.push(blockhash) | ||
} | ||
return this.rpcCall<JsonRpcResponse<any>>('gettxoutproof', params) | ||
} | ||
|
||
async sendRawTransaction(hexstring: string): Promise<JsonRpcResponse<string>> { | ||
return this.rpcCall<JsonRpcResponse<string>>('sendrawtransaction', [hexstring]) | ||
} | ||
|
||
async validateAddress(address: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('validateaddress', [address]) | ||
} | ||
|
||
async verifyMessage( | ||
address: string, | ||
signature: string, | ||
message: string, | ||
): Promise<JsonRpcResponse<boolean>> { | ||
return this.rpcCall<JsonRpcResponse<boolean>>('verifymessage', [address, signature, message]) | ||
} | ||
|
||
async verifyTxOutProof(proof: string): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('verifytxoutproof', [proof]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { DogeRpcInterface, JsonRpcResponse } from '../../../dto' | ||
import { AbstractCommonUtxoRpc } from './AbstractCommonUtxoRpc' | ||
|
||
export abstract class AbstractDogeRpc extends AbstractCommonUtxoRpc implements DogeRpcInterface { | ||
protected abstract rpcCall<T>(method: string, params?: unknown[]): Promise<T> | ||
|
||
async getBlock(hashOrHeight: string, verbose = true): Promise<JsonRpcResponse<any>> { | ||
return this.rpcCall<JsonRpcResponse<any>>('getblock', [hashOrHeight, verbose]) | ||
} | ||
} |
Oops, something went wrong.