Skip to content

Commit 321fd51

Browse files
committed
fix: add P2MR chain codes and remove unnecessary BitGoSignet fixture
Add chain codes 360/361 to the TypeScript chainCodes array so the WASM chain_code_table() entries for P2MR don't crash at module load time. Skip P2MR in utxo-lib comparison tests since utxo-lib won't add P2MR support. Restore the bitcoinBitGoSignet -> bitcoinPublicSignet fixture mapping that was incorrectly removed. Ticket: BTC-3241
1 parent 73de89f commit 321fd51

5 files changed

Lines changed: 11 additions & 147 deletions

File tree

packages/wasm-utxo/js/fixedScriptWallet/chains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { FixedScriptWalletNamespace } from "../wasm/wasm_utxo.js";
88
import type { OutputScriptType } from "./scriptType.js";
99

1010
/** All valid chain codes as a const tuple */
11-
export const chainCodes = [0, 1, 10, 11, 20, 21, 30, 31, 40, 41] as const;
11+
export const chainCodes = [0, 1, 10, 11, 20, 21, 30, 31, 40, 41, 360, 361] as const;
1212

1313
/** A valid chain code value */
1414
export type ChainCode = (typeof chainCodes)[number];

packages/wasm-utxo/src/address/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ mod tests {
462462
"bitcoin.json" => vec![&BITCOIN as &dyn AddressCodec, &BITCOIN_BECH32],
463463
"testnet.json" => vec![&TESTNET, &TESTNET_BECH32],
464464
"bitcoinPublicSignet.json" => vec![&TESTNET, &TESTNET_BECH32],
465-
"bitcoinBitGoSignet.json" => vec![&TESTNET, &TESTNET_BECH32],
466465
"bitcoincash.json" => vec![&BITCOIN_CASH],
467466
"bitcoincash-cashaddr.json" => vec![&BITCOIN_CASH_CASHADDR],
468467
"bitcoincashTestnet.json" => vec![&BITCOIN_CASH_TESTNET],

packages/wasm-utxo/test/address/utxolibCompat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const __dirname = dirname(__filename);
1414
type Fixture = [type: string, script: string, address: string];
1515

1616
async function getFixtures(name: string, addressFormat?: AddressFormat): Promise<Fixture[]> {
17+
if (name === "bitcoinBitGoSignet") {
18+
name = "bitcoinPublicSignet";
19+
}
1720
const filename = addressFormat ? `${name}-${addressFormat}` : name;
1821
const fixturePath = path.join(__dirname, "..", "fixtures", "address", `${filename}.json`);
1922
const fixtures = await fs.readFile(fixturePath, "utf8");

packages/wasm-utxo/test/fixedScript/chains.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import { fixedScriptWallet } from "../../js/index.js";
66

77
const { ChainCode, chainCodes } = fixedScriptWallet;
88

9+
// P2MR (360, 361) is wasm-only and not in utxo-lib
10+
const utxolibChainCodes = chainCodes.filter((c) => c !== 360 && c !== 361);
11+
912
describe("ChainCode", function () {
1013
describe("chainCodes array", function () {
1114
it("matches utxo-lib chainCodes", function () {
12-
assert.deepStrictEqual([...chainCodes], [...utxolib.bitgo.chainCodes]);
15+
assert.deepStrictEqual([...utxolibChainCodes], [...utxolib.bitgo.chainCodes]);
1316
});
1417

1518
it("has expected values", function () {
16-
assert.deepStrictEqual([...chainCodes], [0, 1, 10, 11, 20, 21, 30, 31, 40, 41]);
19+
assert.deepStrictEqual([...chainCodes], [0, 1, 10, 11, 20, 21, 30, 31, 40, 41, 360, 361]);
1720
});
1821
});
1922

@@ -69,7 +72,7 @@ describe("ChainCode", function () {
6972
});
7073

7174
it("matches utxo-lib isExternalChainCode/isInternalChainCode", function () {
72-
for (const code of chainCodes) {
75+
for (const code of utxolibChainCodes) {
7376
const wasmScope = ChainCode.scope(code);
7477
const utxolibIsExternal = utxolib.bitgo.isExternalChainCode(code);
7578
const utxolibIsInternal = utxolib.bitgo.isInternalChainCode(code);
@@ -127,7 +130,7 @@ describe("ChainCode", function () {
127130
});
128131

129132
it("matches utxo-lib scriptTypeForChain", function () {
130-
for (const code of chainCodes) {
133+
for (const code of utxolibChainCodes) {
131134
const wasmType = ChainCode.scriptType(code);
132135
const utxolibType = utxolib.bitgo.scriptTypeForChain(code);
133136

packages/wasm-utxo/test/fixtures/address/bitcoinBitGoSignet.json

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)