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,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 };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { BitcoinNetwork, WalletAccount, SignPsbtOptions } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Trezor address type configuration
|
|
6
|
+
*/
|
|
7
|
+
type TrezorAddressType = 'legacy' | 'nested-segwit' | 'segwit' | 'taproot';
|
|
8
|
+
/**
|
|
9
|
+
* Trezor connector options
|
|
10
|
+
*/
|
|
11
|
+
interface TrezorConnectorOptions {
|
|
12
|
+
/** Address type for derivation (default: 'segwit') */
|
|
13
|
+
addressType?: TrezorAddressType;
|
|
14
|
+
/** Account index (default: 0) */
|
|
15
|
+
accountIndex?: number;
|
|
16
|
+
/** Address index (default: 0) */
|
|
17
|
+
addressIndex?: number;
|
|
18
|
+
/** Manifest email for Trezor Connect */
|
|
19
|
+
manifestEmail?: string;
|
|
20
|
+
/** Manifest app URL for Trezor Connect */
|
|
21
|
+
manifestAppUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for sendBitcoin method
|
|
25
|
+
*/
|
|
26
|
+
interface TrezorSendBitcoinOptions {
|
|
27
|
+
/** Fee rate in sat/vB (optional, defaults to "hour" priority) */
|
|
28
|
+
feeRate?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Trezor Hardware Wallet Connector
|
|
32
|
+
*
|
|
33
|
+
* @see https://docs.trezor.io/trezor-suite/packages/connect/index.html
|
|
34
|
+
* @see https://github.com/trezor/trezor-suite/tree/develop/packages/connect
|
|
35
|
+
*/
|
|
36
|
+
declare class TrezorConnector extends BaseConnector {
|
|
37
|
+
readonly id = "trezor";
|
|
38
|
+
readonly name = "Trezor";
|
|
39
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM3XzExNSkiPgo8cGF0aCBkPSJNMjAwIDBIMFYyMDBIMjAwVjBaIiBmaWxsPSIjMDYyRDE2Ii8+CjxwYXRoIGQ9Ik0xMzMuMjYgNjMuMDUzNkMxMzMuMjYgNDUuNTM0IDExOC4wNjIgMzEgOTkuNTYyNyAzMUM4MS4wNjMxIDMxIDY1Ljg2NTYgNDUuNTQxMyA2NS44NjU2IDYzLjA1MzZWNzMuMjk5SDUyVjE0Ni45OTFMOTkuNTYyNyAxNjkuMTE3TDE0Ny4xMzYgMTQ2Ljk3NlY3My42MTI5SDEzMy4yNzFMMTMzLjI2IDYzLjA1MzZaTTgzLjA0NDQgNjMuMDUzNkM4My4wNDQ0IDU0Ljc5MzggOTAuMzEyOSA0OC4xODM4IDk5LjU2MjcgNDguMTgzOEMxMDguODEzIDQ4LjE4MzggMTE2LjA4MSA1NC43OTM4IDExNi4wODEgNjMuMDUzNlY3My4yOTlIODMuMDQ0NFY2My4wNTM2Wk0xMjcuOTczIDEzNS4wOTJMOTkuNTYyNyAxNDguMzEyTDcxLjE1MjggMTM1LjA5MlY5MC44MTEzSDEyNy45NzNWMTM1LjA5MloiIGZpbGw9IndoaXRlIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfNzAzN18xMTUiPgo8cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgcng9IjM1LjU1NTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
40
|
+
private _trezorConnect;
|
|
41
|
+
private _account;
|
|
42
|
+
private _network;
|
|
43
|
+
private _options;
|
|
44
|
+
private _derivationPath;
|
|
45
|
+
private _initialized;
|
|
46
|
+
constructor(options?: TrezorConnectorOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Override checkReady - Trezor is always "ready" since it doesn't require browser extension
|
|
49
|
+
* The actual device connection happens when connect() is called
|
|
50
|
+
*/
|
|
51
|
+
protected checkReady(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get the provider - Trezor doesn't use window injection
|
|
54
|
+
*/
|
|
55
|
+
protected getProvider(): null;
|
|
56
|
+
/**
|
|
57
|
+
* Get current address type
|
|
58
|
+
*/
|
|
59
|
+
getAddressType(): TrezorAddressType;
|
|
60
|
+
/**
|
|
61
|
+
* Set address type options before connecting
|
|
62
|
+
* Call this before connect() to change the address derivation path
|
|
63
|
+
*/
|
|
64
|
+
setOptions(options: Omit<TrezorConnectorOptions, 'manifestEmail' | 'manifestAppUrl'>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get available address types for UI selection
|
|
67
|
+
*/
|
|
68
|
+
static getAvailableAddressTypes(): Array<{
|
|
69
|
+
type: TrezorAddressType;
|
|
70
|
+
label: string;
|
|
71
|
+
description: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize Trezor Connect
|
|
75
|
+
*/
|
|
76
|
+
private initTrezorConnect;
|
|
77
|
+
/**
|
|
78
|
+
* Build BIP32 derivation path
|
|
79
|
+
*/
|
|
80
|
+
private buildDerivationPath;
|
|
81
|
+
/**
|
|
82
|
+
* Parse derivation path string to array of numbers
|
|
83
|
+
*/
|
|
84
|
+
private parseDerivationPath;
|
|
85
|
+
/**
|
|
86
|
+
* Connect to Trezor device
|
|
87
|
+
* IMPORTANT: This must be called within a user gesture (click event)
|
|
88
|
+
*
|
|
89
|
+
* This method only calls getPublicKey() once and derives the address locally
|
|
90
|
+
* to avoid opening the Trezor popup twice.
|
|
91
|
+
*/
|
|
92
|
+
connect(network?: BitcoinNetwork): Promise<WalletAccount>;
|
|
93
|
+
/**
|
|
94
|
+
* Get address with verification on device
|
|
95
|
+
*
|
|
96
|
+
* Note: This method calls getAddress() with showOnTrezor=true to display
|
|
97
|
+
* the address on the Trezor device for user verification. The public key
|
|
98
|
+
* is already available from the initial connect() call.
|
|
99
|
+
*/
|
|
100
|
+
getAddressWithVerification(): Promise<WalletAccount>;
|
|
101
|
+
disconnect(): Promise<void>;
|
|
102
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
103
|
+
signMessage(message: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Sign a PSBT with Trezor
|
|
106
|
+
*
|
|
107
|
+
* Note: Trezor Connect doesn't directly support PSBT format.
|
|
108
|
+
* Use signTransaction method or sendBitcoin instead.
|
|
109
|
+
*/
|
|
110
|
+
signPsbt(_psbtHex: string, _options?: SignPsbtOptions): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Sign multiple PSBTs
|
|
113
|
+
*/
|
|
114
|
+
signPsbts(psbtHexs: string[], options?: SignPsbtOptions): Promise<string[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Send a Bitcoin transaction
|
|
117
|
+
*
|
|
118
|
+
* @param to - Recipient address
|
|
119
|
+
* @param satoshis - Amount to send in satoshis
|
|
120
|
+
* @param options - Send options (feeRate, etc.)
|
|
121
|
+
* @returns Transaction ID after broadcast
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const txid = await trezor.sendTransaction('bc1q...', 50000);
|
|
126
|
+
* // With custom fee rate
|
|
127
|
+
* const txid = await trezor.sendTransaction('bc1q...', 50000, { feeRate: 10 });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
sendTransaction(to: string, satoshis: number, options?: TrezorSendBitcoinOptions): Promise<string>;
|
|
131
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
132
|
+
/**
|
|
133
|
+
* Get extended public key (xpub/ypub/zpub) for account
|
|
134
|
+
*/
|
|
135
|
+
getExtendedPublicKey(): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Get multiple addresses for the account
|
|
138
|
+
*
|
|
139
|
+
* This method only calls getPublicKey() for each address and derives
|
|
140
|
+
* addresses locally to minimize Trezor popup interactions.
|
|
141
|
+
*/
|
|
142
|
+
getAddresses(startIndex: number, count: number): Promise<WalletAccount[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Get current derivation path
|
|
145
|
+
*/
|
|
146
|
+
getDerivationPath(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Check if device is connected
|
|
149
|
+
*/
|
|
150
|
+
isConnected(): boolean;
|
|
151
|
+
private mapTrezorAddressType;
|
|
152
|
+
private handleTrezorError;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { type TrezorAddressType, TrezorConnector, type TrezorConnectorOptions, type TrezorSendBitcoinOptions };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { BitcoinNetwork, WalletAccount, SignPsbtOptions } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Trezor address type configuration
|
|
6
|
+
*/
|
|
7
|
+
type TrezorAddressType = 'legacy' | 'nested-segwit' | 'segwit' | 'taproot';
|
|
8
|
+
/**
|
|
9
|
+
* Trezor connector options
|
|
10
|
+
*/
|
|
11
|
+
interface TrezorConnectorOptions {
|
|
12
|
+
/** Address type for derivation (default: 'segwit') */
|
|
13
|
+
addressType?: TrezorAddressType;
|
|
14
|
+
/** Account index (default: 0) */
|
|
15
|
+
accountIndex?: number;
|
|
16
|
+
/** Address index (default: 0) */
|
|
17
|
+
addressIndex?: number;
|
|
18
|
+
/** Manifest email for Trezor Connect */
|
|
19
|
+
manifestEmail?: string;
|
|
20
|
+
/** Manifest app URL for Trezor Connect */
|
|
21
|
+
manifestAppUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for sendBitcoin method
|
|
25
|
+
*/
|
|
26
|
+
interface TrezorSendBitcoinOptions {
|
|
27
|
+
/** Fee rate in sat/vB (optional, defaults to "hour" priority) */
|
|
28
|
+
feeRate?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Trezor Hardware Wallet Connector
|
|
32
|
+
*
|
|
33
|
+
* @see https://docs.trezor.io/trezor-suite/packages/connect/index.html
|
|
34
|
+
* @see https://github.com/trezor/trezor-suite/tree/develop/packages/connect
|
|
35
|
+
*/
|
|
36
|
+
declare class TrezorConnector extends BaseConnector {
|
|
37
|
+
readonly id = "trezor";
|
|
38
|
+
readonly name = "Trezor";
|
|
39
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM3XzExNSkiPgo8cGF0aCBkPSJNMjAwIDBIMFYyMDBIMjAwVjBaIiBmaWxsPSIjMDYyRDE2Ii8+CjxwYXRoIGQ9Ik0xMzMuMjYgNjMuMDUzNkMxMzMuMjYgNDUuNTM0IDExOC4wNjIgMzEgOTkuNTYyNyAzMUM4MS4wNjMxIDMxIDY1Ljg2NTYgNDUuNTQxMyA2NS44NjU2IDYzLjA1MzZWNzMuMjk5SDUyVjE0Ni45OTFMOTkuNTYyNyAxNjkuMTE3TDE0Ny4xMzYgMTQ2Ljk3NlY3My42MTI5SDEzMy4yNzFMMTMzLjI2IDYzLjA1MzZaTTgzLjA0NDQgNjMuMDUzNkM4My4wNDQ0IDU0Ljc5MzggOTAuMzEyOSA0OC4xODM4IDk5LjU2MjcgNDguMTgzOEMxMDguODEzIDQ4LjE4MzggMTE2LjA4MSA1NC43OTM4IDExNi4wODEgNjMuMDUzNlY3My4yOTlIODMuMDQ0NFY2My4wNTM2Wk0xMjcuOTczIDEzNS4wOTJMOTkuNTYyNyAxNDguMzEyTDcxLjE1MjggMTM1LjA5MlY5MC44MTEzSDEyNy45NzNWMTM1LjA5MloiIGZpbGw9IndoaXRlIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfNzAzN18xMTUiPgo8cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgcng9IjM1LjU1NTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
40
|
+
private _trezorConnect;
|
|
41
|
+
private _account;
|
|
42
|
+
private _network;
|
|
43
|
+
private _options;
|
|
44
|
+
private _derivationPath;
|
|
45
|
+
private _initialized;
|
|
46
|
+
constructor(options?: TrezorConnectorOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Override checkReady - Trezor is always "ready" since it doesn't require browser extension
|
|
49
|
+
* The actual device connection happens when connect() is called
|
|
50
|
+
*/
|
|
51
|
+
protected checkReady(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get the provider - Trezor doesn't use window injection
|
|
54
|
+
*/
|
|
55
|
+
protected getProvider(): null;
|
|
56
|
+
/**
|
|
57
|
+
* Get current address type
|
|
58
|
+
*/
|
|
59
|
+
getAddressType(): TrezorAddressType;
|
|
60
|
+
/**
|
|
61
|
+
* Set address type options before connecting
|
|
62
|
+
* Call this before connect() to change the address derivation path
|
|
63
|
+
*/
|
|
64
|
+
setOptions(options: Omit<TrezorConnectorOptions, 'manifestEmail' | 'manifestAppUrl'>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get available address types for UI selection
|
|
67
|
+
*/
|
|
68
|
+
static getAvailableAddressTypes(): Array<{
|
|
69
|
+
type: TrezorAddressType;
|
|
70
|
+
label: string;
|
|
71
|
+
description: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize Trezor Connect
|
|
75
|
+
*/
|
|
76
|
+
private initTrezorConnect;
|
|
77
|
+
/**
|
|
78
|
+
* Build BIP32 derivation path
|
|
79
|
+
*/
|
|
80
|
+
private buildDerivationPath;
|
|
81
|
+
/**
|
|
82
|
+
* Parse derivation path string to array of numbers
|
|
83
|
+
*/
|
|
84
|
+
private parseDerivationPath;
|
|
85
|
+
/**
|
|
86
|
+
* Connect to Trezor device
|
|
87
|
+
* IMPORTANT: This must be called within a user gesture (click event)
|
|
88
|
+
*
|
|
89
|
+
* This method only calls getPublicKey() once and derives the address locally
|
|
90
|
+
* to avoid opening the Trezor popup twice.
|
|
91
|
+
*/
|
|
92
|
+
connect(network?: BitcoinNetwork): Promise<WalletAccount>;
|
|
93
|
+
/**
|
|
94
|
+
* Get address with verification on device
|
|
95
|
+
*
|
|
96
|
+
* Note: This method calls getAddress() with showOnTrezor=true to display
|
|
97
|
+
* the address on the Trezor device for user verification. The public key
|
|
98
|
+
* is already available from the initial connect() call.
|
|
99
|
+
*/
|
|
100
|
+
getAddressWithVerification(): Promise<WalletAccount>;
|
|
101
|
+
disconnect(): Promise<void>;
|
|
102
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
103
|
+
signMessage(message: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Sign a PSBT with Trezor
|
|
106
|
+
*
|
|
107
|
+
* Note: Trezor Connect doesn't directly support PSBT format.
|
|
108
|
+
* Use signTransaction method or sendBitcoin instead.
|
|
109
|
+
*/
|
|
110
|
+
signPsbt(_psbtHex: string, _options?: SignPsbtOptions): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Sign multiple PSBTs
|
|
113
|
+
*/
|
|
114
|
+
signPsbts(psbtHexs: string[], options?: SignPsbtOptions): Promise<string[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Send a Bitcoin transaction
|
|
117
|
+
*
|
|
118
|
+
* @param to - Recipient address
|
|
119
|
+
* @param satoshis - Amount to send in satoshis
|
|
120
|
+
* @param options - Send options (feeRate, etc.)
|
|
121
|
+
* @returns Transaction ID after broadcast
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const txid = await trezor.sendTransaction('bc1q...', 50000);
|
|
126
|
+
* // With custom fee rate
|
|
127
|
+
* const txid = await trezor.sendTransaction('bc1q...', 50000, { feeRate: 10 });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
sendTransaction(to: string, satoshis: number, options?: TrezorSendBitcoinOptions): Promise<string>;
|
|
131
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
132
|
+
/**
|
|
133
|
+
* Get extended public key (xpub/ypub/zpub) for account
|
|
134
|
+
*/
|
|
135
|
+
getExtendedPublicKey(): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Get multiple addresses for the account
|
|
138
|
+
*
|
|
139
|
+
* This method only calls getPublicKey() for each address and derives
|
|
140
|
+
* addresses locally to minimize Trezor popup interactions.
|
|
141
|
+
*/
|
|
142
|
+
getAddresses(startIndex: number, count: number): Promise<WalletAccount[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Get current derivation path
|
|
145
|
+
*/
|
|
146
|
+
getDerivationPath(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Check if device is connected
|
|
149
|
+
*/
|
|
150
|
+
isConnected(): boolean;
|
|
151
|
+
private mapTrezorAddressType;
|
|
152
|
+
private handleTrezorError;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { type TrezorAddressType, TrezorConnector, type TrezorConnectorOptions, type TrezorSendBitcoinOptions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkEQHR7P7G_js = require('../chunk-EQHR7P7G.js');
|
|
4
|
+
require('../chunk-FISNQZZ7.js');
|
|
5
|
+
require('../chunk-MFXLQWOE.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "TrezorConnector", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkEQHR7P7G_js.TrezorConnector; }
|
|
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,75 @@
|
|
|
1
|
+
import { BitcoinNetwork, WalletAccount, SignPsbtOptions } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unisat network types
|
|
6
|
+
* @see https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet#switchnetwork
|
|
7
|
+
*/
|
|
8
|
+
type UnisatNetwork = 'livenet' | 'testnet' | 'testnet4' | 'signet';
|
|
9
|
+
interface UnisatProvider {
|
|
10
|
+
requestAccounts(): Promise<string[]>;
|
|
11
|
+
getAccounts(): Promise<string[]>;
|
|
12
|
+
getPublicKey(): Promise<string>;
|
|
13
|
+
getNetwork(): Promise<string>;
|
|
14
|
+
getChain(): Promise<{
|
|
15
|
+
enum: string;
|
|
16
|
+
name: string;
|
|
17
|
+
network: string;
|
|
18
|
+
}>;
|
|
19
|
+
switchChain(chain: string): Promise<{
|
|
20
|
+
enum: string;
|
|
21
|
+
name: string;
|
|
22
|
+
network: string;
|
|
23
|
+
}>;
|
|
24
|
+
switchNetwork(network: UnisatNetwork): Promise<void>;
|
|
25
|
+
signMessage(message: string, type?: string): Promise<string>;
|
|
26
|
+
signPsbt(psbtHex: string, options?: UnisatSignOptions): Promise<string>;
|
|
27
|
+
signPsbts(psbtHexs: string[], options?: UnisatSignOptions[]): Promise<string[]>;
|
|
28
|
+
sendBitcoin(to: string, satoshis: number, options?: object): Promise<string>;
|
|
29
|
+
on(event: string, callback: (arg: unknown) => void): void;
|
|
30
|
+
removeListener(event: string, callback: (arg: unknown) => void): void;
|
|
31
|
+
}
|
|
32
|
+
interface UnisatSignOptions {
|
|
33
|
+
autoFinalized?: boolean;
|
|
34
|
+
toSignInputs?: Array<{
|
|
35
|
+
index: number;
|
|
36
|
+
address?: string;
|
|
37
|
+
publicKey?: string;
|
|
38
|
+
sighashTypes?: number[];
|
|
39
|
+
disableTweakSigner?: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
interface Window {
|
|
44
|
+
unisat_wallet?: UnisatProvider;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Unisat Wallet Connector
|
|
49
|
+
*
|
|
50
|
+
* @see https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet
|
|
51
|
+
*/
|
|
52
|
+
declare class UnisatConnector extends BaseConnector {
|
|
53
|
+
readonly id = "unisat";
|
|
54
|
+
readonly name = "Unisat Wallet";
|
|
55
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM3XzkxKSI+CjxwYXRoIG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
|
+
protected getProvider(): UnisatProvider | undefined;
|
|
60
|
+
connect(network?: BitcoinNetwork): Promise<WalletAccount>;
|
|
61
|
+
disconnect(): Promise<void>;
|
|
62
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
63
|
+
signMessage(message: string): Promise<string>;
|
|
64
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
65
|
+
signPsbts(psbtHexs: string[], options?: SignPsbtOptions): Promise<string[]>;
|
|
66
|
+
sendTransaction(to: string, satoshis: number): Promise<string>;
|
|
67
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
68
|
+
switchNetwork(network: BitcoinNetwork): Promise<void>;
|
|
69
|
+
private checkAndSwitchNetwork;
|
|
70
|
+
private setupListeners;
|
|
71
|
+
private mapNetwork;
|
|
72
|
+
private mapToUnisatNetwork;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { UnisatConnector };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BitcoinNetwork, WalletAccount, SignPsbtOptions } from 'otx-btc-wallet-core';
|
|
2
|
+
import { B as BaseConnector } from '../base-IAFq7sd8.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unisat network types
|
|
6
|
+
* @see https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet#switchnetwork
|
|
7
|
+
*/
|
|
8
|
+
type UnisatNetwork = 'livenet' | 'testnet' | 'testnet4' | 'signet';
|
|
9
|
+
interface UnisatProvider {
|
|
10
|
+
requestAccounts(): Promise<string[]>;
|
|
11
|
+
getAccounts(): Promise<string[]>;
|
|
12
|
+
getPublicKey(): Promise<string>;
|
|
13
|
+
getNetwork(): Promise<string>;
|
|
14
|
+
getChain(): Promise<{
|
|
15
|
+
enum: string;
|
|
16
|
+
name: string;
|
|
17
|
+
network: string;
|
|
18
|
+
}>;
|
|
19
|
+
switchChain(chain: string): Promise<{
|
|
20
|
+
enum: string;
|
|
21
|
+
name: string;
|
|
22
|
+
network: string;
|
|
23
|
+
}>;
|
|
24
|
+
switchNetwork(network: UnisatNetwork): Promise<void>;
|
|
25
|
+
signMessage(message: string, type?: string): Promise<string>;
|
|
26
|
+
signPsbt(psbtHex: string, options?: UnisatSignOptions): Promise<string>;
|
|
27
|
+
signPsbts(psbtHexs: string[], options?: UnisatSignOptions[]): Promise<string[]>;
|
|
28
|
+
sendBitcoin(to: string, satoshis: number, options?: object): Promise<string>;
|
|
29
|
+
on(event: string, callback: (arg: unknown) => void): void;
|
|
30
|
+
removeListener(event: string, callback: (arg: unknown) => void): void;
|
|
31
|
+
}
|
|
32
|
+
interface UnisatSignOptions {
|
|
33
|
+
autoFinalized?: boolean;
|
|
34
|
+
toSignInputs?: Array<{
|
|
35
|
+
index: number;
|
|
36
|
+
address?: string;
|
|
37
|
+
publicKey?: string;
|
|
38
|
+
sighashTypes?: number[];
|
|
39
|
+
disableTweakSigner?: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
interface Window {
|
|
44
|
+
unisat_wallet?: UnisatProvider;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Unisat Wallet Connector
|
|
49
|
+
*
|
|
50
|
+
* @see https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet
|
|
51
|
+
*/
|
|
52
|
+
declare class UnisatConnector extends BaseConnector {
|
|
53
|
+
readonly id = "unisat";
|
|
54
|
+
readonly name = "Unisat Wallet";
|
|
55
|
+
readonly icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF83MDM3XzkxKSI+CjxwYXRoIGQ9Ik0yMDAgMEgwVjIwMEgyMDBWMFoiIGZpbGw9ImJsYWNr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I9IjExMS43NTIiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iIzFGMUQxQyIvPgo8c3RvcCBvZmZzZXQ9IjAuMzciIHN0b3AtY29sb3I9IiM3NzM5MEQiLz4KPHN0b3Agb2Zmc2V0PSIwLjY3IiBzdG9wLWNvbG9yPSIjRUE4MTAxIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iI0Y0RkI1MiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8cmFkaWFsR3JhZGllbnQgaWQ9InBhaW50Ml9yYWRpYWxfNzAzN185MSIgY3g9IjAiIGN5PSIwIiByPSIxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgZ3JhZGllbnRUcmFuc2Zvcm09InRyYW5zbGF0ZSg5NS4yMzQzIDcwLjg5ODEpIHNjYWxlKDExLjM4NzEgMTEuMzg3MSkiPgo8c3RvcCBzdG9wLWNvbG9yPSIjRjRCODUyIi8+CjxzdG9wIG9mZnNldD0iMC4zMyIgc3RvcC1jb2xvcj0iI0VBODEwMSIvPgo8c3RvcCBvZmZzZXQ9IjAuNjQiIHN0b3AtY29sb3I9IiM3NzM5MEQiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjMjExQzFEIi8+CjwvcmFkaWFsR3JhZGllbnQ+CjxjbGlwUGF0aCBpZD0iY2xpcDBfNzAzN185MSI+CjxyZWN0IHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIiByeD0iMzUuNTU1NiIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K";
|
|
56
|
+
readonly BITCOIN_TESTNET4 = "BITCOIN_TESTNET4";
|
|
57
|
+
private _unsubscribeAccounts?;
|
|
58
|
+
private _unsubscribeNetwork?;
|
|
59
|
+
protected getProvider(): UnisatProvider | undefined;
|
|
60
|
+
connect(network?: BitcoinNetwork): Promise<WalletAccount>;
|
|
61
|
+
disconnect(): Promise<void>;
|
|
62
|
+
getAccounts(): Promise<WalletAccount[]>;
|
|
63
|
+
signMessage(message: string): Promise<string>;
|
|
64
|
+
signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
|
|
65
|
+
signPsbts(psbtHexs: string[], options?: SignPsbtOptions): Promise<string[]>;
|
|
66
|
+
sendTransaction(to: string, satoshis: number): Promise<string>;
|
|
67
|
+
getNetwork(): Promise<BitcoinNetwork>;
|
|
68
|
+
switchNetwork(network: BitcoinNetwork): Promise<void>;
|
|
69
|
+
private checkAndSwitchNetwork;
|
|
70
|
+
private setupListeners;
|
|
71
|
+
private mapNetwork;
|
|
72
|
+
private mapToUnisatNetwork;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { UnisatConnector };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQ7QVQYEB_js = require('../chunk-Q7QVQYEB.js');
|
|
4
|
+
require('../chunk-MFXLQWOE.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "UnisatConnector", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkQ7QVQYEB_js.UnisatConnector; }
|
|
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":""}
|