@bitgo/wasm-utxo 1.4.0 → 1.6.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/{ast → js/ast}/formatNode.js +2 -2
- package/dist/cjs/{ast → js/ast}/fromWasmNode.js +2 -1
- package/dist/{esm → cjs/js}/fixedScriptWallet.d.ts +21 -0
- package/dist/cjs/{fixedScriptWallet.js → js/fixedScriptWallet.js} +25 -0
- package/dist/{esm → cjs/js}/wasm/wasm_utxo.d.ts +29 -0
- package/dist/cjs/{wasm → js/wasm}/wasm_utxo.js +77 -0
- package/dist/{esm → cjs/js}/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/{wasm → js/wasm}/wasm_utxo_bg.wasm.d.ts +19 -16
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/esm/{ast → js/ast}/formatNode.js +2 -2
- package/dist/esm/{ast → js/ast}/fromWasmNode.js +2 -1
- package/dist/{cjs → esm/js}/fixedScriptWallet.d.ts +21 -0
- package/dist/esm/{fixedScriptWallet.js → js/fixedScriptWallet.js} +25 -0
- package/dist/{cjs → esm/js}/wasm/wasm_utxo.d.ts +29 -0
- package/dist/esm/{wasm → js/wasm}/wasm_utxo_bg.js +77 -0
- package/dist/{cjs → esm/js}/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/{wasm → js/wasm}/wasm_utxo_bg.wasm.d.ts +19 -16
- package/dist/esm/test/address/utxolibCompat.d.ts +1 -0
- package/dist/esm/test/address/utxolibCompat.js +107 -0
- package/dist/esm/test/ast/formatNode.d.ts +1 -0
- package/dist/esm/test/ast/formatNode.js +15 -0
- package/dist/esm/test/descriptorFixtures.d.ts +25 -0
- package/dist/esm/test/descriptorFixtures.js +605 -0
- package/dist/esm/test/descriptorUtil.d.ts +13 -0
- package/dist/esm/test/descriptorUtil.js +52 -0
- package/dist/esm/test/fixedScript/address.d.ts +1 -0
- package/dist/esm/test/fixedScript/address.js +66 -0
- package/dist/esm/test/fixedScript/finalizeExtract.d.ts +1 -0
- package/dist/esm/test/fixedScript/finalizeExtract.js +66 -0
- package/dist/esm/test/fixedScript/fixtureUtil.d.ts +93 -0
- package/dist/esm/test/fixedScript/fixtureUtil.js +44 -0
- package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.d.ts +1 -0
- package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.js +168 -0
- package/dist/esm/test/fixedScript/verifySignature.d.ts +1 -0
- package/dist/esm/test/fixedScript/verifySignature.js +141 -0
- package/dist/esm/test/fixedScriptToDescriptor.d.ts +1 -0
- package/dist/esm/test/fixedScriptToDescriptor.js +93 -0
- package/dist/esm/test/fixtures.d.ts +1 -0
- package/dist/esm/test/fixtures.js +16 -0
- package/dist/esm/test/opdrop.d.ts +1 -0
- package/dist/esm/test/opdrop.js +85 -0
- package/dist/esm/test/psbt.util.d.ts +8 -0
- package/dist/esm/test/psbt.util.js +113 -0
- package/dist/esm/test/psbtFixedScriptCompat.d.ts +1 -0
- package/dist/esm/test/psbtFixedScriptCompat.js +116 -0
- package/dist/esm/test/psbtFixedScriptCompatFixtures.d.ts +10 -0
- package/dist/esm/test/psbtFixedScriptCompatFixtures.js +53 -0
- package/dist/esm/test/psbtFromDescriptor.d.ts +1 -0
- package/dist/esm/test/psbtFromDescriptor.js +104 -0
- package/dist/esm/test/psbtFromDescriptor.util.d.ts +63 -0
- package/dist/esm/test/psbtFromDescriptor.util.js +101 -0
- package/dist/esm/test/test.d.ts +1 -0
- package/dist/esm/test/test.js +123 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +19 -14
- /package/dist/cjs/{address.d.ts → js/address.d.ts} +0 -0
- /package/dist/cjs/{address.js → js/address.js} +0 -0
- /package/dist/cjs/{ast → js/ast}/formatNode.d.ts +0 -0
- /package/dist/cjs/{ast → js/ast}/fromWasmNode.d.ts +0 -0
- /package/dist/cjs/{ast → js/ast}/index.d.ts +0 -0
- /package/dist/cjs/{ast → js/ast}/index.js +0 -0
- /package/dist/cjs/{coinName.d.ts → js/coinName.d.ts} +0 -0
- /package/dist/cjs/{coinName.js → js/coinName.js} +0 -0
- /package/dist/cjs/{index.d.ts → js/index.d.ts} +0 -0
- /package/dist/cjs/{index.js → js/index.js} +0 -0
- /package/dist/cjs/{triple.d.ts → js/triple.d.ts} +0 -0
- /package/dist/cjs/{triple.js → js/triple.js} +0 -0
- /package/dist/cjs/{utxolibCompat.d.ts → js/utxolibCompat.d.ts} +0 -0
- /package/dist/cjs/{utxolibCompat.js → js/utxolibCompat.js} +0 -0
- /package/dist/esm/{address.d.ts → js/address.d.ts} +0 -0
- /package/dist/esm/{address.js → js/address.js} +0 -0
- /package/dist/esm/{ast → js/ast}/formatNode.d.ts +0 -0
- /package/dist/esm/{ast → js/ast}/fromWasmNode.d.ts +0 -0
- /package/dist/esm/{ast → js/ast}/index.d.ts +0 -0
- /package/dist/esm/{ast → js/ast}/index.js +0 -0
- /package/dist/esm/{coinName.d.ts → js/coinName.d.ts} +0 -0
- /package/dist/esm/{coinName.js → js/coinName.js} +0 -0
- /package/dist/esm/{index.d.ts → js/index.d.ts} +0 -0
- /package/dist/esm/{index.js → js/index.js} +0 -0
- /package/dist/esm/{triple.d.ts → js/triple.d.ts} +0 -0
- /package/dist/esm/{triple.js → js/triple.js} +0 -0
- /package/dist/esm/{utxolibCompat.d.ts → js/utxolibCompat.d.ts} +0 -0
- /package/dist/esm/{utxolibCompat.js → js/utxolibCompat.js} +0 -0
- /package/dist/esm/{wasm → js/wasm}/wasm_utxo.js +0 -0
|
@@ -345,6 +345,58 @@ export class BitGoPsbt {
|
|
|
345
345
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Extract the final transaction from a finalized PSBT
|
|
350
|
+
*
|
|
351
|
+
* This method should be called after all inputs have been finalized.
|
|
352
|
+
* It extracts the fully signed transaction.
|
|
353
|
+
*
|
|
354
|
+
* # Returns
|
|
355
|
+
* - `Ok(Vec<u8>)` containing the serialized transaction bytes
|
|
356
|
+
* - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
|
|
357
|
+
* @returns {Uint8Array}
|
|
358
|
+
*/
|
|
359
|
+
extract_transaction() {
|
|
360
|
+
try {
|
|
361
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
362
|
+
wasm.bitgopsbt_extract_transaction(retptr, this.__wbg_ptr);
|
|
363
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
364
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
365
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
366
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
367
|
+
if (r3) {
|
|
368
|
+
throw takeObject(r2);
|
|
369
|
+
}
|
|
370
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
371
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
372
|
+
return v1;
|
|
373
|
+
} finally {
|
|
374
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Finalize all inputs in the PSBT
|
|
379
|
+
*
|
|
380
|
+
* This method attempts to finalize all inputs in the PSBT, computing the final
|
|
381
|
+
* scriptSig and witness data for each input.
|
|
382
|
+
*
|
|
383
|
+
* # Returns
|
|
384
|
+
* - `Ok(())` if all inputs were successfully finalized
|
|
385
|
+
* - `Err(WasmUtxoError)` if any input failed to finalize
|
|
386
|
+
*/
|
|
387
|
+
finalize_all_inputs() {
|
|
388
|
+
try {
|
|
389
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
390
|
+
wasm.bitgopsbt_finalize_all_inputs(retptr, this.__wbg_ptr);
|
|
391
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
392
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
393
|
+
if (r1) {
|
|
394
|
+
throw takeObject(r0);
|
|
395
|
+
}
|
|
396
|
+
} finally {
|
|
397
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
348
400
|
/**
|
|
349
401
|
* Parse outputs with wallet keys to identify which outputs belong to a wallet
|
|
350
402
|
*
|
|
@@ -423,6 +475,31 @@ export class BitGoPsbt {
|
|
|
423
475
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
424
476
|
}
|
|
425
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Serialize the PSBT to bytes
|
|
480
|
+
*
|
|
481
|
+
* # Returns
|
|
482
|
+
* The serialized PSBT as a byte array
|
|
483
|
+
* @returns {Uint8Array}
|
|
484
|
+
*/
|
|
485
|
+
serialize() {
|
|
486
|
+
try {
|
|
487
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
488
|
+
wasm.bitgopsbt_serialize(retptr, this.__wbg_ptr);
|
|
489
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
490
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
491
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
492
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
493
|
+
if (r3) {
|
|
494
|
+
throw takeObject(r2);
|
|
495
|
+
}
|
|
496
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
497
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
498
|
+
return v1;
|
|
499
|
+
} finally {
|
|
500
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
426
503
|
}
|
|
427
504
|
if (Symbol.dispose) BitGoPsbt.prototype[Symbol.dispose] = BitGoPsbt.prototype.free;
|
|
428
505
|
|
|
Binary file
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
4
5
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
5
6
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
6
|
-
export const
|
|
7
|
+
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
8
|
+
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
9
|
+
export const bitgopsbt_extract_transaction: (a: number, b: number) => void;
|
|
10
|
+
export const bitgopsbt_finalize_all_inputs: (a: number, b: number) => void;
|
|
7
11
|
export const bitgopsbt_from_bytes: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
12
|
export const bitgopsbt_parse_outputs_with_wallet_keys: (a: number, b: number, c: number) => void;
|
|
9
13
|
export const bitgopsbt_parse_transaction_with_wallet_keys: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const bitgopsbt_serialize: (a: number, b: number) => void;
|
|
10
15
|
export const bitgopsbt_unsigned_txid: (a: number, b: number) => void;
|
|
11
16
|
export const bitgopsbt_verify_replay_protection_signature: (a: number, b: number, c: number, d: number) => void;
|
|
12
17
|
export const bitgopsbt_verify_signature: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
13
18
|
export const fixedscriptwalletnamespace_address: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
14
19
|
export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
|
-
export const
|
|
16
|
-
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
17
|
-
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
18
|
-
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
19
|
-
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
20
|
-
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
21
|
-
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
22
|
-
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
-
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
24
|
-
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
25
|
-
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
20
|
+
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
26
21
|
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
22
|
+
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
23
|
+
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
24
|
+
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
25
|
+
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
27
26
|
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
28
27
|
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
29
28
|
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
@@ -35,16 +34,20 @@ export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
|
35
34
|
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
36
35
|
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
37
36
|
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
38
|
-
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
39
|
-
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
40
|
-
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
41
|
-
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
42
37
|
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
43
38
|
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
44
39
|
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
45
40
|
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
46
41
|
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
47
42
|
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
43
|
+
export const wrappsbt_clone: (a: number) => number;
|
|
44
|
+
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
45
|
+
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
46
|
+
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
47
|
+
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
48
|
+
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
49
|
+
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
50
|
+
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
48
51
|
export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
49
52
|
export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
50
53
|
export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import * as utxolib from "@bitgo/utxo-lib";
|
|
6
|
+
import assert from "node:assert";
|
|
7
|
+
import { utxolibCompat, address as addressNs, } from "../../js/index.js";
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
function getCoinNameForNetwork(name) {
|
|
11
|
+
switch (name) {
|
|
12
|
+
case "bitcoin":
|
|
13
|
+
return "btc";
|
|
14
|
+
case "testnet":
|
|
15
|
+
return "tbtc";
|
|
16
|
+
case "bitcoinTestnet4":
|
|
17
|
+
return "tbtc4";
|
|
18
|
+
case "bitcoinPublicSignet":
|
|
19
|
+
return "tbtcsig";
|
|
20
|
+
case "bitcoinBitGoSignet":
|
|
21
|
+
return "tbtcbgsig";
|
|
22
|
+
case "bitcoincash":
|
|
23
|
+
return "bch";
|
|
24
|
+
case "bitcoincashTestnet":
|
|
25
|
+
return "tbch";
|
|
26
|
+
case "ecash":
|
|
27
|
+
return "bcha";
|
|
28
|
+
case "ecashTest":
|
|
29
|
+
return "tbcha";
|
|
30
|
+
case "bitcoingold":
|
|
31
|
+
return "btg";
|
|
32
|
+
case "bitcoingoldTestnet":
|
|
33
|
+
return "tbtg";
|
|
34
|
+
case "bitcoinsv":
|
|
35
|
+
return "bsv";
|
|
36
|
+
case "bitcoinsvTestnet":
|
|
37
|
+
return "tbsv";
|
|
38
|
+
case "dash":
|
|
39
|
+
return "dash";
|
|
40
|
+
case "dashTest":
|
|
41
|
+
return "tdash";
|
|
42
|
+
case "dogecoin":
|
|
43
|
+
return "doge";
|
|
44
|
+
case "dogecoinTest":
|
|
45
|
+
return "tdoge";
|
|
46
|
+
case "litecoin":
|
|
47
|
+
return "ltc";
|
|
48
|
+
case "litecoinTest":
|
|
49
|
+
return "tltc";
|
|
50
|
+
case "zcash":
|
|
51
|
+
return "zec";
|
|
52
|
+
case "zcashTest":
|
|
53
|
+
return "tzec";
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`Unknown network: ${name}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function getFixtures(name, addressFormat) {
|
|
59
|
+
if (name === "bitcoinBitGoSignet") {
|
|
60
|
+
name = "bitcoinPublicSignet";
|
|
61
|
+
}
|
|
62
|
+
const filename = addressFormat ? `${name}-${addressFormat}` : name;
|
|
63
|
+
const fixturePath = path.join(__dirname, "..", "fixtures", "address", `${filename}.json`);
|
|
64
|
+
const fixtures = await fs.readFile(fixturePath, "utf8");
|
|
65
|
+
return JSON.parse(fixtures);
|
|
66
|
+
}
|
|
67
|
+
function runTest(network, addressFormat) {
|
|
68
|
+
const name = utxolib.getNetworkName(network);
|
|
69
|
+
describe(`utxolibCompat ${name} ${addressFormat ?? "default"}`, function () {
|
|
70
|
+
let fixtures;
|
|
71
|
+
before(async function () {
|
|
72
|
+
fixtures = await getFixtures(name, addressFormat);
|
|
73
|
+
});
|
|
74
|
+
it("should convert to utxolib compatible network", function () {
|
|
75
|
+
for (const fixture of fixtures) {
|
|
76
|
+
const [, script, addressRef] = fixture;
|
|
77
|
+
const scriptBuf = Buffer.from(script, "hex");
|
|
78
|
+
const address = utxolibCompat.fromOutputScript(scriptBuf, network, addressFormat);
|
|
79
|
+
assert.strictEqual(address, addressRef);
|
|
80
|
+
const scriptFromAddress = utxolibCompat.toOutputScript(address, network, addressFormat);
|
|
81
|
+
assert.deepStrictEqual(Buffer.from(scriptFromAddress), scriptBuf);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
it("should convert using coin name", function () {
|
|
85
|
+
const coinName = getCoinNameForNetwork(name);
|
|
86
|
+
for (const fixture of fixtures) {
|
|
87
|
+
const [, script, addressRef] = fixture;
|
|
88
|
+
const scriptBuf = Buffer.from(script, "hex");
|
|
89
|
+
// Test encoding (script -> address)
|
|
90
|
+
const address = addressNs.fromOutputScriptWithCoin(scriptBuf, coinName, addressFormat);
|
|
91
|
+
assert.strictEqual(address, addressRef);
|
|
92
|
+
// Test decoding (address -> script)
|
|
93
|
+
const scriptFromAddress = addressNs.toOutputScriptWithCoin(addressRef, coinName);
|
|
94
|
+
assert.deepStrictEqual(Buffer.from(scriptFromAddress), scriptBuf);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
describe("utxolib compatible address encoding/decoding", function () {
|
|
100
|
+
utxolib.getNetworkList().forEach((network) => {
|
|
101
|
+
runTest(network);
|
|
102
|
+
const mainnet = utxolib.getMainnet(network);
|
|
103
|
+
if (mainnet === utxolib.networks.bitcoincash || mainnet === utxolib.networks.ecash) {
|
|
104
|
+
runTest(network, "cashaddr");
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as assert from "assert";
|
|
2
|
+
import { formatNode } from "../../js/ast/index.js";
|
|
3
|
+
describe("formatNode", function () {
|
|
4
|
+
it("formats simple nodes", function () {
|
|
5
|
+
assert.strictEqual(formatNode({ pk: "lol" }), "pk(lol)");
|
|
6
|
+
assert.strictEqual(formatNode({ after: 1 }), "after(1)");
|
|
7
|
+
assert.strictEqual(formatNode({ and_v: [{ after: 1 }, { after: 1 }] }), "and_v(after(1),after(1))");
|
|
8
|
+
// taproot single key
|
|
9
|
+
assert.strictEqual(formatNode({ tr: "k" }), "tr(k)");
|
|
10
|
+
// key with single-node taproot tree
|
|
11
|
+
assert.strictEqual(formatNode({ tr: ["k", { pk: "k1" }] }), "tr(k,pk(k1))");
|
|
12
|
+
// key with multi-node taproot tree
|
|
13
|
+
assert.strictEqual(formatNode({ tr: ["k", [{ pk: "k1" }, { pk: "k2" }]] }), "tr(k,{pk(k1),pk(k2)})");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const fixtures: {
|
|
2
|
+
valid: ({
|
|
3
|
+
descriptor: string;
|
|
4
|
+
script: string;
|
|
5
|
+
checksumRequired: boolean;
|
|
6
|
+
index?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
descriptor: string;
|
|
9
|
+
script: string;
|
|
10
|
+
index: number;
|
|
11
|
+
checksumRequired: boolean;
|
|
12
|
+
} | {
|
|
13
|
+
descriptor: string;
|
|
14
|
+
script: string;
|
|
15
|
+
checksumRequired?: undefined;
|
|
16
|
+
index?: undefined;
|
|
17
|
+
})[];
|
|
18
|
+
invalid: ({
|
|
19
|
+
descriptor: string;
|
|
20
|
+
checksumRequired: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
descriptor: string;
|
|
23
|
+
checksumRequired?: undefined;
|
|
24
|
+
})[];
|
|
25
|
+
};
|