@bitgo/wasm-utxo 4.0.2 → 4.2.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/dist/cjs/js/descriptorWallet/Psbt.d.ts +3 -15
- package/dist/cjs/js/descriptorWallet/Psbt.js +3 -41
- package/dist/cjs/js/fixedScriptWallet/BitGoKeySubtype.d.ts +37 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoKeySubtype.js +5 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +7 -52
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +4 -75
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/cjs/js/fixedScriptWallet/index.js +3 -1
- package/dist/cjs/js/index.d.ts +5 -0
- package/dist/cjs/js/index.js +8 -3
- package/dist/cjs/js/psbt.d.ts +7 -0
- package/dist/cjs/js/psbtBase.d.ts +44 -0
- package/dist/cjs/js/psbtBase.js +62 -0
- package/dist/cjs/js/transaction.d.ts +6 -58
- package/dist/cjs/js/transaction.js +10 -117
- package/dist/cjs/js/transactionBase.d.ts +28 -0
- package/dist/cjs/js/transactionBase.js +37 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +31 -4
- package/dist/cjs/js/wasm/wasm_utxo.js +333 -13
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +148 -133
- package/dist/esm/js/descriptorWallet/Psbt.d.ts +3 -15
- package/dist/esm/js/descriptorWallet/Psbt.js +3 -41
- package/dist/esm/js/fixedScriptWallet/BitGoKeySubtype.d.ts +37 -0
- package/dist/esm/js/fixedScriptWallet/BitGoKeySubtype.js +2 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +7 -52
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +4 -75
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/esm/js/fixedScriptWallet/index.js +1 -0
- package/dist/esm/js/index.d.ts +5 -0
- package/dist/esm/js/index.js +4 -0
- package/dist/esm/js/psbt.d.ts +7 -0
- package/dist/esm/js/psbtBase.d.ts +44 -0
- package/dist/esm/js/psbtBase.js +58 -0
- package/dist/esm/js/transaction.d.ts +6 -58
- package/dist/esm/js/transaction.js +11 -118
- package/dist/esm/js/transactionBase.d.ts +28 -0
- package/dist/esm/js/transactionBase.js +33 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +31 -4
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +332 -13
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +148 -133
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BitGoPsbt as WasmBitGoPsbt, FixedScriptWalletNamespace, } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { PsbtBase } from "../psbtBase.js";
|
|
2
3
|
import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
3
4
|
import { ReplayProtection } from "./ReplayProtection.js";
|
|
4
5
|
import { BIP32, isBIP32Arg } from "../bip32.js";
|
|
5
6
|
import { ECPair } from "../ecpair.js";
|
|
6
7
|
import { Transaction, DashTransaction, ZcashTransaction, } from "../transaction.js";
|
|
7
|
-
export class BitGoPsbt {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this._wasm = _wasm;
|
|
8
|
+
export class BitGoPsbt extends PsbtBase {
|
|
9
|
+
constructor(wasm) {
|
|
10
|
+
super(wasm);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Get the underlying WASM instance
|
|
@@ -230,29 +230,6 @@ export class BitGoPsbt {
|
|
|
230
230
|
const ecpair = ECPair.from(key);
|
|
231
231
|
return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
|
|
232
232
|
}
|
|
233
|
-
removeInput(index) {
|
|
234
|
-
this._wasm.remove_input(index);
|
|
235
|
-
}
|
|
236
|
-
removeOutput(index) {
|
|
237
|
-
this._wasm.remove_output(index);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Get the unsigned transaction ID
|
|
241
|
-
* @returns The unsigned transaction ID
|
|
242
|
-
*/
|
|
243
|
-
unsignedTxId() {
|
|
244
|
-
return this._wasm.unsigned_txid();
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Get the transaction version
|
|
248
|
-
* @returns The transaction version number
|
|
249
|
-
*/
|
|
250
|
-
version() {
|
|
251
|
-
return this._wasm.version();
|
|
252
|
-
}
|
|
253
|
-
lockTime() {
|
|
254
|
-
return this._wasm.lock_time();
|
|
255
|
-
}
|
|
256
233
|
/**
|
|
257
234
|
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
258
235
|
* @param walletKeys - The wallet keys to use for identification
|
|
@@ -446,14 +423,6 @@ export class BitGoPsbt {
|
|
|
446
423
|
const rp = ReplayProtection.from(replayProtection, this._wasm.network());
|
|
447
424
|
return this._wasm.verify_replay_protection_signature(inputIndex, rp.wasm);
|
|
448
425
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Serialize the PSBT to bytes
|
|
451
|
-
*
|
|
452
|
-
* @returns The serialized PSBT as a byte array
|
|
453
|
-
*/
|
|
454
|
-
serialize() {
|
|
455
|
-
return this._wasm.serialize();
|
|
456
|
-
}
|
|
457
426
|
/**
|
|
458
427
|
* Generate and store MuSig2 nonces for all MuSig2 inputs
|
|
459
428
|
*
|
|
@@ -572,39 +541,6 @@ export class BitGoPsbt {
|
|
|
572
541
|
getHalfSignedLegacyFormat() {
|
|
573
542
|
return this._wasm.extract_half_signed_legacy_tx();
|
|
574
543
|
}
|
|
575
|
-
/**
|
|
576
|
-
* Get the number of inputs in the PSBT
|
|
577
|
-
* @returns The number of inputs
|
|
578
|
-
*/
|
|
579
|
-
inputCount() {
|
|
580
|
-
return this._wasm.input_count();
|
|
581
|
-
}
|
|
582
|
-
outputCount() {
|
|
583
|
-
return this._wasm.output_count();
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Get all PSBT inputs as an array
|
|
587
|
-
*
|
|
588
|
-
* Returns raw PSBT input data including witness_utxo and derivation info.
|
|
589
|
-
* For parsed transaction data with address identification, use
|
|
590
|
-
* parseTransactionWithWalletKeys() instead.
|
|
591
|
-
*
|
|
592
|
-
* @returns Array of PsbtInputData objects
|
|
593
|
-
*/
|
|
594
|
-
getInputs() {
|
|
595
|
-
return this._wasm.get_inputs();
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Get all PSBT outputs as an array
|
|
599
|
-
*
|
|
600
|
-
* Returns raw PSBT output data without address resolution.
|
|
601
|
-
* For output data with addresses, use getOutputsWithAddress().
|
|
602
|
-
*
|
|
603
|
-
* @returns Array of PsbtOutputData objects
|
|
604
|
-
*/
|
|
605
|
-
getOutputs() {
|
|
606
|
-
return this._wasm.get_outputs();
|
|
607
|
-
}
|
|
608
544
|
/**
|
|
609
545
|
* Get all PSBT outputs with resolved address strings
|
|
610
546
|
*
|
|
@@ -624,13 +560,6 @@ export class BitGoPsbt {
|
|
|
624
560
|
getOutputsWithAddress() {
|
|
625
561
|
return this._wasm.get_outputs_with_address();
|
|
626
562
|
}
|
|
627
|
-
/**
|
|
628
|
-
* Returns the unordered global xpubs from this PSBT as BIP32 instances.
|
|
629
|
-
*/
|
|
630
|
-
getGlobalXpubs() {
|
|
631
|
-
const result = this._wasm.get_global_xpubs();
|
|
632
|
-
return result.map((w) => BIP32.fromWasm(w));
|
|
633
|
-
}
|
|
634
563
|
}
|
|
635
564
|
/**
|
|
636
565
|
* Extract sorted wallet keys from a PSBT's global xpub fields.
|
|
@@ -6,8 +6,8 @@ export { Dimensions } from "./Dimensions.js";
|
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, type OutputScriptType, type InputScriptType, type ScriptType, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js";
|
|
8
8
|
export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
|
|
9
|
+
export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
|
|
9
10
|
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
10
|
-
export type { PsbtBip32Derivation, PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress, PsbtWitnessUtxo, } from "../wasm/wasm_utxo.js";
|
|
11
11
|
import type { ScriptType } from "./scriptType.js";
|
|
12
12
|
/**
|
|
13
13
|
* Check if a network supports a given fixed-script wallet script type
|
|
@@ -7,6 +7,7 @@ export { outputScriptTypes, inputScriptTypes, } from "./scriptType.js";
|
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode } from "./chains.js";
|
|
8
8
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
9
9
|
export { BitGoPsbt, getWalletKeysFromPsbt, } from "./BitGoPsbt.js";
|
|
10
|
+
export { BitGoKeySubtype } from "./BitGoKeySubtype.js";
|
|
10
11
|
// Zcash-specific PSBT subclass
|
|
11
12
|
export { ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
|
|
12
13
|
/**
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export * as ecpair from "./ecpair.js";
|
|
|
11
11
|
export { ECPair } from "./ecpair.js";
|
|
12
12
|
export { BIP32 } from "./bip32.js";
|
|
13
13
|
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
14
|
+
export type WasmUtxoVersionInfo = {
|
|
15
|
+
version: string;
|
|
16
|
+
gitHash: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function getWasmUtxoVersion(): WasmUtxoVersionInfo;
|
|
14
19
|
export { type CoinName, getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
15
20
|
export type { Triple } from "./triple.js";
|
|
16
21
|
export type { AddressFormat } from "./address.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as wasm from "./wasm/wasm_utxo.js";
|
|
2
|
+
import { WasmUtxoNamespace } from "./wasm/wasm_utxo.js";
|
|
2
3
|
// we need to access the wasm module here, otherwise webpack gets all weird
|
|
3
4
|
// and forgets to include it in the bundle
|
|
4
5
|
void wasm;
|
|
@@ -18,6 +19,9 @@ export * as ecpair from "./ecpair.js";
|
|
|
18
19
|
export { ECPair } from "./ecpair.js";
|
|
19
20
|
export { BIP32 } from "./bip32.js";
|
|
20
21
|
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
22
|
+
export function getWasmUtxoVersion() {
|
|
23
|
+
return WasmUtxoNamespace.get_wasm_utxo_version();
|
|
24
|
+
}
|
|
21
25
|
export { getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
22
26
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
23
27
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
package/dist/esm/js/psbt.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
2
|
import type { BIP32 } from "./bip32.js";
|
|
3
3
|
import type { ITransactionCommon } from "./transaction.js";
|
|
4
|
+
import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
|
|
4
5
|
/** Common interface for PSBT types */
|
|
5
6
|
export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
|
|
6
7
|
getGlobalXpubs(): BIP32[];
|
|
@@ -9,6 +10,12 @@ export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData>
|
|
|
9
10
|
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
10
11
|
removeInput(index: number): void;
|
|
11
12
|
removeOutput(index: number): void;
|
|
13
|
+
setKV(key: PsbtKvKey, value: Uint8Array): void;
|
|
14
|
+
getKV(key: PsbtKvKey): Uint8Array | undefined;
|
|
15
|
+
setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
16
|
+
getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
17
|
+
setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
18
|
+
getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
12
19
|
}
|
|
13
20
|
/** Extended PSBT with address resolution (no coin parameter needed) */
|
|
14
21
|
export interface IPsbtWithAddress extends IPsbt {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PsbtInputData, PsbtOutputData } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import { BIP32 } from "./bip32.js";
|
|
3
|
+
import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
|
|
4
|
+
interface WasmPsbtBase {
|
|
5
|
+
input_count(): number;
|
|
6
|
+
output_count(): number;
|
|
7
|
+
version(): number;
|
|
8
|
+
lock_time(): number;
|
|
9
|
+
unsigned_tx_id(): string;
|
|
10
|
+
serialize(): Uint8Array;
|
|
11
|
+
get_inputs(): unknown;
|
|
12
|
+
get_outputs(): unknown;
|
|
13
|
+
get_global_xpubs(): unknown;
|
|
14
|
+
remove_input(index: number): void;
|
|
15
|
+
remove_output(index: number): void;
|
|
16
|
+
set_kv(key: unknown, value: Uint8Array): void;
|
|
17
|
+
get_kv(key: unknown): Uint8Array | null | undefined;
|
|
18
|
+
set_input_kv(index: number, key: unknown, value: Uint8Array): void;
|
|
19
|
+
get_input_kv(index: number, key: unknown): Uint8Array | null | undefined;
|
|
20
|
+
set_output_kv(index: number, key: unknown, value: Uint8Array): void;
|
|
21
|
+
get_output_kv(index: number, key: unknown): Uint8Array | null | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare abstract class PsbtBase<W extends WasmPsbtBase> {
|
|
24
|
+
protected _wasm: W;
|
|
25
|
+
constructor(wasm: W);
|
|
26
|
+
inputCount(): number;
|
|
27
|
+
outputCount(): number;
|
|
28
|
+
version(): number;
|
|
29
|
+
lockTime(): number;
|
|
30
|
+
unsignedTxId(): string;
|
|
31
|
+
serialize(): Uint8Array;
|
|
32
|
+
getInputs(): PsbtInputData[];
|
|
33
|
+
getOutputs(): PsbtOutputData[];
|
|
34
|
+
getGlobalXpubs(): BIP32[];
|
|
35
|
+
removeInput(index: number): void;
|
|
36
|
+
removeOutput(index: number): void;
|
|
37
|
+
setKV(key: PsbtKvKey, value: Uint8Array): void;
|
|
38
|
+
getKV(key: PsbtKvKey): Uint8Array | undefined;
|
|
39
|
+
setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
40
|
+
getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
41
|
+
setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
42
|
+
getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BIP32 } from "./bip32.js";
|
|
2
|
+
export class PsbtBase {
|
|
3
|
+
_wasm;
|
|
4
|
+
constructor(wasm) {
|
|
5
|
+
this._wasm = wasm;
|
|
6
|
+
}
|
|
7
|
+
inputCount() {
|
|
8
|
+
return this._wasm.input_count();
|
|
9
|
+
}
|
|
10
|
+
outputCount() {
|
|
11
|
+
return this._wasm.output_count();
|
|
12
|
+
}
|
|
13
|
+
version() {
|
|
14
|
+
return this._wasm.version();
|
|
15
|
+
}
|
|
16
|
+
lockTime() {
|
|
17
|
+
return this._wasm.lock_time();
|
|
18
|
+
}
|
|
19
|
+
unsignedTxId() {
|
|
20
|
+
return this._wasm.unsigned_tx_id();
|
|
21
|
+
}
|
|
22
|
+
serialize() {
|
|
23
|
+
return this._wasm.serialize();
|
|
24
|
+
}
|
|
25
|
+
getInputs() {
|
|
26
|
+
return this._wasm.get_inputs();
|
|
27
|
+
}
|
|
28
|
+
getOutputs() {
|
|
29
|
+
return this._wasm.get_outputs();
|
|
30
|
+
}
|
|
31
|
+
getGlobalXpubs() {
|
|
32
|
+
return this._wasm.get_global_xpubs().map((w) => BIP32.fromWasm(w));
|
|
33
|
+
}
|
|
34
|
+
removeInput(index) {
|
|
35
|
+
this._wasm.remove_input(index);
|
|
36
|
+
}
|
|
37
|
+
removeOutput(index) {
|
|
38
|
+
this._wasm.remove_output(index);
|
|
39
|
+
}
|
|
40
|
+
setKV(key, value) {
|
|
41
|
+
this._wasm.set_kv(key, value);
|
|
42
|
+
}
|
|
43
|
+
getKV(key) {
|
|
44
|
+
return this._wasm.get_kv(key) ?? undefined;
|
|
45
|
+
}
|
|
46
|
+
setInputKV(index, key, value) {
|
|
47
|
+
this._wasm.set_input_kv(index, key, value);
|
|
48
|
+
}
|
|
49
|
+
getInputKV(index, key) {
|
|
50
|
+
return this._wasm.get_input_kv(index, key) ?? undefined;
|
|
51
|
+
}
|
|
52
|
+
setOutputKV(index, key, value) {
|
|
53
|
+
this._wasm.set_output_kv(index, key, value);
|
|
54
|
+
}
|
|
55
|
+
getOutputKV(index, key) {
|
|
56
|
+
return this._wasm.get_output_kv(index, key) ?? undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction
|
|
1
|
+
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import type { TxInputData, TxOutputData, TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
3
|
import type { CoinName } from "./coinName.js";
|
|
4
|
+
import { TransactionBase } from "./transactionBase.js";
|
|
3
5
|
/** Common read-only interface shared by transactions and PSBTs */
|
|
4
6
|
export interface ITransactionCommon<TInput, TOutput> {
|
|
5
7
|
inputCount(): number;
|
|
@@ -20,8 +22,7 @@ export interface ITransaction extends ITransactionCommon<TxInputData, TxOutputDa
|
|
|
20
22
|
*
|
|
21
23
|
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
22
24
|
*/
|
|
23
|
-
export declare class Transaction
|
|
24
|
-
private _wasm;
|
|
25
|
+
export declare class Transaction extends TransactionBase<WasmTransaction> {
|
|
25
26
|
private constructor();
|
|
26
27
|
/**
|
|
27
28
|
* Create an empty transaction (version 1, locktime 0)
|
|
@@ -41,16 +42,6 @@ export declare class Transaction implements ITransaction {
|
|
|
41
42
|
addInput(txid: string, vout: number, sequence?: number): number;
|
|
42
43
|
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
43
44
|
addOutput(script: Uint8Array, value: bigint): number;
|
|
44
|
-
toBytes(): Uint8Array;
|
|
45
|
-
/**
|
|
46
|
-
* Get the transaction ID (txid)
|
|
47
|
-
*
|
|
48
|
-
* The txid is the double SHA256 of the transaction bytes (excluding witness
|
|
49
|
-
* data for segwit transactions), displayed in reverse byte order as is standard.
|
|
50
|
-
*
|
|
51
|
-
* @returns The transaction ID as a hex string
|
|
52
|
-
*/
|
|
53
|
-
getId(): string;
|
|
54
45
|
/**
|
|
55
46
|
* Get the virtual size of the transaction
|
|
56
47
|
*
|
|
@@ -59,13 +50,6 @@ export declare class Transaction implements ITransaction {
|
|
|
59
50
|
* @returns The virtual size in virtual bytes (vbytes)
|
|
60
51
|
*/
|
|
61
52
|
getVSize(): number;
|
|
62
|
-
inputCount(): number;
|
|
63
|
-
outputCount(): number;
|
|
64
|
-
version(): number;
|
|
65
|
-
lockTime(): number;
|
|
66
|
-
getInputs(): TxInputData[];
|
|
67
|
-
getOutputs(): TxOutputData[];
|
|
68
|
-
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
69
53
|
/** @internal */
|
|
70
54
|
get wasm(): WasmTransaction;
|
|
71
55
|
}
|
|
@@ -74,29 +58,11 @@ export declare class Transaction implements ITransaction {
|
|
|
74
58
|
*
|
|
75
59
|
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
76
60
|
*/
|
|
77
|
-
export declare class ZcashTransaction
|
|
78
|
-
private _wasm;
|
|
61
|
+
export declare class ZcashTransaction extends TransactionBase<WasmZcashTransaction> {
|
|
79
62
|
private constructor();
|
|
80
63
|
static fromBytes(bytes: Uint8Array): ZcashTransaction;
|
|
81
64
|
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
82
65
|
static fromWasm(wasm: WasmZcashTransaction): ZcashTransaction;
|
|
83
|
-
toBytes(): Uint8Array;
|
|
84
|
-
/**
|
|
85
|
-
* Get the transaction ID (txid)
|
|
86
|
-
*
|
|
87
|
-
* The txid is the double SHA256 of the full Zcash transaction bytes,
|
|
88
|
-
* displayed in reverse byte order as is standard.
|
|
89
|
-
*
|
|
90
|
-
* @returns The transaction ID as a hex string
|
|
91
|
-
*/
|
|
92
|
-
getId(): string;
|
|
93
|
-
inputCount(): number;
|
|
94
|
-
outputCount(): number;
|
|
95
|
-
version(): number;
|
|
96
|
-
lockTime(): number;
|
|
97
|
-
getInputs(): TxInputData[];
|
|
98
|
-
getOutputs(): TxOutputData[];
|
|
99
|
-
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
100
66
|
/** @internal */
|
|
101
67
|
get wasm(): WasmZcashTransaction;
|
|
102
68
|
}
|
|
@@ -105,29 +71,11 @@ export declare class ZcashTransaction implements ITransaction {
|
|
|
105
71
|
*
|
|
106
72
|
* Round-trip only: bytes -> parse -> bytes.
|
|
107
73
|
*/
|
|
108
|
-
export declare class DashTransaction
|
|
109
|
-
private _wasm;
|
|
74
|
+
export declare class DashTransaction extends TransactionBase<WasmDashTransaction> {
|
|
110
75
|
private constructor();
|
|
111
76
|
static fromBytes(bytes: Uint8Array): DashTransaction;
|
|
112
77
|
/** @internal Create from WASM instance directly (avoids re-parsing bytes) */
|
|
113
78
|
static fromWasm(wasm: WasmDashTransaction): DashTransaction;
|
|
114
|
-
toBytes(): Uint8Array;
|
|
115
|
-
/**
|
|
116
|
-
* Get the transaction ID (txid)
|
|
117
|
-
*
|
|
118
|
-
* The txid is the double SHA256 of the full Dash transaction bytes,
|
|
119
|
-
* displayed in reverse byte order as is standard.
|
|
120
|
-
*
|
|
121
|
-
* @returns The transaction ID as a hex string
|
|
122
|
-
*/
|
|
123
|
-
getId(): string;
|
|
124
|
-
inputCount(): number;
|
|
125
|
-
outputCount(): number;
|
|
126
|
-
version(): number;
|
|
127
|
-
lockTime(): number;
|
|
128
|
-
getInputs(): TxInputData[];
|
|
129
|
-
getOutputs(): TxOutputData[];
|
|
130
|
-
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
131
79
|
/** @internal */
|
|
132
80
|
get wasm(): WasmDashTransaction;
|
|
133
81
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction
|
|
1
|
+
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import { TransactionBase } from "./transactionBase.js";
|
|
2
3
|
/**
|
|
3
4
|
* Transaction wrapper (Bitcoin-like networks)
|
|
4
5
|
*
|
|
5
6
|
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
6
7
|
*/
|
|
7
|
-
export class Transaction {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this._wasm = _wasm;
|
|
8
|
+
export class Transaction extends TransactionBase {
|
|
9
|
+
constructor(wasm) {
|
|
10
|
+
super(wasm);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Create an empty transaction (version 1, locktime 0)
|
|
@@ -41,20 +41,6 @@ export class Transaction {
|
|
|
41
41
|
addOutput(script, value) {
|
|
42
42
|
return this._wasm.add_output(script, value);
|
|
43
43
|
}
|
|
44
|
-
toBytes() {
|
|
45
|
-
return this._wasm.to_bytes();
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the transaction ID (txid)
|
|
49
|
-
*
|
|
50
|
-
* The txid is the double SHA256 of the transaction bytes (excluding witness
|
|
51
|
-
* data for segwit transactions), displayed in reverse byte order as is standard.
|
|
52
|
-
*
|
|
53
|
-
* @returns The transaction ID as a hex string
|
|
54
|
-
*/
|
|
55
|
-
getId() {
|
|
56
|
-
return this._wasm.get_txid();
|
|
57
|
-
}
|
|
58
44
|
/**
|
|
59
45
|
* Get the virtual size of the transaction
|
|
60
46
|
*
|
|
@@ -65,27 +51,6 @@ export class Transaction {
|
|
|
65
51
|
getVSize() {
|
|
66
52
|
return this._wasm.get_vsize();
|
|
67
53
|
}
|
|
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
54
|
/** @internal */
|
|
90
55
|
get wasm() {
|
|
91
56
|
return this._wasm;
|
|
@@ -96,10 +61,9 @@ export class Transaction {
|
|
|
96
61
|
*
|
|
97
62
|
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
98
63
|
*/
|
|
99
|
-
export class ZcashTransaction {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this._wasm = _wasm;
|
|
64
|
+
export class ZcashTransaction extends TransactionBase {
|
|
65
|
+
constructor(wasm) {
|
|
66
|
+
super(wasm);
|
|
103
67
|
}
|
|
104
68
|
static fromBytes(bytes) {
|
|
105
69
|
return new ZcashTransaction(WasmZcashTransaction.from_bytes(bytes));
|
|
@@ -108,41 +72,6 @@ export class ZcashTransaction {
|
|
|
108
72
|
static fromWasm(wasm) {
|
|
109
73
|
return new ZcashTransaction(wasm);
|
|
110
74
|
}
|
|
111
|
-
toBytes() {
|
|
112
|
-
return this._wasm.to_bytes();
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the transaction ID (txid)
|
|
116
|
-
*
|
|
117
|
-
* The txid is the double SHA256 of the full Zcash transaction bytes,
|
|
118
|
-
* displayed in reverse byte order as is standard.
|
|
119
|
-
*
|
|
120
|
-
* @returns The transaction ID as a hex string
|
|
121
|
-
*/
|
|
122
|
-
getId() {
|
|
123
|
-
return this._wasm.get_txid();
|
|
124
|
-
}
|
|
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
75
|
/** @internal */
|
|
147
76
|
get wasm() {
|
|
148
77
|
return this._wasm;
|
|
@@ -153,10 +82,9 @@ export class ZcashTransaction {
|
|
|
153
82
|
*
|
|
154
83
|
* Round-trip only: bytes -> parse -> bytes.
|
|
155
84
|
*/
|
|
156
|
-
export class DashTransaction {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this._wasm = _wasm;
|
|
85
|
+
export class DashTransaction extends TransactionBase {
|
|
86
|
+
constructor(wasm) {
|
|
87
|
+
super(wasm);
|
|
160
88
|
}
|
|
161
89
|
static fromBytes(bytes) {
|
|
162
90
|
return new DashTransaction(WasmDashTransaction.from_bytes(bytes));
|
|
@@ -165,41 +93,6 @@ export class DashTransaction {
|
|
|
165
93
|
static fromWasm(wasm) {
|
|
166
94
|
return new DashTransaction(wasm);
|
|
167
95
|
}
|
|
168
|
-
toBytes() {
|
|
169
|
-
return this._wasm.to_bytes();
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get the transaction ID (txid)
|
|
173
|
-
*
|
|
174
|
-
* The txid is the double SHA256 of the full Dash transaction bytes,
|
|
175
|
-
* displayed in reverse byte order as is standard.
|
|
176
|
-
*
|
|
177
|
-
* @returns The transaction ID as a hex string
|
|
178
|
-
*/
|
|
179
|
-
getId() {
|
|
180
|
-
return this._wasm.get_txid();
|
|
181
|
-
}
|
|
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
96
|
/** @internal */
|
|
204
97
|
get wasm() {
|
|
205
98
|
return this._wasm;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TxInputData, TxOutputData, TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import type { CoinName } from "./coinName.js";
|
|
3
|
+
import type { ITransaction } from "./transaction.js";
|
|
4
|
+
interface WasmTransactionLike {
|
|
5
|
+
input_count(): number;
|
|
6
|
+
output_count(): number;
|
|
7
|
+
version(): number;
|
|
8
|
+
lock_time(): number;
|
|
9
|
+
to_bytes(): Uint8Array;
|
|
10
|
+
get_txid(): string;
|
|
11
|
+
get_inputs(): unknown;
|
|
12
|
+
get_outputs(): unknown;
|
|
13
|
+
get_outputs_with_address(coin: string): unknown;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class TransactionBase<W extends WasmTransactionLike> implements ITransaction {
|
|
16
|
+
protected _wasm: W;
|
|
17
|
+
constructor(wasm: W);
|
|
18
|
+
inputCount(): number;
|
|
19
|
+
outputCount(): number;
|
|
20
|
+
version(): number;
|
|
21
|
+
lockTime(): number;
|
|
22
|
+
toBytes(): Uint8Array;
|
|
23
|
+
getId(): string;
|
|
24
|
+
getInputs(): TxInputData[];
|
|
25
|
+
getOutputs(): TxOutputData[];
|
|
26
|
+
getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class TransactionBase {
|
|
2
|
+
_wasm;
|
|
3
|
+
constructor(wasm) {
|
|
4
|
+
this._wasm = wasm;
|
|
5
|
+
}
|
|
6
|
+
inputCount() {
|
|
7
|
+
return this._wasm.input_count();
|
|
8
|
+
}
|
|
9
|
+
outputCount() {
|
|
10
|
+
return this._wasm.output_count();
|
|
11
|
+
}
|
|
12
|
+
version() {
|
|
13
|
+
return this._wasm.version();
|
|
14
|
+
}
|
|
15
|
+
lockTime() {
|
|
16
|
+
return this._wasm.lock_time();
|
|
17
|
+
}
|
|
18
|
+
toBytes() {
|
|
19
|
+
return this._wasm.to_bytes();
|
|
20
|
+
}
|
|
21
|
+
getId() {
|
|
22
|
+
return this._wasm.get_txid();
|
|
23
|
+
}
|
|
24
|
+
getInputs() {
|
|
25
|
+
return this._wasm.get_inputs();
|
|
26
|
+
}
|
|
27
|
+
getOutputs() {
|
|
28
|
+
return this._wasm.get_outputs();
|
|
29
|
+
}
|
|
30
|
+
getOutputsWithAddress(coin) {
|
|
31
|
+
return this._wasm.get_outputs_with_address(coin);
|
|
32
|
+
}
|
|
33
|
+
}
|