@bitgo/wasm-utxo 1.17.0 → 1.19.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/fixedScriptWallet/BitGoPsbt.d.ts +7 -2
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +35 -28
- package/dist/cjs/js/fixedScriptWallet/Dimensions.d.ts +65 -0
- package/dist/cjs/js/fixedScriptWallet/Dimensions.js +83 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +3 -1
- package/dist/cjs/js/index.d.ts +1 -0
- package/dist/cjs/js/index.js +3 -1
- package/dist/cjs/js/transaction.d.ts +8 -0
- package/dist/cjs/js/transaction.js +10 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +72 -1
- package/dist/cjs/js/wasm/wasm_utxo.js +194 -1
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +43 -32
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +7 -2
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +35 -28
- package/dist/esm/js/fixedScriptWallet/Dimensions.d.ts +65 -0
- package/dist/esm/js/fixedScriptWallet/Dimensions.js +79 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/esm/js/fixedScriptWallet/index.js +1 -0
- package/dist/esm/js/index.d.ts +1 -0
- package/dist/esm/js/index.js +1 -0
- package/dist/esm/js/transaction.d.ts +8 -0
- package/dist/esm/js/transaction.js +10 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +72 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +193 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +43 -32
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { WasmDimensions } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { toOutputScriptWithCoin } from "../address.js";
|
|
3
|
+
/**
|
|
4
|
+
* Dimensions class for estimating transaction virtual size.
|
|
5
|
+
*
|
|
6
|
+
* Tracks weight internally with min/max bounds to handle ECDSA signature variance.
|
|
7
|
+
* Schnorr signatures have no variance (always 64 bytes).
|
|
8
|
+
*
|
|
9
|
+
* This is a thin wrapper over the WASM implementation.
|
|
10
|
+
*/
|
|
11
|
+
export class Dimensions {
|
|
12
|
+
_wasm;
|
|
13
|
+
constructor(_wasm) {
|
|
14
|
+
this._wasm = _wasm;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create empty dimensions (zero weight)
|
|
18
|
+
*/
|
|
19
|
+
static empty() {
|
|
20
|
+
return new Dimensions(WasmDimensions.empty());
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create dimensions from a BitGoPsbt
|
|
24
|
+
*
|
|
25
|
+
* Parses PSBT inputs and outputs to compute weight bounds without
|
|
26
|
+
* requiring wallet keys. Input types are detected from BIP32 derivation
|
|
27
|
+
* paths stored in the PSBT.
|
|
28
|
+
*/
|
|
29
|
+
static fromPsbt(psbt) {
|
|
30
|
+
return new Dimensions(WasmDimensions.from_psbt(psbt.wasm));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create dimensions for a single input
|
|
34
|
+
*
|
|
35
|
+
* @param params - Either `{ chain, signPath? }` or `{ scriptType }`
|
|
36
|
+
*/
|
|
37
|
+
static fromInput(params) {
|
|
38
|
+
if ("scriptType" in params) {
|
|
39
|
+
return new Dimensions(WasmDimensions.from_input_script_type(params.scriptType));
|
|
40
|
+
}
|
|
41
|
+
return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
|
|
42
|
+
}
|
|
43
|
+
static fromOutput(scriptOrAddress, network) {
|
|
44
|
+
if (typeof scriptOrAddress === "string") {
|
|
45
|
+
if (network === undefined) {
|
|
46
|
+
throw new Error("network is required when passing an address string");
|
|
47
|
+
}
|
|
48
|
+
const script = toOutputScriptWithCoin(scriptOrAddress, network);
|
|
49
|
+
return new Dimensions(WasmDimensions.from_output_script(script));
|
|
50
|
+
}
|
|
51
|
+
return new Dimensions(WasmDimensions.from_output_script(scriptOrAddress));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Combine with another Dimensions instance
|
|
55
|
+
*/
|
|
56
|
+
plus(other) {
|
|
57
|
+
return new Dimensions(this._wasm.plus(other._wasm));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether any inputs are segwit (affects overhead calculation)
|
|
61
|
+
*/
|
|
62
|
+
get hasSegwit() {
|
|
63
|
+
return this._wasm.has_segwit();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get total weight (min or max)
|
|
67
|
+
* @param size - "min" or "max", defaults to "max"
|
|
68
|
+
*/
|
|
69
|
+
getWeight(size = "max") {
|
|
70
|
+
return this._wasm.get_weight(size);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get virtual size (min or max)
|
|
74
|
+
* @param size - "min" or "max", defaults to "max"
|
|
75
|
+
*/
|
|
76
|
+
getVSize(size = "max") {
|
|
77
|
+
return this._wasm.get_vsize(size);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { RootWalletKeys, type WalletKeysArg, type IWalletKeys } from "./RootWalletKeys.js";
|
|
2
2
|
export { ReplayProtection, type ReplayProtectionArg } from "./ReplayProtection.js";
|
|
3
3
|
export { outputScript, address } from "./address.js";
|
|
4
|
+
export { Dimensions } from "./Dimensions.js";
|
|
4
5
|
export { BitGoPsbt, type NetworkName, type ScriptId, type InputScriptType, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, } from "./BitGoPsbt.js";
|
|
5
6
|
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { RootWalletKeys } from "./RootWalletKeys.js";
|
|
2
2
|
export { ReplayProtection } from "./ReplayProtection.js";
|
|
3
3
|
export { outputScript, address } from "./address.js";
|
|
4
|
+
export { Dimensions } from "./Dimensions.js";
|
|
4
5
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
5
6
|
export { BitGoPsbt, } from "./BitGoPsbt.js";
|
|
6
7
|
// Zcash-specific PSBT subclass
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * as bip32 from "./bip32.js";
|
|
|
6
6
|
export * as ecpair from "./ecpair.js";
|
|
7
7
|
export { ECPair } from "./ecpair.js";
|
|
8
8
|
export { BIP32 } from "./bip32.js";
|
|
9
|
+
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
9
10
|
export type { CoinName } from "./coinName.js";
|
|
10
11
|
export type { Triple } from "./triple.js";
|
|
11
12
|
export type { AddressFormat } from "./address.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * as ecpair from "./ecpair.js";
|
|
|
13
13
|
// Only the most commonly used classes and types are exported at the top level for convenience
|
|
14
14
|
export { ECPair } from "./ecpair.js";
|
|
15
15
|
export { BIP32 } from "./bip32.js";
|
|
16
|
+
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
16
17
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
17
18
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
18
19
|
export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
|
|
@@ -9,6 +9,14 @@ export declare class Transaction {
|
|
|
9
9
|
private constructor();
|
|
10
10
|
static fromBytes(bytes: Uint8Array): Transaction;
|
|
11
11
|
toBytes(): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Get the virtual size of the transaction
|
|
14
|
+
*
|
|
15
|
+
* Virtual size accounts for the segwit discount on witness data.
|
|
16
|
+
*
|
|
17
|
+
* @returns The virtual size in virtual bytes (vbytes)
|
|
18
|
+
*/
|
|
19
|
+
getVSize(): number;
|
|
12
20
|
/**
|
|
13
21
|
* @internal
|
|
14
22
|
*/
|
|
@@ -15,6 +15,16 @@ export class Transaction {
|
|
|
15
15
|
toBytes() {
|
|
16
16
|
return this._wasm.to_bytes();
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the virtual size of the transaction
|
|
20
|
+
*
|
|
21
|
+
* Virtual size accounts for the segwit discount on witness data.
|
|
22
|
+
*
|
|
23
|
+
* @returns The virtual size in virtual bytes (vbytes)
|
|
24
|
+
*/
|
|
25
|
+
getVSize() {
|
|
26
|
+
return this._wasm.get_vsize();
|
|
27
|
+
}
|
|
18
28
|
/**
|
|
19
29
|
* @internal
|
|
20
30
|
*/
|
|
@@ -148,7 +148,7 @@ export class BitGoPsbt {
|
|
|
148
148
|
* Extract the final transaction from a finalized PSBT
|
|
149
149
|
*
|
|
150
150
|
* This method should be called after all inputs have been finalized.
|
|
151
|
-
* It extracts the fully signed transaction.
|
|
151
|
+
* It extracts the fully signed transaction with network-appropriate serialization.
|
|
152
152
|
*
|
|
153
153
|
* # Returns
|
|
154
154
|
* - `Ok(Vec<u8>)` containing the serialized transaction bytes
|
|
@@ -502,6 +502,67 @@ export class WasmDashTransaction {
|
|
|
502
502
|
to_bytes(): Uint8Array;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
+
export class WasmDimensions {
|
|
506
|
+
private constructor();
|
|
507
|
+
free(): void;
|
|
508
|
+
[Symbol.dispose](): void;
|
|
509
|
+
/**
|
|
510
|
+
* Create dimensions for a single input from chain code
|
|
511
|
+
*
|
|
512
|
+
* # Arguments
|
|
513
|
+
* * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
|
|
514
|
+
* * `signer` - Optional signer key ("user", "backup", "bitgo")
|
|
515
|
+
* * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
|
|
516
|
+
*/
|
|
517
|
+
static from_input(chain: number, signer?: string | null, cosigner?: string | null): WasmDimensions;
|
|
518
|
+
/**
|
|
519
|
+
* Get total weight (min or max)
|
|
520
|
+
*
|
|
521
|
+
* # Arguments
|
|
522
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
523
|
+
*/
|
|
524
|
+
get_weight(size?: string | null): number;
|
|
525
|
+
/**
|
|
526
|
+
* Whether any inputs are segwit (affects overhead calculation)
|
|
527
|
+
*/
|
|
528
|
+
has_segwit(): boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Create dimensions for a single output from script bytes
|
|
531
|
+
*/
|
|
532
|
+
static from_output_script(script: Uint8Array): WasmDimensions;
|
|
533
|
+
/**
|
|
534
|
+
* Create dimensions for a single input from script type string
|
|
535
|
+
*
|
|
536
|
+
* # Arguments
|
|
537
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
|
|
538
|
+
* "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
|
|
539
|
+
*/
|
|
540
|
+
static from_input_script_type(script_type: string): WasmDimensions;
|
|
541
|
+
/**
|
|
542
|
+
* Combine with another Dimensions instance
|
|
543
|
+
*/
|
|
544
|
+
plus(other: WasmDimensions): WasmDimensions;
|
|
545
|
+
/**
|
|
546
|
+
* Create empty dimensions (zero weight)
|
|
547
|
+
*/
|
|
548
|
+
static empty(): WasmDimensions;
|
|
549
|
+
/**
|
|
550
|
+
* Create dimensions from a BitGoPsbt
|
|
551
|
+
*
|
|
552
|
+
* Parses PSBT inputs and outputs to compute weight bounds without
|
|
553
|
+
* requiring wallet keys. Input types are detected from BIP32 derivation
|
|
554
|
+
* paths stored in the PSBT.
|
|
555
|
+
*/
|
|
556
|
+
static from_psbt(psbt: BitGoPsbt): WasmDimensions;
|
|
557
|
+
/**
|
|
558
|
+
* Get virtual size (min or max)
|
|
559
|
+
*
|
|
560
|
+
* # Arguments
|
|
561
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
562
|
+
*/
|
|
563
|
+
get_vsize(size?: string | null): number;
|
|
564
|
+
}
|
|
565
|
+
|
|
505
566
|
export class WasmECPair {
|
|
506
567
|
private constructor();
|
|
507
568
|
free(): void;
|
|
@@ -629,6 +690,16 @@ export class WasmTransaction {
|
|
|
629
690
|
* The serialized transaction bytes
|
|
630
691
|
*/
|
|
631
692
|
to_bytes(): Uint8Array;
|
|
693
|
+
/**
|
|
694
|
+
* Get the virtual size of the transaction
|
|
695
|
+
*
|
|
696
|
+
* Virtual size is calculated as ceil(weight / 4), where weight accounts
|
|
697
|
+
* for the segwit discount on witness data.
|
|
698
|
+
*
|
|
699
|
+
* # Returns
|
|
700
|
+
* The virtual size in virtual bytes (vbytes)
|
|
701
|
+
*/
|
|
702
|
+
get_vsize(): number;
|
|
632
703
|
}
|
|
633
704
|
|
|
634
705
|
export class WasmZcashTransaction {
|
|
@@ -190,6 +190,10 @@ const WasmDashTransactionFinalization = (typeof FinalizationRegistry === 'undefi
|
|
|
190
190
|
? { register: () => {}, unregister: () => {} }
|
|
191
191
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdashtransaction_free(ptr >>> 0, 1));
|
|
192
192
|
|
|
193
|
+
const WasmDimensionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
194
|
+
? { register: () => {}, unregister: () => {} }
|
|
195
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdimensions_free(ptr >>> 0, 1));
|
|
196
|
+
|
|
193
197
|
const WasmECPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
194
198
|
? { register: () => {}, unregister: () => {} }
|
|
195
199
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmecpair_free(ptr >>> 0, 1));
|
|
@@ -647,7 +651,7 @@ export class BitGoPsbt {
|
|
|
647
651
|
* Extract the final transaction from a finalized PSBT
|
|
648
652
|
*
|
|
649
653
|
* This method should be called after all inputs have been finalized.
|
|
650
|
-
* It extracts the fully signed transaction.
|
|
654
|
+
* It extracts the fully signed transaction with network-appropriate serialization.
|
|
651
655
|
*
|
|
652
656
|
* # Returns
|
|
653
657
|
* - `Ok(Vec<u8>)` containing the serialized transaction bytes
|
|
@@ -1738,6 +1742,180 @@ export class WasmDashTransaction {
|
|
|
1738
1742
|
}
|
|
1739
1743
|
if (Symbol.dispose) WasmDashTransaction.prototype[Symbol.dispose] = WasmDashTransaction.prototype.free;
|
|
1740
1744
|
|
|
1745
|
+
/**
|
|
1746
|
+
* Dimensions for estimating transaction virtual size.
|
|
1747
|
+
*
|
|
1748
|
+
* Tracks weight internally with min/max bounds to handle ECDSA signature variance.
|
|
1749
|
+
* Schnorr signatures have no variance (always 64 bytes).
|
|
1750
|
+
*/
|
|
1751
|
+
export class WasmDimensions {
|
|
1752
|
+
static __wrap(ptr) {
|
|
1753
|
+
ptr = ptr >>> 0;
|
|
1754
|
+
const obj = Object.create(WasmDimensions.prototype);
|
|
1755
|
+
obj.__wbg_ptr = ptr;
|
|
1756
|
+
WasmDimensionsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1757
|
+
return obj;
|
|
1758
|
+
}
|
|
1759
|
+
__destroy_into_raw() {
|
|
1760
|
+
const ptr = this.__wbg_ptr;
|
|
1761
|
+
this.__wbg_ptr = 0;
|
|
1762
|
+
WasmDimensionsFinalization.unregister(this);
|
|
1763
|
+
return ptr;
|
|
1764
|
+
}
|
|
1765
|
+
free() {
|
|
1766
|
+
const ptr = this.__destroy_into_raw();
|
|
1767
|
+
wasm.__wbg_wasmdimensions_free(ptr, 0);
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Create dimensions for a single input from chain code
|
|
1771
|
+
*
|
|
1772
|
+
* # Arguments
|
|
1773
|
+
* * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
|
|
1774
|
+
* * `signer` - Optional signer key ("user", "backup", "bitgo")
|
|
1775
|
+
* * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
|
|
1776
|
+
* @param {number} chain
|
|
1777
|
+
* @param {string | null} [signer]
|
|
1778
|
+
* @param {string | null} [cosigner]
|
|
1779
|
+
* @returns {WasmDimensions}
|
|
1780
|
+
*/
|
|
1781
|
+
static from_input(chain, signer, cosigner) {
|
|
1782
|
+
try {
|
|
1783
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1784
|
+
var ptr0 = isLikeNone(signer) ? 0 : passStringToWasm0(signer, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1785
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1786
|
+
var ptr1 = isLikeNone(cosigner) ? 0 : passStringToWasm0(cosigner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1787
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1788
|
+
wasm.wasmdimensions_from_input(retptr, chain, ptr0, len0, ptr1, len1);
|
|
1789
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1790
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1791
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1792
|
+
if (r2) {
|
|
1793
|
+
throw takeObject(r1);
|
|
1794
|
+
}
|
|
1795
|
+
return WasmDimensions.__wrap(r0);
|
|
1796
|
+
} finally {
|
|
1797
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Get total weight (min or max)
|
|
1802
|
+
*
|
|
1803
|
+
* # Arguments
|
|
1804
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1805
|
+
* @param {string | null} [size]
|
|
1806
|
+
* @returns {number}
|
|
1807
|
+
*/
|
|
1808
|
+
get_weight(size) {
|
|
1809
|
+
var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1810
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1811
|
+
const ret = wasm.wasmdimensions_get_weight(this.__wbg_ptr, ptr0, len0);
|
|
1812
|
+
return ret >>> 0;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Whether any inputs are segwit (affects overhead calculation)
|
|
1816
|
+
* @returns {boolean}
|
|
1817
|
+
*/
|
|
1818
|
+
has_segwit() {
|
|
1819
|
+
const ret = wasm.wasmdimensions_has_segwit(this.__wbg_ptr);
|
|
1820
|
+
return ret !== 0;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Create dimensions for a single output from script bytes
|
|
1824
|
+
* @param {Uint8Array} script
|
|
1825
|
+
* @returns {WasmDimensions}
|
|
1826
|
+
*/
|
|
1827
|
+
static from_output_script(script) {
|
|
1828
|
+
const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
|
|
1829
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1830
|
+
const ret = wasm.wasmdimensions_from_output_script(ptr0, len0);
|
|
1831
|
+
return WasmDimensions.__wrap(ret);
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Create dimensions for a single input from script type string
|
|
1835
|
+
*
|
|
1836
|
+
* # Arguments
|
|
1837
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
|
|
1838
|
+
* "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
|
|
1839
|
+
* @param {string} script_type
|
|
1840
|
+
* @returns {WasmDimensions}
|
|
1841
|
+
*/
|
|
1842
|
+
static from_input_script_type(script_type) {
|
|
1843
|
+
try {
|
|
1844
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1845
|
+
const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1846
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1847
|
+
wasm.wasmdimensions_from_input_script_type(retptr, ptr0, len0);
|
|
1848
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1849
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1850
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1851
|
+
if (r2) {
|
|
1852
|
+
throw takeObject(r1);
|
|
1853
|
+
}
|
|
1854
|
+
return WasmDimensions.__wrap(r0);
|
|
1855
|
+
} finally {
|
|
1856
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Combine with another Dimensions instance
|
|
1861
|
+
* @param {WasmDimensions} other
|
|
1862
|
+
* @returns {WasmDimensions}
|
|
1863
|
+
*/
|
|
1864
|
+
plus(other) {
|
|
1865
|
+
_assertClass(other, WasmDimensions);
|
|
1866
|
+
const ret = wasm.wasmdimensions_plus(this.__wbg_ptr, other.__wbg_ptr);
|
|
1867
|
+
return WasmDimensions.__wrap(ret);
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Create empty dimensions (zero weight)
|
|
1871
|
+
* @returns {WasmDimensions}
|
|
1872
|
+
*/
|
|
1873
|
+
static empty() {
|
|
1874
|
+
const ret = wasm.wasmdimensions_empty();
|
|
1875
|
+
return WasmDimensions.__wrap(ret);
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Create dimensions from a BitGoPsbt
|
|
1879
|
+
*
|
|
1880
|
+
* Parses PSBT inputs and outputs to compute weight bounds without
|
|
1881
|
+
* requiring wallet keys. Input types are detected from BIP32 derivation
|
|
1882
|
+
* paths stored in the PSBT.
|
|
1883
|
+
* @param {BitGoPsbt} psbt
|
|
1884
|
+
* @returns {WasmDimensions}
|
|
1885
|
+
*/
|
|
1886
|
+
static from_psbt(psbt) {
|
|
1887
|
+
try {
|
|
1888
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1889
|
+
_assertClass(psbt, BitGoPsbt);
|
|
1890
|
+
wasm.wasmdimensions_from_psbt(retptr, psbt.__wbg_ptr);
|
|
1891
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1892
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1893
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1894
|
+
if (r2) {
|
|
1895
|
+
throw takeObject(r1);
|
|
1896
|
+
}
|
|
1897
|
+
return WasmDimensions.__wrap(r0);
|
|
1898
|
+
} finally {
|
|
1899
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Get virtual size (min or max)
|
|
1904
|
+
*
|
|
1905
|
+
* # Arguments
|
|
1906
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1907
|
+
* @param {string | null} [size]
|
|
1908
|
+
* @returns {number}
|
|
1909
|
+
*/
|
|
1910
|
+
get_vsize(size) {
|
|
1911
|
+
var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1912
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1913
|
+
const ret = wasm.wasmdimensions_get_vsize(this.__wbg_ptr, ptr0, len0);
|
|
1914
|
+
return ret >>> 0;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
if (Symbol.dispose) WasmDimensions.prototype[Symbol.dispose] = WasmDimensions.prototype.free;
|
|
1918
|
+
|
|
1741
1919
|
/**
|
|
1742
1920
|
* WASM wrapper for elliptic curve key pairs (always uses compressed keys)
|
|
1743
1921
|
*/
|
|
@@ -2258,6 +2436,20 @@ export class WasmTransaction {
|
|
|
2258
2436
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2259
2437
|
}
|
|
2260
2438
|
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Get the virtual size of the transaction
|
|
2441
|
+
*
|
|
2442
|
+
* Virtual size is calculated as ceil(weight / 4), where weight accounts
|
|
2443
|
+
* for the segwit discount on witness data.
|
|
2444
|
+
*
|
|
2445
|
+
* # Returns
|
|
2446
|
+
* The virtual size in virtual bytes (vbytes)
|
|
2447
|
+
* @returns {number}
|
|
2448
|
+
*/
|
|
2449
|
+
get_vsize() {
|
|
2450
|
+
const ret = wasm.wasmtransaction_get_vsize(this.__wbg_ptr);
|
|
2451
|
+
return ret >>> 0;
|
|
2452
|
+
}
|
|
2261
2453
|
}
|
|
2262
2454
|
if (Symbol.dispose) WasmTransaction.prototype[Symbol.dispose] = WasmTransaction.prototype.free;
|
|
2263
2455
|
|
|
Binary file
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
8
|
+
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
4
9
|
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
10
|
+
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
11
|
+
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
12
|
+
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
13
|
+
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
14
|
+
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
|
|
16
|
+
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
17
|
+
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
18
|
+
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
19
|
+
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
20
|
+
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
21
|
+
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
22
|
+
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
23
|
+
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
5
24
|
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
6
25
|
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
7
26
|
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
@@ -13,16 +32,27 @@ export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
|
13
32
|
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
14
33
|
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
15
34
|
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
35
|
+
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
36
|
+
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
37
|
+
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
38
|
+
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
39
|
+
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
40
|
+
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
41
|
+
export const wrappsbt_clone: (a: number) => number;
|
|
42
|
+
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
43
|
+
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
44
|
+
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
45
|
+
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
46
|
+
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
47
|
+
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
48
|
+
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
16
49
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
17
50
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
18
51
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
19
52
|
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
53
|
+
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
20
54
|
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
21
|
-
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
22
55
|
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
23
|
-
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
24
|
-
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
25
|
-
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
26
56
|
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
27
57
|
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
28
58
|
export const bitgopsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number, k: number) => void;
|
|
@@ -75,6 +105,15 @@ export const wasmbip32_private_key: (a: number) => number;
|
|
|
75
105
|
export const wasmbip32_public_key: (a: number) => number;
|
|
76
106
|
export const wasmbip32_to_base58: (a: number, b: number) => void;
|
|
77
107
|
export const wasmbip32_to_wif: (a: number, b: number) => void;
|
|
108
|
+
export const wasmdimensions_empty: () => number;
|
|
109
|
+
export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
110
|
+
export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number) => void;
|
|
111
|
+
export const wasmdimensions_from_output_script: (a: number, b: number) => number;
|
|
112
|
+
export const wasmdimensions_from_psbt: (a: number, b: number) => void;
|
|
113
|
+
export const wasmdimensions_get_vsize: (a: number, b: number, c: number) => number;
|
|
114
|
+
export const wasmdimensions_get_weight: (a: number, b: number, c: number) => number;
|
|
115
|
+
export const wasmdimensions_has_segwit: (a: number) => number;
|
|
116
|
+
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
78
117
|
export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
|
|
79
118
|
export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
|
|
80
119
|
export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
|
|
@@ -85,40 +124,12 @@ export const wasmecpair_public_key: (a: number) => number;
|
|
|
85
124
|
export const wasmecpair_to_wif: (a: number, b: number) => void;
|
|
86
125
|
export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
|
|
87
126
|
export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
88
|
-
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
89
|
-
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
90
|
-
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
91
127
|
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
92
128
|
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
93
129
|
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
94
130
|
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
95
131
|
export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
96
|
-
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
97
|
-
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
98
|
-
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
99
|
-
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
100
|
-
export const wrappsbt_clone: (a: number) => number;
|
|
101
|
-
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
102
|
-
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
103
|
-
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
104
|
-
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
105
|
-
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
106
|
-
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
107
|
-
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
108
132
|
export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
|
|
109
|
-
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
110
|
-
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
111
|
-
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
112
|
-
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
113
|
-
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
114
|
-
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
115
|
-
export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
|
|
116
|
-
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
117
|
-
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
118
|
-
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
119
|
-
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
120
|
-
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
121
|
-
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
122
133
|
export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
123
134
|
export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
124
135
|
export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|