Skip to content

Commit 3e9662b

Browse files
feat: add Bitcoin support (#80)
* feat: add Bitcoin support * refactor: rename BitcoinRpc to Bip122Rpc for consistency * refactor: remove Commitment type from bip122.types.ts
1 parent 1430469 commit 3e9662b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/types/scopes/bip122.types.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { RpcMethod } from '.';
2+
3+
type Utxo = {
4+
// Outpoint of the utxo in the format <txid>:<vout>
5+
outpoint: string;
6+
// Value of output in satoshis
7+
value: string;
8+
derivationIndex: number;
9+
// scriptPubley in ASM format
10+
scriptPubkey: string;
11+
scriptPubkeyHex: string;
12+
// If the script can be represented as an address, omitted otherwise
13+
address?: string;
14+
};
15+
16+
export type Bip122Rpc = {
17+
methods: {
18+
signMessage: RpcMethod<
19+
{
20+
account: { address: string };
21+
message: string;
22+
},
23+
{ signature: string }
24+
>;
25+
sendTransfer: RpcMethod<
26+
{
27+
account: { address: string };
28+
recipients: { address: string; amount: string }[];
29+
feeRate?: number;
30+
},
31+
{ txid: string }
32+
>;
33+
signPsbt: RpcMethod<
34+
{
35+
account: { address: string };
36+
options: {
37+
fill: boolean;
38+
broadcast: boolean;
39+
};
40+
psbt: string;
41+
feeRate?: number | undefined;
42+
},
43+
{ psbt: string; txid: string | null }
44+
>;
45+
fillPsbt: RpcMethod<{ account: { address: string }; psbt: string }, { psbt: string }>;
46+
broadcastPsbt: RpcMethod<{ account: { address: string }; psbt: string }, { txid: string }>;
47+
computeFee: RpcMethod<{ account: { address: string }; psbt: string }, { fee: string }>;
48+
getUtxo: RpcMethod<{ account: { address: string }; outpoint: string }, Utxo>;
49+
};
50+
};

src/types/scopes/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Bip122Rpc } from './bip122.types';
12
import type { Eip155Rpc } from './eip155.types';
23
import type { SolanaRpc } from './solana.types';
34

@@ -32,4 +33,5 @@ export type MethodReturn<T extends RpcApi, S extends Scope<T>, M extends MethodN
3233
export type DefaultRpcApi = {
3334
eip155: Eip155Rpc;
3435
solana: SolanaRpc;
36+
bip122: Bip122Rpc;
3537
};

0 commit comments

Comments
 (0)