11import { FixedScriptWalletNamespace } from "./wasm/wasm_utxo" ;
22import type { UtxolibNetwork , UtxolibRootWalletKeys } from "./utxolibCompat" ;
33import { Triple } from "./triple" ;
4+ import { AddressFormat } from "./address" ;
45
56export type WalletKeys =
67 /** Just an xpub triple, will assume default derivation prefixes */
@@ -11,19 +12,33 @@ export type WalletKeys =
1112/**
1213 * Create the output script for a given wallet keys and chain and index
1314 */
14- export function outputScript ( keys : WalletKeys , chain : number , index : number ) : Uint8Array {
15- return FixedScriptWalletNamespace . output_script ( keys , chain , index ) ;
15+ export function outputScript (
16+ keys : WalletKeys ,
17+ chain : number ,
18+ index : number ,
19+ network : UtxolibNetwork ,
20+ ) : Uint8Array {
21+ return FixedScriptWalletNamespace . output_script ( keys , chain , index , network ) ;
1622}
1723
1824/**
1925 * Create the address for a given wallet keys and chain and index and network.
2026 * Wrapper for outputScript that also encodes the script to an address.
27+ * @param keys - The wallet keys to use.
28+ * @param chain - The chain to use.
29+ * @param index - The index to use.
30+ * @param network - The network to use.
31+ * @param addressFormat - The address format to use.
32+ * Only relevant for Bitcoin Cash and eCash networks, where:
33+ * - "default" means base58check,
34+ * - "cashaddr" means cashaddr.
2135 */
2236export function address (
2337 keys : WalletKeys ,
2438 chain : number ,
2539 index : number ,
2640 network : UtxolibNetwork ,
41+ addressFormat ?: AddressFormat ,
2742) : string {
28- return FixedScriptWalletNamespace . address ( keys , chain , index , network ) ;
43+ return FixedScriptWalletNamespace . address ( keys , chain , index , network , addressFormat ) ;
2944}
0 commit comments