Skip to content

Commit

Permalink
Fix typing issue with BitcoinRpcNetworkProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Mar 30, 2021
1 parent c807592 commit 52e3561
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
40 changes: 39 additions & 1 deletion packages/cashscript/src/network/BitcoinRpcNetworkProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import RpcClientRetry from 'bitcoin-rpc-promise-retry';
import { Utxo, Network } from '../interfaces';
import NetworkProvider from './NetworkProvider';

const RpcClientRetry = require('bitcoin-rpc-promise-retry');

export default class BitcoinRpcNetworkProvider implements NetworkProvider {
private rpcClient: RpcClientRetry;

Expand Down Expand Up @@ -41,3 +42,40 @@ export default class BitcoinRpcNetworkProvider implements NetworkProvider {
return this.rpcClient;
}
}

interface ListUnspentItem {
txid: string;
vout: number;
address: string;
label: string;
scriptPubKey: string;
amount: number;
confirmations: number;
redeemScript: string;
spendable: boolean;
solvable: boolean;
safe: boolean;
}

interface RpcClientRetry {
constructor(url: string, opts?: object): void;
listUnspent(
minconf?: number,
maxconf?: number,
addresses?: string[],
include_unsafe?: boolean,
query_options?: object,
): Promise<ListUnspentItem[]>;
getBlockCount(): Promise<number>;
getRawTransaction(txid: string, verbose?: boolean, blockhash?: string): Promise<string>;
sendRawTransaction(hexstring: string, allowhighfees?: boolean): Promise<string>;

// below are not required for NetworkProvider interface, but very useful
generate(nblocks: number, maxtries?: number): Promise<string[]>;
generateToAddress(nblocks: number, address: string, maxtries?: number): Promise<string[]>;
getNewAddress(label?: string): Promise<string>;
dumpPrivKey(address: string): Promise<string>;
getBalance(dummy?: string, minconf?: number, include_watchonly?: boolean): Promise<number>;
getBlock(blockhash: string, verbosity?: number): Promise<string>;
importAddress(address: string, label?: string, rescan?: boolean, p2sh?: boolean): Promise<void>;
}
33 changes: 0 additions & 33 deletions packages/cashscript/src/network/bitcoin-rpc-promise-retry.d.ts

This file was deleted.

0 comments on commit 52e3561

Please sign in to comment.