@sequence0/sdk 1.0.3 → 1.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 +137 -10
- package/dist/chains/bitcoin-taproot.d.ts +308 -0
- package/dist/chains/bitcoin-taproot.d.ts.map +1 -0
- package/dist/chains/bitcoin-taproot.js +982 -0
- package/dist/chains/bitcoin-taproot.js.map +1 -0
- package/dist/erc4337/account.d.ts +241 -0
- package/dist/erc4337/account.d.ts.map +1 -0
- package/dist/erc4337/account.js +810 -0
- package/dist/erc4337/account.js.map +1 -0
- package/dist/erc4337/index.d.ts +9 -0
- package/dist/erc4337/index.d.ts.map +1 -0
- package/dist/erc4337/index.js +16 -0
- package/dist/erc4337/index.js.map +1 -0
- package/dist/erc4337/types.d.ts +173 -0
- package/dist/erc4337/types.d.ts.map +1 -0
- package/dist/erc4337/types.js +52 -0
- package/dist/erc4337/types.js.map +1 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/wallet/wallet.d.ts +7 -0
- package/dist/wallet/wallet.d.ts.map +1 -1
- package/dist/wallet/wallet.js +18 -3
- package/dist/wallet/wallet.js.map +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -30,6 +30,74 @@ const txHash = await wallet.sendTransaction({
|
|
|
30
30
|
console.log('TX Hash:', txHash);
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## What's New in v1.1.0
|
|
34
|
+
|
|
35
|
+
### Bitcoin Taproot (P2TR) Support
|
|
36
|
+
|
|
37
|
+
Full Bitcoin Taproot transaction lifecycle: address derivation, UTXO management, transaction building, FROST Schnorr signing, and broadcast. FROST-secp256k1 produces BIP-340 compatible Schnorr signatures that are native to Taproot key-path spends.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { BitcoinTaprootAdapter } from '@sequence0/sdk';
|
|
41
|
+
|
|
42
|
+
const btc = new BitcoinTaprootAdapter({ network: 'mainnet' });
|
|
43
|
+
|
|
44
|
+
// Derive a Taproot address from a FROST group public key
|
|
45
|
+
const addr = btc.deriveAddress('02abcdef...');
|
|
46
|
+
console.log(addr.address); // bc1p...
|
|
47
|
+
|
|
48
|
+
// Get balance and UTXOs
|
|
49
|
+
const balance = await btc.getBalance('bc1p...');
|
|
50
|
+
const utxos = await btc.getUTXOs('bc1p...');
|
|
51
|
+
|
|
52
|
+
// Build a transaction
|
|
53
|
+
const unsignedTx = await btc.buildTransaction(
|
|
54
|
+
{ to: 'bc1p...recipient', amount: 50000, feeRate: 15 },
|
|
55
|
+
'bc1p...sender'
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// Or use via the Wallet class for automatic signing
|
|
59
|
+
const wallet = await s0.createWallet({ chain: 'bitcoin' });
|
|
60
|
+
const txHash = await wallet.sendTransaction({
|
|
61
|
+
to: 'bc1p...recipient',
|
|
62
|
+
amount: 50000,
|
|
63
|
+
feeRate: 15,
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### ERC-4337 Account Abstraction
|
|
68
|
+
|
|
69
|
+
Smart accounts backed by FROST threshold signing. Enables gas-sponsored transactions, batch calls, and programmable transaction validation.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { Sequence0Account } from '@sequence0/sdk';
|
|
73
|
+
|
|
74
|
+
// Create a new AA wallet backed by FROST
|
|
75
|
+
const account = await Sequence0Account.create({
|
|
76
|
+
threshold: 16,
|
|
77
|
+
committeeSize: 24,
|
|
78
|
+
chain: 'ethereum',
|
|
79
|
+
ownerPrivateKey: '0x...',
|
|
80
|
+
bundlerUrl: 'https://api.pimlico.io/v2/1/rpc?apikey=YOUR_KEY',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log('Smart Account:', account.getAddress());
|
|
84
|
+
|
|
85
|
+
// Send a single transaction
|
|
86
|
+
const txHash = await account.sendTransaction({
|
|
87
|
+
to: '0xRecipient',
|
|
88
|
+
value: BigInt('1000000000000000000'),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Batch multiple calls
|
|
92
|
+
const txHash2 = await account.sendBatchTransaction([
|
|
93
|
+
{ to: '0xTokenA', data: '0xa9059cbb...' },
|
|
94
|
+
{ to: '0xTokenB', data: '0xa9059cbb...' },
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
// Sign messages
|
|
98
|
+
const sig = await account.signMessage('Hello from Sequence0 AA!');
|
|
99
|
+
```
|
|
100
|
+
|
|
33
101
|
## Features
|
|
34
102
|
|
|
35
103
|
| Feature | Description |
|
|
@@ -37,22 +105,27 @@ console.log('TX Hash:', txHash);
|
|
|
37
105
|
| **Multi-Chain** | Ethereum, Bitcoin, Solana, Polygon, Arbitrum, Base, and 60+ more (67 total) |
|
|
38
106
|
| **Threshold Signing** | FROST (t-of-n) — no single point of failure |
|
|
39
107
|
| **No Private Keys** | Keys are sharded across the agent network |
|
|
108
|
+
| **Bitcoin Taproot** | Native P2TR support with BIP-340 Schnorr signatures |
|
|
109
|
+
| **Account Abstraction** | ERC-4337 smart accounts with batched transactions |
|
|
40
110
|
| **Real-Time Events** | WebSocket subscriptions for signing progress |
|
|
41
111
|
| **Chain Adapters** | Auto-builds chain-native transactions |
|
|
42
112
|
|
|
43
113
|
## Supported Chains
|
|
44
114
|
|
|
45
115
|
### EVM (secp256k1)
|
|
46
|
-
Ethereum, Polygon, Arbitrum, Optimism, Base, BSC, Avalanche
|
|
116
|
+
Ethereum, Polygon, Arbitrum, Optimism, Base, BSC, Avalanche, and 40+ more
|
|
47
117
|
|
|
48
|
-
###
|
|
49
|
-
|
|
118
|
+
### Bitcoin (Taproot/Schnorr)
|
|
119
|
+
Full P2TR lifecycle: address derivation, UTXO selection, transaction building, Schnorr signing, and broadcast via the `BitcoinTaprootAdapter`.
|
|
50
120
|
|
|
51
|
-
|
|
121
|
+
### Solana (Ed25519)
|
|
122
|
+
Native SOL transfers with versioned transactions.
|
|
123
|
+
|
|
124
|
+
> **Note:** Dogecoin and Litecoin support wallet creation and raw message signing via `sign()`. Full `sendTransaction()` support for these UTXO chains is coming soon.
|
|
52
125
|
|
|
53
126
|
## API Reference
|
|
54
127
|
|
|
55
|
-
### `Sequence0`
|
|
128
|
+
### `Sequence0` -- Main Client
|
|
56
129
|
|
|
57
130
|
```typescript
|
|
58
131
|
const s0 = new Sequence0({
|
|
@@ -105,7 +178,7 @@ const wallet = await s0.createWallet({
|
|
|
105
178
|
| `subscribe(walletId?)` | `Promise<WsClient>` | Subscribe to real-time events |
|
|
106
179
|
| `refreshKeys(walletId)` | `Promise<void>` | Proactive key rotation |
|
|
107
180
|
|
|
108
|
-
### `Wallet`
|
|
181
|
+
### `Wallet` -- Threshold Wallet
|
|
109
182
|
|
|
110
183
|
```typescript
|
|
111
184
|
const wallet = await s0.createWallet({
|
|
@@ -127,15 +200,69 @@ const wallet = await s0.createWallet({
|
|
|
127
200
|
| `getBalance()` | `Promise<string>` | Get native token balance |
|
|
128
201
|
| `info()` | `Record<string, unknown>` | Get wallet summary |
|
|
129
202
|
|
|
203
|
+
### `BitcoinTaprootAdapter` -- Bitcoin P2TR
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { BitcoinTaprootAdapter } from '@sequence0/sdk';
|
|
207
|
+
|
|
208
|
+
const btc = new BitcoinTaprootAdapter({ network: 'mainnet' });
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
| Method | Returns | Description |
|
|
212
|
+
|--------|---------|-------------|
|
|
213
|
+
| `deriveAddress(pubkeyHex)` | `TaprootAddressInfo` | Derive bc1p... address from FROST public key |
|
|
214
|
+
| `getBalance(address)` | `Promise<string>` | Get balance in satoshis |
|
|
215
|
+
| `getUTXOs(address)` | `Promise<TaprootUtxo[]>` | Fetch unspent outputs |
|
|
216
|
+
| `getFeeRates()` | `Promise<FeeRateEstimate>` | Get recommended fee rates |
|
|
217
|
+
| `buildTransaction(tx, from)` | `Promise<string>` | Build unsigned transaction |
|
|
218
|
+
| `buildUnsignedTx(inputs, outputs, feeRate)` | `UnsignedTaprootTx` | Build with explicit inputs/outputs |
|
|
219
|
+
| `attachSignature(unsignedTx, sig)` | `Promise<string>` | Attach FROST Schnorr signature |
|
|
220
|
+
| `broadcast(signedTx)` | `Promise<string>` | Broadcast to Bitcoin network |
|
|
221
|
+
| `getTransaction(txid)` | `Promise<any>` | Get transaction details |
|
|
222
|
+
| `getBlockHeight()` | `Promise<number>` | Get current block height |
|
|
223
|
+
|
|
224
|
+
### `Sequence0Account` -- ERC-4337 Smart Account
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import { Sequence0Account } from '@sequence0/sdk';
|
|
228
|
+
|
|
229
|
+
const account = await Sequence0Account.create({
|
|
230
|
+
threshold: 16,
|
|
231
|
+
committeeSize: 24,
|
|
232
|
+
chain: 'ethereum',
|
|
233
|
+
ownerPrivateKey: '0x...',
|
|
234
|
+
bundlerUrl: 'https://bundler.example.com',
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
| Method | Returns | Description |
|
|
239
|
+
|--------|---------|-------------|
|
|
240
|
+
| `Sequence0Account.create(options)` | `Promise<Sequence0Account>` | Create new AA wallet via DKG |
|
|
241
|
+
| `Sequence0Account.fromExisting(walletId, pubkey, options)` | `Promise<Sequence0Account>` | Reconnect to existing wallet |
|
|
242
|
+
| `getAddress()` | `string` | Get smart account address |
|
|
243
|
+
| `sendTransaction(tx)` | `Promise<string>` | Build, sign, submit UserOperation |
|
|
244
|
+
| `sendBatchTransaction(txs)` | `Promise<string>` | Batch multiple calls |
|
|
245
|
+
| `signMessage(message)` | `Promise<string>` | Sign with EIP-191 prefix |
|
|
246
|
+
| `buildUserOp(callData)` | `Promise<PackedUserOperation>` | Build unsigned UserOp |
|
|
247
|
+
| `submitUserOp(userOp, bundlerUrl?)` | `Promise<string>` | Submit to bundler |
|
|
248
|
+
| `estimateUserOpGas(userOp)` | `Promise<UserOperationGasEstimate>` | Estimate gas |
|
|
249
|
+
| `waitForUserOp(hash, timeout?)` | `Promise<UserOperationReceipt>` | Wait for inclusion |
|
|
250
|
+
| `getBalance()` | `Promise<string>` | Get native token balance |
|
|
251
|
+
| `isDeployed()` | `boolean` | Check if deployed on-chain |
|
|
252
|
+
|
|
130
253
|
### Chain Adapters
|
|
131
254
|
|
|
132
255
|
Use chain adapters directly for advanced control:
|
|
133
256
|
|
|
134
257
|
```typescript
|
|
135
|
-
import {
|
|
258
|
+
import {
|
|
259
|
+
EthereumAdapter,
|
|
260
|
+
BitcoinTaprootAdapter,
|
|
261
|
+
SolanaAdapter,
|
|
262
|
+
} from '@sequence0/sdk';
|
|
136
263
|
|
|
137
264
|
const eth = new EthereumAdapter('ethereum', 'https://eth.llamarpc.com');
|
|
138
|
-
const btc = new
|
|
265
|
+
const btc = new BitcoinTaprootAdapter({ network: 'mainnet' });
|
|
139
266
|
const sol = new SolanaAdapter('mainnet');
|
|
140
267
|
```
|
|
141
268
|
|
|
@@ -169,7 +296,7 @@ try {
|
|
|
169
296
|
|
|
170
297
|
## Any Language (REST API)
|
|
171
298
|
|
|
172
|
-
This SDK wraps a plain **HTTP + JSON** REST API exposed by every agent node. You can integrate from **any language**
|
|
299
|
+
This SDK wraps a plain **HTTP + JSON** REST API exposed by every agent node. You can integrate from **any language** -- Python, Go, Rust, Java, etc. -- by calling the API directly:
|
|
173
300
|
|
|
174
301
|
```bash
|
|
175
302
|
# Health check
|
|
@@ -208,4 +335,4 @@ Signing fees are always paid in **ETH on the Sequence0 chain** (chain 800801). F
|
|
|
208
335
|
|
|
209
336
|
## License
|
|
210
337
|
|
|
211
|
-
MIT
|
|
338
|
+
MIT (c) Sequence0 Network
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitcoin Taproot (P2TR) Chain Adapter
|
|
3
|
+
*
|
|
4
|
+
* Full Taproot transaction lifecycle: address derivation, UTXO management,
|
|
5
|
+
* transaction building, FROST Schnorr signing, and broadcast.
|
|
6
|
+
*
|
|
7
|
+
* FROST-secp256k1 produces BIP-340 compatible Schnorr signatures that are
|
|
8
|
+
* NATIVE to Taproot key-path spends -- no signature format conversion needed.
|
|
9
|
+
*
|
|
10
|
+
* Depends on the WASM crate's bitcoin.rs for:
|
|
11
|
+
* - Address derivation (group pubkey -> bc1p... P2TR address)
|
|
12
|
+
* - Transaction construction (inputs/outputs -> unsigned TX + sighash)
|
|
13
|
+
* - Signature attachment (FROST sig -> witness data)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { BitcoinTaprootAdapter } from '@sequence0/sdk';
|
|
18
|
+
*
|
|
19
|
+
* const btc = new BitcoinTaprootAdapter({ network: 'mainnet' });
|
|
20
|
+
*
|
|
21
|
+
* // Derive a Taproot address from a FROST group public key
|
|
22
|
+
* const addr = btc.deriveAddress('02abcdef...');
|
|
23
|
+
* console.log(addr.address); // bc1p...
|
|
24
|
+
*
|
|
25
|
+
* // Get balance and UTXOs
|
|
26
|
+
* const balance = await btc.getBalance('bc1p...');
|
|
27
|
+
* const utxos = await btc.getUTXOs('bc1p...');
|
|
28
|
+
*
|
|
29
|
+
* // Build, sign, and broadcast
|
|
30
|
+
* const unsignedTx = await btc.buildTransaction(
|
|
31
|
+
* { to: 'bc1p...recipient', amount: 50000, feeRate: 15 },
|
|
32
|
+
* 'bc1p...sender'
|
|
33
|
+
* );
|
|
34
|
+
* // ... sign via FROST ...
|
|
35
|
+
* const txid = await btc.broadcast(signedTxHex);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
import { ChainAdapter, BtcTransaction } from '../core/types';
|
|
39
|
+
/** Bitcoin network type */
|
|
40
|
+
export type BitcoinNetwork = 'mainnet' | 'testnet' | 'signet' | 'regtest';
|
|
41
|
+
/** UTXO from the indexer API */
|
|
42
|
+
export interface TaprootUtxo {
|
|
43
|
+
/** Transaction hash (big-endian hex, 64 chars) */
|
|
44
|
+
txid: string;
|
|
45
|
+
/** Output index */
|
|
46
|
+
vout: number;
|
|
47
|
+
/** Value in satoshis */
|
|
48
|
+
value: number;
|
|
49
|
+
/** ScriptPubKey (hex-encoded) */
|
|
50
|
+
scriptPubkey: string;
|
|
51
|
+
/** Confirmation status */
|
|
52
|
+
status: {
|
|
53
|
+
confirmed: boolean;
|
|
54
|
+
blockHeight?: number;
|
|
55
|
+
blockHash?: string;
|
|
56
|
+
blockTime?: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Taproot address metadata returned by deriveAddress */
|
|
60
|
+
export interface TaprootAddressInfo {
|
|
61
|
+
/** Bech32m-encoded Taproot address (bc1p... / tb1p...) */
|
|
62
|
+
address: string;
|
|
63
|
+
/** X-only internal public key (64-char hex) */
|
|
64
|
+
xOnlyPubkey: string;
|
|
65
|
+
/** X-only output key after tweak (64-char hex) */
|
|
66
|
+
outputKey: string;
|
|
67
|
+
/** ScriptPubKey (hex-encoded, OP_1 <32-byte output key>) */
|
|
68
|
+
scriptPubkey: string;
|
|
69
|
+
/** Network */
|
|
70
|
+
network: BitcoinNetwork;
|
|
71
|
+
}
|
|
72
|
+
/** Unsigned Taproot transaction ready for FROST signing */
|
|
73
|
+
export interface UnsignedTaprootTx {
|
|
74
|
+
/** Sighash to sign via FROST (32 bytes, hex-encoded) */
|
|
75
|
+
sighash: string;
|
|
76
|
+
/** Serialized unsigned transaction (hex-encoded) */
|
|
77
|
+
rawUnsigned: string;
|
|
78
|
+
/** Transaction inputs */
|
|
79
|
+
inputs: TaprootTxInput[];
|
|
80
|
+
/** Transaction outputs */
|
|
81
|
+
outputs: TaprootTxOutput[];
|
|
82
|
+
/** Estimated virtual size in vbytes */
|
|
83
|
+
estimatedVsize: number;
|
|
84
|
+
/** Estimated fee in satoshis */
|
|
85
|
+
estimatedFee: number;
|
|
86
|
+
}
|
|
87
|
+
/** Signed Taproot transaction */
|
|
88
|
+
export interface SignedTaprootTx {
|
|
89
|
+
/** Serialized signed transaction (hex-encoded), ready for broadcast */
|
|
90
|
+
rawSigned: string;
|
|
91
|
+
/** Transaction ID */
|
|
92
|
+
txid: string;
|
|
93
|
+
/** Virtual size in vbytes */
|
|
94
|
+
vsize: number;
|
|
95
|
+
}
|
|
96
|
+
/** Transaction input (a UTXO being spent) */
|
|
97
|
+
export interface TaprootTxInput {
|
|
98
|
+
txid: string;
|
|
99
|
+
vout: number;
|
|
100
|
+
value: number;
|
|
101
|
+
scriptPubkey: string;
|
|
102
|
+
}
|
|
103
|
+
/** Transaction output */
|
|
104
|
+
export interface TaprootTxOutput {
|
|
105
|
+
address: string;
|
|
106
|
+
value: number;
|
|
107
|
+
}
|
|
108
|
+
/** Options for creating the adapter */
|
|
109
|
+
export interface BitcoinTaprootOptions {
|
|
110
|
+
/** Bitcoin network (default: 'mainnet') */
|
|
111
|
+
network?: BitcoinNetwork;
|
|
112
|
+
/** Custom Mempool/Blockstream API URL for UTXO queries and broadcast */
|
|
113
|
+
apiUrl?: string;
|
|
114
|
+
/** Custom Electrum RPC URL (alternative to HTTP API) */
|
|
115
|
+
electrumUrl?: string;
|
|
116
|
+
}
|
|
117
|
+
/** Fee rate estimates from the mempool */
|
|
118
|
+
export interface FeeRateEstimate {
|
|
119
|
+
/** Fee rate for next block confirmation (sat/vB) */
|
|
120
|
+
fastest: number;
|
|
121
|
+
/** Fee rate for confirmation within 30 minutes (sat/vB) */
|
|
122
|
+
halfHour: number;
|
|
123
|
+
/** Fee rate for confirmation within 1 hour (sat/vB) */
|
|
124
|
+
hour: number;
|
|
125
|
+
/** Fee rate for economy confirmation (sat/vB) */
|
|
126
|
+
economy: number;
|
|
127
|
+
/** Minimum relay fee (sat/vB) */
|
|
128
|
+
minimum: number;
|
|
129
|
+
}
|
|
130
|
+
export declare class BitcoinTaprootAdapter implements ChainAdapter {
|
|
131
|
+
private network;
|
|
132
|
+
private apiUrl;
|
|
133
|
+
constructor(options?: BitcoinTaprootOptions);
|
|
134
|
+
getRpcUrl(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Derive a Taproot (P2TR) address from a FROST group public key.
|
|
137
|
+
*
|
|
138
|
+
* The FROST group verifying key is a secp256k1 point. For Taproot:
|
|
139
|
+
* 1. Extract the x-only public key (32 bytes)
|
|
140
|
+
* 2. Compute the Taproot tweak: t = hash_TapTweak(x_only_pubkey)
|
|
141
|
+
* 3. Compute the output key: Q = P + t*G
|
|
142
|
+
* 4. Encode as Bech32m with witness version 1
|
|
143
|
+
*
|
|
144
|
+
* @param groupPubkeyHex - Hex-encoded FROST group verifying key (33 bytes compressed or 32 bytes x-only)
|
|
145
|
+
* @returns TaprootAddressInfo with address, keys, and scriptPubkey
|
|
146
|
+
*/
|
|
147
|
+
deriveAddress(groupPubkeyHex: string): TaprootAddressInfo;
|
|
148
|
+
/**
|
|
149
|
+
* Fetch unspent transaction outputs (UTXOs) for a Taproot address.
|
|
150
|
+
*
|
|
151
|
+
* @param address - Bech32m Taproot address (bc1p... / tb1p...)
|
|
152
|
+
* @returns Array of UTXOs sorted by value (largest first)
|
|
153
|
+
*/
|
|
154
|
+
getUTXOs(address: string): Promise<TaprootUtxo[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Get the balance of a Bitcoin address in satoshis.
|
|
157
|
+
* Includes both confirmed and unconfirmed (mempool) balances.
|
|
158
|
+
*
|
|
159
|
+
* @param address - Taproot address
|
|
160
|
+
* @returns Balance in satoshis as a string
|
|
161
|
+
*/
|
|
162
|
+
getBalance(address: string): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Get the confirmed balance only (excluding mempool transactions).
|
|
165
|
+
*
|
|
166
|
+
* @param address - Taproot address
|
|
167
|
+
* @returns Confirmed balance in satoshis as a string
|
|
168
|
+
*/
|
|
169
|
+
getConfirmedBalance(address: string): Promise<string>;
|
|
170
|
+
/**
|
|
171
|
+
* Get recommended fee rates from the mempool.
|
|
172
|
+
*
|
|
173
|
+
* @returns Fee rate estimates in sat/vB
|
|
174
|
+
*/
|
|
175
|
+
getFeeRates(): Promise<FeeRateEstimate>;
|
|
176
|
+
/**
|
|
177
|
+
* Estimate the fee for a transaction with the given number of inputs and outputs.
|
|
178
|
+
*
|
|
179
|
+
* @param inputCount - Number of Taproot inputs
|
|
180
|
+
* @param outputCount - Number of outputs (including change)
|
|
181
|
+
* @param feeRate - Fee rate in sat/vB
|
|
182
|
+
* @returns Estimated fee in satoshis
|
|
183
|
+
*/
|
|
184
|
+
estimateFee(inputCount: number, outputCount: number, feeRate: number): number;
|
|
185
|
+
/**
|
|
186
|
+
* Build an unsigned Bitcoin Taproot transaction.
|
|
187
|
+
*
|
|
188
|
+
* Fetches UTXOs, selects inputs using a largest-first strategy,
|
|
189
|
+
* constructs outputs (recipient + change), computes the BIP-341
|
|
190
|
+
* sighash, and returns the serialized unsigned transaction.
|
|
191
|
+
*
|
|
192
|
+
* The returned sighash is what gets passed to the FROST signing
|
|
193
|
+
* protocol. The resulting 64-byte Schnorr signature is directly
|
|
194
|
+
* usable as the Taproot witness.
|
|
195
|
+
*
|
|
196
|
+
* @param tx - Transaction parameters (to, amount, feeRate)
|
|
197
|
+
* @param fromAddress - Sender's Taproot address
|
|
198
|
+
* @returns Hex-encoded unsigned transaction data (JSON-encoded internally)
|
|
199
|
+
*/
|
|
200
|
+
buildTransaction(tx: BtcTransaction, fromAddress: string): Promise<string>;
|
|
201
|
+
/**
|
|
202
|
+
* Build an unsigned Taproot transaction with explicit control over inputs and outputs.
|
|
203
|
+
*
|
|
204
|
+
* For advanced usage when you want to manually select UTXOs and construct
|
|
205
|
+
* the transaction outputs.
|
|
206
|
+
*
|
|
207
|
+
* @param inputs - UTXOs to spend
|
|
208
|
+
* @param outputs - Transaction outputs
|
|
209
|
+
* @param xOnlyInternalKey - 32-byte x-only internal key (hex-encoded)
|
|
210
|
+
* @param feeRate - Fee rate in sat/vB
|
|
211
|
+
* @returns UnsignedTaprootTx ready for FROST signing
|
|
212
|
+
*/
|
|
213
|
+
buildUnsignedTx(inputs: TaprootTxInput[], outputs: TaprootTxOutput[], feeRate: number): UnsignedTaprootTx;
|
|
214
|
+
/**
|
|
215
|
+
* Attach a FROST Schnorr signature to an unsigned Taproot transaction.
|
|
216
|
+
*
|
|
217
|
+
* The FROST signing protocol produces a 64-byte BIP-340 Schnorr signature
|
|
218
|
+
* (R_x || s) that is directly used as the Taproot witness for key-path spends.
|
|
219
|
+
*
|
|
220
|
+
* @param unsignedTxHex - Hex-encoded unsigned transaction (from buildTransaction)
|
|
221
|
+
* @param signatureHex - 64-byte FROST Schnorr signature (hex-encoded, 128 chars)
|
|
222
|
+
* @returns Hex-encoded signed transaction ready for broadcast
|
|
223
|
+
*/
|
|
224
|
+
attachSignature(unsignedTxHex: string, signatureHex: string): Promise<string>;
|
|
225
|
+
/**
|
|
226
|
+
* Attach a FROST Schnorr signature with full output (returns structured data).
|
|
227
|
+
*
|
|
228
|
+
* @param unsignedTx - The UnsignedTaprootTx from buildUnsignedTx
|
|
229
|
+
* @param signatureHex - 64-byte FROST Schnorr signature (hex, 128 chars)
|
|
230
|
+
* @returns SignedTaprootTx with raw_signed, txid, and vsize
|
|
231
|
+
*/
|
|
232
|
+
attachSignatureToTx(unsignedTx: UnsignedTaprootTx, signatureHex: string): SignedTaprootTx;
|
|
233
|
+
/**
|
|
234
|
+
* Broadcast a signed Taproot transaction to the Bitcoin network.
|
|
235
|
+
*
|
|
236
|
+
* Accepts either a raw Bitcoin transaction hex or the hex-encoded JSON
|
|
237
|
+
* format from attachSignature().
|
|
238
|
+
*
|
|
239
|
+
* @param signedTx - Hex-encoded signed transaction
|
|
240
|
+
* @returns Transaction ID (txid)
|
|
241
|
+
*/
|
|
242
|
+
broadcast(signedTx: string): Promise<string>;
|
|
243
|
+
/**
|
|
244
|
+
* Get transaction details by txid.
|
|
245
|
+
*
|
|
246
|
+
* @param txid - Transaction ID
|
|
247
|
+
* @returns Transaction data or null if not found
|
|
248
|
+
*/
|
|
249
|
+
getTransaction(txid: string): Promise<any | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Get the current block height.
|
|
252
|
+
*/
|
|
253
|
+
getBlockHeight(): Promise<number>;
|
|
254
|
+
/**
|
|
255
|
+
* Check if an address is a valid Taproot (P2TR) address.
|
|
256
|
+
*/
|
|
257
|
+
isTaprootAddress(address: string): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Convert a Taproot address to its scriptPubKey.
|
|
260
|
+
* P2TR scriptPubKey: OP_1 (0x51) + PUSH32 (0x20) + <32-byte witness program>
|
|
261
|
+
*/
|
|
262
|
+
addressToScriptPubkey(address: string): string;
|
|
263
|
+
private selectUTXOs;
|
|
264
|
+
/**
|
|
265
|
+
* Serialize an unsigned Taproot transaction.
|
|
266
|
+
*
|
|
267
|
+
* Bitcoin transaction format (segwit):
|
|
268
|
+
* - Version (4 bytes LE)
|
|
269
|
+
* - Marker + Flag (00 01 for segwit)
|
|
270
|
+
* - Input count (varint)
|
|
271
|
+
* - Inputs (outpoint + empty scriptSig + sequence)
|
|
272
|
+
* - Output count (varint)
|
|
273
|
+
* - Outputs (value + scriptPubkey)
|
|
274
|
+
* - Witness (placeholder for signing)
|
|
275
|
+
* - Locktime (4 bytes LE)
|
|
276
|
+
*/
|
|
277
|
+
private serializeUnsignedTx;
|
|
278
|
+
/**
|
|
279
|
+
* Serialize a signed Taproot transaction.
|
|
280
|
+
*/
|
|
281
|
+
private serializeSignedTx;
|
|
282
|
+
/**
|
|
283
|
+
* Compute the BIP-341 Taproot sighash for key-path spend.
|
|
284
|
+
*
|
|
285
|
+
* The sighash message for SIGHASH_DEFAULT (0x00) includes:
|
|
286
|
+
* - Epoch (0x00)
|
|
287
|
+
* - Sighash type (0x00)
|
|
288
|
+
* - Transaction version (4 bytes LE)
|
|
289
|
+
* - Locktime (4 bytes LE)
|
|
290
|
+
* - SHA-256 of prevouts
|
|
291
|
+
* - SHA-256 of amounts
|
|
292
|
+
* - SHA-256 of scriptPubKeys
|
|
293
|
+
* - SHA-256 of sequences
|
|
294
|
+
* - SHA-256 of outputs
|
|
295
|
+
* - Spend type (0x00 for key-path, no annex)
|
|
296
|
+
* - Input index (4 bytes LE)
|
|
297
|
+
*/
|
|
298
|
+
private computeSighash;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Create a Bitcoin Taproot adapter for mainnet.
|
|
302
|
+
*/
|
|
303
|
+
export declare function createBitcoinTaprootAdapter(options?: Omit<BitcoinTaprootOptions, 'network'>): BitcoinTaprootAdapter;
|
|
304
|
+
/**
|
|
305
|
+
* Create a Bitcoin Taproot adapter for testnet.
|
|
306
|
+
*/
|
|
307
|
+
export declare function createBitcoinTestnetTaprootAdapter(options?: Omit<BitcoinTaprootOptions, 'network'>): BitcoinTaprootAdapter;
|
|
308
|
+
//# sourceMappingURL=bitcoin-taproot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin-taproot.d.ts","sourceRoot":"","sources":["../../src/chains/bitcoin-taproot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK7D,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE1E,gCAAgC;AAChC,MAAM,WAAW,WAAW;IACxB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,MAAM,EAAE;QACJ,SAAS,EAAE,OAAO,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACL;AAED,yDAAy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