@bitgo/wasm-utxo 1.15.0 → 1.17.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/README.md +10 -1
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +5 -2
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +2 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +113 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.js +114 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/cjs/js/fixedScriptWallet/index.js +5 -1
- package/dist/cjs/js/index.d.ts +1 -0
- package/dist/cjs/js/index.js +5 -1
- package/dist/cjs/js/transaction.d.ts +46 -0
- package/dist/cjs/js/transaction.js +76 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +109 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +345 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +54 -41
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +5 -2
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +2 -0
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +113 -0
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.js +110 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/esm/js/fixedScriptWallet/index.js +3 -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 +46 -0
- package/dist/esm/js/transaction.js +70 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +109 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.js +342 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +54 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,16 @@ This project is under active development.
|
|
|
20
20
|
| Descriptor Wallet: Address Support | ✅ Complete | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 |
|
|
21
21
|
| Descriptor Wallet: Transaction Support | ✅ Complete | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 |
|
|
22
22
|
| FixedScript Wallet: Address Generation | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete |
|
|
23
|
-
| FixedScript Wallet: Transaction Support | ✅ Complete | ✅ Complete | ✅ Complete |
|
|
23
|
+
| FixedScript Wallet: Transaction Support | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete | ✅ Complete |
|
|
24
|
+
|
|
25
|
+
### Zcash Features
|
|
26
|
+
|
|
27
|
+
Zcash support includes:
|
|
28
|
+
|
|
29
|
+
- **Network Upgrade Awareness**: Automatic consensus branch ID determination based on block height
|
|
30
|
+
- **All Network Upgrades**: Support for Overwinter, Sapling, Blossom, Heartwood, Canopy, Nu5, Nu6, and Nu6_1
|
|
31
|
+
- **Height-Based API**: Preferred `createEmpty()` method automatically selects correct consensus rules
|
|
32
|
+
- **Parity Testing**: Validated against `zebra-chain` for accuracy across all network upgrades
|
|
24
33
|
|
|
25
34
|
## Building
|
|
26
35
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BitGoPsbt as WasmBitGoPsbt } from "../wasm/wasm_utxo.js";
|
|
1
2
|
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
3
|
import { type ReplayProtectionArg } from "./ReplayProtection.js";
|
|
3
4
|
import { type BIP32Arg } from "../bip32.js";
|
|
@@ -85,14 +86,16 @@ export type AddWalletOutputOptions = {
|
|
|
85
86
|
value: bigint;
|
|
86
87
|
};
|
|
87
88
|
export declare class BitGoPsbt {
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
protected wasm: WasmBitGoPsbt;
|
|
90
|
+
protected constructor(wasm: WasmBitGoPsbt);
|
|
90
91
|
/**
|
|
91
92
|
* Create an empty PSBT for the given network with wallet keys
|
|
92
93
|
*
|
|
93
94
|
* The wallet keys are used to set global xpubs in the PSBT, which identifies
|
|
94
95
|
* the keys that will be used for signing.
|
|
95
96
|
*
|
|
97
|
+
* For Zcash networks, use ZcashBitGoPsbt.createEmpty() instead.
|
|
98
|
+
*
|
|
96
99
|
* @param network - Network name (utxolib name like "bitcoin" or coin name like "btc")
|
|
97
100
|
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
98
101
|
* @param options - Optional transaction parameters (version, lockTime)
|
|
@@ -17,6 +17,8 @@ class BitGoPsbt {
|
|
|
17
17
|
* The wallet keys are used to set global xpubs in the PSBT, which identifies
|
|
18
18
|
* the keys that will be used for signing.
|
|
19
19
|
*
|
|
20
|
+
* For Zcash networks, use ZcashBitGoPsbt.createEmpty() instead.
|
|
21
|
+
*
|
|
20
22
|
* @param network - Network name (utxolib name like "bitcoin" or coin name like "btc")
|
|
21
23
|
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
22
24
|
* @param options - Optional transaction parameters (version, lockTime)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
|
+
import { BitGoPsbt, type CreateEmptyOptions } from "./BitGoPsbt.js";
|
|
3
|
+
/** Zcash network names */
|
|
4
|
+
export type ZcashNetworkName = "zcash" | "zcashTest" | "zec" | "tzec";
|
|
5
|
+
/** Options for creating an empty Zcash PSBT (preferred method using block height) */
|
|
6
|
+
export type CreateEmptyZcashOptions = CreateEmptyOptions & {
|
|
7
|
+
/** Block height to determine consensus branch ID automatically */
|
|
8
|
+
blockHeight: number;
|
|
9
|
+
/** Zcash version group ID (defaults to Sapling: 0x892F2085) */
|
|
10
|
+
versionGroupId?: number;
|
|
11
|
+
/** Zcash transaction expiry height */
|
|
12
|
+
expiryHeight?: number;
|
|
13
|
+
};
|
|
14
|
+
/** Options for creating an empty Zcash PSBT with explicit consensus branch ID (advanced use) */
|
|
15
|
+
export type CreateEmptyZcashWithConsensusBranchIdOptions = CreateEmptyOptions & {
|
|
16
|
+
/** Zcash consensus branch ID (required, e.g., 0xC2D6D0B4 for NU5, 0x76B809BB for Sapling) */
|
|
17
|
+
consensusBranchId: number;
|
|
18
|
+
/** Zcash version group ID (defaults to Sapling: 0x892F2085) */
|
|
19
|
+
versionGroupId?: number;
|
|
20
|
+
/** Zcash transaction expiry height */
|
|
21
|
+
expiryHeight?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Zcash-specific PSBT implementation
|
|
25
|
+
*
|
|
26
|
+
* This class extends BitGoPsbt with Zcash-specific functionality:
|
|
27
|
+
* - Required consensus branch ID for sighash computation
|
|
28
|
+
* - Version group ID for Zcash transaction format
|
|
29
|
+
* - Expiry height for transaction validity
|
|
30
|
+
*
|
|
31
|
+
* All Zcash-specific getters return non-optional types since they're
|
|
32
|
+
* guaranteed to be present for Zcash PSBTs.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Create a new Zcash PSBT
|
|
37
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
38
|
+
* consensusBranchId: 0x76B809BB, // Sapling
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Deserialize from bytes
|
|
42
|
+
* const psbt = ZcashBitGoPsbt.fromBytes(bytes, "zcash");
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class ZcashBitGoPsbt extends BitGoPsbt {
|
|
46
|
+
/**
|
|
47
|
+
* Create an empty Zcash PSBT with consensus branch ID determined from block height
|
|
48
|
+
*
|
|
49
|
+
* **This is the preferred method for creating Zcash PSBTs.** It automatically determines
|
|
50
|
+
* the correct consensus branch ID based on the network and block height using Zcash
|
|
51
|
+
* network upgrade activation heights, eliminating the need to manually look up branch IDs.
|
|
52
|
+
*
|
|
53
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
54
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
55
|
+
* @param options - Options including blockHeight to determine consensus rules
|
|
56
|
+
* @returns A new ZcashBitGoPsbt instance
|
|
57
|
+
* @throws Error if block height is before Overwinter activation
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Create PSBT for a specific block height (recommended)
|
|
62
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
63
|
+
* blockHeight: 1687104, // Automatically uses Nu5 branch ID
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Create PSBT for current block height
|
|
67
|
+
* const currentHeight = await getBlockHeight();
|
|
68
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
69
|
+
* blockHeight: currentHeight,
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
static createEmpty(network: ZcashNetworkName, walletKeys: WalletKeysArg, options: CreateEmptyZcashOptions): ZcashBitGoPsbt;
|
|
74
|
+
/**
|
|
75
|
+
* Create an empty Zcash PSBT with explicit consensus branch ID
|
|
76
|
+
*
|
|
77
|
+
* **Advanced use only.** This method requires manually specifying the consensus branch ID.
|
|
78
|
+
* In most cases, you should use `createEmpty()` instead, which automatically determines
|
|
79
|
+
* the correct branch ID from the block height.
|
|
80
|
+
*
|
|
81
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
82
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
83
|
+
* @param options - Zcash-specific options including required consensusBranchId
|
|
84
|
+
* @returns A new ZcashBitGoPsbt instance
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* // Only use this if you need explicit control over the branch ID
|
|
89
|
+
* const psbt = ZcashBitGoPsbt.createEmptyWithConsensusBranchId("zcash", walletKeys, {
|
|
90
|
+
* consensusBranchId: 0xC2D6D0B4, // Nu5 branch ID
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
static createEmptyWithConsensusBranchId(network: ZcashNetworkName, walletKeys: WalletKeysArg, options: CreateEmptyZcashWithConsensusBranchIdOptions): ZcashBitGoPsbt;
|
|
95
|
+
/**
|
|
96
|
+
* Deserialize a Zcash PSBT from bytes
|
|
97
|
+
*
|
|
98
|
+
* @param bytes - The PSBT bytes
|
|
99
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
100
|
+
* @returns A ZcashBitGoPsbt instance
|
|
101
|
+
*/
|
|
102
|
+
static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashBitGoPsbt;
|
|
103
|
+
/**
|
|
104
|
+
* Get the Zcash version group ID
|
|
105
|
+
* @returns The version group ID (e.g., 0x892F2085 for Sapling)
|
|
106
|
+
*/
|
|
107
|
+
get versionGroupId(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Get the Zcash expiry height
|
|
110
|
+
* @returns The expiry height (0 if not set)
|
|
111
|
+
*/
|
|
112
|
+
get expiryHeight(): number;
|
|
113
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZcashBitGoPsbt = void 0;
|
|
4
|
+
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
5
|
+
const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
6
|
+
const BitGoPsbt_js_1 = require("./BitGoPsbt.js");
|
|
7
|
+
/**
|
|
8
|
+
* Zcash-specific PSBT implementation
|
|
9
|
+
*
|
|
10
|
+
* This class extends BitGoPsbt with Zcash-specific functionality:
|
|
11
|
+
* - Required consensus branch ID for sighash computation
|
|
12
|
+
* - Version group ID for Zcash transaction format
|
|
13
|
+
* - Expiry height for transaction validity
|
|
14
|
+
*
|
|
15
|
+
* All Zcash-specific getters return non-optional types since they're
|
|
16
|
+
* guaranteed to be present for Zcash PSBTs.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Create a new Zcash PSBT
|
|
21
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
22
|
+
* consensusBranchId: 0x76B809BB, // Sapling
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Deserialize from bytes
|
|
26
|
+
* const psbt = ZcashBitGoPsbt.fromBytes(bytes, "zcash");
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class ZcashBitGoPsbt extends BitGoPsbt_js_1.BitGoPsbt {
|
|
30
|
+
/**
|
|
31
|
+
* Create an empty Zcash PSBT with consensus branch ID determined from block height
|
|
32
|
+
*
|
|
33
|
+
* **This is the preferred method for creating Zcash PSBTs.** It automatically determines
|
|
34
|
+
* the correct consensus branch ID based on the network and block height using Zcash
|
|
35
|
+
* network upgrade activation heights, eliminating the need to manually look up branch IDs.
|
|
36
|
+
*
|
|
37
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
38
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
39
|
+
* @param options - Options including blockHeight to determine consensus rules
|
|
40
|
+
* @returns A new ZcashBitGoPsbt instance
|
|
41
|
+
* @throws Error if block height is before Overwinter activation
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Create PSBT for a specific block height (recommended)
|
|
46
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
47
|
+
* blockHeight: 1687104, // Automatically uses Nu5 branch ID
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Create PSBT for current block height
|
|
51
|
+
* const currentHeight = await getBlockHeight();
|
|
52
|
+
* const psbt = ZcashBitGoPsbt.createEmpty("zcash", walletKeys, {
|
|
53
|
+
* blockHeight: currentHeight,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
static createEmpty(network, walletKeys, options) {
|
|
58
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
59
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.create_empty_zcash_at_height(network, keys.wasm, options.blockHeight, options.version, options.lockTime, options.versionGroupId, options.expiryHeight);
|
|
60
|
+
return new ZcashBitGoPsbt(wasm);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create an empty Zcash PSBT with explicit consensus branch ID
|
|
64
|
+
*
|
|
65
|
+
* **Advanced use only.** This method requires manually specifying the consensus branch ID.
|
|
66
|
+
* In most cases, you should use `createEmpty()` instead, which automatically determines
|
|
67
|
+
* the correct branch ID from the block height.
|
|
68
|
+
*
|
|
69
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
70
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
71
|
+
* @param options - Zcash-specific options including required consensusBranchId
|
|
72
|
+
* @returns A new ZcashBitGoPsbt instance
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Only use this if you need explicit control over the branch ID
|
|
77
|
+
* const psbt = ZcashBitGoPsbt.createEmptyWithConsensusBranchId("zcash", walletKeys, {
|
|
78
|
+
* consensusBranchId: 0xC2D6D0B4, // Nu5 branch ID
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
static createEmptyWithConsensusBranchId(network, walletKeys, options) {
|
|
83
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
84
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.create_empty_zcash(network, keys.wasm, options.consensusBranchId, options.version, options.lockTime, options.versionGroupId, options.expiryHeight);
|
|
85
|
+
return new ZcashBitGoPsbt(wasm);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Deserialize a Zcash PSBT from bytes
|
|
89
|
+
*
|
|
90
|
+
* @param bytes - The PSBT bytes
|
|
91
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
92
|
+
* @returns A ZcashBitGoPsbt instance
|
|
93
|
+
*/
|
|
94
|
+
static fromBytes(bytes, network) {
|
|
95
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
|
|
96
|
+
return new ZcashBitGoPsbt(wasm);
|
|
97
|
+
}
|
|
98
|
+
// --- Zcash-specific getters ---
|
|
99
|
+
/**
|
|
100
|
+
* Get the Zcash version group ID
|
|
101
|
+
* @returns The version group ID (e.g., 0x892F2085 for Sapling)
|
|
102
|
+
*/
|
|
103
|
+
get versionGroupId() {
|
|
104
|
+
return this.wasm.version_group_id();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the Zcash expiry height
|
|
108
|
+
* @returns The expiry height (0 if not set)
|
|
109
|
+
*/
|
|
110
|
+
get expiryHeight() {
|
|
111
|
+
return this.wasm.expiry_height();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.ZcashBitGoPsbt = ZcashBitGoPsbt;
|
|
@@ -1,4 +1,5 @@
|
|
|
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 { BitGoPsbt, type NetworkName, type ScriptId, type InputScriptType, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, } from "./BitGoPsbt.js";
|
|
4
|
+
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
|
+
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitGoPsbt = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
3
|
+
exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
4
4
|
var RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
5
5
|
Object.defineProperty(exports, "RootWalletKeys", { enumerable: true, get: function () { return RootWalletKeys_js_1.RootWalletKeys; } });
|
|
6
6
|
var ReplayProtection_js_1 = require("./ReplayProtection.js");
|
|
@@ -8,5 +8,9 @@ Object.defineProperty(exports, "ReplayProtection", { enumerable: true, get: func
|
|
|
8
8
|
var address_js_1 = require("./address.js");
|
|
9
9
|
Object.defineProperty(exports, "outputScript", { enumerable: true, get: function () { return address_js_1.outputScript; } });
|
|
10
10
|
Object.defineProperty(exports, "address", { enumerable: true, get: function () { return address_js_1.address; } });
|
|
11
|
+
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
11
12
|
var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
|
|
12
13
|
Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
|
|
14
|
+
// Zcash-specific PSBT subclass
|
|
15
|
+
var ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
|
|
16
|
+
Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.ZcashBitGoPsbt; } });
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -39,3 +39,4 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
39
39
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
40
40
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
41
41
|
export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
|
|
42
|
+
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.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.Psbt = exports.Miniscript = exports.Descriptor = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.ast = exports.address = void 0;
|
|
36
|
+
exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.ast = exports.address = void 0;
|
|
37
37
|
const wasm = __importStar(require("./wasm/wasm_utxo.js"));
|
|
38
38
|
// we need to access the wasm module here, otherwise webpack gets all weird
|
|
39
39
|
// and forgets to include it in the bundle
|
|
@@ -57,3 +57,7 @@ var wasm_utxo_js_2 = require("./wasm/wasm_utxo.js");
|
|
|
57
57
|
Object.defineProperty(exports, "Miniscript", { enumerable: true, get: function () { return wasm_utxo_js_2.WrapMiniscript; } });
|
|
58
58
|
var wasm_utxo_js_3 = require("./wasm/wasm_utxo.js");
|
|
59
59
|
Object.defineProperty(exports, "Psbt", { enumerable: true, get: function () { return wasm_utxo_js_3.WrapPsbt; } });
|
|
60
|
+
var transaction_js_1 = require("./transaction.js");
|
|
61
|
+
Object.defineProperty(exports, "DashTransaction", { enumerable: true, get: function () { return transaction_js_1.DashTransaction; } });
|
|
62
|
+
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return transaction_js_1.Transaction; } });
|
|
63
|
+
Object.defineProperty(exports, "ZcashTransaction", { enumerable: true, get: function () { return transaction_js_1.ZcashTransaction; } });
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transaction wrapper (Bitcoin-like networks)
|
|
4
|
+
*
|
|
5
|
+
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Transaction {
|
|
8
|
+
private _wasm;
|
|
9
|
+
private constructor();
|
|
10
|
+
static fromBytes(bytes: Uint8Array): Transaction;
|
|
11
|
+
toBytes(): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
get wasm(): WasmTransaction;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Zcash Transaction wrapper
|
|
19
|
+
*
|
|
20
|
+
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ZcashTransaction {
|
|
23
|
+
private _wasm;
|
|
24
|
+
private constructor();
|
|
25
|
+
static fromBytes(bytes: Uint8Array): ZcashTransaction;
|
|
26
|
+
toBytes(): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
get wasm(): WasmZcashTransaction;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Dash Transaction wrapper (supports EVO special transactions)
|
|
34
|
+
*
|
|
35
|
+
* Round-trip only: bytes -> parse -> bytes.
|
|
36
|
+
*/
|
|
37
|
+
export declare class DashTransaction {
|
|
38
|
+
private _wasm;
|
|
39
|
+
private constructor();
|
|
40
|
+
static fromBytes(bytes: Uint8Array): DashTransaction;
|
|
41
|
+
toBytes(): Uint8Array;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
get wasm(): WasmDashTransaction;
|
|
46
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DashTransaction = exports.ZcashTransaction = exports.Transaction = void 0;
|
|
4
|
+
const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
|
|
5
|
+
/**
|
|
6
|
+
* Transaction wrapper (Bitcoin-like networks)
|
|
7
|
+
*
|
|
8
|
+
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
9
|
+
*/
|
|
10
|
+
class Transaction {
|
|
11
|
+
_wasm;
|
|
12
|
+
constructor(_wasm) {
|
|
13
|
+
this._wasm = _wasm;
|
|
14
|
+
}
|
|
15
|
+
static fromBytes(bytes) {
|
|
16
|
+
return new Transaction(wasm_utxo_js_1.WasmTransaction.from_bytes(bytes));
|
|
17
|
+
}
|
|
18
|
+
toBytes() {
|
|
19
|
+
return this._wasm.to_bytes();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
get wasm() {
|
|
25
|
+
return this._wasm;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Transaction = Transaction;
|
|
29
|
+
/**
|
|
30
|
+
* Zcash Transaction wrapper
|
|
31
|
+
*
|
|
32
|
+
* Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
|
|
33
|
+
*/
|
|
34
|
+
class ZcashTransaction {
|
|
35
|
+
_wasm;
|
|
36
|
+
constructor(_wasm) {
|
|
37
|
+
this._wasm = _wasm;
|
|
38
|
+
}
|
|
39
|
+
static fromBytes(bytes) {
|
|
40
|
+
return new ZcashTransaction(wasm_utxo_js_1.WasmZcashTransaction.from_bytes(bytes));
|
|
41
|
+
}
|
|
42
|
+
toBytes() {
|
|
43
|
+
return this._wasm.to_bytes();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
get wasm() {
|
|
49
|
+
return this._wasm;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ZcashTransaction = ZcashTransaction;
|
|
53
|
+
/**
|
|
54
|
+
* Dash Transaction wrapper (supports EVO special transactions)
|
|
55
|
+
*
|
|
56
|
+
* Round-trip only: bytes -> parse -> bytes.
|
|
57
|
+
*/
|
|
58
|
+
class DashTransaction {
|
|
59
|
+
_wasm;
|
|
60
|
+
constructor(_wasm) {
|
|
61
|
+
this._wasm = _wasm;
|
|
62
|
+
}
|
|
63
|
+
static fromBytes(bytes) {
|
|
64
|
+
return new DashTransaction(wasm_utxo_js_1.WasmDashTransaction.from_bytes(bytes));
|
|
65
|
+
}
|
|
66
|
+
toBytes() {
|
|
67
|
+
return this._wasm.to_bytes();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
get wasm() {
|
|
73
|
+
return this._wasm;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.DashTransaction = DashTransaction;
|
|
@@ -38,6 +38,10 @@ export class BitGoPsbt {
|
|
|
38
38
|
* * `lock_time` - Optional lock time (default: 0)
|
|
39
39
|
*/
|
|
40
40
|
static create_empty(network: string, wallet_keys: WasmRootWalletKeys, version?: number | null, lock_time?: number | null): BitGoPsbt;
|
|
41
|
+
/**
|
|
42
|
+
* Get the Zcash expiry height (returns None for non-Zcash PSBTs)
|
|
43
|
+
*/
|
|
44
|
+
expiry_height(): number | undefined;
|
|
41
45
|
/**
|
|
42
46
|
* Get the unsigned transaction ID
|
|
43
47
|
*/
|
|
@@ -84,6 +88,10 @@ export class BitGoPsbt {
|
|
|
84
88
|
* The index of the newly added input
|
|
85
89
|
*/
|
|
86
90
|
add_wallet_input(txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
91
|
+
/**
|
|
92
|
+
* Get the Zcash version group ID (returns None for non-Zcash PSBTs)
|
|
93
|
+
*/
|
|
94
|
+
version_group_id(): number | undefined;
|
|
87
95
|
/**
|
|
88
96
|
* Add a wallet output with full PSBT metadata
|
|
89
97
|
*
|
|
@@ -120,6 +128,22 @@ export class BitGoPsbt {
|
|
|
120
128
|
* - `Err(WasmUtxoError)` if signing fails
|
|
121
129
|
*/
|
|
122
130
|
sign_with_privkey(input_index: number, ecpair: WasmECPair): void;
|
|
131
|
+
/**
|
|
132
|
+
* Create an empty Zcash PSBT with the required consensus branch ID
|
|
133
|
+
*
|
|
134
|
+
* This method is specifically for Zcash networks which require additional
|
|
135
|
+
* parameters for sighash computation.
|
|
136
|
+
*
|
|
137
|
+
* # Arguments
|
|
138
|
+
* * `network` - Network name (must be "zcash" or "zcashTest")
|
|
139
|
+
* * `wallet_keys` - The wallet's root keys (used to set global xpubs)
|
|
140
|
+
* * `consensus_branch_id` - Zcash consensus branch ID (e.g., 0xC2D6D0B4 for NU5)
|
|
141
|
+
* * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
|
|
142
|
+
* * `lock_time` - Optional lock time (default: 0)
|
|
143
|
+
* * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
|
|
144
|
+
* * `expiry_height` - Optional expiry height
|
|
145
|
+
*/
|
|
146
|
+
static create_empty_zcash(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
123
147
|
/**
|
|
124
148
|
* Extract the final transaction from a finalized PSBT
|
|
125
149
|
*
|
|
@@ -257,6 +281,25 @@ export class BitGoPsbt {
|
|
|
257
281
|
* The index of the newly added input
|
|
258
282
|
*/
|
|
259
283
|
add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null): number;
|
|
284
|
+
/**
|
|
285
|
+
* Create an empty Zcash PSBT with consensus branch ID determined from block height
|
|
286
|
+
*
|
|
287
|
+
* This method automatically determines the correct consensus branch ID based on
|
|
288
|
+
* the network and block height using the network upgrade activation heights.
|
|
289
|
+
*
|
|
290
|
+
* # Arguments
|
|
291
|
+
* * `network` - Network name (must be "zcash" or "zcashTest")
|
|
292
|
+
* * `wallet_keys` - The wallet's root keys (used to set global xpubs)
|
|
293
|
+
* * `block_height` - Block height to determine consensus rules
|
|
294
|
+
* * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
|
|
295
|
+
* * `lock_time` - Optional lock time (default: 0)
|
|
296
|
+
* * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
|
|
297
|
+
* * `expiry_height` - Optional expiry height
|
|
298
|
+
*
|
|
299
|
+
* # Errors
|
|
300
|
+
* Returns error if block height is before Overwinter activation
|
|
301
|
+
*/
|
|
302
|
+
static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
260
303
|
/**
|
|
261
304
|
* Parse outputs with wallet keys to identify which outputs belong to a wallet
|
|
262
305
|
*
|
|
@@ -445,6 +488,20 @@ export class WasmBIP32 {
|
|
|
445
488
|
readonly index: number;
|
|
446
489
|
}
|
|
447
490
|
|
|
491
|
+
export class WasmDashTransaction {
|
|
492
|
+
private constructor();
|
|
493
|
+
free(): void;
|
|
494
|
+
[Symbol.dispose](): void;
|
|
495
|
+
/**
|
|
496
|
+
* Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
|
|
497
|
+
*/
|
|
498
|
+
static from_bytes(bytes: Uint8Array): WasmDashTransaction;
|
|
499
|
+
/**
|
|
500
|
+
* Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
|
|
501
|
+
*/
|
|
502
|
+
to_bytes(): Uint8Array;
|
|
503
|
+
}
|
|
504
|
+
|
|
448
505
|
export class WasmECPair {
|
|
449
506
|
private constructor();
|
|
450
507
|
free(): void;
|
|
@@ -548,6 +605,58 @@ export class WasmRootWalletKeys {
|
|
|
548
605
|
bitgo_key(): WasmBIP32;
|
|
549
606
|
}
|
|
550
607
|
|
|
608
|
+
export class WasmTransaction {
|
|
609
|
+
private constructor();
|
|
610
|
+
free(): void;
|
|
611
|
+
[Symbol.dispose](): void;
|
|
612
|
+
/**
|
|
613
|
+
* Deserialize a transaction from bytes
|
|
614
|
+
*
|
|
615
|
+
* # Arguments
|
|
616
|
+
* * `bytes` - The serialized transaction bytes
|
|
617
|
+
*
|
|
618
|
+
* # Returns
|
|
619
|
+
* A WasmTransaction instance
|
|
620
|
+
*
|
|
621
|
+
* # Errors
|
|
622
|
+
* Returns an error if the bytes cannot be parsed as a valid transaction
|
|
623
|
+
*/
|
|
624
|
+
static from_bytes(bytes: Uint8Array): WasmTransaction;
|
|
625
|
+
/**
|
|
626
|
+
* Serialize the transaction to bytes
|
|
627
|
+
*
|
|
628
|
+
* # Returns
|
|
629
|
+
* The serialized transaction bytes
|
|
630
|
+
*/
|
|
631
|
+
to_bytes(): Uint8Array;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export class WasmZcashTransaction {
|
|
635
|
+
private constructor();
|
|
636
|
+
free(): void;
|
|
637
|
+
[Symbol.dispose](): void;
|
|
638
|
+
/**
|
|
639
|
+
* Deserialize a Zcash transaction from bytes
|
|
640
|
+
*
|
|
641
|
+
* # Arguments
|
|
642
|
+
* * `bytes` - The serialized transaction bytes
|
|
643
|
+
*
|
|
644
|
+
* # Returns
|
|
645
|
+
* A WasmZcashTransaction instance
|
|
646
|
+
*
|
|
647
|
+
* # Errors
|
|
648
|
+
* Returns an error if the bytes cannot be parsed as a valid Zcash transaction
|
|
649
|
+
*/
|
|
650
|
+
static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
|
|
651
|
+
/**
|
|
652
|
+
* Serialize the transaction to bytes
|
|
653
|
+
*
|
|
654
|
+
* # Returns
|
|
655
|
+
* The serialized transaction bytes
|
|
656
|
+
*/
|
|
657
|
+
to_bytes(): Uint8Array;
|
|
658
|
+
}
|
|
659
|
+
|
|
551
660
|
export class WrapDescriptor {
|
|
552
661
|
private constructor();
|
|
553
662
|
free(): void;
|