@@ -8,10 +8,36 @@ export type DescriptorPkType = "derivable" | "definite" | "string";
88
99export type ScriptContext = "tap" | "segwitv0" | "legacy" ;
1010
11+ export type AddressFormat = "default" | "cashaddr" ;
12+
1113export type SignPsbtResult = {
1214 [ inputIndex : number ] : [ pubkey : string ] [ ] ;
1315} ;
1416
17+ // BitGo coin names (from Network::from_coin_name in src/networks.rs)
18+ export type CoinName =
19+ | "btc"
20+ | "tbtc"
21+ | "tbtc4"
22+ | "tbtcsig"
23+ | "tbtcbgsig"
24+ | "bch"
25+ | "tbch"
26+ | "bcha"
27+ | "tbcha"
28+ | "btg"
29+ | "tbtg"
30+ | "bsv"
31+ | "tbsv"
32+ | "dash"
33+ | "tdash"
34+ | "doge"
35+ | "tdoge"
36+ | "ltc"
37+ | "tltc"
38+ | "zec"
39+ | "tzec" ;
40+
1541declare module "./wasm/wasm_utxo" {
1642 interface WrapDescriptor {
1743 /** These are not the same types of nodes as in the ast module */
@@ -37,16 +63,46 @@ declare module "./wasm/wasm_utxo" {
3763 signWithXprv ( this : WrapPsbt , xprv : string ) : SignPsbtResult ;
3864 signWithPrv ( this : WrapPsbt , prv : Uint8Array ) : SignPsbtResult ;
3965 }
66+
67+ interface Address {
68+ /**
69+ * Convert output script to address string
70+ * @param script - The output script as a byte array
71+ * @param network - The utxolib Network object from JavaScript
72+ * @param format - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
73+ */
74+ fromOutputScript ( script : Uint8Array , network : any , format ?: AddressFormat ) : string ;
75+ /**
76+ * Convert address string to output script
77+ * @param address - The address string
78+ * @param network - The utxolib Network object from JavaScript
79+ * @param format - Optional address format (currently unused for decoding as all formats are accepted)
80+ */
81+ toOutputScript ( address : string , network : any , format ?: AddressFormat ) : Uint8Array ;
82+ }
4083}
4184
4285import { Address as WasmAddress } from "./wasm/wasm_utxo" ;
4386
4487export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo" ;
4588export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo" ;
4689export { WrapPsbt as Psbt } from "./wasm/wasm_utxo" ;
90+ export { FixedScriptWallet } from "./wasm/wasm_utxo" ;
4791
4892export namespace utxolibCompat {
4993 export const Address = WasmAddress ;
5094}
5195
96+ export function toOutputScriptWithCoin ( address : string , coin : CoinName ) : Uint8Array {
97+ return wasm . toOutputScriptWithCoin ( address , coin ) ;
98+ }
99+
100+ export function fromOutputScriptWithCoin (
101+ script : Uint8Array ,
102+ coin : CoinName ,
103+ format ?: AddressFormat ,
104+ ) : string {
105+ return wasm . fromOutputScriptWithCoin ( script , coin , format ) ;
106+ }
107+
52108export * as ast from "./ast" ;
0 commit comments