@bitgo/wasm-utxo 3.1.0 → 4.0.1
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/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +18 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +17 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/cjs/js/index.d.ts +22 -1
- package/dist/cjs/js/psbt.d.ts +2 -7
- package/dist/cjs/js/transaction.d.ts +41 -23
- package/dist/cjs/js/transaction.js +69 -18
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +31 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +311 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +71 -49
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +18 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +17 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/esm/js/index.d.ts +22 -1
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/psbt.d.ts +2 -7
- package/dist/esm/js/transaction.d.ts +41 -23
- package/dist/esm/js/transaction.js +70 -19
- package/dist/esm/js/wasm/wasm_utxo.d.ts +31 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.js +311 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +71 -49
- package/package.json +1 -1
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -61,9 +61,30 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
61
61
|
interface PsbtOutputDataWithAddress extends PsbtOutputData {
|
|
62
62
|
address: string;
|
|
63
63
|
}
|
|
64
|
+
/** Outpoint referencing a previous transaction output */
|
|
65
|
+
interface TxOutPoint {
|
|
66
|
+
txid: string;
|
|
67
|
+
vout: number;
|
|
68
|
+
}
|
|
69
|
+
/** Raw transaction input data returned by Transaction.getInputs() */
|
|
70
|
+
interface TxInputData {
|
|
71
|
+
previousOutput: TxOutPoint;
|
|
72
|
+
sequence: number;
|
|
73
|
+
scriptSig: Uint8Array;
|
|
74
|
+
witness: Uint8Array[];
|
|
75
|
+
}
|
|
76
|
+
/** Raw transaction output data returned by Transaction.getOutputs() */
|
|
77
|
+
interface TxOutputData {
|
|
78
|
+
script: Uint8Array;
|
|
79
|
+
value: bigint;
|
|
80
|
+
}
|
|
81
|
+
/** Transaction output data with resolved address */
|
|
82
|
+
interface TxOutputDataWithAddress extends TxOutputData {
|
|
83
|
+
address: string;
|
|
84
|
+
}
|
|
64
85
|
}
|
|
65
86
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
66
87
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
67
88
|
export { Psbt } from "./descriptorWallet/Psbt.js";
|
|
68
|
-
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
89
|
+
export { DashTransaction, Transaction, ZcashTransaction, type ITransaction, type ITransactionCommon, } from "./transaction.js";
|
|
69
90
|
export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -22,5 +22,5 @@ export { getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
|
22
22
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
23
23
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
24
24
|
export { Psbt } from "./descriptorWallet/Psbt.js";
|
|
25
|
-
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
25
|
+
export { DashTransaction, Transaction, ZcashTransaction, } from "./transaction.js";
|
|
26
26
|
export { hasPsbtMagic } from "./psbt.js";
|
package/dist/esm/js/psbt.d.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
2
|
import type { BIP32 } from "./bip32.js";
|
|
3
|
+
import type { ITransactionCommon } from "./transaction.js";
|
|
3
4
|
/** Common interface for PSBT types */
|
|
4
|
-
export interface IPsbt {
|
|
5
|
-
inputCount(): number;
|
|
6
|
-
outputCount(): number;
|
|
7
|
-
getInputs(): PsbtInputData[];
|
|
8
|
-
getOutputs(): PsbtOutputData[];
|
|
5
|
+
export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
|
|
9
6
|
getGlobalXpubs(): BIP32[];
|
|
10
|
-
version(): number;
|
|
11
|
-
lockTime(): number;
|
|
12
7
|
unsignedTxId(): string;
|
|
13
8
|
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
14
9
|
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction, type TxInputData, type TxOutputData, type TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import type { CoinName } from "./coinName.js";
|
|
3
|
+
/** Common read-only interface shared by transactions and PSBTs */
|
|
4
|
+
export interface ITransactionCommon<TInput, TOutput> {
|
|
5
|
+
inputCount(): number;
|
|
6
|
+
outputCount(): number;
|
|
7
|
+
version(): number;
|
|
8
|
+
lockTime(): number;
|
|
9
|
+
getInputs(): TInput[];
|
|
10
|
+
getOutputs(): TOutput[];
|
|
11
|
+
}
|
|
12
|
+
/** Common interface for all transaction types */
|
|
13
|
+
export interface ITransaction extends ITransactionCommon<TxInputData, TxOutputData> {
|
|
6
14
|
toBytes(): Uint8Array;
|
|
7
15
|
getId(): string;
|
|
16
|
+
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
8
17
|
}
|
|
9
18
|
/**
|
|
10
19
|
* Transaction wrapper (Bitcoin-like networks)
|
|
@@ -19,9 +28,7 @@ export declare class Transaction implements ITransaction {
|
|
|
19
28
|
*/
|
|
20
29
|
static create(): Transaction;
|
|
21
30
|
static fromBytes(bytes: Uint8Array): Transaction;
|
|
22
|
-
/**
|
|
23
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
24
|
-
*/
|
|
31
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
25
32
|
static fromWasm(wasm: WasmTransaction): Transaction;
|
|
26
33
|
/**
|
|
27
34
|
* Add an input to the transaction
|
|
@@ -52,9 +59,14 @@ export declare class Transaction implements ITransaction {
|
|
|
52
59
|
* @returns The virtual size in virtual bytes (vbytes)
|
|
53
60
|
*/
|
|
54
61
|
getVSize(): number;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
inputCount(): number;
|
|
63
|
+
outputCount(): number;
|
|
64
|
+
version(): number;
|
|
65
|
+
lockTime(): number;
|
|
66
|
+
getInputs(): TxInputData[];
|
|
67
|
+
getOutputs(): TxOutputData[];
|
|
68
|
+
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
69
|
+
/** @internal */
|
|
58
70
|
get wasm(): WasmTransaction;
|
|
59
71
|
}
|
|
60
72
|
/**
|
|
@@ -66,9 +78,7 @@ export declare class ZcashTransaction implements ITransaction {
|
|
|
66
78
|
private _wasm;
|
|
67
79
|
private constructor();
|
|
68
80
|
static fromBytes(bytes: Uint8Array): ZcashTransaction;
|
|
69
|
-
/**
|
|
70
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
71
|
-
*/
|
|
81
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
72
82
|
static fromWasm(wasm: WasmZcashTransaction): ZcashTransaction;
|
|
73
83
|
toBytes(): Uint8Array;
|
|
74
84
|
/**
|
|
@@ -80,9 +90,14 @@ export declare class ZcashTransaction implements ITransaction {
|
|
|
80
90
|
* @returns The transaction ID as a hex string
|
|
81
91
|
*/
|
|
82
92
|
getId(): string;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
inputCount(): number;
|
|
94
|
+
outputCount(): number;
|
|
95
|
+
version(): number;
|
|
96
|
+
lockTime(): number;
|
|
97
|
+
getInputs(): TxInputData[];
|
|
98
|
+
getOutputs(): TxOutputData[];
|
|
99
|
+
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
100
|
+
/** @internal */
|
|
86
101
|
get wasm(): WasmZcashTransaction;
|
|
87
102
|
}
|
|
88
103
|
/**
|
|
@@ -94,9 +109,7 @@ export declare class DashTransaction implements ITransaction {
|
|
|
94
109
|
private _wasm;
|
|
95
110
|
private constructor();
|
|
96
111
|
static fromBytes(bytes: Uint8Array): DashTransaction;
|
|
97
|
-
/**
|
|
98
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
99
|
-
*/
|
|
112
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
100
113
|
static fromWasm(wasm: WasmDashTransaction): DashTransaction;
|
|
101
114
|
toBytes(): Uint8Array;
|
|
102
115
|
/**
|
|
@@ -108,8 +121,13 @@ export declare class DashTransaction implements ITransaction {
|
|
|
108
121
|
* @returns The transaction ID as a hex string
|
|
109
122
|
*/
|
|
110
123
|
getId(): string;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
inputCount(): number;
|
|
125
|
+
outputCount(): number;
|
|
126
|
+
version(): number;
|
|
127
|
+
lockTime(): number;
|
|
128
|
+
getInputs(): TxInputData[];
|
|
129
|
+
getOutputs(): TxOutputData[];
|
|
130
|
+
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
131
|
+
/** @internal */
|
|
114
132
|
get wasm(): WasmDashTransaction;
|
|
115
133
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
|
|
1
|
+
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction, } from "./wasm/wasm_utxo.js";
|
|
2
2
|
/**
|
|
3
3
|
* Transaction wrapper (Bitcoin-like networks)
|
|
4
4
|
*
|
|
@@ -18,9 +18,7 @@ export class Transaction {
|
|
|
18
18
|
static fromBytes(bytes) {
|
|
19
19
|
return new Transaction(WasmTransaction.from_bytes(bytes));
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
23
|
-
*/
|
|
21
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
24
22
|
static fromWasm(wasm) {
|
|
25
23
|
return new Transaction(wasm);
|
|
26
24
|
}
|
|
@@ -67,9 +65,28 @@ export class Transaction {
|
|
|
67
65
|
getVSize() {
|
|
68
66
|
return this._wasm.get_vsize();
|
|
69
67
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
inputCount() {
|
|
69
|
+
return this._wasm.input_count();
|
|
70
|
+
}
|
|
71
|
+
outputCount() {
|
|
72
|
+
return this._wasm.output_count();
|
|
73
|
+
}
|
|
74
|
+
version() {
|
|
75
|
+
return this._wasm.version();
|
|
76
|
+
}
|
|
77
|
+
lockTime() {
|
|
78
|
+
return this._wasm.lock_time();
|
|
79
|
+
}
|
|
80
|
+
getInputs() {
|
|
81
|
+
return this._wasm.get_inputs();
|
|
82
|
+
}
|
|
83
|
+
getOutputs() {
|
|
84
|
+
return this._wasm.get_outputs();
|
|
85
|
+
}
|
|
86
|
+
getOutputsWithAddress(coin) {
|
|
87
|
+
return this._wasm.get_outputs_with_address(coin);
|
|
88
|
+
}
|
|
89
|
+
/** @internal */
|
|
73
90
|
get wasm() {
|
|
74
91
|
return this._wasm;
|
|
75
92
|
}
|
|
@@ -87,9 +104,7 @@ export class ZcashTransaction {
|
|
|
87
104
|
static fromBytes(bytes) {
|
|
88
105
|
return new ZcashTransaction(WasmZcashTransaction.from_bytes(bytes));
|
|
89
106
|
}
|
|
90
|
-
/**
|
|
91
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
92
|
-
*/
|
|
107
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
93
108
|
static fromWasm(wasm) {
|
|
94
109
|
return new ZcashTransaction(wasm);
|
|
95
110
|
}
|
|
@@ -107,9 +122,28 @@ export class ZcashTransaction {
|
|
|
107
122
|
getId() {
|
|
108
123
|
return this._wasm.get_txid();
|
|
109
124
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
inputCount() {
|
|
126
|
+
return this._wasm.input_count();
|
|
127
|
+
}
|
|
128
|
+
outputCount() {
|
|
129
|
+
return this._wasm.output_count();
|
|
130
|
+
}
|
|
131
|
+
version() {
|
|
132
|
+
return this._wasm.version();
|
|
133
|
+
}
|
|
134
|
+
lockTime() {
|
|
135
|
+
return this._wasm.lock_time();
|
|
136
|
+
}
|
|
137
|
+
getInputs() {
|
|
138
|
+
return this._wasm.get_inputs();
|
|
139
|
+
}
|
|
140
|
+
getOutputs() {
|
|
141
|
+
return this._wasm.get_outputs();
|
|
142
|
+
}
|
|
143
|
+
getOutputsWithAddress(coin) {
|
|
144
|
+
return this._wasm.get_outputs_with_address(coin);
|
|
145
|
+
}
|
|
146
|
+
/** @internal */
|
|
113
147
|
get wasm() {
|
|
114
148
|
return this._wasm;
|
|
115
149
|
}
|
|
@@ -127,9 +161,7 @@ export class DashTransaction {
|
|
|
127
161
|
static fromBytes(bytes) {
|
|
128
162
|
return new DashTransaction(WasmDashTransaction.from_bytes(bytes));
|
|
129
163
|
}
|
|
130
|
-
/**
|
|
131
|
-
* @internal Create from WASM instance directly (avoids re-parsing bytes)
|
|
132
|
-
*/
|
|
164
|
+
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
133
165
|
static fromWasm(wasm) {
|
|
134
166
|
return new DashTransaction(wasm);
|
|
135
167
|
}
|
|
@@ -147,9 +179,28 @@ export class DashTransaction {
|
|
|
147
179
|
getId() {
|
|
148
180
|
return this._wasm.get_txid();
|
|
149
181
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
182
|
+
inputCount() {
|
|
183
|
+
return this._wasm.input_count();
|
|
184
|
+
}
|
|
185
|
+
outputCount() {
|
|
186
|
+
return this._wasm.output_count();
|
|
187
|
+
}
|
|
188
|
+
version() {
|
|
189
|
+
return this._wasm.version();
|
|
190
|
+
}
|
|
191
|
+
lockTime() {
|
|
192
|
+
return this._wasm.lock_time();
|
|
193
|
+
}
|
|
194
|
+
getInputs() {
|
|
195
|
+
return this._wasm.get_inputs();
|
|
196
|
+
}
|
|
197
|
+
getOutputs() {
|
|
198
|
+
return this._wasm.get_outputs();
|
|
199
|
+
}
|
|
200
|
+
getOutputsWithAddress(coin) {
|
|
201
|
+
return this._wasm.get_outputs_with_address(coin);
|
|
202
|
+
}
|
|
203
|
+
/** @internal */
|
|
153
204
|
get wasm() {
|
|
154
205
|
return this._wasm;
|
|
155
206
|
}
|
|
@@ -294,6 +294,16 @@ export class BitGoPsbt {
|
|
|
294
294
|
* Deserialize a PSBT from bytes with network-specific logic
|
|
295
295
|
*/
|
|
296
296
|
static from_bytes(bytes: Uint8Array, network: string): BitGoPsbt;
|
|
297
|
+
/**
|
|
298
|
+
* Convert a half-signed legacy transaction to a psbt-lite.
|
|
299
|
+
*
|
|
300
|
+
* # Arguments
|
|
301
|
+
* * `tx_bytes` - The serialized half-signed legacy transaction
|
|
302
|
+
* * `network` - Network name (utxolib or coin name)
|
|
303
|
+
* * `wallet_keys` - The wallet's root keys
|
|
304
|
+
* * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
|
|
305
|
+
*/
|
|
306
|
+
static from_half_signed_legacy_transaction(tx_bytes: Uint8Array, network: string, wallet_keys: WasmRootWalletKeys, unspents: any): BitGoPsbt;
|
|
297
307
|
/**
|
|
298
308
|
* Generate and store MuSig2 nonces for all MuSig2 inputs
|
|
299
309
|
*
|
|
@@ -904,6 +914,9 @@ export class WasmDashTransaction {
|
|
|
904
914
|
* Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
|
|
905
915
|
*/
|
|
906
916
|
static from_bytes(bytes: Uint8Array): WasmDashTransaction;
|
|
917
|
+
get_inputs(): any;
|
|
918
|
+
get_outputs(): any;
|
|
919
|
+
get_outputs_with_address(coin: string): any;
|
|
907
920
|
/**
|
|
908
921
|
* Get the transaction ID (txid)
|
|
909
922
|
*
|
|
@@ -917,10 +930,14 @@ export class WasmDashTransaction {
|
|
|
917
930
|
* Returns an error if the transaction cannot be serialized
|
|
918
931
|
*/
|
|
919
932
|
get_txid(): string;
|
|
933
|
+
input_count(): number;
|
|
934
|
+
lock_time(): number;
|
|
935
|
+
output_count(): number;
|
|
920
936
|
/**
|
|
921
937
|
* Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
|
|
922
938
|
*/
|
|
923
939
|
to_bytes(): Uint8Array;
|
|
940
|
+
version(): number;
|
|
924
941
|
}
|
|
925
942
|
|
|
926
943
|
/**
|
|
@@ -1180,6 +1197,9 @@ export class WasmTransaction {
|
|
|
1180
1197
|
* Returns an error if the bytes cannot be parsed as a valid transaction
|
|
1181
1198
|
*/
|
|
1182
1199
|
static from_bytes(bytes: Uint8Array): WasmTransaction;
|
|
1200
|
+
get_inputs(): any;
|
|
1201
|
+
get_outputs(): any;
|
|
1202
|
+
get_outputs_with_address(coin: string): any;
|
|
1183
1203
|
/**
|
|
1184
1204
|
* Get the transaction ID (txid)
|
|
1185
1205
|
*
|
|
@@ -1201,6 +1221,9 @@ export class WasmTransaction {
|
|
|
1201
1221
|
* The virtual size in virtual bytes (vbytes)
|
|
1202
1222
|
*/
|
|
1203
1223
|
get_vsize(): number;
|
|
1224
|
+
input_count(): number;
|
|
1225
|
+
lock_time(): number;
|
|
1226
|
+
output_count(): number;
|
|
1204
1227
|
/**
|
|
1205
1228
|
* Serialize the transaction to bytes
|
|
1206
1229
|
*
|
|
@@ -1208,6 +1231,7 @@ export class WasmTransaction {
|
|
|
1208
1231
|
* The serialized transaction bytes
|
|
1209
1232
|
*/
|
|
1210
1233
|
to_bytes(): Uint8Array;
|
|
1234
|
+
version(): number;
|
|
1211
1235
|
}
|
|
1212
1236
|
|
|
1213
1237
|
/**
|
|
@@ -1233,6 +1257,9 @@ export class WasmZcashTransaction {
|
|
|
1233
1257
|
* Returns an error if the bytes cannot be parsed as a valid Zcash transaction
|
|
1234
1258
|
*/
|
|
1235
1259
|
static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
|
|
1260
|
+
get_inputs(): any;
|
|
1261
|
+
get_outputs(): any;
|
|
1262
|
+
get_outputs_with_address(coin: string): any;
|
|
1236
1263
|
/**
|
|
1237
1264
|
* Get the transaction ID (txid)
|
|
1238
1265
|
*
|
|
@@ -1246,6 +1273,9 @@ export class WasmZcashTransaction {
|
|
|
1246
1273
|
* Returns an error if the transaction cannot be serialized
|
|
1247
1274
|
*/
|
|
1248
1275
|
get_txid(): string;
|
|
1276
|
+
input_count(): number;
|
|
1277
|
+
lock_time(): number;
|
|
1278
|
+
output_count(): number;
|
|
1249
1279
|
/**
|
|
1250
1280
|
* Serialize the transaction to bytes
|
|
1251
1281
|
*
|
|
@@ -1253,6 +1283,7 @@ export class WasmZcashTransaction {
|
|
|
1253
1283
|
* The serialized transaction bytes
|
|
1254
1284
|
*/
|
|
1255
1285
|
to_bytes(): Uint8Array;
|
|
1286
|
+
version(): number;
|
|
1256
1287
|
}
|
|
1257
1288
|
|
|
1258
1289
|
export class WrapDescriptor {
|