otx-btc-wallet-connectors 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +554 -0
- package/dist/base-IAFq7sd8.d.mts +53 -0
- package/dist/base-IAFq7sd8.d.ts +53 -0
- package/dist/binance/index.d.mts +81 -0
- package/dist/binance/index.d.ts +81 -0
- package/dist/binance/index.js +13 -0
- package/dist/binance/index.js.map +1 -0
- package/dist/binance/index.mjs +4 -0
- package/dist/binance/index.mjs.map +1 -0
- package/dist/bitget/index.d.mts +84 -0
- package/dist/bitget/index.d.ts +84 -0
- package/dist/bitget/index.js +13 -0
- package/dist/bitget/index.js.map +1 -0
- package/dist/bitget/index.mjs +4 -0
- package/dist/bitget/index.mjs.map +1 -0
- package/dist/chunk-5Z5Q2Y75.mjs +91 -0
- package/dist/chunk-5Z5Q2Y75.mjs.map +1 -0
- package/dist/chunk-7KK2LZLZ.mjs +208 -0
- package/dist/chunk-7KK2LZLZ.mjs.map +1 -0
- package/dist/chunk-AW2JZIHR.mjs +753 -0
- package/dist/chunk-AW2JZIHR.mjs.map +1 -0
- package/dist/chunk-EIJOSZXZ.js +331 -0
- package/dist/chunk-EIJOSZXZ.js.map +1 -0
- package/dist/chunk-EQHR7P7G.js +541 -0
- package/dist/chunk-EQHR7P7G.js.map +1 -0
- package/dist/chunk-EWRXLZO4.mjs +539 -0
- package/dist/chunk-EWRXLZO4.mjs.map +1 -0
- package/dist/chunk-FISNQZZ7.js +802 -0
- package/dist/chunk-FISNQZZ7.js.map +1 -0
- package/dist/chunk-HL4WDMGS.js +200 -0
- package/dist/chunk-HL4WDMGS.js.map +1 -0
- package/dist/chunk-IPYWR76I.js +314 -0
- package/dist/chunk-IPYWR76I.js.map +1 -0
- package/dist/chunk-JYYNWR5G.js +142 -0
- package/dist/chunk-JYYNWR5G.js.map +1 -0
- package/dist/chunk-LNKTYZJM.js +701 -0
- package/dist/chunk-LNKTYZJM.js.map +1 -0
- package/dist/chunk-LVZMONQL.mjs +699 -0
- package/dist/chunk-LVZMONQL.mjs.map +1 -0
- package/dist/chunk-MFXLQWOE.js +93 -0
- package/dist/chunk-MFXLQWOE.js.map +1 -0
- package/dist/chunk-NBIA4TTE.mjs +204 -0
- package/dist/chunk-NBIA4TTE.mjs.map +1 -0
- package/dist/chunk-O4DD2XJ2.js +206 -0
- package/dist/chunk-O4DD2XJ2.js.map +1 -0
- package/dist/chunk-P7HVBU2B.mjs +140 -0
- package/dist/chunk-P7HVBU2B.mjs.map +1 -0
- package/dist/chunk-Q7QVQYEB.js +210 -0
- package/dist/chunk-Q7QVQYEB.js.map +1 -0
- package/dist/chunk-RLZEG6KL.mjs +329 -0
- package/dist/chunk-RLZEG6KL.mjs.map +1 -0
- package/dist/chunk-SYLDBJ75.mjs +246 -0
- package/dist/chunk-SYLDBJ75.mjs.map +1 -0
- package/dist/chunk-TTEUU3CI.mjs +198 -0
- package/dist/chunk-TTEUU3CI.mjs.map +1 -0
- package/dist/chunk-V66BXDTR.mjs +292 -0
- package/dist/chunk-V66BXDTR.mjs.map +1 -0
- package/dist/chunk-X77ZT4OI.js +268 -0
- package/dist/chunk-X77ZT4OI.js.map +1 -0
- package/dist/imtoken/index.d.mts +116 -0
- package/dist/imtoken/index.d.ts +116 -0
- package/dist/imtoken/index.js +14 -0
- package/dist/imtoken/index.js.map +1 -0
- package/dist/imtoken/index.mjs +5 -0
- package/dist/imtoken/index.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ledger/index.d.mts +290 -0
- package/dist/ledger/index.d.ts +290 -0
- package/dist/ledger/index.js +14 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/index.mjs +5 -0
- package/dist/ledger/index.mjs.map +1 -0
- package/dist/okx/index.d.mts +88 -0
- package/dist/okx/index.d.ts +88 -0
- package/dist/okx/index.js +13 -0
- package/dist/okx/index.js.map +1 -0
- package/dist/okx/index.mjs +4 -0
- package/dist/okx/index.mjs.map +1 -0
- package/dist/phantom/index.d.mts +96 -0
- package/dist/phantom/index.d.ts +96 -0
- package/dist/phantom/index.js +14 -0
- package/dist/phantom/index.js.map +1 -0
- package/dist/phantom/index.mjs +5 -0
- package/dist/phantom/index.mjs.map +1 -0
- package/dist/psbt-builder-CFOs69Z5.d.mts +131 -0
- package/dist/psbt-builder-CFOs69Z5.d.ts +131 -0
- package/dist/trezor/index.d.mts +155 -0
- package/dist/trezor/index.d.ts +155 -0
- package/dist/trezor/index.js +14 -0
- package/dist/trezor/index.js.map +1 -0
- package/dist/trezor/index.mjs +5 -0
- package/dist/trezor/index.mjs.map +1 -0
- package/dist/unisat/index.d.mts +75 -0
- package/dist/unisat/index.d.ts +75 -0
- package/dist/unisat/index.js +13 -0
- package/dist/unisat/index.js.map +1 -0
- package/dist/unisat/index.mjs +4 -0
- package/dist/unisat/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +398 -0
- package/dist/utils/index.d.ts +398 -0
- package/dist/utils/index.js +120 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +3 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/xverse/index.d.mts +79 -0
- package/dist/xverse/index.d.ts +79 -0
- package/dist/xverse/index.js +13 -0
- package/dist/xverse/index.js.map +1 -0
- package/dist/xverse/index.mjs +4 -0
- package/dist/xverse/index.mjs.map +1 -0
- package/package.json +108 -0
- package/src/base.ts +132 -0
- package/src/binance/BinanceConnector.ts +307 -0
- package/src/binance/index.ts +1 -0
- package/src/bitget/BitgetConnector.ts +301 -0
- package/src/bitget/index.ts +1 -0
- package/src/imtoken/ImTokenConnector.ts +420 -0
- package/src/imtoken/index.ts +2 -0
- package/src/index.ts +78 -0
- package/src/ledger/LedgerConnector.ts +1019 -0
- package/src/ledger/index.ts +8 -0
- package/src/okx/OKXConnector.ts +230 -0
- package/src/okx/index.ts +1 -0
- package/src/phantom/PhantomConnector.ts +381 -0
- package/src/phantom/index.ts +2 -0
- package/src/trezor/TrezorConnector.ts +824 -0
- package/src/trezor/index.ts +6 -0
- package/src/unisat/UnisatConnector.ts +312 -0
- package/src/unisat/index.ts +1 -0
- package/src/utils/blockstream.ts +230 -0
- package/src/utils/btc-service.ts +364 -0
- package/src/utils/index.ts +56 -0
- package/src/utils/mempool.ts +232 -0
- package/src/utils/psbt-builder.ts +492 -0
- package/src/utils/types.ts +183 -0
- package/src/xverse/XverseConnector.ts +479 -0
- package/src/xverse/index.ts +1 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { WalletAccount, SignPsbtOptions, BitcoinNetwork } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* OKX sign PSBT options
|
|
6
|
+
* @see https://web3.okx.com/build/dev-docs/sdks/chains/bitcoin/provider
|
|
7
|
+
*/
|
|
8
|
+
interface OKXSignPsbtOptions {
|
|
9
|
+
autoFinalized?: boolean;
|
|
10
|
+
toSignInputs?: Array<{
|
|
11
|
+
index: number;
|
|
12
|
+
address?: string;
|
|
13
|
+
publicKey?: string;
|
|
14
|
+
sighashTypes?: number[];
|
|
15
|
+
disableTweakSigner?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* OKX account changed event data
|
|
20
|
+
*/
|
|
21
|
+
interface OKXAccountChangedData {
|
|
22
|
+
address: string;
|
|
23
|
+
publicKey: string;
|
|
24
|
+
compressedPublicKey: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OKX Bitcoin provider interface
|
|
28
|
+
* @see https://web3.okx.com/build/dev-docs/sdks/chains/bitcoin/provider
|
|
29
|
+
*/
|
|
30
|
+
interface OKXBitcoinProvider {
|
|
31
|
+
connect(): Promise<{
|
|
32
|
+
address: string;
|
|
33
|
+
publicKey: string;
|
|
34
|
+
}>;
|
|
35
|
+
requestAccounts(): Promise<string[]>;
|
|
36
|
+
getAccounts(): Promise<string[]>;
|
|
37
|
+
getPublicKey(): Promise<string>;
|
|
38
|
+
getNetwork(): Promise<string>;
|
|
39
|
+
getBalance(): Promise<{
|
|
40
|
+
confirmed: number;
|
|
41
|
+
unconfirmed: number;
|
|
42
|
+
total: number;
|
|
43
|
+
}>;
|
|
44
|
+
signMessage(message: string, type?: 'ecdsa' | 'bip322-simple'): Promise<string>;
|
|
45
|
+
signPsbt(psbtHex: string, options?: OKXSignPsbtOptions): Promise<string>;
|
|
46
|
+
signPsbts(psbtHexs: string[], options?: OKXSignPsbtOptions[]): Promise<string[]>;
|
|
47
|
+
pushPsbt(psbtHex: string): Promise<string>;
|
|
48
|
+
sendBitcoin(toAddress: string, satoshis: number, options?: {
|
|
49
|
+
feeRate?: number;
|
|
50
|
+
}): Promise<string>;
|
|
51
|
+
on(event: 'accountChanged', callback: (data: OKXAccountChangedData) => void): void;
|
|
52
|
+
on(event: 'accountsChanged', callback: (addresses: string[]) => void): void;
|
|
53
|
+
on(event: 'networkChanged', callback: (network: string) => void): void;
|
|
54
|
+
removeListener(event: 'accountChanged', callback: (data: OKXAccountChangedData) => void): void;
|
|
55
|
+
removeListener(event: 'accountsChanged', callback: (addresses: string[]) => void): void;
|
|
56
|
+
removeListener(event: 'networkChanged', callback: (network: string) => void): void;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface Window {
|
|
60
|
+
okxwallet?: {
|
|
61
|
+
bitcoin?: OKXBitcoinProvider;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* OKX Wallet Connector
|
|
67
|
+
*
|
|
68
|
+
* @see https://www.okx.com/web3/build/docs/sdks/app-connect-overview
|
|
69
|
+
*/
|
|
70
|
+
declare class OKXConnector extends BaseConnector {
|
|
71
|
+
readonly id = "okx";
|
|
72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XRoIGQ9Ik0xNTQuNDg3IDExOS4zMzFIMTIxLjg0M0MxMjAuNDU2IDExOS4zMzEgMTE5LjMzMiAxMjAuNDU1IDExOS4zMzIgMTIxLjg0MlYxNTQuNDg2QzExOS4zMzIgMTU1Ljg3MyAxMjAuNDU2IDE1Ni45OTggMTIxLjg0MyAxNTYuOTk4SDE1NC40ODdDMTU1Ljg3NCAxNTYuOTk4IDE1Ni45OTggMTU1Ljg3MyAxNTYuOTk4IDE1NC40ODZWMTIxLjg0MkMxNTYuOTk4IDEyMC40NTUgMTU1Ljg3NCAxMTkuMzMxIDE1NC40ODcgMTE5LjMzMVoiIGZpbGw9IndoaXRlIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfNzAzNV81MTQ4Ij4KPHJlY3Qgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
74
|
+
private _unsubscribeAccounts?;
|
|
75
|
+
private _unsubscribeNetwork?;
|
|
76
|
+
protected getProvider(): OKXBitcoinProvider | undefined;
|
|
77
|
+
connect(): Promise<WalletAccount>;
|
|
78
|
+
disconnect(): Promise<void>;
|
|
79
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
80
|
+
signMessage(message: string): Promise<string>;
|
|
81
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
82
|
+
sendTransaction(to: string, satoshis: number): Promise<string>;
|
|
83
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
84
|
+
private setupListeners;
|
|
85
|
+
private mapNetwork;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { OKXConnector };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { WalletAccount, SignPsbtOptions, BitcoinNetwork } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* OKX sign PSBT options
|
|
6
|
+
* @see https://web3.okx.com/build/dev-docs/sdks/chains/bitcoin/provider
|
|
7
|
+
*/
|
|
8
|
+
interface OKXSignPsbtOptions {
|
|
9
|
+
autoFinalized?: boolean;
|
|
10
|
+
toSignInputs?: Array<{
|
|
11
|
+
index: number;
|
|
12
|
+
address?: string;
|
|
13
|
+
publicKey?: string;
|
|
14
|
+
sighashTypes?: number[];
|
|
15
|
+
disableTweakSigner?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* OKX account changed event data
|
|
20
|
+
*/
|
|
21
|
+
interface OKXAccountChangedData {
|
|
22
|
+
address: string;
|
|
23
|
+
publicKey: string;
|
|
24
|
+
compressedPublicKey: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OKX Bitcoin provider interface
|
|
28
|
+
* @see https://web3.okx.com/build/dev-docs/sdks/chains/bitcoin/provider
|
|
29
|
+
*/
|
|
30
|
+
interface OKXBitcoinProvider {
|
|
31
|
+
connect(): Promise<{
|
|
32
|
+
address: string;
|
|
33
|
+
publicKey: string;
|
|
34
|
+
}>;
|
|
35
|
+
requestAccounts(): Promise<string[]>;
|
|
36
|
+
getAccounts(): Promise<string[]>;
|
|
37
|
+
getPublicKey(): Promise<string>;
|
|
38
|
+
getNetwork(): Promise<string>;
|
|
39
|
+
getBalance(): Promise<{
|
|
40
|
+
confirmed: number;
|
|
41
|
+
unconfirmed: number;
|
|
42
|
+
total: number;
|
|
43
|
+
}>;
|
|
44
|
+
signMessage(message: string, type?: 'ecdsa' | 'bip322-simple'): Promise<string>;
|
|
45
|
+
signPsbt(psbtHex: string, options?: OKXSignPsbtOptions): Promise<string>;
|
|
46
|
+
signPsbts(psbtHexs: string[], options?: OKXSignPsbtOptions[]): Promise<string[]>;
|
|
47
|
+
pushPsbt(psbtHex: string): Promise<string>;
|
|
48
|
+
sendBitcoin(toAddress: string, satoshis: number, options?: {
|
|
49
|
+
feeRate?: number;
|
|
50
|
+
}): Promise<string>;
|
|
51
|
+
on(event: 'accountChanged', callback: (data: OKXAccountChangedData) => void): void;
|
|
52
|
+
on(event: 'accountsChanged', callback: (addresses: string[]) => void): void;
|
|
53
|
+
on(event: 'networkChanged', callback: (network: string) => void): void;
|
|
54
|
+
removeListener(event: 'accountChanged', callback: (data: OKXAccountChangedData) => void): void;
|
|
55
|
+
removeListener(event: 'accountsChanged', callback: (addresses: string[]) => void): void;
|
|
56
|
+
removeListener(event: 'networkChanged', callback: (network: string) => void): void;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface Window {
|
|
60
|
+
okxwallet?: {
|
|
61
|
+
bitcoin?: OKXBitcoinProvider;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* OKX Wallet Connector
|
|
67
|
+
*
|
|
68
|
+
* @see https://www.okx.com/web3/build/docs/sdks/app-connect-overview
|
|
69
|
+
*/
|
|
70
|
+
declare class OKXConnector extends BaseConnector {
|
|
71
|
+
readonly id = "okx";
|
|
72
|
+
readonly name = "OKX Wallet";
|
|
73
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM1XzUxNDgpIj4KPG1hc2sgaWQ9Im1hc2swXzcwMzVfNTE0OCIgc3R5bGU9Im1hc2stdHlwZTpsdW1pbmFuY2UiIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjAiIHk9IjAiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj4KPHBhdGggZD0iTTIwMCAwSDBWMjAwSDIwMFYwWiIgZmlsbD0id2hpdGUi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0PSIyMDAiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
74
|
+
private _unsubscribeAccounts?;
|
|
75
|
+
private _unsubscribeNetwork?;
|
|
76
|
+
protected getProvider(): OKXBitcoinProvider | undefined;
|
|
77
|
+
connect(): Promise<WalletAccount>;
|
|
78
|
+
disconnect(): Promise<void>;
|
|
79
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
80
|
+
signMessage(message: string): Promise<string>;
|
|
81
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
82
|
+
sendTransaction(to: string, satoshis: number): Promise<string>;
|
|
83
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
84
|
+
private setupListeners;
|
|
85
|
+
private mapNetwork;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { OKXConnector };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJYYNWR5G_js = require('../chunk-JYYNWR5G.js');
|
|
4
|
+
require('../chunk-MFXLQWOE.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "OKXConnector", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkJYYNWR5G_js.OKXConnector; }
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=out.js.map
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { WalletAccount, SignPsbtOptions, BitcoinNetwork } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.mjs';
|
|
3
|
+
import { G as GeneratePsbtOptions } from '../psbt-builder-CFOs69Z5.mjs';
|
|
4
|
+
import 'bitcoinjs-lib';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for sendTransaction method
|
|
8
|
+
*/
|
|
9
|
+
interface PhantomSendOptions extends GeneratePsbtOptions {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Phantom Bitcoin account type
|
|
13
|
+
* @see https://docs.phantom.com/bitcoin/establishing-a-connection
|
|
14
|
+
*/
|
|
15
|
+
interface BtcAccount {
|
|
16
|
+
address: string;
|
|
17
|
+
addressType: 'p2tr' | 'p2wpkh' | 'p2sh' | 'p2pkh';
|
|
18
|
+
publicKey: string;
|
|
19
|
+
purpose: 'payment' | 'ordinals';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Phantom Bitcoin provider interface
|
|
23
|
+
* @see https://docs.phantom.com/bitcoin/provider-api-reference
|
|
24
|
+
*/
|
|
25
|
+
interface PhantomBitcoinProvider {
|
|
26
|
+
isPhantom: boolean;
|
|
27
|
+
requestAccounts(): Promise<BtcAccount[]>;
|
|
28
|
+
signMessage(address: string, message: Uint8Array): Promise<{
|
|
29
|
+
signature: Uint8Array;
|
|
30
|
+
}>;
|
|
31
|
+
signPSBT(psbt: Uint8Array, options: {
|
|
32
|
+
inputsToSign: Array<{
|
|
33
|
+
address: string;
|
|
34
|
+
signingIndexes: number[];
|
|
35
|
+
sigHash?: number;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<Uint8Array>;
|
|
38
|
+
on(event: 'accountsChanged', callback: (accounts: BtcAccount[]) => void): void;
|
|
39
|
+
off(event: 'accountsChanged', callback: (accounts: BtcAccount[]) => void): void;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface Window {
|
|
43
|
+
phantom?: {
|
|
44
|
+
bitcoin?: PhantomBitcoinProvider;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Phantom Wallet Connector (Bitcoin support)
|
|
50
|
+
*
|
|
51
|
+
* @see https://docs.phantom.com/bitcoin/detecting-the-provider
|
|
52
|
+
*/
|
|
53
|
+
declare class PhantomConnector extends BaseConnector {
|
|
54
|
+
readonly id = "phantom";
|
|
55
|
+
readonly name = "Phantom Wallet";
|
|
56
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM1XzUxMjYpIj4KPG1hc2sgaWQ9Im1hc2swXzcwMzVfNTEyNiIgc3R5bGU9Im1hc2stdHlwZTpsdW1pbmFuY2UiIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjAiIHk9IjAiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj4KPHBhdGggZD0iTTIwMCAwSDBWMjAwSDIwMFYwWiIgZmlsbD0id2hpdGUiLz4KPC9tYXNrPgo8ZyBtYXNrPSJ1cmwoI21hc2swXzcwMzVfNTEyNikiPgo8cGF0aCBkPSJNMTU3LjA2OCAwSDQyLjkzMkMxOS4yMjEzIDAgMCAxOS4yMjEzIDAgNDIuOTMyVjE1Ny4wNjhDMCAxODAuNzc5IDE5LjIyMTMgMjAwIDQyLjkzMiAyMDBIMTU3LjA2OEMxODAuNzc5IDIwMCAyMDAgMTgwLjc3OSAyMDAgMTU3LjA2OFY0Mi45MzJDMjAwIDE5LjIyMTMgMTgwLjc3OSAwIDE1Ny4wNjggMFoiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik04Ni4yMDMxIDEyOS45NjlDNzguMzUwMyAxNDIuMDAyIDY1LjE5MTMgMTU3LjIzIDQ3LjY4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DczLjEyMzJDMTIzLjY1OSA3My4xMjMyIDEyNy4zMzggNzYuMjQxNSAxMjcuMzM4IDgyLjQ3ODVaIiBmaWxsPSIjRkZGREY4Ii8+CjwvZz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF83MDM1XzUxMjYiPgo8cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K";
|
|
57
|
+
private _accounts;
|
|
58
|
+
private _paymentAccount;
|
|
59
|
+
private _ordinalsAccount;
|
|
60
|
+
private _removeAccountChangeListener;
|
|
61
|
+
protected getProvider(): PhantomBitcoinProvider | undefined;
|
|
62
|
+
connect(): Promise<WalletAccount>;
|
|
63
|
+
private updateAccountsFromBtcAccounts;
|
|
64
|
+
private mapAddressType;
|
|
65
|
+
private setupEventListeners;
|
|
66
|
+
private removeEventListeners;
|
|
67
|
+
disconnect(): Promise<void>;
|
|
68
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
69
|
+
signMessage(message: string): Promise<string>;
|
|
70
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Send Bitcoin transaction
|
|
73
|
+
* Builds a PSBT, signs it with Phantom, and broadcasts
|
|
74
|
+
*
|
|
75
|
+
* @param to - Recipient address
|
|
76
|
+
* @param satoshis - Amount to send in satoshis
|
|
77
|
+
* @param options - Send options (feeRate, etc.)
|
|
78
|
+
* @returns Transaction ID after broadcast
|
|
79
|
+
*/
|
|
80
|
+
sendTransaction(to: string, satoshis: number, options?: PhantomSendOptions): Promise<string>;
|
|
81
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the ordinals address (if available)
|
|
84
|
+
*/
|
|
85
|
+
getOrdinalsAddress(): WalletAccount | null;
|
|
86
|
+
/**
|
|
87
|
+
* Get the payment address
|
|
88
|
+
*/
|
|
89
|
+
getPaymentAddress(): WalletAccount | null;
|
|
90
|
+
/**
|
|
91
|
+
* Get all connected addresses
|
|
92
|
+
*/
|
|
93
|
+
getAllAddresses(): string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { PhantomConnector, type PhantomSendOptions };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { WalletAccount, SignPsbtOptions, BitcoinNetwork } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.js';
|
|
3
|
+
import { G as GeneratePsbtOptions } from '../psbt-builder-CFOs69Z5.js';
|
|
4
|
+
import 'bitcoinjs-lib';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for sendTransaction method
|
|
8
|
+
*/
|
|
9
|
+
interface PhantomSendOptions extends GeneratePsbtOptions {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Phantom Bitcoin account type
|
|
13
|
+
* @see https://docs.phantom.com/bitcoin/establishing-a-connection
|
|
14
|
+
*/
|
|
15
|
+
interface BtcAccount {
|
|
16
|
+
address: string;
|
|
17
|
+
addressType: 'p2tr' | 'p2wpkh' | 'p2sh' | 'p2pkh';
|
|
18
|
+
publicKey: string;
|
|
19
|
+
purpose: 'payment' | 'ordinals';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Phantom Bitcoin provider interface
|
|
23
|
+
* @see https://docs.phantom.com/bitcoin/provider-api-reference
|
|
24
|
+
*/
|
|
25
|
+
interface PhantomBitcoinProvider {
|
|
26
|
+
isPhantom: boolean;
|
|
27
|
+
requestAccounts(): Promise<BtcAccount[]>;
|
|
28
|
+
signMessage(address: string, message: Uint8Array): Promise<{
|
|
29
|
+
signature: Uint8Array;
|
|
30
|
+
}>;
|
|
31
|
+
signPSBT(psbt: Uint8Array, options: {
|
|
32
|
+
inputsToSign: Array<{
|
|
33
|
+
address: string;
|
|
34
|
+
signingIndexes: number[];
|
|
35
|
+
sigHash?: number;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<Uint8Array>;
|
|
38
|
+
on(event: 'accountsChanged', callback: (accounts: BtcAccount[]) => void): void;
|
|
39
|
+
off(event: 'accountsChanged', callback: (accounts: BtcAccount[]) => void): void;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface Window {
|
|
43
|
+
phantom?: {
|
|
44
|
+
bitcoin?: PhantomBitcoinProvider;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Phantom Wallet Connector (Bitcoin support)
|
|
50
|
+
*
|
|
51
|
+
* @see https://docs.phantom.com/bitcoin/detecting-the-provider
|
|
52
|
+
*/
|
|
53
|
+
declare class PhantomConnector extends BaseConnector {
|
|
54
|
+
readonly id = "phantom";
|
|
55
|
+
readonly name = "Phantom Wallet";
|
|
56
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM1XzUxMjYpIj4KPG1hc2sgaWQ9Im1hc2swXzcwMzVfNTEyNiIgc3R5bGU9Im1hc2stdHlwZTpsdW1pbmFuY2UiIG1hc2tVbml0cz0idXNlclNwYWNlT25Vc2UiIHg9IjAiIHk9IjAiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj4KPHBhdGggZD0iTTIwMCAwSDBWMjAwSDIwMFYwWiIgZmlsbD0id2hpdGUiLz4KPC9tYXNrPgo8ZyBtYXNrPSJ1cmwoI21hc2swXzcwMzVfNTEyNikiPgo8cGF0aCBkPSJNMTU3LjA2OCAwSDQyLjkzMkMxOS4yMjEzIDAgMCAxOS4yMjEzIDAgNDIuOTMyVjE1Ny4wNjhDMCAx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4xMzUgNzYuMjQxMyAxMzguNzUyIDczLjEyMjggMTQyLjkzMSA3My4xMjI4QzE0Ny4wNDcgNzMuMTIyOCAxNTAuNzI3IDc2LjI0MTMgMTUwLjcyNyA4Mi40NzgyWk0xMjcuMzM4IDgyLjQ3ODVDMTI3LjMzOCA4OC43MTU1IDEyMy42NTkgOTEuODM0IDExOS41NDIgOTEuODM0QzExNS4zNjQgOTEuODM0IDExMS43NDYgODguNzE1NSAxMTEuNzQ2IDgyLjQ3ODVDMTExLjc0NiA3Ni4yNDE1IDExNS4zNjQgNzMuMTIzMiAxMTkuNTQyIDczLjEyMzJDMTIzLjY1OSA3My4xMjMyIDEyNy4zMzggNzYuMjQxNSAxMjcuMzM4IDgyLjQ3ODVaIiBmaWxsPSIjRkZGREY4Ii8+CjwvZz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF83MDM1XzUxMjYiPgo8cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K";
|
|
57
|
+
private _accounts;
|
|
58
|
+
private _paymentAccount;
|
|
59
|
+
private _ordinalsAccount;
|
|
60
|
+
private _removeAccountChangeListener;
|
|
61
|
+
protected getProvider(): PhantomBitcoinProvider | undefined;
|
|
62
|
+
connect(): Promise<WalletAccount>;
|
|
63
|
+
private updateAccountsFromBtcAccounts;
|
|
64
|
+
private mapAddressType;
|
|
65
|
+
private setupEventListeners;
|
|
66
|
+
private removeEventListeners;
|
|
67
|
+
disconnect(): Promise<void>;
|
|
68
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
69
|
+
signMessage(message: string): Promise<string>;
|
|
70
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Send Bitcoin transaction
|
|
73
|
+
* Builds a PSBT, signs it with Phantom, and broadcasts
|
|
74
|
+
*
|
|
75
|
+
* @param to - Recipient address
|
|
76
|
+
* @param satoshis - Amount to send in satoshis
|
|
77
|
+
* @param options - Send options (feeRate, etc.)
|
|
78
|
+
* @returns Transaction ID after broadcast
|
|
79
|
+
*/
|
|
80
|
+
sendTransaction(to: string, satoshis: number, options?: PhantomSendOptions): Promise<string>;
|
|
81
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the ordinals address (if available)
|
|
84
|
+
*/
|
|
85
|
+
getOrdinalsAddress(): WalletAccount | null;
|
|
86
|
+
/**
|
|
87
|
+
* Get the payment address
|
|
88
|
+
*/
|
|
89
|
+
getPaymentAddress(): WalletAccount | null;
|
|
90
|
+
/**
|
|
91
|
+
* Get all connected addresses
|
|
92
|
+
*/
|
|
93
|
+
getAllAddresses(): string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { PhantomConnector, type PhantomSendOptions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkX77ZT4OI_js = require('../chunk-X77ZT4OI.js');
|
|
4
|
+
require('../chunk-FISNQZZ7.js');
|
|
5
|
+
require('../chunk-MFXLQWOE.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "PhantomConnector", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkX77ZT4OI_js.PhantomConnector; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=out.js.map
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { BitcoinNetwork, AddressType } from 'otx-btc-wallet-core';
|
|
2
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* PSBT Builder Utility
|
|
6
|
+
* Reusable functions for building PSBTs across different wallet connectors
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* UTXO type
|
|
11
|
+
*/
|
|
12
|
+
interface Utxo {
|
|
13
|
+
txid: string;
|
|
14
|
+
vout: number;
|
|
15
|
+
value: number;
|
|
16
|
+
status?: {
|
|
17
|
+
confirmed: boolean;
|
|
18
|
+
block_height?: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for generating a send PSBT
|
|
23
|
+
*/
|
|
24
|
+
interface GeneratePsbtOptions {
|
|
25
|
+
/** Fee rate in sat/vB */
|
|
26
|
+
feeRate?: number;
|
|
27
|
+
/** Fee rate multiplier */
|
|
28
|
+
feeRateMultiplier?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result from generating a send PSBT
|
|
32
|
+
*/
|
|
33
|
+
interface GeneratePsbtResult {
|
|
34
|
+
/** The constructed PSBT */
|
|
35
|
+
psbt: bitcoin.Psbt;
|
|
36
|
+
/** PSBT as hex string */
|
|
37
|
+
psbtHex: string;
|
|
38
|
+
/** PSBT as base64 string */
|
|
39
|
+
psbtBase64: string;
|
|
40
|
+
/** Bitcoin network used */
|
|
41
|
+
btcNetwork: bitcoin.Network;
|
|
42
|
+
/** Selected UTXOs used in the transaction */
|
|
43
|
+
selectedUtxos: Utxo[];
|
|
44
|
+
/** Total input value in satoshis */
|
|
45
|
+
totalInputValue: number;
|
|
46
|
+
/** Estimated fee in satoshis */
|
|
47
|
+
estimatedFee: number;
|
|
48
|
+
/** Change amount in satoshis (0 if no change output) */
|
|
49
|
+
changeAmount: number;
|
|
50
|
+
/** Inputs to sign (for wallet APIs that require this) */
|
|
51
|
+
inputsToSign: Array<{
|
|
52
|
+
address: string;
|
|
53
|
+
index: number;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Helper to convert hex string to Uint8Array
|
|
58
|
+
*/
|
|
59
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to convert Uint8Array to hex string
|
|
62
|
+
*/
|
|
63
|
+
declare function bytesToHex(bytes: Uint8Array): string;
|
|
64
|
+
/**
|
|
65
|
+
* Helper to convert public key to x-only (for Taproot)
|
|
66
|
+
*/
|
|
67
|
+
declare function toXOnly(pubKey: Uint8Array): Uint8Array;
|
|
68
|
+
/**
|
|
69
|
+
* Get address type from address string
|
|
70
|
+
*/
|
|
71
|
+
declare function getAddressType(address: string): AddressType;
|
|
72
|
+
/**
|
|
73
|
+
* Get bitcoinjs-lib network object from BitcoinNetwork
|
|
74
|
+
*/
|
|
75
|
+
declare function getBitcoinJsNetwork(network: BitcoinNetwork): bitcoin.Network;
|
|
76
|
+
/**
|
|
77
|
+
* Estimate vBytes per input based on address type
|
|
78
|
+
*/
|
|
79
|
+
declare function getInputVBytes(addressType: AddressType): number;
|
|
80
|
+
/**
|
|
81
|
+
* Estimate vBytes per output based on address type
|
|
82
|
+
*/
|
|
83
|
+
declare function getOutputVBytes(addressType: AddressType): number;
|
|
84
|
+
/**
|
|
85
|
+
* Get dust threshold for address type
|
|
86
|
+
*/
|
|
87
|
+
declare function getDustThreshold(addressType: AddressType): number;
|
|
88
|
+
/**
|
|
89
|
+
* Select UTXOs for transaction using a simple greedy algorithm
|
|
90
|
+
*/
|
|
91
|
+
declare function selectUtxos(utxos: Utxo[], fromAddressType: AddressType, toAddressType: AddressType, amount: number, feeRate: number): {
|
|
92
|
+
selectedUtxos: Utxo[];
|
|
93
|
+
totalValue: number;
|
|
94
|
+
estimatedFee: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Generate a PSBT for sending Bitcoin
|
|
98
|
+
*
|
|
99
|
+
* @param toAddress - Recipient address
|
|
100
|
+
* @param amount - Amount to send in satoshis
|
|
101
|
+
* @param fromAddress - Sender address
|
|
102
|
+
* @param publicKey - Sender's public key (hex string)
|
|
103
|
+
* @param network - Bitcoin network
|
|
104
|
+
* @param options - Additional options (feeRate, feeRateMultiplier)
|
|
105
|
+
* @returns GeneratePsbtResult containing the PSBT and related info
|
|
106
|
+
*/
|
|
107
|
+
declare function generatePsbtForSend(toAddress: string, amount: number, fromAddress: string, publicKey: string, network: BitcoinNetwork, options?: GeneratePsbtOptions): Promise<GeneratePsbtResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Finalize all inputs in a signed PSBT
|
|
110
|
+
*/
|
|
111
|
+
declare function finalizeAllInputs(signedPsbt: bitcoin.Psbt, inputCount: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Extract and broadcast a signed PSBT
|
|
114
|
+
*
|
|
115
|
+
* @param signedPsbtHex - Signed PSBT hex string
|
|
116
|
+
* @param network - Bitcoin network
|
|
117
|
+
* @param inputCount - Number of inputs to finalize
|
|
118
|
+
* @returns Transaction ID
|
|
119
|
+
*/
|
|
120
|
+
declare function finalizeAndBroadcast(signedPsbtHex: string, network: BitcoinNetwork, inputCount: number): Promise<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Derive Bitcoin address from public key based on address type
|
|
123
|
+
*
|
|
124
|
+
* @param publicKeyHex - Public key in hex format (33 bytes compressed)
|
|
125
|
+
* @param addressType - Type of address to derive (legacy, nested-segwit, segwit, taproot)
|
|
126
|
+
* @param network - Bitcoin network
|
|
127
|
+
* @returns Derived Bitcoin address
|
|
128
|
+
*/
|
|
129
|
+
declare function deriveAddressFromPublicKey(publicKeyHex: string, addressType: AddressType, network: BitcoinNetwork): string;
|
|
130
|
+
|
|
131
|
+
export { type GeneratePsbtOptions as G, finalizeAndBroadcast as a, bytesToHex as b, getAddressType as c, getBitcoinJsNetwork as d, getInputVBytes as e, finalizeAllInputs as f, generatePsbtForSend as g, hexToBytes as h, getOutputVBytes as i, getDustThreshold as j, deriveAddressFromPublicKey as k, type GeneratePsbtResult as l, selectUtxos as s, toXOnly as t };
|