@bitgo/wasm-utxo 4.41.0 → 5.1.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/address.d.ts +3 -7
- package/dist/cjs/js/address.js +4 -8
- package/dist/cjs/js/descriptorWallet/psbt/findDescriptors.js +16 -12
- package/dist/cjs/js/fixedScriptWallet/Dimensions.d.ts +5 -16
- package/dist/cjs/js/fixedScriptWallet/Dimensions.js +2 -2
- package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.js +30 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
- package/dist/cjs/js/index.d.ts +18 -0
- package/dist/cjs/js/index.js +4 -1
- package/dist/cjs/js/psbt.d.ts +2 -1
- package/dist/cjs/js/psbtBase.d.ts +3 -1
- package/dist/cjs/js/psbtBase.js +3 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +55 -5
- package/dist/cjs/js/wasm/wasm_utxo.js +174 -7
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +93 -85
- package/dist/cjs/js/zcashAddress.d.ts +44 -0
- package/dist/cjs/js/zcashAddress.js +58 -0
- package/dist/esm/js/address.d.ts +3 -7
- package/dist/esm/js/address.js +4 -8
- package/dist/esm/js/descriptorWallet/psbt/findDescriptors.js +16 -12
- package/dist/esm/js/fixedScriptWallet/Dimensions.d.ts +5 -16
- package/dist/esm/js/fixedScriptWallet/Dimensions.js +2 -2
- package/dist/esm/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
- package/dist/esm/js/fixedScriptWallet/ZcashDimensions.js +26 -0
- package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
- package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
- package/dist/esm/js/index.d.ts +18 -0
- package/dist/esm/js/index.js +2 -0
- package/dist/esm/js/psbt.d.ts +2 -1
- package/dist/esm/js/psbtBase.d.ts +3 -1
- package/dist/esm/js/psbtBase.js +3 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +55 -5
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +170 -7
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +93 -85
- package/dist/esm/js/zcashAddress.d.ts +44 -0
- package/dist/esm/js/zcashAddress.js +52 -0
- package/package.json +1 -1
package/dist/cjs/js/address.d.ts
CHANGED
|
@@ -5,12 +5,8 @@ import type { CoinName } from "./coinName.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export type AddressFormat = "default" | "cashaddr";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* scriptPubKey (there is no scriptPubKey for a shielded output). `address` is only even
|
|
11
|
-
* attempted as a unified address when this is set. If `address` looks like a unified address for
|
|
12
|
-
* this coin's network but is malformed, or has no Orchard/Ironwood receiver (e.g. Sapling-only),
|
|
13
|
-
* this throws rather than falling back to the transparent path.
|
|
8
|
+
* Convert `address` to its scriptPubKey bytes for `coin`, decoding it as an ordinary transparent
|
|
9
|
+
* address.
|
|
14
10
|
*/
|
|
15
|
-
export declare function toOutputScriptWithCoin(address: string, coin: CoinName
|
|
11
|
+
export declare function toOutputScriptWithCoin(address: string, coin: CoinName): Uint8Array;
|
|
16
12
|
export declare function fromOutputScriptWithCoin(script: Uint8Array, coin: CoinName, format?: AddressFormat): string;
|
package/dist/cjs/js/address.js
CHANGED
|
@@ -4,15 +4,11 @@ exports.toOutputScriptWithCoin = toOutputScriptWithCoin;
|
|
|
4
4
|
exports.fromOutputScriptWithCoin = fromOutputScriptWithCoin;
|
|
5
5
|
const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* scriptPubKey (there is no scriptPubKey for a shielded output). `address` is only even
|
|
10
|
-
* attempted as a unified address when this is set. If `address` looks like a unified address for
|
|
11
|
-
* this coin's network but is malformed, or has no Orchard/Ironwood receiver (e.g. Sapling-only),
|
|
12
|
-
* this throws rather than falling back to the transparent path.
|
|
7
|
+
* Convert `address` to its scriptPubKey bytes for `coin`, decoding it as an ordinary transparent
|
|
8
|
+
* address.
|
|
13
9
|
*/
|
|
14
|
-
function toOutputScriptWithCoin(address, coin
|
|
15
|
-
return wasm_utxo_js_1.AddressNamespace.to_output_script_with_coin(address, coin
|
|
10
|
+
function toOutputScriptWithCoin(address, coin) {
|
|
11
|
+
return wasm_utxo_js_1.AddressNamespace.to_output_script_with_coin(address, coin);
|
|
16
12
|
}
|
|
17
13
|
function fromOutputScriptWithCoin(script, coin, format) {
|
|
18
14
|
return wasm_utxo_js_1.AddressNamespace.from_output_script_with_coin(script, coin, format);
|
|
@@ -48,11 +48,11 @@ function findDescriptorForDerivationIndex(script, index, descriptorMap) {
|
|
|
48
48
|
function getDerivationIndexFromPath(path) {
|
|
49
49
|
const indexStr = path.split("/").pop();
|
|
50
50
|
if (!indexStr) {
|
|
51
|
-
|
|
51
|
+
return undefined;
|
|
52
52
|
}
|
|
53
|
-
const index =
|
|
54
|
-
if (index.toString() !== indexStr) {
|
|
55
|
-
|
|
53
|
+
const index = Number(indexStr);
|
|
54
|
+
if (!Number.isSafeInteger(index) || index < 0 || index.toString() !== indexStr) {
|
|
55
|
+
return undefined;
|
|
56
56
|
}
|
|
57
57
|
return index;
|
|
58
58
|
}
|
|
@@ -63,7 +63,13 @@ function getDerivationIndexFromPath(path) {
|
|
|
63
63
|
* @param descriptorMap
|
|
64
64
|
*/
|
|
65
65
|
function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorMap) {
|
|
66
|
-
const derivationIndexSet = new Set(
|
|
66
|
+
const derivationIndexSet = new Set();
|
|
67
|
+
for (const path of derivationPaths) {
|
|
68
|
+
const index = getDerivationIndexFromPath(path);
|
|
69
|
+
if (index !== undefined) {
|
|
70
|
+
derivationIndexSet.add(index);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
67
73
|
for (const index of [...derivationIndexSet]) {
|
|
68
74
|
const desc = findDescriptorForDerivationIndex(script, index, descriptorMap);
|
|
69
75
|
if (desc) {
|
|
@@ -73,13 +79,11 @@ function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorM
|
|
|
73
79
|
return undefined;
|
|
74
80
|
}
|
|
75
81
|
function getDerivationPaths(v) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
82
|
+
const paths = [
|
|
83
|
+
...(v.bip32Derivation ?? []).map((derivation) => derivation.path),
|
|
84
|
+
...(v.tapBip32Derivation ?? []).map((derivation) => derivation.path),
|
|
85
|
+
].filter((path) => path !== "" && path !== "m");
|
|
86
|
+
return paths.length > 0 ? paths : undefined;
|
|
83
87
|
}
|
|
84
88
|
/**
|
|
85
89
|
* @param input
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WasmDimensions } from "../wasm/wasm_utxo.js";
|
|
1
2
|
import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
|
|
2
3
|
import type { CoinName } from "../coinName.js";
|
|
3
4
|
import type { OutputScriptType } from "./scriptType.js";
|
|
@@ -17,16 +18,6 @@ export type FromInputOptions = {
|
|
|
17
18
|
*/
|
|
18
19
|
utxolibCompat?: boolean;
|
|
19
20
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Options for output dimension calculation
|
|
22
|
-
*/
|
|
23
|
-
export type FromOutputOptions = {
|
|
24
|
-
/**
|
|
25
|
-
* Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
|
|
26
|
-
* as a shielded output. Forwarded to `toOutputScriptWithCoin`'s `canBeShieldedOutput`.
|
|
27
|
-
*/
|
|
28
|
-
isShielded?: boolean;
|
|
29
|
-
};
|
|
30
21
|
/**
|
|
31
22
|
* Dimensions class for estimating transaction virtual size.
|
|
32
23
|
*
|
|
@@ -37,7 +28,7 @@ export type FromOutputOptions = {
|
|
|
37
28
|
*/
|
|
38
29
|
export declare class Dimensions {
|
|
39
30
|
private _wasm;
|
|
40
|
-
|
|
31
|
+
protected constructor(_wasm: WasmDimensions);
|
|
41
32
|
/**
|
|
42
33
|
* Create empty dimensions (zero weight)
|
|
43
34
|
*/
|
|
@@ -62,12 +53,10 @@ export declare class Dimensions {
|
|
|
62
53
|
*/
|
|
63
54
|
static fromOutput(script: Uint8Array): Dimensions;
|
|
64
55
|
/**
|
|
65
|
-
* Create dimensions for a single output from an address
|
|
66
|
-
*
|
|
67
|
-
* Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
|
|
68
|
-
* receiver should be sized as a shielded output
|
|
56
|
+
* Create dimensions for a single output from an address, decoded as an ordinary transparent
|
|
57
|
+
* address for `network`.
|
|
69
58
|
*/
|
|
70
|
-
static fromOutput(address: string, network: CoinName
|
|
59
|
+
static fromOutput(address: string, network: CoinName): Dimensions;
|
|
71
60
|
/**
|
|
72
61
|
* Create dimensions for a single output from script length only
|
|
73
62
|
*/
|
|
@@ -45,12 +45,12 @@ class Dimensions {
|
|
|
45
45
|
}
|
|
46
46
|
return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
|
|
47
47
|
}
|
|
48
|
-
static fromOutput(params, network
|
|
48
|
+
static fromOutput(params, network) {
|
|
49
49
|
if (typeof params === "string") {
|
|
50
50
|
if (network === undefined) {
|
|
51
51
|
throw new Error("network is required when passing an address string");
|
|
52
52
|
}
|
|
53
|
-
const script = (0, address_js_1.toOutputScriptWithCoin)(params, network
|
|
53
|
+
const script = (0, address_js_1.toOutputScriptWithCoin)(params, network);
|
|
54
54
|
return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(script.length));
|
|
55
55
|
}
|
|
56
56
|
if (typeof params === "object" && "scriptType" in params) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CoinName } from "../coinName.js";
|
|
2
|
+
import type { OutputScriptType } from "./scriptType.js";
|
|
3
|
+
import { Dimensions } from "./Dimensions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link ZcashDimensions.fromOutput}.
|
|
6
|
+
*/
|
|
7
|
+
export type ZcashFromOutputOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
|
|
10
|
+
* as a shielded output. Forwarded to `zcashAddress.toShieldedReceiverWithCoin`; when unset,
|
|
11
|
+
* `zcashAddress.toTransparentReceiverWithCoin` is used instead.
|
|
12
|
+
*/
|
|
13
|
+
isShielded?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
|
|
17
|
+
* shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
|
|
18
|
+
* does for every other coin.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ZcashDimensions extends Dimensions {
|
|
21
|
+
/**
|
|
22
|
+
* Create dimensions for a single output from script bytes
|
|
23
|
+
*/
|
|
24
|
+
static fromOutput(script: Uint8Array): Dimensions;
|
|
25
|
+
/**
|
|
26
|
+
* Create dimensions for a single output from a Zcash address for `network`.
|
|
27
|
+
*
|
|
28
|
+
* Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
|
|
29
|
+
* receiver should be sized as a shielded output; otherwise its transparent receiver is
|
|
30
|
+
* resolved (a UA with no transparent receiver throws rather than falling back to Orchard).
|
|
31
|
+
*/
|
|
32
|
+
static fromOutput(address: string, network: CoinName, options?: ZcashFromOutputOptions): Dimensions;
|
|
33
|
+
/**
|
|
34
|
+
* Create dimensions for a single output from script length only
|
|
35
|
+
*/
|
|
36
|
+
static fromOutput(params: {
|
|
37
|
+
length: number;
|
|
38
|
+
}): Dimensions;
|
|
39
|
+
/**
|
|
40
|
+
* Create dimensions for a single output from script type
|
|
41
|
+
*/
|
|
42
|
+
static fromOutput(params: {
|
|
43
|
+
scriptType: OutputScriptType;
|
|
44
|
+
}): Dimensions;
|
|
45
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZcashDimensions = void 0;
|
|
4
|
+
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
5
|
+
const zcashAddress_js_1 = require("../zcashAddress.js");
|
|
6
|
+
const Dimensions_js_1 = require("./Dimensions.js");
|
|
7
|
+
/**
|
|
8
|
+
* Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
|
|
9
|
+
* shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
|
|
10
|
+
* does for every other coin.
|
|
11
|
+
*/
|
|
12
|
+
class ZcashDimensions extends Dimensions_js_1.Dimensions {
|
|
13
|
+
static fromOutput(params, network, options) {
|
|
14
|
+
if (typeof params === "string") {
|
|
15
|
+
if (network === undefined) {
|
|
16
|
+
throw new Error("network is required when passing an address string");
|
|
17
|
+
}
|
|
18
|
+
const receiver = options?.isShielded
|
|
19
|
+
? (0, zcashAddress_js_1.toShieldedReceiverWithCoin)(params, network)
|
|
20
|
+
: (0, zcashAddress_js_1.toTransparentReceiverWithCoin)(params, network);
|
|
21
|
+
return new ZcashDimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(receiver.length));
|
|
22
|
+
}
|
|
23
|
+
if (typeof params === "object" && "scriptType" in params) {
|
|
24
|
+
return Dimensions_js_1.Dimensions.fromOutput(params);
|
|
25
|
+
}
|
|
26
|
+
// Both Uint8Array and { length: number } have .length
|
|
27
|
+
return Dimensions_js_1.Dimensions.fromOutput(params);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ZcashDimensions = ZcashDimensions;
|
|
@@ -15,6 +15,8 @@ import type { ZcashNetworkName } from "./ZcashBitGoPsbt.js";
|
|
|
15
15
|
* const ua = ZcashUnifiedAddress.parse(uaString, "zec");
|
|
16
16
|
* const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
|
|
17
17
|
* const script = ua.transparentScript; // scriptPubKey bytes, or undefined
|
|
18
|
+
* ua.hasOrchardReceiver; // true iff orchardReceiver is present
|
|
19
|
+
* ua.hasTransparentReceiver; // true iff transparentScript is present
|
|
18
20
|
* ua.contains(transparentAddress); // is it one of this UA's receivers?
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
@@ -43,6 +45,20 @@ export declare class ZcashUnifiedAddress {
|
|
|
43
45
|
* a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
|
|
44
46
|
*/
|
|
45
47
|
get transparentScript(): Uint8Array | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Whether this Unified Address carries an Orchard/Ironwood receiver.
|
|
50
|
+
*
|
|
51
|
+
* Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
|
|
52
|
+
* matters, since it avoids copying the receiver bytes.
|
|
53
|
+
*/
|
|
54
|
+
get hasOrchardReceiver(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
|
|
57
|
+
*
|
|
58
|
+
* Equivalent to `transparentScript !== undefined`; prefer this when only presence
|
|
59
|
+
* matters, since it avoids copying the script bytes.
|
|
60
|
+
*/
|
|
61
|
+
get hasTransparentReceiver(): boolean;
|
|
46
62
|
/**
|
|
47
63
|
* Whether `candidate` is a receiver of this unified address.
|
|
48
64
|
*
|
|
@@ -17,6 +17,8 @@ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
|
17
17
|
* const ua = ZcashUnifiedAddress.parse(uaString, "zec");
|
|
18
18
|
* const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
|
|
19
19
|
* const script = ua.transparentScript; // scriptPubKey bytes, or undefined
|
|
20
|
+
* ua.hasOrchardReceiver; // true iff orchardReceiver is present
|
|
21
|
+
* ua.hasTransparentReceiver; // true iff transparentScript is present
|
|
20
22
|
* ua.contains(transparentAddress); // is it one of this UA's receivers?
|
|
21
23
|
* ```
|
|
22
24
|
*/
|
|
@@ -55,6 +57,24 @@ class ZcashUnifiedAddress {
|
|
|
55
57
|
get transparentScript() {
|
|
56
58
|
return this._wasm.transparentScript;
|
|
57
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether this Unified Address carries an Orchard/Ironwood receiver.
|
|
62
|
+
*
|
|
63
|
+
* Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
|
|
64
|
+
* matters, since it avoids copying the receiver bytes.
|
|
65
|
+
*/
|
|
66
|
+
get hasOrchardReceiver() {
|
|
67
|
+
return this._wasm.hasOrchardReceiver;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
|
|
71
|
+
*
|
|
72
|
+
* Equivalent to `transparentScript !== undefined`; prefer this when only presence
|
|
73
|
+
* matters, since it avoids copying the script bytes.
|
|
74
|
+
*/
|
|
75
|
+
get hasTransparentReceiver() {
|
|
76
|
+
return this._wasm.hasTransparentReceiver;
|
|
77
|
+
}
|
|
58
78
|
/**
|
|
59
79
|
* Whether `candidate` is a receiver of this unified address.
|
|
60
80
|
*
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as address from "./address.js";
|
|
2
|
+
export * as zcashAddress from "./zcashAddress.js";
|
|
2
3
|
export * as ast from "./ast/index.js";
|
|
3
4
|
export * as bip322 from "./bip322/index.js";
|
|
4
5
|
export * as inscriptions from "./inscriptions.js";
|
|
@@ -11,6 +12,7 @@ export * as ecpair from "./ecpair.js";
|
|
|
11
12
|
export { ECPair } from "./ecpair.js";
|
|
12
13
|
export { BIP32 } from "./bip32.js";
|
|
13
14
|
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
15
|
+
export { ZcashDimensions } from "./fixedScriptWallet/ZcashDimensions.js";
|
|
14
16
|
export type WasmUtxoVersionInfo = {
|
|
15
17
|
version: string;
|
|
16
18
|
gitHash: string;
|
|
@@ -68,6 +70,21 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
68
70
|
bip32Derivation: PsbtBip32Derivation[];
|
|
69
71
|
tapBip32Derivation: PsbtBip32Derivation[];
|
|
70
72
|
}
|
|
73
|
+
/** A serialized input-map record with a standard PSBT key type. */
|
|
74
|
+
interface PsbtKnownInputKeyValue {
|
|
75
|
+
type: "known";
|
|
76
|
+
key: string;
|
|
77
|
+
keyData: Uint8Array;
|
|
78
|
+
value: Uint8Array;
|
|
79
|
+
}
|
|
80
|
+
/** A serialized input-map record whose key type is unrecognized. */
|
|
81
|
+
interface PsbtUnknownInputKeyValue {
|
|
82
|
+
type: "unknown";
|
|
83
|
+
keyType: bigint;
|
|
84
|
+
keyData: Uint8Array;
|
|
85
|
+
value: Uint8Array;
|
|
86
|
+
}
|
|
87
|
+
type PsbtInputKeyValue = PsbtKnownInputKeyValue | PsbtUnknownInputKeyValue;
|
|
71
88
|
/** Raw PSBT output data returned by getOutputs() */
|
|
72
89
|
interface PsbtOutputData {
|
|
73
90
|
script: Uint8Array;
|
|
@@ -110,3 +127,4 @@ export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
|
110
127
|
export { Psbt } from "./descriptorWallet/Psbt.js";
|
|
111
128
|
export { DashTransaction, Transaction, ZcashTransaction, type ITransaction, type ITransactionCommon, } from "./transaction.js";
|
|
112
129
|
export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
|
|
130
|
+
export type { PsbtInputKeyValue } from "./wasm/wasm_utxo.js";
|
package/dist/cjs/js/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.descriptorWallet = exports.fixedScriptWallet = exports.utxolibCompat = exports.message = exports.inscriptions = exports.bip322 = exports.ast = exports.address = void 0;
|
|
36
|
+
exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.ZcashDimensions = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.descriptorWallet = exports.fixedScriptWallet = exports.utxolibCompat = exports.message = exports.inscriptions = exports.bip322 = exports.ast = exports.zcashAddress = exports.address = void 0;
|
|
37
37
|
exports.getWasmUtxoVersion = getWasmUtxoVersion;
|
|
38
38
|
exports.isWasmUtxoError = isWasmUtxoError;
|
|
39
39
|
const wasm = __importStar(require("./wasm/wasm_utxo.js"));
|
|
@@ -44,6 +44,7 @@ void wasm;
|
|
|
44
44
|
// Most exports are namespaced to avoid polluting the top-level namespace
|
|
45
45
|
// and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
|
|
46
46
|
exports.address = __importStar(require("./address.js"));
|
|
47
|
+
exports.zcashAddress = __importStar(require("./zcashAddress.js"));
|
|
47
48
|
exports.ast = __importStar(require("./ast/index.js"));
|
|
48
49
|
exports.bip322 = __importStar(require("./bip322/index.js"));
|
|
49
50
|
exports.inscriptions = __importStar(require("./inscriptions.js"));
|
|
@@ -60,6 +61,8 @@ var bip32_js_1 = require("./bip32.js");
|
|
|
60
61
|
Object.defineProperty(exports, "BIP32", { enumerable: true, get: function () { return bip32_js_1.BIP32; } });
|
|
61
62
|
var Dimensions_js_1 = require("./fixedScriptWallet/Dimensions.js");
|
|
62
63
|
Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
|
|
64
|
+
var ZcashDimensions_js_1 = require("./fixedScriptWallet/ZcashDimensions.js");
|
|
65
|
+
Object.defineProperty(exports, "ZcashDimensions", { enumerable: true, get: function () { return ZcashDimensions_js_1.ZcashDimensions; } });
|
|
63
66
|
function getWasmUtxoVersion() {
|
|
64
67
|
return wasm_utxo_js_1.WasmUtxoNamespace.get_wasm_utxo_version();
|
|
65
68
|
}
|
package/dist/cjs/js/psbt.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
1
|
+
import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
2
|
import type { BIP32 } from "./bip32.js";
|
|
3
3
|
import type { ITransactionCommon } from "./transaction.js";
|
|
4
4
|
import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
|
|
5
5
|
/** Common interface for PSBT types */
|
|
6
6
|
export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
|
|
7
7
|
getGlobalXpubs(): BIP32[];
|
|
8
|
+
getInputKeyValues(index: number): PsbtInputKeyValue[];
|
|
8
9
|
unsignedTxId(): string;
|
|
9
10
|
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
10
11
|
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PsbtInputData, PsbtOutputData } from "./wasm/wasm_utxo.js";
|
|
1
|
+
import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData } from "./wasm/wasm_utxo.js";
|
|
2
2
|
import { BIP32 } from "./bip32.js";
|
|
3
3
|
import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
|
|
4
4
|
interface WasmPsbtBase {
|
|
@@ -9,6 +9,7 @@ interface WasmPsbtBase {
|
|
|
9
9
|
unsigned_tx_id(): string;
|
|
10
10
|
serialize(): Uint8Array;
|
|
11
11
|
get_inputs(): unknown;
|
|
12
|
+
get_input_key_values(index: number): unknown;
|
|
12
13
|
get_outputs(): unknown;
|
|
13
14
|
get_global_xpubs(): unknown;
|
|
14
15
|
remove_input(index: number): void;
|
|
@@ -33,6 +34,7 @@ export declare abstract class PsbtBase<W extends WasmPsbtBase> {
|
|
|
33
34
|
unsignedTxId(): string;
|
|
34
35
|
serialize(): Uint8Array;
|
|
35
36
|
getInputs(): PsbtInputData[];
|
|
37
|
+
getInputKeyValues(index: number): PsbtInputKeyValue[];
|
|
36
38
|
getOutputs(): PsbtOutputData[];
|
|
37
39
|
getGlobalXpubs(): BIP32[];
|
|
38
40
|
removeInput(index: number): void;
|
package/dist/cjs/js/psbtBase.js
CHANGED
|
@@ -7,12 +7,9 @@ export class AddressNamespace {
|
|
|
7
7
|
[Symbol.dispose](): void;
|
|
8
8
|
static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* Orchard/Ironwood receiver, returns that raw 43-byte receiver instead of a transparent
|
|
12
|
-
* scriptPubKey. See [`to_output_script_or_shielded_receiver_with_coin`] for the exact
|
|
13
|
-
* fallback/error rules.
|
|
10
|
+
* Convert `address` to its scriptPubKey bytes for `coin`.
|
|
14
11
|
*/
|
|
15
|
-
static to_output_script_with_coin(address: string, coin: string
|
|
12
|
+
static to_output_script_with_coin(address: string, coin: string): Uint8Array;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
/**
|
|
@@ -491,6 +488,7 @@ export class BitGoPsbt {
|
|
|
491
488
|
*/
|
|
492
489
|
generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
|
|
493
490
|
get_global_xpubs(): any;
|
|
491
|
+
get_input_key_values(index: number): any;
|
|
494
492
|
get_input_kv(index: number, key: any): Uint8Array | undefined;
|
|
495
493
|
get_inputs(): any;
|
|
496
494
|
get_kv(key: any): Uint8Array | undefined;
|
|
@@ -1661,6 +1659,7 @@ export class WrapPsbt {
|
|
|
1661
1659
|
*/
|
|
1662
1660
|
finalize_mut_zcash(consensus_branch_id: number, version_group_id?: number | null, expiry_height?: number | null): void;
|
|
1663
1661
|
get_global_xpubs(): any;
|
|
1662
|
+
get_input_key_values(index: number): any;
|
|
1664
1663
|
get_input_kv(index: number, key: any): Uint8Array | undefined;
|
|
1665
1664
|
get_inputs(): any;
|
|
1666
1665
|
get_kv(key: any): Uint8Array | undefined;
|
|
@@ -1798,6 +1797,20 @@ export class ZcashUnifiedAddress {
|
|
|
1798
1797
|
* below are infallible. Throws if the address is malformed or on the wrong network.
|
|
1799
1798
|
*/
|
|
1800
1799
|
static parse(address: string, network: string): ZcashUnifiedAddress;
|
|
1800
|
+
/**
|
|
1801
|
+
* Whether this Unified Address carries an Orchard/Ironwood receiver.
|
|
1802
|
+
*
|
|
1803
|
+
* Equivalent to `orchardReceiver !== undefined`, without cloning the receiver bytes
|
|
1804
|
+
* when the caller only needs presence.
|
|
1805
|
+
*/
|
|
1806
|
+
readonly hasOrchardReceiver: boolean;
|
|
1807
|
+
/**
|
|
1808
|
+
* Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
|
|
1809
|
+
*
|
|
1810
|
+
* Equivalent to `transparentScript !== undefined`, without cloning the script bytes
|
|
1811
|
+
* when the caller only needs presence.
|
|
1812
|
+
*/
|
|
1813
|
+
readonly hasTransparentReceiver: boolean;
|
|
1801
1814
|
/**
|
|
1802
1815
|
* The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
|
|
1803
1816
|
*/
|
|
@@ -1966,6 +1979,43 @@ export function parsePsbtToJson(psbt_bytes: Uint8Array, coin_name: string): stri
|
|
|
1966
1979
|
*/
|
|
1967
1980
|
export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
|
|
1968
1981
|
|
|
1982
|
+
/**
|
|
1983
|
+
* Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
|
|
1984
|
+
* Orchard/Ironwood receiver. `false` (never throws) for a malformed/wrong-network unified
|
|
1985
|
+
* address, an ordinary address, or a UA with no Orchard/Ironwood receiver.
|
|
1986
|
+
*/
|
|
1987
|
+
export function zcashHasOrchardReceiver(address: string, coin: string): boolean;
|
|
1988
|
+
|
|
1989
|
+
/**
|
|
1990
|
+
* Whether `address` has a usable transparent receiver for `coin`'s network: either it's a
|
|
1991
|
+
* unified address carrying a transparent receiver, or it's itself a valid transparent address
|
|
1992
|
+
* for `coin`. `false` (never throws) otherwise.
|
|
1993
|
+
*/
|
|
1994
|
+
export function zcashHasTransparentReceiver(address: string, coin: string): boolean;
|
|
1995
|
+
|
|
1996
|
+
export function zcashToShieldedReceiverWithCoin(address: string, coin: string): Uint8Array;
|
|
1997
|
+
|
|
1998
|
+
/**
|
|
1999
|
+
* Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as
|
|
2000
|
+
* its raw 43 bytes (diversifier + `pk_d`) — there is no scriptPubKey for a shielded output, so
|
|
2001
|
+
* this can't return script bytes uniformly and returns raw receiver bytes instead.
|
|
2002
|
+
*
|
|
2003
|
+
* A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only) throws rather than falling back
|
|
2004
|
+
* to the transparent receiver. If `address` merely looks like a unified address for this coin's
|
|
2005
|
+
* network (right Bech32m HRP) but is malformed, this also throws. `address` must be a unified
|
|
2006
|
+
* address — an ordinary transparent address is rejected, since it can never carry a shielded
|
|
2007
|
+
* receiver; use {@link toOutputScriptWithCoin} in `js/address.ts` for the transparent case.
|
|
2008
|
+
* Resolve the transparent receiver of an `address` for `coin`'s network, as its scriptPubKey
|
|
2009
|
+
* bytes. When `address` is a ZIP-316 unified address, resolves its transparent receiver rather
|
|
2010
|
+
* than rejecting the UA string outright — a UA with no transparent receiver (e.g. Orchard-only)
|
|
2011
|
+
* throws rather than falling back to a shielded one. An ordinary (non-UA) address falls through
|
|
2012
|
+
* to the same transparent codec path as any other coin.
|
|
2013
|
+
*
|
|
2014
|
+
* This is the zcash-aware counterpart of `toOutputScriptWithCoin` in `js/address.ts`, which
|
|
2015
|
+
* dispatches here for zcash/tzec so that non-zcash coins never pay for a unified-address check.
|
|
2016
|
+
*/
|
|
2017
|
+
export function zcashToTransparentReceiverWithCoin(address: string, coin: string): Uint8Array;
|
|
2018
|
+
|
|
1969
2019
|
/**
|
|
1970
2020
|
* Return the Zcash consensus branch ID active at `height` on `network`.
|
|
1971
2021
|
*
|