@bitgo/wasm-utxo 4.19.0 → 4.20.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/index.d.ts +1 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +4 -1
- package/dist/cjs/js/fixedScriptWallet/prevTx.d.ts +36 -0
- package/dist/cjs/js/fixedScriptWallet/prevTx.js +50 -0
- package/dist/cjs/js/index.d.ts +1 -0
- package/dist/cjs/js/index.js +3 -1
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/esm/js/fixedScriptWallet/index.js +2 -0
- package/dist/esm/js/fixedScriptWallet/prevTx.d.ts +36 -0
- package/dist/esm/js/fixedScriptWallet/prevTx.js +47 -0
- package/dist/esm/js/index.d.ts +1 -0
- package/dist/esm/js/index.js +1 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ export { outputScript, address } from "./address.js";
|
|
|
5
5
|
export { Dimensions } from "./Dimensions.js";
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, type OutputScriptType, type InputScriptType, type ScriptType, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js";
|
|
8
|
+
export { requiresPrevTxForP2sh } from "./prevTx.js";
|
|
8
9
|
export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
|
|
9
10
|
export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
|
|
10
11
|
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.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
3
|
+
exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
4
4
|
exports.supportsScriptType = supportsScriptType;
|
|
5
5
|
exports.createOpReturnScript = createOpReturnScript;
|
|
6
6
|
exports.p2shP2pkOutputScript = p2shP2pkOutputScript;
|
|
@@ -21,6 +21,9 @@ var chains_js_1 = require("./chains.js");
|
|
|
21
21
|
Object.defineProperty(exports, "ChainCode", { enumerable: true, get: function () { return chains_js_1.ChainCode; } });
|
|
22
22
|
Object.defineProperty(exports, "chainCodes", { enumerable: true, get: function () { return chains_js_1.chainCodes; } });
|
|
23
23
|
Object.defineProperty(exports, "assertChainCode", { enumerable: true, get: function () { return chains_js_1.assertChainCode; } });
|
|
24
|
+
// Previous-transaction inclusion policy (pure JS, no WASM init)
|
|
25
|
+
var prevTx_js_1 = require("./prevTx.js");
|
|
26
|
+
Object.defineProperty(exports, "requiresPrevTxForP2sh", { enumerable: true, get: function () { return prevTx_js_1.requiresPrevTxForP2sh; } });
|
|
24
27
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
25
28
|
var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
|
|
26
29
|
Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Previous-transaction inclusion policy for fixed-script wallet PSBT inputs.
|
|
3
|
+
*
|
|
4
|
+
* Decides whether a p2sh input requires the full previous transaction
|
|
5
|
+
* (PSBT_IN_NON_WITNESS_UTXO) or can be signed from witness_utxo-only.
|
|
6
|
+
*
|
|
7
|
+
* This is a pure-JS module (no WASM initialization) so callers can evaluate
|
|
8
|
+
* the policy cheaply without loading the wasm-utxo module.
|
|
9
|
+
*/
|
|
10
|
+
import { type CoinName } from "../coinName.js";
|
|
11
|
+
/**
|
|
12
|
+
* Whether a p2sh input requires the full previous transaction
|
|
13
|
+
* (PSBT_IN_NON_WITNESS_UTXO). Callers are expected to have already
|
|
14
|
+
* confirmed the input is p2sh (non-segwit) and that the tx format
|
|
15
|
+
* includes prevTx (e.g. "psbt", not "psbt-lite"); this predicate only
|
|
16
|
+
* answers the coin-level question.
|
|
17
|
+
*
|
|
18
|
+
* Returns false for value-committing coins whose sighash commits the
|
|
19
|
+
* input amount, making `non_witness_utxo` (full prevTx) cryptographically
|
|
20
|
+
* pointless for signing p2sh inputs — `witness_utxo` (value +
|
|
21
|
+
* scriptPubKey) suffices:
|
|
22
|
+
*
|
|
23
|
+
* - Zcash (`zec`/`tzec`): ZIP-243 transparent sighash commits the amount.
|
|
24
|
+
* Including prevTx also crashes wasm-utxo, whose consensus::deserialize
|
|
25
|
+
* rejects Zcash overwintered transactions.
|
|
26
|
+
* - BCH family (`bch`/`bcha`/`bsv`/`btg` + testnets): replay-protected
|
|
27
|
+
* BIP-143 sighash (SIGHASH_FORKID, the default for the whole family)
|
|
28
|
+
* commits the 8-byte value as preimage item #6. eCash is `bcha`/`tbcha`.
|
|
29
|
+
* For the BCH family, skipping prevTx is an optimization (no DB fetch)
|
|
30
|
+
* plus defense-in-depth, with the same fee-validation risk that the
|
|
31
|
+
* existing `psbt-lite` path already accepts for all coins.
|
|
32
|
+
*
|
|
33
|
+
* Testnets are normalized via `getMainnet` before the switch. True
|
|
34
|
+
* otherwise.
|
|
35
|
+
*/
|
|
36
|
+
export declare function requiresPrevTxForP2sh(coinName: CoinName): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requiresPrevTxForP2sh = requiresPrevTxForP2sh;
|
|
4
|
+
/**
|
|
5
|
+
* Previous-transaction inclusion policy for fixed-script wallet PSBT inputs.
|
|
6
|
+
*
|
|
7
|
+
* Decides whether a p2sh input requires the full previous transaction
|
|
8
|
+
* (PSBT_IN_NON_WITNESS_UTXO) or can be signed from witness_utxo-only.
|
|
9
|
+
*
|
|
10
|
+
* This is a pure-JS module (no WASM initialization) so callers can evaluate
|
|
11
|
+
* the policy cheaply without loading the wasm-utxo module.
|
|
12
|
+
*/
|
|
13
|
+
const coinName_js_1 = require("../coinName.js");
|
|
14
|
+
/**
|
|
15
|
+
* Whether a p2sh input requires the full previous transaction
|
|
16
|
+
* (PSBT_IN_NON_WITNESS_UTXO). Callers are expected to have already
|
|
17
|
+
* confirmed the input is p2sh (non-segwit) and that the tx format
|
|
18
|
+
* includes prevTx (e.g. "psbt", not "psbt-lite"); this predicate only
|
|
19
|
+
* answers the coin-level question.
|
|
20
|
+
*
|
|
21
|
+
* Returns false for value-committing coins whose sighash commits the
|
|
22
|
+
* input amount, making `non_witness_utxo` (full prevTx) cryptographically
|
|
23
|
+
* pointless for signing p2sh inputs — `witness_utxo` (value +
|
|
24
|
+
* scriptPubKey) suffices:
|
|
25
|
+
*
|
|
26
|
+
* - Zcash (`zec`/`tzec`): ZIP-243 transparent sighash commits the amount.
|
|
27
|
+
* Including prevTx also crashes wasm-utxo, whose consensus::deserialize
|
|
28
|
+
* rejects Zcash overwintered transactions.
|
|
29
|
+
* - BCH family (`bch`/`bcha`/`bsv`/`btg` + testnets): replay-protected
|
|
30
|
+
* BIP-143 sighash (SIGHASH_FORKID, the default for the whole family)
|
|
31
|
+
* commits the 8-byte value as preimage item #6. eCash is `bcha`/`tbcha`.
|
|
32
|
+
* For the BCH family, skipping prevTx is an optimization (no DB fetch)
|
|
33
|
+
* plus defense-in-depth, with the same fee-validation risk that the
|
|
34
|
+
* existing `psbt-lite` path already accepts for all coins.
|
|
35
|
+
*
|
|
36
|
+
* Testnets are normalized via `getMainnet` before the switch. True
|
|
37
|
+
* otherwise.
|
|
38
|
+
*/
|
|
39
|
+
function requiresPrevTxForP2sh(coinName) {
|
|
40
|
+
switch ((0, coinName_js_1.getMainnet)(coinName)) {
|
|
41
|
+
case "zec": // Zcash (ZIP-243)
|
|
42
|
+
case "bch": // Bitcoin Cash (BIP-143/FORKID)
|
|
43
|
+
case "bcha": // eCash (BIP-143/FORKID)
|
|
44
|
+
case "bsv": // Bitcoin SV (BIP-143/FORKID)
|
|
45
|
+
case "btg": // Bitcoin Gold (BIP-143/FORKID)
|
|
46
|
+
return false;
|
|
47
|
+
default:
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type WasmUtxoVersionInfo = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function getWasmUtxoVersion(): WasmUtxoVersionInfo;
|
|
19
19
|
export { type CoinName, getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
20
|
+
export { requiresPrevTxForP2sh } from "./fixedScriptWallet/prevTx.js";
|
|
20
21
|
export type { Triple } from "./triple.js";
|
|
21
22
|
export type { AddressFormat } from "./address.js";
|
|
22
23
|
export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.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.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.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;
|
|
37
37
|
exports.getWasmUtxoVersion = getWasmUtxoVersion;
|
|
38
38
|
exports.isWasmUtxoError = isWasmUtxoError;
|
|
39
39
|
const wasm = __importStar(require("./wasm/wasm_utxo.js"));
|
|
@@ -68,6 +68,8 @@ Object.defineProperty(exports, "getMainnet", { enumerable: true, get: function (
|
|
|
68
68
|
Object.defineProperty(exports, "isMainnet", { enumerable: true, get: function () { return coinName_js_1.isMainnet; } });
|
|
69
69
|
Object.defineProperty(exports, "isTestnet", { enumerable: true, get: function () { return coinName_js_1.isTestnet; } });
|
|
70
70
|
Object.defineProperty(exports, "isCoinName", { enumerable: true, get: function () { return coinName_js_1.isCoinName; } });
|
|
71
|
+
var prevTx_js_1 = require("./fixedScriptWallet/prevTx.js");
|
|
72
|
+
Object.defineProperty(exports, "requiresPrevTxForP2sh", { enumerable: true, get: function () { return prevTx_js_1.requiresPrevTxForP2sh; } });
|
|
71
73
|
const WASM_UTXO_ERROR_SYMBOL = Symbol.for("@bitgo/wasm-utxo/error");
|
|
72
74
|
function isWasmUtxoError(e) {
|
|
73
75
|
return (e instanceof Error &&
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ export { outputScript, address } from "./address.js";
|
|
|
5
5
|
export { Dimensions } from "./Dimensions.js";
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, type OutputScriptType, type InputScriptType, type ScriptType, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js";
|
|
8
|
+
export { requiresPrevTxForP2sh } from "./prevTx.js";
|
|
8
9
|
export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
|
|
9
10
|
export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
|
|
10
11
|
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
@@ -5,6 +5,8 @@ export { outputScript, address } from "./address.js";
|
|
|
5
5
|
export { Dimensions } from "./Dimensions.js";
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode } from "./chains.js";
|
|
8
|
+
// Previous-transaction inclusion policy (pure JS, no WASM init)
|
|
9
|
+
export { requiresPrevTxForP2sh } from "./prevTx.js";
|
|
8
10
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
9
11
|
export { BitGoPsbt, getWalletKeysFromPsbt, } from "./BitGoPsbt.js";
|
|
10
12
|
export { BitGoKeySubtype } from "./BitGoKeySubtype.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Previous-transaction inclusion policy for fixed-script wallet PSBT inputs.
|
|
3
|
+
*
|
|
4
|
+
* Decides whether a p2sh input requires the full previous transaction
|
|
5
|
+
* (PSBT_IN_NON_WITNESS_UTXO) or can be signed from witness_utxo-only.
|
|
6
|
+
*
|
|
7
|
+
* This is a pure-JS module (no WASM initialization) so callers can evaluate
|
|
8
|
+
* the policy cheaply without loading the wasm-utxo module.
|
|
9
|
+
*/
|
|
10
|
+
import { type CoinName } from "../coinName.js";
|
|
11
|
+
/**
|
|
12
|
+
* Whether a p2sh input requires the full previous transaction
|
|
13
|
+
* (PSBT_IN_NON_WITNESS_UTXO). Callers are expected to have already
|
|
14
|
+
* confirmed the input is p2sh (non-segwit) and that the tx format
|
|
15
|
+
* includes prevTx (e.g. "psbt", not "psbt-lite"); this predicate only
|
|
16
|
+
* answers the coin-level question.
|
|
17
|
+
*
|
|
18
|
+
* Returns false for value-committing coins whose sighash commits the
|
|
19
|
+
* input amount, making `non_witness_utxo` (full prevTx) cryptographically
|
|
20
|
+
* pointless for signing p2sh inputs — `witness_utxo` (value +
|
|
21
|
+
* scriptPubKey) suffices:
|
|
22
|
+
*
|
|
23
|
+
* - Zcash (`zec`/`tzec`): ZIP-243 transparent sighash commits the amount.
|
|
24
|
+
* Including prevTx also crashes wasm-utxo, whose consensus::deserialize
|
|
25
|
+
* rejects Zcash overwintered transactions.
|
|
26
|
+
* - BCH family (`bch`/`bcha`/`bsv`/`btg` + testnets): replay-protected
|
|
27
|
+
* BIP-143 sighash (SIGHASH_FORKID, the default for the whole family)
|
|
28
|
+
* commits the 8-byte value as preimage item #6. eCash is `bcha`/`tbcha`.
|
|
29
|
+
* For the BCH family, skipping prevTx is an optimization (no DB fetch)
|
|
30
|
+
* plus defense-in-depth, with the same fee-validation risk that the
|
|
31
|
+
* existing `psbt-lite` path already accepts for all coins.
|
|
32
|
+
*
|
|
33
|
+
* Testnets are normalized via `getMainnet` before the switch. True
|
|
34
|
+
* otherwise.
|
|
35
|
+
*/
|
|
36
|
+
export declare function requiresPrevTxForP2sh(coinName: CoinName): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Previous-transaction inclusion policy for fixed-script wallet PSBT inputs.
|
|
3
|
+
*
|
|
4
|
+
* Decides whether a p2sh input requires the full previous transaction
|
|
5
|
+
* (PSBT_IN_NON_WITNESS_UTXO) or can be signed from witness_utxo-only.
|
|
6
|
+
*
|
|
7
|
+
* This is a pure-JS module (no WASM initialization) so callers can evaluate
|
|
8
|
+
* the policy cheaply without loading the wasm-utxo module.
|
|
9
|
+
*/
|
|
10
|
+
import { getMainnet } from "../coinName.js";
|
|
11
|
+
/**
|
|
12
|
+
* Whether a p2sh input requires the full previous transaction
|
|
13
|
+
* (PSBT_IN_NON_WITNESS_UTXO). Callers are expected to have already
|
|
14
|
+
* confirmed the input is p2sh (non-segwit) and that the tx format
|
|
15
|
+
* includes prevTx (e.g. "psbt", not "psbt-lite"); this predicate only
|
|
16
|
+
* answers the coin-level question.
|
|
17
|
+
*
|
|
18
|
+
* Returns false for value-committing coins whose sighash commits the
|
|
19
|
+
* input amount, making `non_witness_utxo` (full prevTx) cryptographically
|
|
20
|
+
* pointless for signing p2sh inputs — `witness_utxo` (value +
|
|
21
|
+
* scriptPubKey) suffices:
|
|
22
|
+
*
|
|
23
|
+
* - Zcash (`zec`/`tzec`): ZIP-243 transparent sighash commits the amount.
|
|
24
|
+
* Including prevTx also crashes wasm-utxo, whose consensus::deserialize
|
|
25
|
+
* rejects Zcash overwintered transactions.
|
|
26
|
+
* - BCH family (`bch`/`bcha`/`bsv`/`btg` + testnets): replay-protected
|
|
27
|
+
* BIP-143 sighash (SIGHASH_FORKID, the default for the whole family)
|
|
28
|
+
* commits the 8-byte value as preimage item #6. eCash is `bcha`/`tbcha`.
|
|
29
|
+
* For the BCH family, skipping prevTx is an optimization (no DB fetch)
|
|
30
|
+
* plus defense-in-depth, with the same fee-validation risk that the
|
|
31
|
+
* existing `psbt-lite` path already accepts for all coins.
|
|
32
|
+
*
|
|
33
|
+
* Testnets are normalized via `getMainnet` before the switch. True
|
|
34
|
+
* otherwise.
|
|
35
|
+
*/
|
|
36
|
+
export function requiresPrevTxForP2sh(coinName) {
|
|
37
|
+
switch (getMainnet(coinName)) {
|
|
38
|
+
case "zec": // Zcash (ZIP-243)
|
|
39
|
+
case "bch": // Bitcoin Cash (BIP-143/FORKID)
|
|
40
|
+
case "bcha": // eCash (BIP-143/FORKID)
|
|
41
|
+
case "bsv": // Bitcoin SV (BIP-143/FORKID)
|
|
42
|
+
case "btg": // Bitcoin Gold (BIP-143/FORKID)
|
|
43
|
+
return false;
|
|
44
|
+
default:
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type WasmUtxoVersionInfo = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function getWasmUtxoVersion(): WasmUtxoVersionInfo;
|
|
19
19
|
export { type CoinName, getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
20
|
+
export { requiresPrevTxForP2sh } from "./fixedScriptWallet/prevTx.js";
|
|
20
21
|
export type { Triple } from "./triple.js";
|
|
21
22
|
export type { AddressFormat } from "./address.js";
|
|
22
23
|
export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export function getWasmUtxoVersion() {
|
|
|
23
23
|
return WasmUtxoNamespace.get_wasm_utxo_version();
|
|
24
24
|
}
|
|
25
25
|
export { getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
26
|
+
export { requiresPrevTxForP2sh } from "./fixedScriptWallet/prevTx.js";
|
|
26
27
|
const WASM_UTXO_ERROR_SYMBOL = Symbol.for("@bitgo/wasm-utxo/error");
|
|
27
28
|
export function isWasmUtxoError(e) {
|
|
28
29
|
return (e instanceof Error &&
|
|
Binary file
|