react-native-bdk-sdk 0.1.4 → 0.1.6
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/cpp/generated/bdk_ffi.cpp +345 -12
- package/cpp/generated/bdk_ffi.hpp +17 -0
- package/lib/commonjs/generated/bdk_ffi-ffi.js.map +1 -1
- package/lib/commonjs/generated/bdk_ffi.js +1946 -1266
- package/lib/commonjs/generated/bdk_ffi.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/wrapper.js +433 -0
- package/lib/commonjs/wrapper.js.map +1 -0
- package/lib/module/generated/bdk_ffi-ffi.js.map +1 -1
- package/lib/module/generated/bdk_ffi.js +1941 -1266
- package/lib/module/generated/bdk_ffi.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/wrapper.js +427 -0
- package/lib/module/wrapper.js.map +1 -0
- package/lib/typescript/commonjs/src/generated/bdk_ffi-ffi.d.ts +21 -4
- package/lib/typescript/commonjs/src/generated/bdk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/generated/bdk_ffi.d.ts +3372 -1829
- package/lib/typescript/commonjs/src/generated/bdk_ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/wrapper.d.ts +168 -0
- package/lib/typescript/commonjs/src/wrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/generated/bdk_ffi-ffi.d.ts +21 -4
- package/lib/typescript/module/src/generated/bdk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/bdk_ffi.d.ts +3372 -1829
- package/lib/typescript/module/src/generated/bdk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/wrapper.d.ts +168 -0
- package/lib/typescript/module/src/wrapper.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/generated/bdk_ffi-ffi.ts +63 -5
- package/src/generated/bdk_ffi.ts +2743 -1692
- package/src/index.tsx +3 -0
- package/src/wrapper.ts +614 -0
package/src/index.tsx
CHANGED
|
@@ -13,6 +13,9 @@ if (!rustInstalled) {
|
|
|
13
13
|
// Export the generated bindings to the app.
|
|
14
14
|
export * from './generated/bdk_ffi';
|
|
15
15
|
|
|
16
|
+
// Export number-friendly wrappers (lives outside generated/ so codegen won't overwrite).
|
|
17
|
+
export * from './wrapper';
|
|
18
|
+
|
|
16
19
|
// Now import the bindings so we can:
|
|
17
20
|
// - intialize them
|
|
18
21
|
// - export them as namespaced objects as the default export.
|
package/src/wrapper.ts
ADDED
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number-friendly wrappers for react-native-bdk-sdk.
|
|
3
|
+
*
|
|
4
|
+
* The generated FFI bindings use `bigint` for all u64/i64 fields.
|
|
5
|
+
* These wrappers accept plain `number` for satoshi amounts and stop gaps,
|
|
6
|
+
* and return `number` in output types — for a more natural React Native DX.
|
|
7
|
+
*
|
|
8
|
+
* JS `number` safely handles up to 2^53 (~9 quadrillion), which covers
|
|
9
|
+
* the entire Bitcoin supply in satoshis (2.1 quadrillion).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
AddressInfo,
|
|
14
|
+
BlockId,
|
|
15
|
+
ChangeSpendPolicy,
|
|
16
|
+
DerivationInfo,
|
|
17
|
+
ElectrumClientLike,
|
|
18
|
+
KeychainInfo,
|
|
19
|
+
KeychainKind,
|
|
20
|
+
Network,
|
|
21
|
+
OutPoint,
|
|
22
|
+
PsbtLike,
|
|
23
|
+
TxOrdering,
|
|
24
|
+
} from './generated/bdk_ffi';
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
ElectrumClient,
|
|
28
|
+
TxBuilder,
|
|
29
|
+
Wallet,
|
|
30
|
+
createWallet as rawCreateWallet,
|
|
31
|
+
} from './generated/bdk_ffi';
|
|
32
|
+
|
|
33
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
34
|
+
// Number-friendly output types
|
|
35
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
36
|
+
|
|
37
|
+
export type BalanceN = {
|
|
38
|
+
immature: number;
|
|
39
|
+
trustedPending: number;
|
|
40
|
+
untrustedPending: number;
|
|
41
|
+
confirmed: number;
|
|
42
|
+
trustedSpendable: number;
|
|
43
|
+
total: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ConfirmationBlockTimeN = {
|
|
47
|
+
height: number;
|
|
48
|
+
blockHash: string;
|
|
49
|
+
timestamp: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type TxOutN = {
|
|
53
|
+
value: number;
|
|
54
|
+
scriptPubkeyHex: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type LocalOutputN = {
|
|
58
|
+
outpoint: OutPoint;
|
|
59
|
+
txout: TxOutN;
|
|
60
|
+
keychain: KeychainKind;
|
|
61
|
+
isSpent: boolean;
|
|
62
|
+
derivationIndex: number;
|
|
63
|
+
confirmationBlockTime?: ConfirmationBlockTimeN;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type SentAndReceivedN = {
|
|
67
|
+
sent: number;
|
|
68
|
+
received: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type TxInputN = {
|
|
72
|
+
previousTxid: string;
|
|
73
|
+
previousVout: number;
|
|
74
|
+
sequence: number;
|
|
75
|
+
scriptSigHex: string;
|
|
76
|
+
witness: string[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type TxOutputN = {
|
|
80
|
+
value: number;
|
|
81
|
+
scriptPubkeyHex: string;
|
|
82
|
+
address?: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type TxDetailsN = {
|
|
86
|
+
txid: string;
|
|
87
|
+
sent: number;
|
|
88
|
+
received: number;
|
|
89
|
+
fee?: number;
|
|
90
|
+
feeRate?: number;
|
|
91
|
+
balanceDelta: number;
|
|
92
|
+
confirmationBlockTime?: ConfirmationBlockTimeN;
|
|
93
|
+
txHex: string;
|
|
94
|
+
version: number;
|
|
95
|
+
locktime: number;
|
|
96
|
+
inputs: TxInputN[];
|
|
97
|
+
outputs: TxOutputN[];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// ── Converters ───────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
function toConfirmationN(
|
|
103
|
+
c?: { height: number; blockHash: string; timestamp: bigint }
|
|
104
|
+
): ConfirmationBlockTimeN | undefined {
|
|
105
|
+
if (!c) return undefined;
|
|
106
|
+
return { height: c.height, blockHash: c.blockHash, timestamp: Number(c.timestamp) };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function toBalanceN(b: {
|
|
110
|
+
immature: bigint;
|
|
111
|
+
trustedPending: bigint;
|
|
112
|
+
untrustedPending: bigint;
|
|
113
|
+
confirmed: bigint;
|
|
114
|
+
trustedSpendable: bigint;
|
|
115
|
+
total: bigint;
|
|
116
|
+
}): BalanceN {
|
|
117
|
+
return {
|
|
118
|
+
immature: Number(b.immature),
|
|
119
|
+
trustedPending: Number(b.trustedPending),
|
|
120
|
+
untrustedPending: Number(b.untrustedPending),
|
|
121
|
+
confirmed: Number(b.confirmed),
|
|
122
|
+
trustedSpendable: Number(b.trustedSpendable),
|
|
123
|
+
total: Number(b.total),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function toTxDetailsN(tx: {
|
|
128
|
+
txid: string;
|
|
129
|
+
sent: bigint;
|
|
130
|
+
received: bigint;
|
|
131
|
+
fee?: bigint;
|
|
132
|
+
feeRate?: number;
|
|
133
|
+
balanceDelta: bigint;
|
|
134
|
+
confirmationBlockTime?: { height: number; blockHash: string; timestamp: bigint };
|
|
135
|
+
txHex: string;
|
|
136
|
+
version: number;
|
|
137
|
+
locktime: number;
|
|
138
|
+
inputs: Array<{ previousTxid: string; previousVout: number; sequence: number; scriptSigHex: string; witness: string[] }>;
|
|
139
|
+
outputs: Array<{ value: bigint; scriptPubkeyHex: string; address?: string }>;
|
|
140
|
+
}): TxDetailsN {
|
|
141
|
+
return {
|
|
142
|
+
txid: tx.txid,
|
|
143
|
+
sent: Number(tx.sent),
|
|
144
|
+
received: Number(tx.received),
|
|
145
|
+
fee: tx.fee != null ? Number(tx.fee) : undefined,
|
|
146
|
+
feeRate: tx.feeRate ?? undefined,
|
|
147
|
+
balanceDelta: Number(tx.balanceDelta),
|
|
148
|
+
confirmationBlockTime: toConfirmationN(tx.confirmationBlockTime),
|
|
149
|
+
txHex: tx.txHex,
|
|
150
|
+
version: tx.version,
|
|
151
|
+
locktime: tx.locktime,
|
|
152
|
+
inputs: tx.inputs.map((inp) => ({
|
|
153
|
+
previousTxid: inp.previousTxid,
|
|
154
|
+
previousVout: inp.previousVout,
|
|
155
|
+
sequence: inp.sequence,
|
|
156
|
+
scriptSigHex: inp.scriptSigHex,
|
|
157
|
+
witness: inp.witness,
|
|
158
|
+
})),
|
|
159
|
+
outputs: tx.outputs.map((out) => ({
|
|
160
|
+
value: Number(out.value),
|
|
161
|
+
scriptPubkeyHex: out.scriptPubkeyHex,
|
|
162
|
+
address: out.address ?? undefined,
|
|
163
|
+
})),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function toSentAndReceivedN(s: { sent: bigint; received: bigint }): SentAndReceivedN {
|
|
168
|
+
return { sent: Number(s.sent), received: Number(s.received) };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function toLocalOutputN(o: {
|
|
172
|
+
outpoint: OutPoint;
|
|
173
|
+
txout: { value: bigint; scriptPubkeyHex: string };
|
|
174
|
+
keychain: KeychainKind;
|
|
175
|
+
isSpent: boolean;
|
|
176
|
+
derivationIndex: number;
|
|
177
|
+
confirmationBlockTime?: { height: number; blockHash: string; timestamp: bigint };
|
|
178
|
+
}): LocalOutputN {
|
|
179
|
+
return {
|
|
180
|
+
outpoint: o.outpoint,
|
|
181
|
+
txout: { value: Number(o.txout.value), scriptPubkeyHex: o.txout.scriptPubkeyHex },
|
|
182
|
+
keychain: o.keychain,
|
|
183
|
+
isSpent: o.isSpent,
|
|
184
|
+
derivationIndex: o.derivationIndex,
|
|
185
|
+
confirmationBlockTime: toConfirmationN(o.confirmationBlockTime),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
190
|
+
// ElectrumClient wrapper
|
|
191
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
192
|
+
|
|
193
|
+
/** Pass a URL string (creates temp connection) or a BdkElectrumClient (reuses). */
|
|
194
|
+
export type ElectrumInput = string | BdkElectrumClient;
|
|
195
|
+
|
|
196
|
+
export class BdkElectrumClient {
|
|
197
|
+
private readonly inner: ElectrumClient;
|
|
198
|
+
|
|
199
|
+
constructor(url: string) {
|
|
200
|
+
this.inner = new ElectrumClient(url);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
get raw(): ElectrumClientLike {
|
|
204
|
+
return this.inner;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function resolveElectrum(input: ElectrumInput): ElectrumClientLike {
|
|
209
|
+
if (typeof input === 'string') {
|
|
210
|
+
return new ElectrumClient(input);
|
|
211
|
+
}
|
|
212
|
+
return input.raw;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
216
|
+
// Async wallet factory
|
|
217
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
218
|
+
|
|
219
|
+
export async function bdkCreateWallet(
|
|
220
|
+
descriptor: string,
|
|
221
|
+
changeDescriptor: string | undefined,
|
|
222
|
+
network: Network,
|
|
223
|
+
dbPath: string
|
|
224
|
+
): Promise<BdkWallet> {
|
|
225
|
+
const inner = await rawCreateWallet(descriptor, changeDescriptor, network, dbPath);
|
|
226
|
+
return BdkWallet.fromRaw(inner as Wallet);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
230
|
+
// Wallet wrapper
|
|
231
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
232
|
+
|
|
233
|
+
export class BdkWallet {
|
|
234
|
+
private readonly inner: Wallet;
|
|
235
|
+
|
|
236
|
+
constructor(
|
|
237
|
+
descriptor: string,
|
|
238
|
+
changeDescriptor: string | undefined,
|
|
239
|
+
network: Network,
|
|
240
|
+
dbPath: string
|
|
241
|
+
) {
|
|
242
|
+
this.inner = new Wallet(descriptor, changeDescriptor, network, dbPath);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
static fromRaw(wallet: Wallet): BdkWallet {
|
|
246
|
+
const instance = Object.create(BdkWallet.prototype) as BdkWallet;
|
|
247
|
+
(instance as any).inner = wallet;
|
|
248
|
+
return instance;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
get raw(): Wallet {
|
|
252
|
+
return this.inner;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ── Address management ──────────────────────────────────────────────────
|
|
256
|
+
|
|
257
|
+
nextUnusedAddress(keychain: KeychainKind): AddressInfo {
|
|
258
|
+
return this.inner.nextUnusedAddress(keychain);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
revealNextAddress(keychain: KeychainKind): AddressInfo {
|
|
262
|
+
return this.inner.revealNextAddress(keychain);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
revealAddressesTo(keychain: KeychainKind, index: number): AddressInfo[] {
|
|
266
|
+
return this.inner.revealAddressesTo(keychain, index);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
peekAddress(keychain: KeychainKind, index: number): AddressInfo {
|
|
270
|
+
return this.inner.peekAddress(keychain, index);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
listUnusedAddresses(keychain: KeychainKind): AddressInfo[] {
|
|
274
|
+
return this.inner.listUnusedAddresses(keychain);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
markUsed(keychain: KeychainKind, index: number): boolean {
|
|
278
|
+
return this.inner.markUsed(keychain, index);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
unmarkUsed(keychain: KeychainKind, index: number): boolean {
|
|
282
|
+
return this.inner.unmarkUsed(keychain, index);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ── Balance ─────────────────────────────────────────────────────────────
|
|
286
|
+
|
|
287
|
+
getBalance(): BalanceN {
|
|
288
|
+
return toBalanceN(this.inner.getBalance());
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ── UTXOs ───────────────────────────────────────────────────────────────
|
|
292
|
+
|
|
293
|
+
listUnspent(): LocalOutputN[] {
|
|
294
|
+
return this.inner.listUnspent().map(toLocalOutputN);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
listOutput(): LocalOutputN[] {
|
|
298
|
+
return this.inner.listOutput().map(toLocalOutputN);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
getUtxo(outpoint: OutPoint): LocalOutputN | undefined {
|
|
302
|
+
const o = this.inner.getUtxo(outpoint);
|
|
303
|
+
return o ? toLocalOutputN(o) : undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
insertTxout(outpoint: OutPoint, txout: { value: number; scriptPubkeyHex: string }): void {
|
|
307
|
+
this.inner.insertTxout(outpoint, {
|
|
308
|
+
value: BigInt(txout.value),
|
|
309
|
+
scriptPubkeyHex: txout.scriptPubkeyHex,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// ── Transactions ────────────────────────────────────────────────────────
|
|
314
|
+
|
|
315
|
+
transactions(): TxDetailsN[] {
|
|
316
|
+
return this.inner.transactions().map(toTxDetailsN);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
txDetails(txid: string): TxDetailsN | undefined {
|
|
320
|
+
const tx = this.inner.txDetails(txid);
|
|
321
|
+
return tx ? toTxDetailsN(tx) : undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
getTx(txid: string): string | undefined {
|
|
325
|
+
return this.inner.getTx(txid);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
sentAndReceived(txHex: string): SentAndReceivedN {
|
|
329
|
+
return toSentAndReceivedN(this.inner.sentAndReceived(txHex));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
calculateFee(txHex: string): number {
|
|
333
|
+
return Number(this.inner.calculateFee(txHex));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
calculateFeeRate(txHex: string): number {
|
|
337
|
+
return this.inner.calculateFeeRate(txHex);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
cancelTx(txHex: string): void {
|
|
341
|
+
this.inner.cancelTx(txHex);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ── PSBT / Signing ──────────────────────────────────────────────────────
|
|
345
|
+
|
|
346
|
+
sign(psbt: PsbtLike): boolean {
|
|
347
|
+
return this.inner.sign(psbt);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
finalizePsbt(psbt: PsbtLike): boolean {
|
|
351
|
+
return this.inner.finalizePsbt(psbt);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// ── Sync (Esplora) ─────────────────────────────────────────────────────
|
|
355
|
+
|
|
356
|
+
fullScanWithEsplora(url: string, stopGap: number): Promise<void> {
|
|
357
|
+
return this.inner.fullScanWithEsplora(url, BigInt(stopGap));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
syncWithEsplora(url: string, stopGap: number): Promise<void> {
|
|
361
|
+
return this.inner.syncWithEsplora(url, BigInt(stopGap));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ── Sync (Electrum) ────────────────────────────────────────────────────
|
|
365
|
+
|
|
366
|
+
fullScanWithElectrum(client: ElectrumInput, stopGap: number): Promise<void> {
|
|
367
|
+
return this.inner.fullScanWithElectrum(resolveElectrum(client), BigInt(stopGap));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
syncWithElectrum(client: ElectrumInput, stopGap: number): Promise<void> {
|
|
371
|
+
return this.inner.syncWithElectrum(resolveElectrum(client), BigInt(stopGap));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// ── Broadcast ───────────────────────────────────────────────────────────
|
|
375
|
+
|
|
376
|
+
broadcastWithEsplora(url: string, psbt: PsbtLike): Promise<string> {
|
|
377
|
+
return this.inner.broadcastWithEsplora(url, psbt);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
broadcastWithElectrum(client: ElectrumInput, psbt: PsbtLike): Promise<string> {
|
|
381
|
+
return this.inner.broadcastWithElectrum(resolveElectrum(client), psbt);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ── Convenience (Esplora) ───────────────────────────────────────────────
|
|
385
|
+
|
|
386
|
+
send(address: string, amountSats: number, feeRate: number, esploraUrl: string): Promise<string> {
|
|
387
|
+
return this.inner.send(address, BigInt(amountSats), feeRate, esploraUrl);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
drain(address: string, feeRate: number, esploraUrl: string): Promise<string> {
|
|
391
|
+
return this.inner.drain(address, feeRate, esploraUrl);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// ── Convenience (Electrum) ──────────────────────────────────────────────
|
|
395
|
+
|
|
396
|
+
sendWithElectrum(
|
|
397
|
+
address: string,
|
|
398
|
+
amountSats: number,
|
|
399
|
+
feeRate: number,
|
|
400
|
+
client: ElectrumInput
|
|
401
|
+
): Promise<string> {
|
|
402
|
+
return this.inner.sendWithElectrum(address, BigInt(amountSats), feeRate, resolveElectrum(client));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
drainWithElectrum(address: string, feeRate: number, client: ElectrumInput): Promise<string> {
|
|
406
|
+
return this.inner.drainWithElectrum(address, feeRate, resolveElectrum(client));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ── Fee bumping ─────────────────────────────────────────────────────────
|
|
410
|
+
|
|
411
|
+
buildFeeBump(txid: string, newFeeRate: number): PsbtLike {
|
|
412
|
+
return this.inner.buildFeeBump(txid, newFeeRate);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// ── Script / SPK queries ────────────────────────────────────────────────
|
|
416
|
+
|
|
417
|
+
isMine(scriptHex: string): boolean {
|
|
418
|
+
return this.inner.isMine(scriptHex);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
derivationOfSpk(scriptHex: string): DerivationInfo | undefined {
|
|
422
|
+
return this.inner.derivationOfSpk(scriptHex);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// ── Descriptor / keychain info ──────────────────────────────────────────
|
|
426
|
+
|
|
427
|
+
publicDescriptor(keychain: KeychainKind): string {
|
|
428
|
+
return this.inner.publicDescriptor(keychain);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
descriptorChecksum(keychain: KeychainKind): string {
|
|
432
|
+
return this.inner.descriptorChecksum(keychain);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
keychains(): KeychainInfo[] {
|
|
436
|
+
return this.inner.keychains();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
policies(keychain: KeychainKind): string | undefined {
|
|
440
|
+
return this.inner.policies(keychain);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
derivationIndex(keychain: KeychainKind): number | undefined {
|
|
444
|
+
return this.inner.derivationIndex(keychain);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
nextDerivationIndex(keychain: KeychainKind): number {
|
|
448
|
+
return this.inner.nextDerivationIndex(keychain);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ── Chain state ─────────────────────────────────────────────────────────
|
|
452
|
+
|
|
453
|
+
latestCheckpoint(): BlockId | undefined {
|
|
454
|
+
return this.inner.latestCheckpoint();
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
checkpoints(): BlockId[] {
|
|
458
|
+
return this.inner.checkpoints();
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ── Persistence ─────────────────────────────────────────────────────────
|
|
462
|
+
|
|
463
|
+
persist(): boolean {
|
|
464
|
+
return this.inner.persist();
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ── Accessors ───────────────────────────────────────────────────────────
|
|
468
|
+
|
|
469
|
+
network(): Network {
|
|
470
|
+
return this.inner.network();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
475
|
+
// TxBuilder wrapper
|
|
476
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
477
|
+
|
|
478
|
+
export class BdkTxBuilder {
|
|
479
|
+
private readonly inner: TxBuilder;
|
|
480
|
+
|
|
481
|
+
constructor() {
|
|
482
|
+
this.inner = new TxBuilder();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
get raw(): TxBuilder {
|
|
486
|
+
return this.inner;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
addRecipient(address: string, amountSats: number): void {
|
|
490
|
+
this.inner.addRecipient(address, BigInt(amountSats));
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
setRecipients(recipients: Array<{ address: string; amountSats: number }>): void {
|
|
494
|
+
this.inner.setRecipients(
|
|
495
|
+
recipients.map((r) => ({ address: r.address, amountSats: BigInt(r.amountSats) }))
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
addData(data: Array<number>): void {
|
|
500
|
+
this.inner.addData(data);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
feeRate(satPerVbyte: number): void {
|
|
504
|
+
this.inner.feeRate(satPerVbyte);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
feeAbsolute(feeSats: number): void {
|
|
508
|
+
this.inner.feeAbsolute(BigInt(feeSats));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
drainWallet(): void {
|
|
512
|
+
this.inner.drainWallet();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
drainTo(address: string): void {
|
|
516
|
+
this.inner.drainTo(address);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
manuallySelectedOnly(): void {
|
|
520
|
+
this.inner.manuallySelectedOnly();
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
addUtxo(outpoint: OutPoint): void {
|
|
524
|
+
this.inner.addUtxo(outpoint);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
addUtxos(outpoints: Array<OutPoint>): void {
|
|
528
|
+
this.inner.addUtxos(outpoints);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
unspendable(outpoints: Array<OutPoint>): void {
|
|
532
|
+
this.inner.unspendable(outpoints);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
addUnspendable(outpoint: OutPoint): void {
|
|
536
|
+
this.inner.addUnspendable(outpoint);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
excludeBelowConfirmations(minConfirms: number): void {
|
|
540
|
+
this.inner.excludeBelowConfirmations(minConfirms);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
excludeUnconfirmed(): void {
|
|
544
|
+
this.inner.excludeUnconfirmed();
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
doNotSpendChange(): void {
|
|
548
|
+
this.inner.doNotSpendChange();
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
onlySpendChange(): void {
|
|
552
|
+
this.inner.onlySpendChange();
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
changePolicy(policy: ChangeSpendPolicy): void {
|
|
556
|
+
this.inner.changePolicy(policy);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
enableRbf(): void {
|
|
560
|
+
this.inner.enableRbf();
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
enableRbfWithSequence(nsequence: number): void {
|
|
564
|
+
this.inner.enableRbfWithSequence(nsequence);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
setExactSequence(nsequence: number): void {
|
|
568
|
+
this.inner.setExactSequence(nsequence);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
ordering(ordering: TxOrdering): void {
|
|
572
|
+
this.inner.ordering(ordering);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
nlocktime(lockHeight: number): void {
|
|
576
|
+
this.inner.nlocktime(lockHeight);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
txVersion(version: number): void {
|
|
580
|
+
this.inner.txVersion(version);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
allowDust(allow: boolean): void {
|
|
584
|
+
this.inner.allowDust(allow);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
currentHeight(height: number): void {
|
|
588
|
+
this.inner.currentHeight(height);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
onlyWitnessUtxo(): void {
|
|
592
|
+
this.inner.onlyWitnessUtxo();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
includeOutputRedeemWitnessScript(): void {
|
|
596
|
+
this.inner.includeOutputRedeemWitnessScript();
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
addGlobalXpubs(): void {
|
|
600
|
+
this.inner.addGlobalXpubs();
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
sighash(sighashType: number): void {
|
|
604
|
+
this.inner.sighash(sighashType);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
policyPath(pathMapJson: string, keychain: KeychainKind): void {
|
|
608
|
+
this.inner.policyPath(pathMapJson, keychain);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async finish(wallet: BdkWallet): Promise<PsbtLike> {
|
|
612
|
+
return this.inner.finish(wallet.raw);
|
|
613
|
+
}
|
|
614
|
+
}
|