@bitgo/wasm-utxo 4.3.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +8 -3
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +22 -3
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +47 -2
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.js +54 -0
- package/dist/cjs/js/fixedScriptWallet/chains.d.ts +1 -1
- package/dist/cjs/js/fixedScriptWallet/chains.js +1 -1
- package/dist/cjs/js/psbt.d.ts +3 -0
- package/dist/cjs/js/psbtBase.d.ts +6 -0
- package/dist/cjs/js/psbtBase.js +9 -0
- package/dist/cjs/js/transaction.d.ts +18 -0
- package/dist/cjs/js/transaction.js +28 -1
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +41 -2
- package/dist/cjs/js/wasm/wasm_utxo.js +210 -7
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +45 -36
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +8 -3
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +22 -3
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +47 -2
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.js +54 -0
- package/dist/esm/js/fixedScriptWallet/chains.d.ts +1 -1
- package/dist/esm/js/fixedScriptWallet/chains.js +1 -1
- package/dist/esm/js/psbt.d.ts +3 -0
- package/dist/esm/js/psbtBase.d.ts +6 -0
- package/dist/esm/js/psbtBase.js +9 -0
- package/dist/esm/js/transaction.d.ts +18 -0
- package/dist/esm/js/transaction.js +28 -1
- package/dist/esm/js/wasm/wasm_utxo.d.ts +41 -2
- package/dist/esm/js/wasm/wasm_utxo_bg.js +210 -7
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +45 -36
- package/package.json +1 -1
|
@@ -920,6 +920,56 @@ class BitGoPsbt {
|
|
|
920
920
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
+
/**
|
|
924
|
+
* @param {number} index
|
|
925
|
+
* @param {any} key
|
|
926
|
+
*/
|
|
927
|
+
delete_input_kv(index, key) {
|
|
928
|
+
try {
|
|
929
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
930
|
+
wasm.bitgopsbt_delete_input_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
|
|
931
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
932
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
933
|
+
if (r1) {
|
|
934
|
+
throw takeObject(r0);
|
|
935
|
+
}
|
|
936
|
+
} finally {
|
|
937
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* @param {any} key
|
|
942
|
+
*/
|
|
943
|
+
delete_kv(key) {
|
|
944
|
+
try {
|
|
945
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
946
|
+
wasm.bitgopsbt_delete_kv(retptr, this.__wbg_ptr, addHeapObject(key));
|
|
947
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
948
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
949
|
+
if (r1) {
|
|
950
|
+
throw takeObject(r0);
|
|
951
|
+
}
|
|
952
|
+
} finally {
|
|
953
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* @param {number} index
|
|
958
|
+
* @param {any} key
|
|
959
|
+
*/
|
|
960
|
+
delete_output_kv(index, key) {
|
|
961
|
+
try {
|
|
962
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
963
|
+
wasm.bitgopsbt_delete_output_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
|
|
964
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
965
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
966
|
+
if (r1) {
|
|
967
|
+
throw takeObject(r0);
|
|
968
|
+
}
|
|
969
|
+
} finally {
|
|
970
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
923
973
|
/**
|
|
924
974
|
* Get the Zcash expiry height (returns None for non-Zcash PSBTs)
|
|
925
975
|
* @returns {number | undefined}
|
|
@@ -1112,25 +1162,128 @@ class BitGoPsbt {
|
|
|
1112
1162
|
* Convert a half-signed legacy transaction to a psbt-lite.
|
|
1113
1163
|
*
|
|
1114
1164
|
* # Arguments
|
|
1115
|
-
* * `
|
|
1165
|
+
* * `tx` - The decoded half-signed legacy transaction
|
|
1116
1166
|
* * `network` - Network name (utxolib or coin name)
|
|
1117
1167
|
* * `wallet_keys` - The wallet's root keys
|
|
1118
1168
|
* * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
|
|
1119
|
-
* @param {
|
|
1169
|
+
* @param {WasmTransaction} tx
|
|
1120
1170
|
* @param {string} network
|
|
1121
1171
|
* @param {WasmRootWalletKeys} wallet_keys
|
|
1122
1172
|
* @param {any} unspents
|
|
1123
1173
|
* @returns {BitGoPsbt}
|
|
1124
1174
|
*/
|
|
1125
|
-
static from_half_signed_legacy_transaction(
|
|
1175
|
+
static from_half_signed_legacy_transaction(tx, network, wallet_keys, unspents) {
|
|
1126
1176
|
try {
|
|
1127
1177
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1128
|
-
|
|
1178
|
+
_assertClass(tx, WasmTransaction);
|
|
1179
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1129
1180
|
const len0 = WASM_VECTOR_LEN;
|
|
1130
|
-
const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1131
|
-
const len1 = WASM_VECTOR_LEN;
|
|
1132
1181
|
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1133
|
-
wasm.bitgopsbt_from_half_signed_legacy_transaction(retptr, ptr0, len0,
|
|
1182
|
+
wasm.bitgopsbt_from_half_signed_legacy_transaction(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents));
|
|
1183
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1184
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1185
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1186
|
+
if (r2) {
|
|
1187
|
+
throw takeObject(r1);
|
|
1188
|
+
}
|
|
1189
|
+
return BitGoPsbt.__wrap(r0);
|
|
1190
|
+
} finally {
|
|
1191
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Convert a half-signed legacy Dash transaction to a psbt-lite.
|
|
1196
|
+
*
|
|
1197
|
+
* # Arguments
|
|
1198
|
+
* * `tx` - The decoded Dash transaction
|
|
1199
|
+
* * `network` - Network name ("dash" or "tdash")
|
|
1200
|
+
* * `wallet_keys` - The wallet's root keys
|
|
1201
|
+
* * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
|
|
1202
|
+
* @param {WasmDashTransaction} tx
|
|
1203
|
+
* @param {string} network
|
|
1204
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
1205
|
+
* @param {any} unspents
|
|
1206
|
+
* @returns {BitGoPsbt}
|
|
1207
|
+
*/
|
|
1208
|
+
static from_half_signed_legacy_transaction_dash(tx, network, wallet_keys, unspents) {
|
|
1209
|
+
try {
|
|
1210
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1211
|
+
_assertClass(tx, WasmDashTransaction);
|
|
1212
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1213
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1214
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1215
|
+
wasm.bitgopsbt_from_half_signed_legacy_transaction_dash(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents));
|
|
1216
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1217
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1218
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1219
|
+
if (r2) {
|
|
1220
|
+
throw takeObject(r1);
|
|
1221
|
+
}
|
|
1222
|
+
return BitGoPsbt.__wrap(r0);
|
|
1223
|
+
} finally {
|
|
1224
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Convert a half-signed legacy Zcash transaction to a psbt-lite (with block height).
|
|
1229
|
+
* Thin wrapper: resolves block_height → consensus_branch_id and delegates to the explicit variant.
|
|
1230
|
+
*
|
|
1231
|
+
* # Arguments
|
|
1232
|
+
* * `tx` - The decoded Zcash transaction
|
|
1233
|
+
* * `network` - Network name ("zec" or "tzec")
|
|
1234
|
+
* * `wallet_keys` - The wallet's root keys
|
|
1235
|
+
* * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
|
|
1236
|
+
* * `block_height` - Block height to determine consensus branch ID
|
|
1237
|
+
* @param {WasmZcashTransaction} tx
|
|
1238
|
+
* @param {string} network
|
|
1239
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
1240
|
+
* @param {any} unspents
|
|
1241
|
+
* @param {number} block_height
|
|
1242
|
+
* @returns {BitGoPsbt}
|
|
1243
|
+
*/
|
|
1244
|
+
static from_half_signed_legacy_transaction_zcash_with_block_height(tx, network, wallet_keys, unspents, block_height) {
|
|
1245
|
+
try {
|
|
1246
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1247
|
+
_assertClass(tx, WasmZcashTransaction);
|
|
1248
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1250
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1251
|
+
wasm.bitgopsbt_from_half_signed_legacy_transaction_zcash_with_block_height(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents), block_height);
|
|
1252
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1253
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1254
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1255
|
+
if (r2) {
|
|
1256
|
+
throw takeObject(r1);
|
|
1257
|
+
}
|
|
1258
|
+
return BitGoPsbt.__wrap(r0);
|
|
1259
|
+
} finally {
|
|
1260
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Convert a half-signed legacy Zcash transaction to a psbt-lite (with consensus branch ID).
|
|
1265
|
+
*
|
|
1266
|
+
* # Arguments
|
|
1267
|
+
* * `tx` - The decoded Zcash transaction
|
|
1268
|
+
* * `network` - Network name ("zec" or "tzec")
|
|
1269
|
+
* * `wallet_keys` - The wallet's root keys
|
|
1270
|
+
* * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
|
|
1271
|
+
* * `consensus_branch_id` - Zcash consensus branch ID
|
|
1272
|
+
* @param {WasmZcashTransaction} tx
|
|
1273
|
+
* @param {string} network
|
|
1274
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
1275
|
+
* @param {any} unspents
|
|
1276
|
+
* @param {number} consensus_branch_id
|
|
1277
|
+
* @returns {BitGoPsbt}
|
|
1278
|
+
*/
|
|
1279
|
+
static from_half_signed_legacy_transaction_zcash_with_branch_id(tx, network, wallet_keys, unspents, consensus_branch_id) {
|
|
1280
|
+
try {
|
|
1281
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1282
|
+
_assertClass(tx, WasmZcashTransaction);
|
|
1283
|
+
const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1284
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1285
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
1286
|
+
wasm.bitgopsbt_from_half_signed_legacy_transaction_zcash_with_branch_id(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents), consensus_branch_id);
|
|
1134
1287
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1135
1288
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1136
1289
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -5049,6 +5202,56 @@ class WrapPsbt {
|
|
|
5049
5202
|
const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
|
|
5050
5203
|
return WrapPsbt.__wrap(ret);
|
|
5051
5204
|
}
|
|
5205
|
+
/**
|
|
5206
|
+
* @param {number} index
|
|
5207
|
+
* @param {any} key
|
|
5208
|
+
*/
|
|
5209
|
+
delete_input_kv(index, key) {
|
|
5210
|
+
try {
|
|
5211
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5212
|
+
wasm.wrappsbt_delete_input_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
|
|
5213
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
5214
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
5215
|
+
if (r1) {
|
|
5216
|
+
throw takeObject(r0);
|
|
5217
|
+
}
|
|
5218
|
+
} finally {
|
|
5219
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
/**
|
|
5223
|
+
* @param {any} key
|
|
5224
|
+
*/
|
|
5225
|
+
delete_kv(key) {
|
|
5226
|
+
try {
|
|
5227
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5228
|
+
wasm.wrappsbt_delete_kv(retptr, this.__wbg_ptr, addHeapObject(key));
|
|
5229
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
5230
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
5231
|
+
if (r1) {
|
|
5232
|
+
throw takeObject(r0);
|
|
5233
|
+
}
|
|
5234
|
+
} finally {
|
|
5235
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
/**
|
|
5239
|
+
* @param {number} index
|
|
5240
|
+
* @param {any} key
|
|
5241
|
+
*/
|
|
5242
|
+
delete_output_kv(index, key) {
|
|
5243
|
+
try {
|
|
5244
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5245
|
+
wasm.wrappsbt_delete_output_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
|
|
5246
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
5247
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
5248
|
+
if (r1) {
|
|
5249
|
+
throw takeObject(r0);
|
|
5250
|
+
}
|
|
5251
|
+
} finally {
|
|
5252
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5253
|
+
}
|
|
5254
|
+
}
|
|
5052
5255
|
/**
|
|
5053
5256
|
* @param {Uint8Array} psbt
|
|
5054
5257
|
* @returns {WrapPsbt}
|
|
Binary file
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
6
|
+
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
+
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
8
|
+
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
9
|
+
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
10
|
+
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
11
|
+
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
12
|
+
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
13
|
+
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;
|
|
4
14
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
5
15
|
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
6
16
|
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
7
17
|
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
8
18
|
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
9
19
|
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
10
|
-
export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
|
|
11
20
|
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
12
21
|
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
13
22
|
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
14
23
|
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
24
|
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
16
25
|
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;
|
|
17
|
-
export const isInspectEnabled: () => number;
|
|
18
|
-
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
19
26
|
export const wasmbip32_chain_code: (a: number) => number;
|
|
20
27
|
export const wasmbip32_depth: (a: number) => number;
|
|
21
28
|
export const wasmbip32_derive: (a: number, b: number, c: number) => void;
|
|
@@ -70,7 +77,6 @@ export const wasmtransaction_get_outputs_with_address: (a: number, b: number, c:
|
|
|
70
77
|
export const wasmtransaction_get_txid: (a: number, b: number) => void;
|
|
71
78
|
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
72
79
|
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
73
|
-
export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
|
|
74
80
|
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
75
81
|
export const wasmzcashtransaction_get_inputs: (a: number, b: number) => void;
|
|
76
82
|
export const wasmzcashtransaction_get_outputs: (a: number, b: number) => void;
|
|
@@ -82,6 +88,9 @@ export const wrappsbt_add_input_at_index: (a: number, b: number, c: number, d: n
|
|
|
82
88
|
export const wrappsbt_add_output: (a: number, b: number, c: number, d: bigint) => number;
|
|
83
89
|
export const wrappsbt_add_output_at_index: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
|
|
84
90
|
export const wrappsbt_clone: (a: number) => number;
|
|
91
|
+
export const wrappsbt_delete_input_kv: (a: number, b: number, c: number, d: number) => void;
|
|
92
|
+
export const wrappsbt_delete_kv: (a: number, b: number, c: number) => void;
|
|
93
|
+
export const wrappsbt_delete_output_kv: (a: number, b: number, c: number, d: number) => void;
|
|
85
94
|
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
86
95
|
export const wrappsbt_extract_transaction: (a: number, b: number) => void;
|
|
87
96
|
export const wrappsbt_finalize_mut: (a: number, b: number) => void;
|
|
@@ -118,20 +127,38 @@ export const wasmtransaction_input_count: (a: number) => number;
|
|
|
118
127
|
export const wasmtransaction_output_count: (a: number) => number;
|
|
119
128
|
export const wasmzcashtransaction_input_count: (a: number) => number;
|
|
120
129
|
export const wasmzcashtransaction_output_count: (a: number) => number;
|
|
121
|
-
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
122
|
-
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
123
130
|
export const wasmtransaction_lock_time: (a: number) => number;
|
|
124
131
|
export const wasmtransaction_version: (a: number) => number;
|
|
125
132
|
export const wasmzcashtransaction_lock_time: (a: number) => number;
|
|
126
133
|
export const wasmzcashtransaction_version: (a: number) => number;
|
|
127
134
|
export const wrappsbt_lock_time: (a: number) => number;
|
|
128
135
|
export const wrappsbt_version: (a: number) => number;
|
|
136
|
+
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
137
|
+
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
138
|
+
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
139
|
+
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
140
|
+
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
141
|
+
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
142
|
+
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
143
|
+
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
144
|
+
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
145
|
+
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
146
|
+
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
147
|
+
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
148
|
+
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
149
|
+
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
150
|
+
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
151
|
+
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
152
|
+
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
153
|
+
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
154
|
+
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
129
155
|
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
130
156
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
131
157
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
132
158
|
export const __wbg_messagenamespace_free: (a: number, b: number) => void;
|
|
133
159
|
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
134
160
|
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
161
|
+
export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
|
|
135
162
|
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;
|
|
136
163
|
export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
|
|
137
164
|
export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
@@ -155,6 +182,9 @@ export const bitgopsbt_combine_musig2_nonces: (a: number, b: number, c: number)
|
|
|
155
182
|
export const bitgopsbt_create_empty: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
156
183
|
export const bitgopsbt_create_empty_zcash: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
157
184
|
export const bitgopsbt_create_empty_zcash_at_height: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
185
|
+
export const bitgopsbt_delete_input_kv: (a: number, b: number, c: number, d: number) => void;
|
|
186
|
+
export const bitgopsbt_delete_kv: (a: number, b: number, c: number) => void;
|
|
187
|
+
export const bitgopsbt_delete_output_kv: (a: number, b: number, c: number, d: number) => void;
|
|
158
188
|
export const bitgopsbt_expiry_height: (a: number) => number;
|
|
159
189
|
export const bitgopsbt_extract_bitcoin_transaction: (a: number, b: number) => void;
|
|
160
190
|
export const bitgopsbt_extract_dash_transaction: (a: number, b: number) => void;
|
|
@@ -163,7 +193,10 @@ export const bitgopsbt_extract_transaction: (a: number, b: number) => void;
|
|
|
163
193
|
export const bitgopsbt_extract_zcash_transaction: (a: number, b: number) => void;
|
|
164
194
|
export const bitgopsbt_finalize_all_inputs: (a: number, b: number) => void;
|
|
165
195
|
export const bitgopsbt_from_bytes: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
166
|
-
export const bitgopsbt_from_half_signed_legacy_transaction: (a: number, b: number, c: number, d: number, e: number, f: number
|
|
196
|
+
export const bitgopsbt_from_half_signed_legacy_transaction: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
197
|
+
export const bitgopsbt_from_half_signed_legacy_transaction_dash: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
198
|
+
export const bitgopsbt_from_half_signed_legacy_transaction_zcash_with_block_height: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
199
|
+
export const bitgopsbt_from_half_signed_legacy_transaction_zcash_with_branch_id: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
167
200
|
export const bitgopsbt_generate_musig2_nonces: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
168
201
|
export const bitgopsbt_get_global_xpubs: (a: number) => number;
|
|
169
202
|
export const bitgopsbt_get_input_kv: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -210,8 +243,10 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
|
|
|
210
243
|
export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
|
|
211
244
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
212
245
|
export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
246
|
+
export const isInspectEnabled: () => number;
|
|
213
247
|
export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
|
|
214
248
|
export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
249
|
+
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
215
250
|
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
216
251
|
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
217
252
|
export const wasmdimensions_empty: () => number;
|
|
@@ -229,38 +264,12 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
|
|
|
229
264
|
export const wasmdimensions_has_segwit: (a: number) => number;
|
|
230
265
|
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
231
266
|
export const wasmdimensions_times: (a: number, b: number) => number;
|
|
267
|
+
export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
|
|
232
268
|
export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
|
|
269
|
+
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
270
|
+
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
233
271
|
export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
|
|
234
272
|
export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
|
|
235
|
-
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
236
|
-
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
237
|
-
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
238
|
-
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
239
|
-
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
240
|
-
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
241
|
-
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
242
|
-
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
243
|
-
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
244
|
-
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
245
|
-
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
246
|
-
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
247
|
-
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
248
|
-
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
249
|
-
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
250
|
-
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
251
|
-
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
252
|
-
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
253
|
-
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
254
|
-
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
255
|
-
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
256
|
-
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
257
|
-
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
258
|
-
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
259
|
-
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
260
|
-
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
261
|
-
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
262
|
-
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
263
|
-
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;
|
|
264
273
|
export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
265
274
|
export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
266
275
|
export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|
|
@@ -8,7 +8,7 @@ import { type ECPairArg } from "../ecpair.js";
|
|
|
8
8
|
import type { UtxolibName } from "../utxolibCompat.js";
|
|
9
9
|
import type { CoinName } from "../coinName.js";
|
|
10
10
|
import type { InputScriptType } from "./scriptType.js";
|
|
11
|
-
import { type ITransaction } from "../transaction.js";
|
|
11
|
+
import { Transaction, DashTransaction, type ITransaction } from "../transaction.js";
|
|
12
12
|
export type { InputScriptType };
|
|
13
13
|
export type NetworkName = UtxolibName | CoinName;
|
|
14
14
|
export type ScriptId = {
|
|
@@ -151,12 +151,17 @@ export declare class BitGoPsbt extends PsbtBase<WasmBitGoPsbt> implements IPsbtW
|
|
|
151
151
|
* with proper wallet metadata (bip32Derivation, scripts, witnessUtxo).
|
|
152
152
|
* Only supports p2sh, p2shP2wsh, and p2wsh inputs (not taproot).
|
|
153
153
|
*
|
|
154
|
-
*
|
|
154
|
+
* Supports both Bitcoin-like coins (BTC, LTC, DOGE) and Dash (DASH).
|
|
155
|
+
* Zcash is NOT supported; use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead.
|
|
156
|
+
*
|
|
157
|
+
* @param txBytesOrTx - Transaction bytes or decoded transaction instance (Bitcoin-like or Dash)
|
|
155
158
|
* @param network - Network name
|
|
156
159
|
* @param walletKeys - The wallet's root keys
|
|
157
160
|
* @param unspents - Chain, index, and value for each input
|
|
161
|
+
* @param _options - Reserved for future use and signature compatibility with subclasses
|
|
162
|
+
* @throws Error if transaction is Zcash (use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead)
|
|
158
163
|
*/
|
|
159
|
-
static fromHalfSignedLegacyTransaction(
|
|
164
|
+
static fromHalfSignedLegacyTransaction(txBytesOrTx: Uint8Array | Transaction | DashTransaction, network: NetworkName, walletKeys: WalletKeysArg, unspents: HydrationUnspent[], _options?: unknown): BitGoPsbt;
|
|
160
165
|
/**
|
|
161
166
|
* Add an input to the PSBT
|
|
162
167
|
*
|
|
@@ -4,6 +4,7 @@ import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
|
4
4
|
import { ReplayProtection } from "./ReplayProtection.js";
|
|
5
5
|
import { BIP32, isBIP32Arg } from "../bip32.js";
|
|
6
6
|
import { ECPair } from "../ecpair.js";
|
|
7
|
+
import { toCoinName } from "../coinName.js";
|
|
7
8
|
import { Transaction, DashTransaction, ZcashTransaction, } from "../transaction.js";
|
|
8
9
|
export class BitGoPsbt extends PsbtBase {
|
|
9
10
|
constructor(wasm) {
|
|
@@ -60,14 +61,32 @@ export class BitGoPsbt extends PsbtBase {
|
|
|
60
61
|
* with proper wallet metadata (bip32Derivation, scripts, witnessUtxo).
|
|
61
62
|
* Only supports p2sh, p2shP2wsh, and p2wsh inputs (not taproot).
|
|
62
63
|
*
|
|
63
|
-
*
|
|
64
|
+
* Supports both Bitcoin-like coins (BTC, LTC, DOGE) and Dash (DASH).
|
|
65
|
+
* Zcash is NOT supported; use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead.
|
|
66
|
+
*
|
|
67
|
+
* @param txBytesOrTx - Transaction bytes or decoded transaction instance (Bitcoin-like or Dash)
|
|
64
68
|
* @param network - Network name
|
|
65
69
|
* @param walletKeys - The wallet's root keys
|
|
66
70
|
* @param unspents - Chain, index, and value for each input
|
|
71
|
+
* @param _options - Reserved for future use and signature compatibility with subclasses
|
|
72
|
+
* @throws Error if transaction is Zcash (use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead)
|
|
67
73
|
*/
|
|
68
|
-
static fromHalfSignedLegacyTransaction(
|
|
74
|
+
static fromHalfSignedLegacyTransaction(txBytesOrTx, network, walletKeys, unspents,
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
+
_options) {
|
|
69
77
|
const keys = RootWalletKeys.from(walletKeys);
|
|
70
|
-
|
|
78
|
+
// Parse bytes to Transaction if needed
|
|
79
|
+
const tx = txBytesOrTx instanceof Uint8Array
|
|
80
|
+
? Transaction.fromBytes(txBytesOrTx, toCoinName(network))
|
|
81
|
+
: txBytesOrTx;
|
|
82
|
+
// Validate that this is not a Zcash transaction
|
|
83
|
+
if (tx instanceof ZcashTransaction) {
|
|
84
|
+
throw new Error("Use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction() for Zcash transactions");
|
|
85
|
+
}
|
|
86
|
+
// Pass WASM transaction directly to avoid serialization round-trip
|
|
87
|
+
const wasm = tx instanceof DashTransaction
|
|
88
|
+
? WasmBitGoPsbt.from_half_signed_legacy_transaction_dash(tx.wasm, network, keys.wasm, unspents)
|
|
89
|
+
: WasmBitGoPsbt.from_half_signed_legacy_transaction(tx.wasm, network, keys.wasm, unspents);
|
|
71
90
|
return new BitGoPsbt(wasm);
|
|
72
91
|
}
|
|
73
92
|
addInputAtIndex(index, txidOrOptions, voutOrScript, value, script, sequence) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
|
-
import { BitGoPsbt, type CreateEmptyOptions } from "./BitGoPsbt.js";
|
|
3
|
-
import { ZcashTransaction } from "../transaction.js";
|
|
2
|
+
import { BitGoPsbt, type CreateEmptyOptions, type HydrationUnspent } from "./BitGoPsbt.js";
|
|
3
|
+
import { ZcashTransaction, type ITransaction } from "../transaction.js";
|
|
4
4
|
/** Zcash network names */
|
|
5
5
|
export type ZcashNetworkName = "zcash" | "zcashTest" | "zec" | "tzec";
|
|
6
6
|
/** Options for creating an empty Zcash PSBT (preferred method using block height) */
|
|
@@ -101,6 +101,51 @@ export declare class ZcashBitGoPsbt extends BitGoPsbt {
|
|
|
101
101
|
* @returns A ZcashBitGoPsbt instance
|
|
102
102
|
*/
|
|
103
103
|
static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashBitGoPsbt;
|
|
104
|
+
/**
|
|
105
|
+
* Reconstruct a Zcash PSBT from a half-signed legacy transaction
|
|
106
|
+
*
|
|
107
|
+
* This is the inverse of `getHalfSignedLegacyFormat()` for Zcash. It decodes the Zcash wire
|
|
108
|
+
* format (which includes version_group_id, expiry_height, and sapling fields), extracts
|
|
109
|
+
* partial signatures, and reconstructs a proper Zcash PSBT with consensus metadata.
|
|
110
|
+
*
|
|
111
|
+
* Supports two modes for determining consensus_branch_id:
|
|
112
|
+
* - **Recommended**: Pass `blockHeight` to auto-determine consensus_branch_id via network upgrade activation heights
|
|
113
|
+
* - **Advanced**: Pass `consensusBranchId` directly if you already know it (e.g., 0xC2D6D0B4 for NU5)
|
|
114
|
+
*
|
|
115
|
+
* @param txBytesOrTx - Either serialized Zcash transaction bytes or a decoded ZcashTransaction instance
|
|
116
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
117
|
+
* @param walletKeys - The wallet's root keys
|
|
118
|
+
* @param unspents - Chain, index, and value for each input
|
|
119
|
+
* @param options - Either `{ blockHeight: number }` or `{ consensusBranchId: number }`
|
|
120
|
+
* @returns A ZcashBitGoPsbt instance
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Round-trip with block height (recommended)
|
|
125
|
+
* const legacyBytes = psbt.getHalfSignedLegacyFormat();
|
|
126
|
+
* const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
|
|
127
|
+
* legacyBytes,
|
|
128
|
+
* "zec",
|
|
129
|
+
* walletKeys,
|
|
130
|
+
* unspents,
|
|
131
|
+
* { blockHeight: 1687105 } // NU5 activation height
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* // Or with explicit consensus branch ID
|
|
135
|
+
* const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
|
|
136
|
+
* legacyBytes,
|
|
137
|
+
* "zec",
|
|
138
|
+
* walletKeys,
|
|
139
|
+
* unspents,
|
|
140
|
+
* { consensusBranchId: 0xC2D6D0B4 } // NU5 branch ID
|
|
141
|
+
* );
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
static fromHalfSignedLegacyTransaction(txBytesOrTx: Uint8Array | ITransaction, network: ZcashNetworkName, walletKeys: WalletKeysArg, unspents: HydrationUnspent[], options: {
|
|
145
|
+
blockHeight: number;
|
|
146
|
+
} | {
|
|
147
|
+
consensusBranchId: number;
|
|
148
|
+
}): ZcashBitGoPsbt;
|
|
104
149
|
/**
|
|
105
150
|
* Get the Zcash version group ID
|
|
106
151
|
* @returns The version group ID (e.g., 0x892F2085 for Sapling)
|
|
@@ -93,6 +93,60 @@ export class ZcashBitGoPsbt extends BitGoPsbt {
|
|
|
93
93
|
const wasm = WasmBitGoPsbt.from_bytes(bytes, network);
|
|
94
94
|
return new ZcashBitGoPsbt(wasm);
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Reconstruct a Zcash PSBT from a half-signed legacy transaction
|
|
98
|
+
*
|
|
99
|
+
* This is the inverse of `getHalfSignedLegacyFormat()` for Zcash. It decodes the Zcash wire
|
|
100
|
+
* format (which includes version_group_id, expiry_height, and sapling fields), extracts
|
|
101
|
+
* partial signatures, and reconstructs a proper Zcash PSBT with consensus metadata.
|
|
102
|
+
*
|
|
103
|
+
* Supports two modes for determining consensus_branch_id:
|
|
104
|
+
* - **Recommended**: Pass `blockHeight` to auto-determine consensus_branch_id via network upgrade activation heights
|
|
105
|
+
* - **Advanced**: Pass `consensusBranchId` directly if you already know it (e.g., 0xC2D6D0B4 for NU5)
|
|
106
|
+
*
|
|
107
|
+
* @param txBytesOrTx - Either serialized Zcash transaction bytes or a decoded ZcashTransaction instance
|
|
108
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
109
|
+
* @param walletKeys - The wallet's root keys
|
|
110
|
+
* @param unspents - Chain, index, and value for each input
|
|
111
|
+
* @param options - Either `{ blockHeight: number }` or `{ consensusBranchId: number }`
|
|
112
|
+
* @returns A ZcashBitGoPsbt instance
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Round-trip with block height (recommended)
|
|
117
|
+
* const legacyBytes = psbt.getHalfSignedLegacyFormat();
|
|
118
|
+
* const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
|
|
119
|
+
* legacyBytes,
|
|
120
|
+
* "zec",
|
|
121
|
+
* walletKeys,
|
|
122
|
+
* unspents,
|
|
123
|
+
* { blockHeight: 1687105 } // NU5 activation height
|
|
124
|
+
* );
|
|
125
|
+
*
|
|
126
|
+
* // Or with explicit consensus branch ID
|
|
127
|
+
* const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
|
|
128
|
+
* legacyBytes,
|
|
129
|
+
* "zec",
|
|
130
|
+
* walletKeys,
|
|
131
|
+
* unspents,
|
|
132
|
+
* { consensusBranchId: 0xC2D6D0B4 } // NU5 branch ID
|
|
133
|
+
* );
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
static fromHalfSignedLegacyTransaction(txBytesOrTx, network, walletKeys, unspents, options) {
|
|
137
|
+
const keys = RootWalletKeys.from(walletKeys);
|
|
138
|
+
const tx = txBytesOrTx instanceof Uint8Array
|
|
139
|
+
? ZcashTransaction.fromBytes(txBytesOrTx)
|
|
140
|
+
: txBytesOrTx;
|
|
141
|
+
if ("blockHeight" in options) {
|
|
142
|
+
const wasm = WasmBitGoPsbt.from_half_signed_legacy_transaction_zcash_with_block_height(tx.wasm, network, keys.wasm, unspents, options.blockHeight);
|
|
143
|
+
return new ZcashBitGoPsbt(wasm);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const wasm = WasmBitGoPsbt.from_half_signed_legacy_transaction_zcash_with_branch_id(tx.wasm, network, keys.wasm, unspents, options.consensusBranchId);
|
|
147
|
+
return new ZcashBitGoPsbt(wasm);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
96
150
|
// --- Zcash-specific getters ---
|
|
97
151
|
/**
|
|
98
152
|
* Get the Zcash version group ID
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OutputScriptType } from "./scriptType.js";
|
|
2
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];
|
|
3
|
+
export declare const chainCodes: readonly [0, 1, 10, 11, 20, 21, 30, 31, 40, 41, 360, 361];
|
|
4
4
|
/** A valid chain code value */
|
|
5
5
|
export type ChainCode = (typeof chainCodes)[number];
|
|
6
6
|
/** Whether a chain is for receiving (external) or change (internal) addresses */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { FixedScriptWalletNamespace } from "../wasm/wasm_utxo.js";
|
|
8
8
|
/** All valid chain codes as a const tuple */
|
|
9
|
-
export const chainCodes = [0, 1, 10, 11, 20, 21, 30, 31, 40, 41];
|
|
9
|
+
export const chainCodes = [0, 1, 10, 11, 20, 21, 30, 31, 40, 41, 360, 361];
|
|
10
10
|
// Build static lookup tables once at module load time
|
|
11
11
|
const chainCodeSet = new Set(chainCodes);
|
|
12
12
|
const chainToMeta = new Map();
|
package/dist/esm/js/psbt.d.ts
CHANGED
|
@@ -12,10 +12,13 @@ export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData>
|
|
|
12
12
|
removeOutput(index: number): void;
|
|
13
13
|
setKV(key: PsbtKvKey, value: Uint8Array): void;
|
|
14
14
|
getKV(key: PsbtKvKey): Uint8Array | undefined;
|
|
15
|
+
deleteKV(key: PsbtKvKey): void;
|
|
15
16
|
setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
16
17
|
getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
18
|
+
deleteInputKV(index: number, key: PsbtKvKey): void;
|
|
17
19
|
setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
|
|
18
20
|
getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
|
|
21
|
+
deleteOutputKV(index: number, key: PsbtKvKey): void;
|
|
19
22
|
}
|
|
20
23
|
/** Extended PSBT with address resolution (no coin parameter needed) */
|
|
21
24
|
export interface IPsbtWithAddress extends IPsbt {
|