@bitgo/wasm-utxo 1.22.0 → 1.24.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/Dimensions.d.ts +35 -0
- package/dist/cjs/js/fixedScriptWallet/Dimensions.js +41 -5
- package/dist/cjs/js/fixedScriptWallet/chains.d.ts +56 -0
- package/dist/cjs/js/fixedScriptWallet/chains.js +125 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +4 -1
- package/dist/cjs/js/index.d.ts +2 -0
- package/dist/cjs/js/index.js +2 -1
- package/dist/cjs/js/inscriptions.d.ts +84 -0
- package/dist/cjs/js/inscriptions.js +82 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +80 -2
- package/dist/cjs/js/wasm/wasm_utxo.js +204 -8
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +51 -41
- package/dist/esm/js/fixedScriptWallet/Dimensions.d.ts +35 -0
- package/dist/esm/js/fixedScriptWallet/Dimensions.js +41 -5
- package/dist/esm/js/fixedScriptWallet/chains.d.ts +56 -0
- package/dist/esm/js/fixedScriptWallet/chains.js +122 -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 +2 -0
- package/dist/esm/js/index.js +1 -0
- package/dist/esm/js/inscriptions.d.ts +84 -0
- package/dist/esm/js/inscriptions.js +78 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +80 -2
- package/dist/esm/js/wasm/wasm_utxo_bg.js +203 -8
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +51 -41
- package/package.json +1 -1
|
@@ -196,6 +196,10 @@ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry ===
|
|
|
196
196
|
? { register: () => {}, unregister: () => {} }
|
|
197
197
|
: new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
|
|
198
198
|
|
|
199
|
+
const InscriptionsNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
200
|
+
? { register: () => {}, unregister: () => {} }
|
|
201
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_inscriptionsnamespace_free(ptr >>> 0, 1));
|
|
202
|
+
|
|
199
203
|
const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
200
204
|
? { register: () => {}, unregister: () => {} }
|
|
201
205
|
: new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
|
|
@@ -1519,6 +1523,19 @@ class FixedScriptWalletNamespace {
|
|
|
1519
1523
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1520
1524
|
}
|
|
1521
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Get all chain code metadata for building TypeScript lookup tables
|
|
1528
|
+
*
|
|
1529
|
+
* Returns an array of [chainCode, scriptType, scope] tuples where:
|
|
1530
|
+
* - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
|
|
1531
|
+
* - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
|
|
1532
|
+
* - scope: string ("external" or "internal")
|
|
1533
|
+
* @returns {any}
|
|
1534
|
+
*/
|
|
1535
|
+
static chain_code_table() {
|
|
1536
|
+
const ret = wasm.fixedscriptwalletnamespace_chain_code_table();
|
|
1537
|
+
return takeObject(ret);
|
|
1538
|
+
}
|
|
1522
1539
|
/**
|
|
1523
1540
|
* Check if a network supports a given fixed-script wallet script type
|
|
1524
1541
|
*
|
|
@@ -1595,6 +1612,109 @@ class FixedScriptWalletNamespace {
|
|
|
1595
1612
|
if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
|
|
1596
1613
|
exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
|
|
1597
1614
|
|
|
1615
|
+
/**
|
|
1616
|
+
* Namespace for inscription-related functions
|
|
1617
|
+
*/
|
|
1618
|
+
class InscriptionsNamespace {
|
|
1619
|
+
__destroy_into_raw() {
|
|
1620
|
+
const ptr = this.__wbg_ptr;
|
|
1621
|
+
this.__wbg_ptr = 0;
|
|
1622
|
+
InscriptionsNamespaceFinalization.unregister(this);
|
|
1623
|
+
return ptr;
|
|
1624
|
+
}
|
|
1625
|
+
free() {
|
|
1626
|
+
const ptr = this.__destroy_into_raw();
|
|
1627
|
+
wasm.__wbg_inscriptionsnamespace_free(ptr, 0);
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Sign a reveal transaction
|
|
1631
|
+
*
|
|
1632
|
+
* # Arguments
|
|
1633
|
+
* * `private_key` - The private key (32 bytes)
|
|
1634
|
+
* * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
|
|
1635
|
+
* * `commit_tx` - The commit transaction
|
|
1636
|
+
* * `commit_output_script` - The commit output script (P2TR)
|
|
1637
|
+
* * `recipient_output_script` - Where to send the inscription (output script)
|
|
1638
|
+
* * `output_value_sats` - Value in satoshis for the inscription output
|
|
1639
|
+
*
|
|
1640
|
+
* # Returns
|
|
1641
|
+
* The signed PSBT as bytes
|
|
1642
|
+
* @param {Uint8Array} private_key
|
|
1643
|
+
* @param {any} tap_leaf_script
|
|
1644
|
+
* @param {WasmTransaction} commit_tx
|
|
1645
|
+
* @param {Uint8Array} commit_output_script
|
|
1646
|
+
* @param {Uint8Array} recipient_output_script
|
|
1647
|
+
* @param {bigint} output_value_sats
|
|
1648
|
+
* @returns {Uint8Array}
|
|
1649
|
+
*/
|
|
1650
|
+
static sign_reveal_transaction(private_key, tap_leaf_script, commit_tx, commit_output_script, recipient_output_script, output_value_sats) {
|
|
1651
|
+
try {
|
|
1652
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1653
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export);
|
|
1654
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1655
|
+
_assertClass(commit_tx, WasmTransaction);
|
|
1656
|
+
const ptr1 = passArray8ToWasm0(commit_output_script, wasm.__wbindgen_export);
|
|
1657
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1658
|
+
const ptr2 = passArray8ToWasm0(recipient_output_script, wasm.__wbindgen_export);
|
|
1659
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1660
|
+
wasm.inscriptionsnamespace_sign_reveal_transaction(retptr, ptr0, len0, addHeapObject(tap_leaf_script), commit_tx.__wbg_ptr, ptr1, len1, ptr2, len2, output_value_sats);
|
|
1661
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1662
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1663
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1664
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1665
|
+
if (r3) {
|
|
1666
|
+
throw takeObject(r2);
|
|
1667
|
+
}
|
|
1668
|
+
var v4 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1669
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
1670
|
+
return v4;
|
|
1671
|
+
} finally {
|
|
1672
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Create inscription reveal data including the commit output script and tap leaf script
|
|
1677
|
+
*
|
|
1678
|
+
* # Arguments
|
|
1679
|
+
* * `x_only_pubkey` - The x-only public key (32 bytes)
|
|
1680
|
+
* * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
|
|
1681
|
+
* * `inscription_data` - The inscription data bytes
|
|
1682
|
+
*
|
|
1683
|
+
* # Returns
|
|
1684
|
+
* An object containing:
|
|
1685
|
+
* - `output_script`: The commit output script (P2TR, network-agnostic)
|
|
1686
|
+
* - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
|
|
1687
|
+
* - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
|
|
1688
|
+
* @param {Uint8Array} x_only_pubkey
|
|
1689
|
+
* @param {string} content_type
|
|
1690
|
+
* @param {Uint8Array} inscription_data
|
|
1691
|
+
* @returns {any}
|
|
1692
|
+
*/
|
|
1693
|
+
static create_inscription_reveal_data(x_only_pubkey, content_type, inscription_data) {
|
|
1694
|
+
try {
|
|
1695
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1696
|
+
const ptr0 = passArray8ToWasm0(x_only_pubkey, wasm.__wbindgen_export);
|
|
1697
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1698
|
+
const ptr1 = passStringToWasm0(content_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1699
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1700
|
+
const ptr2 = passArray8ToWasm0(inscription_data, wasm.__wbindgen_export);
|
|
1701
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1702
|
+
wasm.inscriptionsnamespace_create_inscription_reveal_data(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1703
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1704
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1705
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1706
|
+
if (r2) {
|
|
1707
|
+
throw takeObject(r1);
|
|
1708
|
+
}
|
|
1709
|
+
return takeObject(r0);
|
|
1710
|
+
} finally {
|
|
1711
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
if (Symbol.dispose) InscriptionsNamespace.prototype[Symbol.dispose] = InscriptionsNamespace.prototype.free;
|
|
1716
|
+
exports.InscriptionsNamespace = InscriptionsNamespace;
|
|
1717
|
+
|
|
1598
1718
|
class UtxolibCompatNamespace {
|
|
1599
1719
|
__destroy_into_raw() {
|
|
1600
1720
|
const ptr = this.__wbg_ptr;
|
|
@@ -2183,15 +2303,48 @@ class WasmDimensions {
|
|
|
2183
2303
|
return ret !== 0;
|
|
2184
2304
|
}
|
|
2185
2305
|
/**
|
|
2186
|
-
*
|
|
2187
|
-
*
|
|
2188
|
-
*
|
|
2306
|
+
* Get input virtual size (min or max)
|
|
2307
|
+
*
|
|
2308
|
+
* # Arguments
|
|
2309
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
2310
|
+
* @param {string | null} [size]
|
|
2311
|
+
* @returns {number}
|
|
2189
2312
|
*/
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
const ret = wasm.
|
|
2194
|
-
return
|
|
2313
|
+
get_input_vsize(size) {
|
|
2314
|
+
var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2315
|
+
var len0 = WASM_VECTOR_LEN;
|
|
2316
|
+
const ret = wasm.wasmdimensions_get_input_vsize(this.__wbg_ptr, ptr0, len0);
|
|
2317
|
+
return ret >>> 0;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* Get input weight only (min or max)
|
|
2321
|
+
*
|
|
2322
|
+
* # Arguments
|
|
2323
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
2324
|
+
* @param {string | null} [size]
|
|
2325
|
+
* @returns {number}
|
|
2326
|
+
*/
|
|
2327
|
+
get_input_weight(size) {
|
|
2328
|
+
var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2329
|
+
var len0 = WASM_VECTOR_LEN;
|
|
2330
|
+
const ret = wasm.wasmdimensions_get_input_weight(this.__wbg_ptr, ptr0, len0);
|
|
2331
|
+
return ret >>> 0;
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Get output virtual size
|
|
2335
|
+
* @returns {number}
|
|
2336
|
+
*/
|
|
2337
|
+
get_output_vsize() {
|
|
2338
|
+
const ret = wasm.wasmdimensions_get_output_vsize(this.__wbg_ptr);
|
|
2339
|
+
return ret >>> 0;
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Get output weight
|
|
2343
|
+
* @returns {number}
|
|
2344
|
+
*/
|
|
2345
|
+
get_output_weight() {
|
|
2346
|
+
const ret = wasm.wasmdimensions_get_output_weight(this.__wbg_ptr);
|
|
2347
|
+
return ret >>> 0;
|
|
2195
2348
|
}
|
|
2196
2349
|
/**
|
|
2197
2350
|
* Create dimensions for a single input from script type string
|
|
@@ -2219,6 +2372,40 @@ class WasmDimensions {
|
|
|
2219
2372
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2220
2373
|
}
|
|
2221
2374
|
}
|
|
2375
|
+
/**
|
|
2376
|
+
* Create dimensions for a single output from script type string
|
|
2377
|
+
*
|
|
2378
|
+
* # Arguments
|
|
2379
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
|
|
2380
|
+
* @param {string} script_type
|
|
2381
|
+
* @returns {WasmDimensions}
|
|
2382
|
+
*/
|
|
2383
|
+
static from_output_script_type(script_type) {
|
|
2384
|
+
try {
|
|
2385
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2386
|
+
const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2387
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2388
|
+
wasm.wasmdimensions_from_output_script_type(retptr, ptr0, len0);
|
|
2389
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2390
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2391
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2392
|
+
if (r2) {
|
|
2393
|
+
throw takeObject(r1);
|
|
2394
|
+
}
|
|
2395
|
+
return WasmDimensions.__wrap(r0);
|
|
2396
|
+
} finally {
|
|
2397
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Create dimensions for a single output from script length
|
|
2402
|
+
* @param {number} length
|
|
2403
|
+
* @returns {WasmDimensions}
|
|
2404
|
+
*/
|
|
2405
|
+
static from_output_script_length(length) {
|
|
2406
|
+
const ret = wasm.wasmdimensions_from_output_script_length(length);
|
|
2407
|
+
return WasmDimensions.__wrap(ret);
|
|
2408
|
+
}
|
|
2222
2409
|
/**
|
|
2223
2410
|
* Combine with another Dimensions instance
|
|
2224
2411
|
* @param {WasmDimensions} other
|
|
@@ -2237,6 +2424,15 @@ class WasmDimensions {
|
|
|
2237
2424
|
const ret = wasm.wasmdimensions_empty();
|
|
2238
2425
|
return WasmDimensions.__wrap(ret);
|
|
2239
2426
|
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Multiply dimensions by a scalar
|
|
2429
|
+
* @param {number} n
|
|
2430
|
+
* @returns {WasmDimensions}
|
|
2431
|
+
*/
|
|
2432
|
+
times(n) {
|
|
2433
|
+
const ret = wasm.wasmdimensions_times(this.__wbg_ptr, n);
|
|
2434
|
+
return WasmDimensions.__wrap(ret);
|
|
2435
|
+
}
|
|
2240
2436
|
/**
|
|
2241
2437
|
* Create dimensions from a BitGoPsbt
|
|
2242
2438
|
*
|
|
Binary file
|
|
@@ -1,52 +1,15 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
5
|
-
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
6
|
-
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
7
|
-
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
8
|
-
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
9
|
-
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
10
|
-
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
11
|
-
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
12
|
-
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
13
|
-
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
14
|
-
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
15
|
-
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
16
|
-
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
17
|
-
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
18
|
-
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
19
|
-
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
20
|
-
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
21
|
-
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
22
|
-
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
23
|
-
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
24
|
-
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
25
|
-
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
26
|
-
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
27
|
-
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
28
|
-
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
29
|
-
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
30
|
-
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
31
|
-
export const wrappsbt_clone: (a: number) => number;
|
|
32
|
-
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
33
|
-
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
34
|
-
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
35
|
-
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
36
|
-
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
37
|
-
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
38
|
-
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
39
4
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
40
5
|
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
41
6
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
42
7
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
43
8
|
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
44
9
|
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
45
|
-
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
46
10
|
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
47
11
|
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
48
12
|
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
49
|
-
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
50
13
|
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
51
14
|
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
52
15
|
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
@@ -84,6 +47,7 @@ export const bitgopsbt_verify_signature_with_xpub: (a: number, b: number, c: num
|
|
|
84
47
|
export const bitgopsbt_version: (a: number) => number;
|
|
85
48
|
export const bitgopsbt_version_group_id: (a: number) => number;
|
|
86
49
|
export const fixedscriptwalletnamespace_address: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
50
|
+
export const fixedscriptwalletnamespace_chain_code_table: () => number;
|
|
87
51
|
export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
88
52
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
89
53
|
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
@@ -108,17 +72,21 @@ export const wasmbip32_private_key: (a: number) => number;
|
|
|
108
72
|
export const wasmbip32_public_key: (a: number) => number;
|
|
109
73
|
export const wasmbip32_to_base58: (a: number, b: number) => void;
|
|
110
74
|
export const wasmbip32_to_wif: (a: number, b: number) => void;
|
|
111
|
-
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
112
|
-
export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
|
|
113
75
|
export const wasmdimensions_empty: () => number;
|
|
114
76
|
export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
115
77
|
export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number) => void;
|
|
116
|
-
export const
|
|
78
|
+
export const wasmdimensions_from_output_script_length: (a: number) => number;
|
|
79
|
+
export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
|
|
117
80
|
export const wasmdimensions_from_psbt: (a: number, b: number) => void;
|
|
81
|
+
export const wasmdimensions_get_input_vsize: (a: number, b: number, c: number) => number;
|
|
82
|
+
export const wasmdimensions_get_input_weight: (a: number, b: number, c: number) => number;
|
|
83
|
+
export const wasmdimensions_get_output_vsize: (a: number) => number;
|
|
84
|
+
export const wasmdimensions_get_output_weight: (a: number) => number;
|
|
118
85
|
export const wasmdimensions_get_vsize: (a: number, b: number, c: number) => number;
|
|
119
86
|
export const wasmdimensions_get_weight: (a: number, b: number, c: number) => number;
|
|
120
87
|
export const wasmdimensions_has_segwit: (a: number) => number;
|
|
121
88
|
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
89
|
+
export const wasmdimensions_times: (a: number, b: number) => number;
|
|
122
90
|
export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
|
|
123
91
|
export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
|
|
124
92
|
export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
|
|
@@ -132,12 +100,54 @@ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
|
132
100
|
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
133
101
|
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
134
102
|
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
103
|
+
export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
|
|
104
|
+
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
105
|
+
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
106
|
+
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
107
|
+
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
108
|
+
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
109
|
+
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
110
|
+
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
111
|
+
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
112
|
+
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
113
|
+
export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => 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;
|
|
135
116
|
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
136
117
|
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
137
118
|
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
138
119
|
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
139
120
|
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;
|
|
140
|
-
export const
|
|
121
|
+
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
122
|
+
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
123
|
+
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
124
|
+
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
125
|
+
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
126
|
+
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
127
|
+
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
128
|
+
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
129
|
+
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
130
|
+
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
131
|
+
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
132
|
+
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
133
|
+
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
134
|
+
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
135
|
+
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
136
|
+
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
137
|
+
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
138
|
+
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
139
|
+
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
140
|
+
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
141
|
+
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
142
|
+
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
143
|
+
export const wrappsbt_clone: (a: number) => number;
|
|
144
|
+
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
145
|
+
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
146
|
+
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
147
|
+
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
148
|
+
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
149
|
+
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
150
|
+
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
141
151
|
export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
142
152
|
export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
143
153
|
export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
|
|
2
2
|
import type { CoinName } from "../coinName.js";
|
|
3
|
+
import type { OutputScriptType } from "./scriptType.js";
|
|
3
4
|
type FromInputParams = {
|
|
4
5
|
chain: number;
|
|
5
6
|
signPath?: SignPath;
|
|
@@ -43,10 +44,26 @@ export declare class Dimensions {
|
|
|
43
44
|
* Create dimensions for a single output from an address
|
|
44
45
|
*/
|
|
45
46
|
static fromOutput(address: string, network: CoinName): Dimensions;
|
|
47
|
+
/**
|
|
48
|
+
* Create dimensions for a single output from script length only
|
|
49
|
+
*/
|
|
50
|
+
static fromOutput(params: {
|
|
51
|
+
length: number;
|
|
52
|
+
}): Dimensions;
|
|
53
|
+
/**
|
|
54
|
+
* Create dimensions for a single output from script type
|
|
55
|
+
*/
|
|
56
|
+
static fromOutput(params: {
|
|
57
|
+
scriptType: OutputScriptType;
|
|
58
|
+
}): Dimensions;
|
|
46
59
|
/**
|
|
47
60
|
* Combine with another Dimensions instance
|
|
48
61
|
*/
|
|
49
62
|
plus(other: Dimensions): Dimensions;
|
|
63
|
+
/**
|
|
64
|
+
* Multiply dimensions by a scalar
|
|
65
|
+
*/
|
|
66
|
+
times(n: number): Dimensions;
|
|
50
67
|
/**
|
|
51
68
|
* Whether any inputs are segwit (affects overhead calculation)
|
|
52
69
|
*/
|
|
@@ -61,5 +78,23 @@ export declare class Dimensions {
|
|
|
61
78
|
* @param size - "min" or "max", defaults to "max"
|
|
62
79
|
*/
|
|
63
80
|
getVSize(size?: "min" | "max"): number;
|
|
81
|
+
/**
|
|
82
|
+
* Get input weight only (min or max)
|
|
83
|
+
* @param size - "min" or "max", defaults to "max"
|
|
84
|
+
*/
|
|
85
|
+
getInputWeight(size?: "min" | "max"): number;
|
|
86
|
+
/**
|
|
87
|
+
* Get input virtual size (min or max)
|
|
88
|
+
* @param size - "min" or "max", defaults to "max"
|
|
89
|
+
*/
|
|
90
|
+
getInputVSize(size?: "min" | "max"): number;
|
|
91
|
+
/**
|
|
92
|
+
* Get output weight
|
|
93
|
+
*/
|
|
94
|
+
getOutputWeight(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Get output virtual size
|
|
97
|
+
*/
|
|
98
|
+
getOutputVSize(): number;
|
|
64
99
|
}
|
|
65
100
|
export {};
|
|
@@ -40,15 +40,19 @@ export class Dimensions {
|
|
|
40
40
|
}
|
|
41
41
|
return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
|
|
42
42
|
}
|
|
43
|
-
static fromOutput(
|
|
44
|
-
if (typeof
|
|
43
|
+
static fromOutput(params, network) {
|
|
44
|
+
if (typeof params === "string") {
|
|
45
45
|
if (network === undefined) {
|
|
46
46
|
throw new Error("network is required when passing an address string");
|
|
47
47
|
}
|
|
48
|
-
const script = toOutputScriptWithCoin(
|
|
49
|
-
return new Dimensions(WasmDimensions.
|
|
48
|
+
const script = toOutputScriptWithCoin(params, network);
|
|
49
|
+
return new Dimensions(WasmDimensions.from_output_script_length(script.length));
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
if (typeof params === "object" && "scriptType" in params) {
|
|
52
|
+
return new Dimensions(WasmDimensions.from_output_script_type(params.scriptType));
|
|
53
|
+
}
|
|
54
|
+
// Both Uint8Array and { length: number } have .length
|
|
55
|
+
return new Dimensions(WasmDimensions.from_output_script_length(params.length));
|
|
52
56
|
}
|
|
53
57
|
/**
|
|
54
58
|
* Combine with another Dimensions instance
|
|
@@ -56,6 +60,12 @@ export class Dimensions {
|
|
|
56
60
|
plus(other) {
|
|
57
61
|
return new Dimensions(this._wasm.plus(other._wasm));
|
|
58
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Multiply dimensions by a scalar
|
|
65
|
+
*/
|
|
66
|
+
times(n) {
|
|
67
|
+
return new Dimensions(this._wasm.times(n));
|
|
68
|
+
}
|
|
59
69
|
/**
|
|
60
70
|
* Whether any inputs are segwit (affects overhead calculation)
|
|
61
71
|
*/
|
|
@@ -76,4 +86,30 @@ export class Dimensions {
|
|
|
76
86
|
getVSize(size = "max") {
|
|
77
87
|
return this._wasm.get_vsize(size);
|
|
78
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Get input weight only (min or max)
|
|
91
|
+
* @param size - "min" or "max", defaults to "max"
|
|
92
|
+
*/
|
|
93
|
+
getInputWeight(size = "max") {
|
|
94
|
+
return this._wasm.get_input_weight(size);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get input virtual size (min or max)
|
|
98
|
+
* @param size - "min" or "max", defaults to "max"
|
|
99
|
+
*/
|
|
100
|
+
getInputVSize(size = "max") {
|
|
101
|
+
return this._wasm.get_input_vsize(size);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get output weight
|
|
105
|
+
*/
|
|
106
|
+
getOutputWeight() {
|
|
107
|
+
return this._wasm.get_output_weight();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get output virtual size
|
|
111
|
+
*/
|
|
112
|
+
getOutputVSize() {
|
|
113
|
+
return this._wasm.get_output_vsize();
|
|
114
|
+
}
|
|
79
115
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { OutputScriptType } from "./scriptType.js";
|
|
2
|
+
/** All valid chain codes as a const tuple */
|
|
3
|
+
export declare const chainCodes: readonly [0, 1, 10, 11, 20, 21, 30, 31, 40, 41];
|
|
4
|
+
/** A valid chain code value */
|
|
5
|
+
export type ChainCode = (typeof chainCodes)[number];
|
|
6
|
+
/** Whether a chain is for receiving (external) or change (internal) addresses */
|
|
7
|
+
export type Scope = "internal" | "external";
|
|
8
|
+
/**
|
|
9
|
+
* ChainCode namespace with utility functions for working with chain codes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ChainCode: {
|
|
12
|
+
/**
|
|
13
|
+
* Check if a value is a valid chain code.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* if (ChainCode.is(maybeChain)) {
|
|
18
|
+
* // maybeChain is now typed as ChainCode
|
|
19
|
+
* const scope = ChainCode.scope(maybeChain);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
is(n: unknown): n is ChainCode;
|
|
24
|
+
/**
|
|
25
|
+
* Get the chain code for a script type and scope.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const externalP2wsh = ChainCode.value("p2wsh", "external"); // 20
|
|
30
|
+
* const internalP2tr = ChainCode.value("p2trLegacy", "internal"); // 31
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
value(scriptType: OutputScriptType | "p2tr", scope: Scope): ChainCode;
|
|
34
|
+
/**
|
|
35
|
+
* Get the scope (external/internal) for a chain code.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* ChainCode.scope(0); // "external"
|
|
40
|
+
* ChainCode.scope(1); // "internal"
|
|
41
|
+
* ChainCode.scope(20); // "external"
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
scope(chainCode: ChainCode): Scope;
|
|
45
|
+
/**
|
|
46
|
+
* Get the script type for a chain code.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* ChainCode.scriptType(0); // "p2sh"
|
|
51
|
+
* ChainCode.scriptType(20); // "p2wsh"
|
|
52
|
+
* ChainCode.scriptType(40); // "p2trMusig2"
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
scriptType(chainCode: ChainCode): OutputScriptType;
|
|
56
|
+
};
|