@bitgo/wasm-utxo 1.5.0 → 1.7.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/ast/formatNode.js +2 -2
- package/dist/cjs/js/ast/fromWasmNode.js +2 -1
- package/dist/cjs/js/bip32.d.ts +140 -0
- package/dist/cjs/js/bip32.js +177 -0
- package/dist/cjs/js/ecpair.d.ts +96 -0
- package/dist/cjs/js/ecpair.js +134 -0
- package/dist/cjs/js/{fixedScriptWallet.d.ts → fixedScriptWallet/BitGoPsbt.d.ts} +40 -41
- package/dist/cjs/js/{fixedScriptWallet.js → fixedScriptWallet/BitGoPsbt.js} +50 -36
- package/dist/cjs/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
- package/dist/cjs/js/fixedScriptWallet/ReplayProtection.js +89 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.js +108 -0
- package/dist/cjs/js/fixedScriptWallet/address.d.ts +20 -0
- package/dist/cjs/js/fixedScriptWallet/address.js +29 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +4 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +12 -0
- package/dist/cjs/js/index.d.ts +5 -1
- package/dist/cjs/js/index.js +11 -2
- package/dist/cjs/js/utxolibCompat.d.ts +0 -18
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +254 -22
- package/dist/cjs/js/wasm/wasm_utxo.js +1081 -223
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +53 -8
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/js/ast/formatNode.js +2 -2
- package/dist/esm/js/ast/fromWasmNode.js +2 -1
- package/dist/esm/js/bip32.d.ts +140 -0
- package/dist/esm/js/bip32.js +173 -0
- package/dist/esm/js/ecpair.d.ts +96 -0
- package/dist/esm/js/ecpair.js +130 -0
- package/dist/esm/js/{fixedScriptWallet.d.ts → fixedScriptWallet/BitGoPsbt.d.ts} +40 -41
- package/dist/esm/js/{fixedScriptWallet.js → fixedScriptWallet/BitGoPsbt.js} +49 -33
- package/dist/esm/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
- package/dist/esm/js/fixedScriptWallet/ReplayProtection.js +85 -0
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.js +104 -0
- package/dist/esm/js/fixedScriptWallet/address.d.ts +20 -0
- package/dist/esm/js/fixedScriptWallet/address.js +25 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +4 -0
- package/dist/esm/js/fixedScriptWallet/index.js +4 -0
- package/dist/esm/js/index.d.ts +5 -1
- package/dist/esm/js/index.js +8 -1
- package/dist/esm/js/utxolibCompat.d.ts +0 -18
- package/dist/esm/js/wasm/wasm_utxo.d.ts +254 -22
- package/dist/esm/js/wasm/wasm_utxo_bg.js +1070 -220
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +53 -8
- package/dist/esm/test/address/utxolibCompat.js +12 -10
- package/dist/esm/test/bip32.d.ts +1 -0
- package/dist/esm/test/bip32.js +242 -0
- package/dist/esm/test/descriptorUtil.js +1 -1
- package/dist/esm/test/ecpair.d.ts +1 -0
- package/dist/esm/test/ecpair.js +137 -0
- package/dist/esm/test/fixedScript/address.js +9 -7
- package/dist/esm/test/fixedScript/fixtureUtil.d.ts +5 -3
- package/dist/esm/test/fixedScript/fixtureUtil.js +18 -7
- package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.js +39 -11
- package/dist/esm/test/fixedScript/verifySignature.js +73 -27
- package/dist/esm/test/fixedScriptToDescriptor.js +6 -4
- package/dist/esm/test/fixtures.js +5 -1
- package/dist/esm/test/psbt.util.js +1 -4
- package/dist/esm/test/psbtFixedScriptCompat.js +19 -17
- package/dist/esm/test/psbtFixedScriptCompatFixtures.js +1 -1
- package/dist/esm/test/psbtFromDescriptor.js +5 -8
- package/dist/esm/test/psbtFromDescriptor.util.js +3 -3
- package/dist/esm/test/test.js +5 -4
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { WasmReplayProtection } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { type ECPairArg } from "../ecpair.js";
|
|
3
|
+
/**
|
|
4
|
+
* ReplayProtectionArg represents the various forms that replay protection can take
|
|
5
|
+
* before being converted to a WasmReplayProtection instance
|
|
6
|
+
*/
|
|
7
|
+
export type ReplayProtectionArg = ReplayProtection | WasmReplayProtection | {
|
|
8
|
+
publicKeys: ECPairArg[];
|
|
9
|
+
} | {
|
|
10
|
+
/** @deprecated - use publicKeys instead */
|
|
11
|
+
outputScripts: Uint8Array[];
|
|
12
|
+
} | {
|
|
13
|
+
/** @deprecated - use publicKeys instead */
|
|
14
|
+
addresses: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* ReplayProtection wrapper class for PSBT replay protection inputs
|
|
18
|
+
*/
|
|
19
|
+
export declare class ReplayProtection {
|
|
20
|
+
private _wasm;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Create a ReplayProtection instance from a WasmReplayProtection instance (internal use)
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
static fromWasm(wasm: WasmReplayProtection): ReplayProtection;
|
|
27
|
+
/**
|
|
28
|
+
* Convert ReplayProtectionArg to ReplayProtection instance
|
|
29
|
+
* @param arg - The replay protection in various formats
|
|
30
|
+
* @param network - Optional network string (required for addresses variant)
|
|
31
|
+
* @returns ReplayProtection instance
|
|
32
|
+
*/
|
|
33
|
+
static from(arg: ReplayProtectionArg, network?: string): ReplayProtection;
|
|
34
|
+
/**
|
|
35
|
+
* Create from public keys (derives P2SH-P2PK output scripts)
|
|
36
|
+
* @param publicKeys - Array of ECPair instances or arguments
|
|
37
|
+
* @returns ReplayProtection instance
|
|
38
|
+
*/
|
|
39
|
+
static fromPublicKeys(publicKeys: ECPairArg[]): ReplayProtection;
|
|
40
|
+
/**
|
|
41
|
+
* Create from output scripts
|
|
42
|
+
* @param outputScripts - Array of output script buffers
|
|
43
|
+
* @returns ReplayProtection instance
|
|
44
|
+
*/
|
|
45
|
+
static fromOutputScripts(outputScripts: Uint8Array[]): ReplayProtection;
|
|
46
|
+
/**
|
|
47
|
+
* Create from addresses
|
|
48
|
+
* @param addresses - Array of address strings
|
|
49
|
+
* @param network - Network string (e.g., "bitcoin", "testnet", "btc", "tbtc")
|
|
50
|
+
* @returns ReplayProtection instance
|
|
51
|
+
*/
|
|
52
|
+
static fromAddresses(addresses: string[], network: string): ReplayProtection;
|
|
53
|
+
/**
|
|
54
|
+
* Get the underlying WASM instance (internal use only)
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
get wasm(): WasmReplayProtection;
|
|
58
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { WasmReplayProtection } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { ECPair } from "../ecpair.js";
|
|
3
|
+
/**
|
|
4
|
+
* ReplayProtection wrapper class for PSBT replay protection inputs
|
|
5
|
+
*/
|
|
6
|
+
export class ReplayProtection {
|
|
7
|
+
_wasm;
|
|
8
|
+
constructor(_wasm) {
|
|
9
|
+
this._wasm = _wasm;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a ReplayProtection instance from a WasmReplayProtection instance (internal use)
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
static fromWasm(wasm) {
|
|
16
|
+
return new ReplayProtection(wasm);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Convert ReplayProtectionArg to ReplayProtection instance
|
|
20
|
+
* @param arg - The replay protection in various formats
|
|
21
|
+
* @param network - Optional network string (required for addresses variant)
|
|
22
|
+
* @returns ReplayProtection instance
|
|
23
|
+
*/
|
|
24
|
+
static from(arg, network) {
|
|
25
|
+
// Short-circuit if already a ReplayProtection instance
|
|
26
|
+
if (arg instanceof ReplayProtection) {
|
|
27
|
+
return arg;
|
|
28
|
+
}
|
|
29
|
+
// If it's a WasmReplayProtection instance, wrap it
|
|
30
|
+
if (arg instanceof WasmReplayProtection) {
|
|
31
|
+
return new ReplayProtection(arg);
|
|
32
|
+
}
|
|
33
|
+
// Handle object variants
|
|
34
|
+
if ("publicKeys" in arg) {
|
|
35
|
+
// Convert ECPairArg to public key bytes
|
|
36
|
+
const publicKeyBytes = arg.publicKeys.map((key) => ECPair.from(key).publicKey);
|
|
37
|
+
const wasm = WasmReplayProtection.from_public_keys(publicKeyBytes);
|
|
38
|
+
return new ReplayProtection(wasm);
|
|
39
|
+
}
|
|
40
|
+
if ("outputScripts" in arg) {
|
|
41
|
+
const wasm = WasmReplayProtection.from_output_scripts(arg.outputScripts);
|
|
42
|
+
return new ReplayProtection(wasm);
|
|
43
|
+
}
|
|
44
|
+
if ("addresses" in arg) {
|
|
45
|
+
if (!network) {
|
|
46
|
+
throw new Error("Network is required when using addresses variant");
|
|
47
|
+
}
|
|
48
|
+
const wasm = WasmReplayProtection.from_addresses(arg.addresses, network);
|
|
49
|
+
return new ReplayProtection(wasm);
|
|
50
|
+
}
|
|
51
|
+
throw new Error("Invalid ReplayProtectionArg type");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create from public keys (derives P2SH-P2PK output scripts)
|
|
55
|
+
* @param publicKeys - Array of ECPair instances or arguments
|
|
56
|
+
* @returns ReplayProtection instance
|
|
57
|
+
*/
|
|
58
|
+
static fromPublicKeys(publicKeys) {
|
|
59
|
+
return ReplayProtection.from({ publicKeys });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create from output scripts
|
|
63
|
+
* @param outputScripts - Array of output script buffers
|
|
64
|
+
* @returns ReplayProtection instance
|
|
65
|
+
*/
|
|
66
|
+
static fromOutputScripts(outputScripts) {
|
|
67
|
+
return ReplayProtection.from({ outputScripts });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create from addresses
|
|
71
|
+
* @param addresses - Array of address strings
|
|
72
|
+
* @param network - Network string (e.g., "bitcoin", "testnet", "btc", "tbtc")
|
|
73
|
+
* @returns ReplayProtection instance
|
|
74
|
+
*/
|
|
75
|
+
static fromAddresses(addresses, network) {
|
|
76
|
+
return ReplayProtection.from({ addresses }, network);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the underlying WASM instance (internal use only)
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
get wasm() {
|
|
83
|
+
return this._wasm;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { BIP32Interface } from "../bip32.js";
|
|
2
|
+
import { BIP32 } from "../bip32.js";
|
|
3
|
+
import { Triple } from "../triple.js";
|
|
4
|
+
import { WasmRootWalletKeys } from "../wasm/wasm_utxo.js";
|
|
5
|
+
/**
|
|
6
|
+
* IWalletKeys represents the various forms that wallet keys can take
|
|
7
|
+
* before being converted to a RootWalletKeys instance
|
|
8
|
+
*/
|
|
9
|
+
export type IWalletKeys = {
|
|
10
|
+
triple: Triple<BIP32Interface>;
|
|
11
|
+
derivationPrefixes: Triple<string>;
|
|
12
|
+
};
|
|
13
|
+
export type WalletKeysArg =
|
|
14
|
+
/** Just an xpub triple, will assume default derivation prefixes */
|
|
15
|
+
Triple<string>
|
|
16
|
+
/** Compatible with utxolib RootWalletKeys */
|
|
17
|
+
| IWalletKeys
|
|
18
|
+
/** RootWalletKeys instance */
|
|
19
|
+
| RootWalletKeys;
|
|
20
|
+
/**
|
|
21
|
+
* RootWalletKeys represents a set of three extended public keys with their derivation prefixes
|
|
22
|
+
*/
|
|
23
|
+
export declare class RootWalletKeys {
|
|
24
|
+
private _wasm;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Create a RootWalletKeys from various input formats
|
|
28
|
+
* @param keys - Can be a triple of xpub strings, an IWalletKeys object, or another RootWalletKeys instance
|
|
29
|
+
* @returns A RootWalletKeys instance
|
|
30
|
+
*/
|
|
31
|
+
static from(keys: WalletKeysArg): RootWalletKeys;
|
|
32
|
+
/**
|
|
33
|
+
* Create a RootWalletKeys from three xpub strings
|
|
34
|
+
* Uses default derivation prefix of m/0/0 for all three keys
|
|
35
|
+
* @param xpubs - Triple of xpub strings
|
|
36
|
+
* @returns A RootWalletKeys instance
|
|
37
|
+
*/
|
|
38
|
+
static fromXpubs(xpubs: Triple<string>): RootWalletKeys;
|
|
39
|
+
/**
|
|
40
|
+
* Create a RootWalletKeys from three xpub strings with custom derivation prefixes
|
|
41
|
+
* @param xpubs - Triple of xpub strings
|
|
42
|
+
* @param derivationPrefixes - Triple of derivation path strings (e.g., ["0/0", "0/0", "0/0"])
|
|
43
|
+
* @returns A RootWalletKeys instance
|
|
44
|
+
*/
|
|
45
|
+
static withDerivationPrefixes(xpubs: Triple<string>, derivationPrefixes: Triple<string>): RootWalletKeys;
|
|
46
|
+
/**
|
|
47
|
+
* Get the user key (first xpub)
|
|
48
|
+
* @returns The user key as a BIP32 instance
|
|
49
|
+
*/
|
|
50
|
+
userKey(): BIP32;
|
|
51
|
+
/**
|
|
52
|
+
* Get the backup key (second xpub)
|
|
53
|
+
* @returns The backup key as a BIP32 instance
|
|
54
|
+
*/
|
|
55
|
+
backupKey(): BIP32;
|
|
56
|
+
/**
|
|
57
|
+
* Get the BitGo key (third xpub)
|
|
58
|
+
* @returns The BitGo key as a BIP32 instance
|
|
59
|
+
*/
|
|
60
|
+
bitgoKey(): BIP32;
|
|
61
|
+
/**
|
|
62
|
+
* Get the underlying WASM instance (internal use only)
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
get wasm(): WasmRootWalletKeys;
|
|
66
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BIP32 } from "../bip32.js";
|
|
2
|
+
import { WasmRootWalletKeys, WasmBIP32 } from "../wasm/wasm_utxo.js";
|
|
3
|
+
/**
|
|
4
|
+
* Convert WalletKeysArg to a triple of BIP32 instances
|
|
5
|
+
*/
|
|
6
|
+
function toBIP32Triple(keys) {
|
|
7
|
+
if (keys instanceof RootWalletKeys) {
|
|
8
|
+
return [keys.userKey(), keys.backupKey(), keys.bitgoKey()];
|
|
9
|
+
}
|
|
10
|
+
// Check if it's an IWalletKeys object
|
|
11
|
+
if (typeof keys === "object" && "triple" in keys) {
|
|
12
|
+
// Extract BIP32 keys from the triple
|
|
13
|
+
return keys.triple.map((key) => BIP32.from(key));
|
|
14
|
+
}
|
|
15
|
+
// Otherwise it's a triple of strings (xpubs)
|
|
16
|
+
return keys.map((xpub) => BIP32.fromWasm(WasmBIP32.from_xpub(xpub)));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extract derivation prefixes from WalletKeysArg, if present
|
|
20
|
+
*/
|
|
21
|
+
function extractDerivationPrefixes(keys) {
|
|
22
|
+
if (typeof keys === "object" && "derivationPrefixes" in keys) {
|
|
23
|
+
return keys.derivationPrefixes;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* RootWalletKeys represents a set of three extended public keys with their derivation prefixes
|
|
29
|
+
*/
|
|
30
|
+
export class RootWalletKeys {
|
|
31
|
+
_wasm;
|
|
32
|
+
constructor(_wasm) {
|
|
33
|
+
this._wasm = _wasm;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a RootWalletKeys from various input formats
|
|
37
|
+
* @param keys - Can be a triple of xpub strings, an IWalletKeys object, or another RootWalletKeys instance
|
|
38
|
+
* @returns A RootWalletKeys instance
|
|
39
|
+
*/
|
|
40
|
+
static from(keys) {
|
|
41
|
+
if (keys instanceof RootWalletKeys) {
|
|
42
|
+
return keys;
|
|
43
|
+
}
|
|
44
|
+
const [user, backup, bitgo] = toBIP32Triple(keys);
|
|
45
|
+
const derivationPrefixes = extractDerivationPrefixes(keys);
|
|
46
|
+
const wasm = derivationPrefixes
|
|
47
|
+
? WasmRootWalletKeys.with_derivation_prefixes(user.wasm, backup.wasm, bitgo.wasm, derivationPrefixes[0], derivationPrefixes[1], derivationPrefixes[2])
|
|
48
|
+
: new WasmRootWalletKeys(user.wasm, backup.wasm, bitgo.wasm);
|
|
49
|
+
return new RootWalletKeys(wasm);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a RootWalletKeys from three xpub strings
|
|
53
|
+
* Uses default derivation prefix of m/0/0 for all three keys
|
|
54
|
+
* @param xpubs - Triple of xpub strings
|
|
55
|
+
* @returns A RootWalletKeys instance
|
|
56
|
+
*/
|
|
57
|
+
static fromXpubs(xpubs) {
|
|
58
|
+
const [user, backup, bitgo] = xpubs.map((xpub) => WasmBIP32.from_xpub(xpub));
|
|
59
|
+
const wasm = new WasmRootWalletKeys(user, backup, bitgo);
|
|
60
|
+
return new RootWalletKeys(wasm);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a RootWalletKeys from three xpub strings with custom derivation prefixes
|
|
64
|
+
* @param xpubs - Triple of xpub strings
|
|
65
|
+
* @param derivationPrefixes - Triple of derivation path strings (e.g., ["0/0", "0/0", "0/0"])
|
|
66
|
+
* @returns A RootWalletKeys instance
|
|
67
|
+
*/
|
|
68
|
+
static withDerivationPrefixes(xpubs, derivationPrefixes) {
|
|
69
|
+
const [user, backup, bitgo] = xpubs.map((xpub) => WasmBIP32.from_xpub(xpub));
|
|
70
|
+
const wasm = WasmRootWalletKeys.with_derivation_prefixes(user, backup, bitgo, derivationPrefixes[0], derivationPrefixes[1], derivationPrefixes[2]);
|
|
71
|
+
return new RootWalletKeys(wasm);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the user key (first xpub)
|
|
75
|
+
* @returns The user key as a BIP32 instance
|
|
76
|
+
*/
|
|
77
|
+
userKey() {
|
|
78
|
+
const wasm = this._wasm.user_key();
|
|
79
|
+
return BIP32.fromWasm(wasm);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the backup key (second xpub)
|
|
83
|
+
* @returns The backup key as a BIP32 instance
|
|
84
|
+
*/
|
|
85
|
+
backupKey() {
|
|
86
|
+
const wasm = this._wasm.backup_key();
|
|
87
|
+
return BIP32.fromWasm(wasm);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the BitGo key (third xpub)
|
|
91
|
+
* @returns The BitGo key as a BIP32 instance
|
|
92
|
+
*/
|
|
93
|
+
bitgoKey() {
|
|
94
|
+
const wasm = this._wasm.bitgo_key();
|
|
95
|
+
return BIP32.fromWasm(wasm);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the underlying WASM instance (internal use only)
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
get wasm() {
|
|
102
|
+
return this._wasm;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
|
+
import type { UtxolibNetwork } from "../utxolibCompat.js";
|
|
3
|
+
import { AddressFormat } from "../address.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create the output script for a given wallet keys and chain and index
|
|
6
|
+
*/
|
|
7
|
+
export declare function outputScript(keys: WalletKeysArg, chain: number, index: number, network: UtxolibNetwork): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Create the address for a given wallet keys and chain and index and network.
|
|
10
|
+
* Wrapper for outputScript that also encodes the script to an address.
|
|
11
|
+
* @param keys - The wallet keys to use.
|
|
12
|
+
* @param chain - The chain to use.
|
|
13
|
+
* @param index - The index to use.
|
|
14
|
+
* @param network - The network to use.
|
|
15
|
+
* @param addressFormat - The address format to use.
|
|
16
|
+
* Only relevant for Bitcoin Cash and eCash networks, where:
|
|
17
|
+
* - "default" means base58check,
|
|
18
|
+
* - "cashaddr" means cashaddr.
|
|
19
|
+
*/
|
|
20
|
+
export declare function address(keys: WalletKeysArg, chain: number, index: number, network: UtxolibNetwork, addressFormat?: AddressFormat): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FixedScriptWalletNamespace } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create the output script for a given wallet keys and chain and index
|
|
5
|
+
*/
|
|
6
|
+
export function outputScript(keys, chain, index, network) {
|
|
7
|
+
const walletKeys = RootWalletKeys.from(keys);
|
|
8
|
+
return FixedScriptWalletNamespace.output_script(walletKeys.wasm, chain, index, network);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create the address for a given wallet keys and chain and index and network.
|
|
12
|
+
* Wrapper for outputScript that also encodes the script to an address.
|
|
13
|
+
* @param keys - The wallet keys to use.
|
|
14
|
+
* @param chain - The chain to use.
|
|
15
|
+
* @param index - The index to use.
|
|
16
|
+
* @param network - The network to use.
|
|
17
|
+
* @param addressFormat - The address format to use.
|
|
18
|
+
* Only relevant for Bitcoin Cash and eCash networks, where:
|
|
19
|
+
* - "default" means base58check,
|
|
20
|
+
* - "cashaddr" means cashaddr.
|
|
21
|
+
*/
|
|
22
|
+
export function address(keys, chain, index, network, addressFormat) {
|
|
23
|
+
const walletKeys = RootWalletKeys.from(keys);
|
|
24
|
+
return FixedScriptWalletNamespace.address(walletKeys.wasm, chain, index, network, addressFormat);
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { RootWalletKeys, type WalletKeysArg, type IWalletKeys } from "./RootWalletKeys.js";
|
|
2
|
+
export { ReplayProtection, type ReplayProtectionArg } from "./ReplayProtection.js";
|
|
3
|
+
export { outputScript, address } from "./address.js";
|
|
4
|
+
export { BitGoPsbt, type NetworkName, type ScriptId, type InputScriptType, type ParsedInput, type ParsedOutput, type ParsedTransaction, } from "./BitGoPsbt.js";
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * as address from "./address.js";
|
|
2
2
|
export * as ast from "./ast/index.js";
|
|
3
3
|
export * as utxolibCompat from "./utxolibCompat.js";
|
|
4
|
-
export * as fixedScriptWallet from "./fixedScriptWallet.js";
|
|
4
|
+
export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
|
|
5
|
+
export * as bip32 from "./bip32.js";
|
|
6
|
+
export * as ecpair from "./ecpair.js";
|
|
7
|
+
export { ECPair } from "./ecpair.js";
|
|
8
|
+
export { BIP32 } from "./bip32.js";
|
|
5
9
|
export type { CoinName } from "./coinName.js";
|
|
6
10
|
export type { Triple } from "./triple.js";
|
|
7
11
|
export type { AddressFormat } from "./address.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -2,10 +2,17 @@ import * as wasm from "./wasm/wasm_utxo.js";
|
|
|
2
2
|
// we need to access the wasm module here, otherwise webpack gets all weird
|
|
3
3
|
// and forgets to include it in the bundle
|
|
4
4
|
void wasm;
|
|
5
|
+
// Most exports are namespaced to avoid polluting the top-level namespace
|
|
6
|
+
// and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
|
|
5
7
|
export * as address from "./address.js";
|
|
6
8
|
export * as ast from "./ast/index.js";
|
|
7
9
|
export * as utxolibCompat from "./utxolibCompat.js";
|
|
8
|
-
export * as fixedScriptWallet from "./fixedScriptWallet.js";
|
|
10
|
+
export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
|
|
11
|
+
export * as bip32 from "./bip32.js";
|
|
12
|
+
export * as ecpair from "./ecpair.js";
|
|
13
|
+
// Only the most commonly used classes and types are exported at the top level for convenience
|
|
14
|
+
export { ECPair } from "./ecpair.js";
|
|
15
|
+
export { BIP32 } from "./bip32.js";
|
|
9
16
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
10
17
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
11
18
|
export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import type { AddressFormat } from "./address.js";
|
|
2
|
-
import { Triple } from "./triple.js";
|
|
3
2
|
export type UtxolibName = "bitcoin" | "testnet" | "bitcoinTestnet4" | "bitcoinPublicSignet" | "bitcoinBitGoSignet" | "bitcoincash" | "bitcoincashTestnet" | "ecash" | "ecashTest" | "bitcoingold" | "bitcoingoldTestnet" | "bitcoinsv" | "bitcoinsvTestnet" | "dash" | "dashTest" | "dogecoin" | "dogecoinTest" | "litecoin" | "litecoinTest" | "zcash" | "zcashTest";
|
|
4
|
-
export type BIP32Interface = {
|
|
5
|
-
network: {
|
|
6
|
-
bip32: {
|
|
7
|
-
public: number;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
depth: number;
|
|
11
|
-
parentFingerprint: number;
|
|
12
|
-
index: number;
|
|
13
|
-
chainCode: Uint8Array;
|
|
14
|
-
publicKey: Uint8Array;
|
|
15
|
-
toBase58?(): string;
|
|
16
|
-
};
|
|
17
|
-
export type UtxolibRootWalletKeys = {
|
|
18
|
-
triple: Triple<BIP32Interface>;
|
|
19
|
-
derivationPrefixes: Triple<string>;
|
|
20
|
-
};
|
|
21
3
|
export type UtxolibNetwork = {
|
|
22
4
|
pubKeyHash: number;
|
|
23
5
|
scriptHash: number;
|