nexa-wallet-sdk 0.1.2
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/.parcel-cache/3e09f086f3c4d605-AssetGraph +0 -0
- package/.parcel-cache/5eac57ec674cdae8-AssetGraph +0 -0
- package/.parcel-cache/data.mdb +0 -0
- package/.parcel-cache/e43547b6c9167b58-RequestGraph +0 -0
- package/.parcel-cache/ecfe15d74834bbfd-BundleGraph +0 -0
- package/.parcel-cache/lock.mdb +0 -0
- package/.parcel-cache/snapshot-e43547b6c9167b58.txt +2 -0
- package/README.md +445 -0
- package/dist/browser/index.js +2456 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/index.d.ts +918 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2915 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2456 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +90 -0
- package/spec.md +257 -0
- package/src/index.ts +93 -0
- package/src/models/rostrum.entities.ts +159 -0
- package/src/models/transaction.entities.ts +46 -0
- package/src/models/wallet.entities.ts +42 -0
- package/src/network/RostrumProvider.ts +137 -0
- package/src/types.ts +0 -0
- package/src/utils/CommonUtils.ts +123 -0
- package/src/utils/TXUtils.ts +445 -0
- package/src/utils/TokenUtils.ts +75 -0
- package/src/utils/ValidationUtils.ts +86 -0
- package/src/utils/WalletUtils.ts +522 -0
- package/src/utils/WatchOnlyTXUtils.ts +275 -0
- package/src/wallet/Wallet.ts +397 -0
- package/src/wallet/WatchOnlyWallet.ts +169 -0
- package/src/wallet/accounts/AccountStore.ts +173 -0
- package/src/wallet/accounts/interfaces/BaseAccountInterface.ts +56 -0
- package/src/wallet/accounts/models/DappAccount.ts +80 -0
- package/src/wallet/accounts/models/DefaultAccount.ts +96 -0
- package/src/wallet/accounts/models/VaultAccount.ts +81 -0
- package/src/wallet/transactions/WalletTransactionCreator.ts +145 -0
- package/src/wallet/transactions/WatchOnlyTransactionCreator.ts +189 -0
- package/src/wallet/transactions/interfaces/TransactionCreator.ts +438 -0
- package/tests/core/tx/transactioncreator.test.ts +455 -0
- package/tests/core/tx/wallettransactioncreator.test.ts +362 -0
- package/tests/core/tx/watchonlytransactioncreator.test.ts +258 -0
- package/tests/core/wallet/accountstore.test.ts +341 -0
- package/tests/core/wallet/wallet.test.ts +69 -0
- package/tests/core/watchonlywallet/watchonlywallet.test.ts +251 -0
- package/tests/index.test.ts +12 -0
- package/tsconfig.json +113 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA,aAAa;;ACAb,4BAAiB,KAAK,KAAK,CAAC;;;;;;AGErB,MAAM,2CAAgB;IACzB,IAAI;IACJ,KAAK;AACT;;;ADaO,MAAM;IAIT,aAAqB,CAAC;IAEtB,MAAa,aAAa;QACtB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAW;IACxC;IAEA,MAAa,cAAc;QACvB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAW;IACxC;IAEA,MAAa,WAAW,OAAe,EAAE;QACrC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAU,kCAAkC,SAAS;IAClF;IAEA,MAAa,uBAAuB,OAAe,EAAE;QACjD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAe,kCAAkC;IAC9E;IAEA,MAAa,YAAY,OAAe,EAAE;QACtC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAY,oCAAoC;IAC7E;IAEA,MAAa,eAAe,EAAU,EAAE,UAAmB,IAAI,EAAE;QAC7D,OAAO,MAAM,IAAI,CAAC,OAAO,CAAe,8BAA8B,IAAI;IAC9E;IAEA,MAAa,QAAQ,QAAgB,EAAE;QACnC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAQ,uBAAuB;IAC5D;IAEA,MAAa,aAAa,OAAe,EAAE;QACvC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAuB,kCAAkC,SAAS;IAC/F;IAEA,MAAa,cAAc,OAAe,EAAE,KAAa,EAAE;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AAC,eAAe,cAAc;AAC1C,eAAe,cAAc,GAAG,CAAC,CAAC,EAAE,GAAA,mCAAS;AAE9C;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,MAAM,kCAAY;kBACd;IACA,SAAS,CAAC,CAAC,EAAE,CAAA,GAAA,iCAAM,GAAG;YACtB;AACJ;IAEA,2CAAe","sources":["src/index.ts","package.json","src/wallet/Wallet.ts","src/network/RostrumProvider.ts","src/models/rostrum.entities.ts","src/utils/WalletUtils.ts","src/wallet/accounts/models/DappAccount.ts","src/wallet/accounts/interfaces/BaseAccountInterface.ts","src/wallet/accounts/models/DefaultAccount.ts","src/wallet/accounts/models/VaultAccount.ts","src/utils/CommonUtils.ts","src/wallet/transactions/WalletTransactionCreator.ts","src/utils/TXUtils.ts","src/utils/TokenUtils.ts","src/wallet/transactions/interfaces/TransactionCreator.ts","src/wallet/accounts/AccountStore.ts","src/utils/ValidationUtils.ts","src/wallet/WatchOnlyWallet.ts","src/wallet/transactions/WatchOnlyTransactionCreator.ts","src/utils/WatchOnlyTXUtils.ts"],"sourcesContent":["// @ts-ignore\nimport { version } from '../package.json';\nimport Wallet from \"./wallet/Wallet\";\n\n/**\n * Guards against multiple instances of the wallet SDK being loaded.\n * This prevents conflicts and ensures only one version is active at a time.\n * @param version - The version string to check\n * @throws {Error} When multiple instances are detected\n */\nfunction versionGuard(version: string): void {\n if (version !== undefined) {\n let message = 'More than one instance of Wallet SDK' +\n 'Please make sure to require Wallet SDK and check that submodules do' +\n ' not also include their own Wallet SDK dependency.';\n throw new Error(message);\n }\n}\n\nversionGuard((global as any)._walletSdk_ver);\n(global as any)._walletSdk_ver = `v${version}`;\n\n/**\n * Wallet SDK - A TypeScript SDK for the Nexa blockchain\n *\n * This SDK provides comprehensive wallet functionality including:\n * - Creating and managing wallets from seed phrases or private keys\n * - Account management with different account types\n * - Transaction building and signing\n * - Token operations and management\n * - Message signing and verification\n *\n * @example\n * ```typescript\n * import { Wallet } from 'wallet-sdk-ts';\n *\n * // Create a new wallet\n * const wallet = Wallet.create();\n *\n * // Or restore from seed phrase\n * const wallet = Wallet.fromSeedPhrase('your seed phrase here');\n *\n * // Initialize and discover accounts\n * await wallet.initialize();\n * ```\n */\nconst walletSdk = {\n versionGuard,\n version: `v${version}`,\n Wallet\n}\n\nexport default walletSdk\n\nexport { default as Wallet } from './wallet/Wallet'\nexport { default as WatchOnlyWallet } from './wallet/WatchOnlyWallet'\n\n// Export utility enums and types\nexport { AccountType, TxTokenType } from './utils/WalletUtils'\n\n// Export account interfaces and classes\nexport { BaseAccount } from './wallet/accounts/interfaces/BaseAccountInterface'\nexport { default as DefaultAccount } from './wallet/accounts/models/DefaultAccount'\nexport { default as DappAccount } from './wallet/accounts/models/DappAccount'\nexport { default as VaultAccount } from './wallet/accounts/models/VaultAccount'\nexport { default as AccountStore } from './wallet/accounts/AccountStore'\n\n// Export transaction creators\nexport { default as WalletTransactionCreator } from './wallet/transactions/WalletTransactionCreator'\nexport { default as WatchOnlyTransactionCreator } from './wallet/transactions/WatchOnlyTransactionCreator'\n\n// Export network provider\nexport { rostrumProvider } from './network/RostrumProvider'\n\n// Export entity types and interfaces\nexport type {\n AccountKeys,\n AccountIndexes,\n AddressKey,\n Balance,\n WatchOnlyAddress,\n TxStatus,\n HodlStatus\n} from './models/wallet.entities'\n\nexport type {\n TxEntityState,\n TxTemplateData,\n TxOptions,\n TokenAction,\n PermissionLabel,\n TransactionEntity\n} from './models/transaction.entities'\n","{\n \"name\": \"@nexa/wallet-sdk-ts\",\n \"version\": \"0.1.0\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"source\": \"src/index.ts\",\n \"scripts\": {\n \"build\": \"parcel build\",\n \"dev\": \"parcel watch\",\n \"test\": \"vitest run\",\n \"clean\": \"rm -rf dist .parcel-cache\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+ssh://git@gitlab.com/nexa/wallet-sdk-ts.git\"\n },\n \"keywords\": [\n \"nexa\",\n \"wallet\",\n \"web3\",\n \"crypto\",\n \"dapp\",\n \"walletcomms\",\n \"walletsdk\"\n ],\n \"contributors\": [\n {\n \"name\": \"Dolaned\"\n },\n {\n \"name\": \"Griffith\"\n },\n {\n \"name\": \"Vgrunner\"\n },\n {\n \"name\": \"myendy\"\n }\n ],\n \"author\": \"Dolaned\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://gitlab.com/nexa/wallet-sdk-ts/issues\"\n },\n \"homepage\": \"https://gitlab.com/nexa/wallet-sdk-ts#readme\",\n \"description\": \"Wallet SDK for the Nexa blockchain\",\n \"devDependencies\": {\n \"@parcel/packager-ts\": \"^2.15.4\",\n \"@parcel/transformer-typescript-types\": \"^2.15.4\",\n \"@types/lodash-es\": \"^4.17.12\",\n \"@types/node\": \"^22.13.1\",\n \"parcel\": \"^2.15.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.0.8\"\n },\n \"targets\": {\n \"main\": {\n \"context\": \"node\",\n \"outputFormat\": \"commonjs\",\n \"distDir\": \"dist\",\n \"isLibrary\": true,\n \"includeNodeModules\": [\n \"lodash-es\"\n ]\n },\n \"module\": {\n \"context\": \"node\",\n \"outputFormat\": \"esmodule\",\n \"distDir\": \"dist\",\n \"isLibrary\": true\n },\n \"browser\": {\n \"context\": \"browser\",\n \"outputFormat\": \"esmodule\",\n \"distDir\": \"dist\",\n \"isLibrary\": true\n }\n },\n \"dependencies\": {\n \"@vgrunner/electrum-cash\": \"^2.0.12\",\n \"bip39\": \"^3.1.0\",\n \"js-big-decimal\": \"^2.2.0\",\n \"libnexa-ts\": \"^1.0.5\",\n \"lodash-es\": \"^4.17.21\"\n },\n \"directories\": {\n \"test\": \"tests\"\n }\n}\n","import {HDPrivateKey, Message, Networkish, Networks, TransactionBuilder,} from \"libnexa-ts\";\nimport * as Bip39 from 'bip39'\nimport {rostrumProvider} from \"../network/RostrumProvider\";\nimport {AccountType, discoverWallet,} from \"../utils/WalletUtils\";\nimport {isBuffer, isNil, isString} from \"lodash-es\";\nimport WalletTransactionCreator from \"./transactions/WalletTransactionCreator\";\nimport AccountStore from \"./accounts/AccountStore\";\nimport {BaseAccount} from \"./accounts/interfaces/BaseAccountInterface\";\nimport ValidationUtils from \"../utils/ValidationUtils\";\nimport {AddressKey} from \"../models/wallet.entities\";\n\n/**\n * Main Wallet class for managing Nexa blockchain wallet operations\n *\n * This class provides comprehensive wallet functionality including:\n * - Creating wallets from seed phrases or private keys\n * - Account discovery and management\n * - Transaction creation and signing\n * - Message signing and verification\n * - Multi-account support with different account types\n *\n * @example\n * ```typescript\n * // Create a new wallet with random seed phrase\n * const wallet = Wallet.create();\n *\n * // Restore wallet from existing seed phrase\n * const wallet = Wallet.fromSeedPhrase('your twelve word seed phrase here');\n *\n * // Initialize wallet (discovers accounts and balances)\n * await wallet.initialize();\n *\n * // Create a new account\n * const account = await wallet.newAccount('DefaultAccount');\n *\n * // Create and send a transaction\n * const tx = wallet.newTransaction(account)\n * .to('nexa:address', 1000000) // 1 NEXA in satoshis\n * .sign();\n *\n * const txId = await wallet.sendTransaction(tx.toHex());\n * ```\n */\nexport default class Wallet {\n\n /** The master HD private key derived from the seed phrase */\n private readonly masterKey!: HDPrivateKey;\n\n /** Store for managing wallet accounts */\n private _accountStore: AccountStore;\n\n /** The blockchain network this wallet operates on */\n private readonly _network: Networkish\n\n /** The BIP39 seed phrase used to generate this wallet (if created from phrase) */\n private readonly phrase?: string;\n\n /**\n * Creates a new Wallet instance\n *\n * @param data - Optional wallet data:\n * - undefined: Generate new random seed phrase\n * - string: Use as BIP39 seed phrase\n * - HDPrivateKey: Use as master key directly\n * @param network - Network name ('mainnet', 'testnet', 'regtest'). Defaults to 'mainnet'\n *\n * @example\n * ```typescript\n * // Create new wallet with random seed\n * const wallet = new Wallet();\n *\n * // Create from seed phrase\n * const wallet = new Wallet('abandon abandon abandon...');\n *\n * // Create from master key\n * const masterKey = HDPrivateKey.fromString('xprv...');\n * const wallet = new Wallet(masterKey);\n *\n * // Create on testnet\n * const wallet = new Wallet(undefined, 'testnet');\n * ```\n */\n constructor(data?: string | HDPrivateKey | undefined, network?: string) {\n this._network = Networks.get(network) ?? Networks.mainnet\n this._accountStore = new AccountStore()\n if(isNil(data)) {\n this.phrase = Bip39.generateMnemonic(128, undefined, Bip39.wordlists.english)\n const seed = Bip39.mnemonicToSeedSync(this.phrase, '')\n\n const masterKey = HDPrivateKey.fromSeed(seed, this._network ?? Networks.mainnet)\n this.masterKey = masterKey.deriveChild(44, true).deriveChild(29223, true)\n } else if(data instanceof HDPrivateKey) {\n this.masterKey = data\n } else if (isString(data)) {\n this.phrase = data\n const seed = Bip39.mnemonicToSeedSync(this.phrase, '')\n\n const masterKey = HDPrivateKey.fromSeed(seed, this._network ?? Networks.mainnet)\n this.masterKey = masterKey.deriveChild(44, true).deriveChild(29223, true)\n }\n }\n\n /**\n * Create a new wallet with a randomly generated seed phrase\n *\n * This is the recommended way to create a new wallet for first-time users.\n * The generated seed phrase should be securely stored by the user.\n *\n * @returns A new Wallet instance with a random 12-word seed phrase\n *\n * @example\n * ```typescript\n * const wallet = Wallet.create();\n * console.log(wallet.export().phrase); // Store this securely!\n * ```\n */\n public static create(): Wallet {\n return new Wallet()\n }\n\n /**\n * Create a wallet from an existing BIP39 seed phrase\n *\n * Use this method to restore a wallet from a previously generated seed phrase.\n * The seed phrase should be a valid BIP39 mnemonic.\n *\n * @param phrase - The BIP39 seed phrase (12 or 24 words)\n * @param network - Optional network name ('mainnet', 'testnet', 'regtest')\n * @returns A new Wallet instance restored from the seed phrase\n * @throws {Error} If the seed phrase is invalid or not provided\n *\n * @example\n * ```typescript\n * const wallet = Wallet.fromSeedPhrase(\n * 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',\n * 'testnet'\n * );\n * ```\n */\n public static fromSeedPhrase(phrase: string, network?: string): Wallet {\n ValidationUtils.validateArgument(isString(phrase), 'seedphrase must be provided')\n return new Wallet(phrase, network)\n }\n\n /**\n * Create a wallet from an extended private key (xpriv)\n *\n * Use this method to create a wallet from a master private key in extended format.\n * This is useful for advanced users who want to use a specific key derivation.\n *\n * @param xpriv - The extended private key string (starts with 'xprv')\n * @param network - Optional network name ('mainnet', 'testnet', 'regtest')\n * @returns A new Wallet instance using the provided master key\n * @throws {Error} If the private key is invalid or not provided\n *\n * @example\n * ```typescript\n * const wallet = Wallet.fromXpriv(\n * 'xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'\n * );\n * ```\n */\n public static fromXpriv(xpriv: string, network?: string): Wallet {\n ValidationUtils.validateArgument(isString(xpriv), 'private key must be provided')\n const masterKey = HDPrivateKey.fromString(xpriv)\n return new Wallet(masterKey, network)\n }\n\n /**\n * Initialize the wallet by discovering accounts and loading balances\n *\n * This method performs account discovery using the BIP44 derivation path\n * and scans for existing accounts with transaction history or balances.\n * Must be called before using the wallet's accounts.\n *\n * @returns Promise that resolves when initialization is complete\n *\n * @example\n * ```typescript\n * const wallet = Wallet.fromSeedPhrase('your seed phrase');\n * await wallet.initialize();\n *\n * // Now you can access discovered accounts\n * const accounts = wallet.accountStore.listAccounts();\n * ```\n */\n public async initialize(): Promise<void> {\n const walletAccounts: BaseAccount[] = await discoverWallet(this.masterKey)\n for(const account of walletAccounts){\n this._accountStore.importAccount(account)\n }\n }\n\n /**\n * Create a new transaction builder for this wallet\n *\n * @param fromAccount - The account to send the transaction from\n * @param x - Optional existing transaction data:\n * - TransactionBuilder: Use existing transaction builder\n * - string: Parse from hex string\n * - Buffer: Parse from binary buffer\n * - undefined: Create new empty transaction\n * @returns A new WalletTransactionCreator instance\n *\n * @example\n * ```typescript\n * const account = wallet.accountStore.getAccount(0);\n * const tx = wallet.newTransaction(account)\n * .to('nexa:address', 1000000) // 1 NEXA\n * .sign();\n *\n * // Or from existing transaction hex\n * const tx = wallet.newTransaction(account, 'raw_tx_hex')\n * .sign();\n * ```\n */\n public newTransaction(fromAccount: BaseAccount, x?: TransactionBuilder | string | Buffer): WalletTransactionCreator {\n let tx: WalletTransactionCreator;\n\n if (x instanceof TransactionBuilder) {\n tx = new WalletTransactionCreator(fromAccount, x);\n } else if (isString(x)) {\n tx = new WalletTransactionCreator(fromAccount).parseTxHex(x);\n } else if (isBuffer(x) && !isNil(x)) {\n tx = new WalletTransactionCreator(fromAccount).parseTxBuffer(x);\n } else {\n tx = new WalletTransactionCreator(fromAccount);\n }\n\n return tx.onNetwork(this._network);\n }\n\n /**\n * Create a new account for this wallet\n *\n * @param accountType - The type of account to create:\n * - 'DefaultAccount': Standard account for general use\n * - 'VaultAccount': Secured account with additional protection\n * - 'DappAccount': Account optimized for dApp interactions\n * @returns Promise that resolves to the newly created account\n *\n * @example\n * ```typescript\n * const defaultAccount = await wallet.newAccount('DefaultAccount');\n * const vaultAccount = await wallet.newAccount('VaultAccount');\n * const dappAccount = await wallet.newAccount('DappAccount');\n * ```\n */\n public async newAccount(accountType: AccountType): Promise<BaseAccount>{\n return await this.accountStore.createAccount(accountType, this.masterKey)\n }\n\n /**\n * Broadcast a signed transaction to the Nexa network\n *\n * @param transaction - The signed transaction in hex format\n * @returns Promise that resolves to the transaction ID (txid)\n * @throws {Error} If the transaction is invalid or broadcast fails\n *\n * @example\n * ```typescript\n * const tx = wallet.newTransaction(account)\n * .to('nexa:address', 1000000)\n * .sign();\n *\n * const txId = await wallet.sendTransaction(tx.toHex());\n * console.log('Transaction sent:', txId);\n * ```\n */\n public async sendTransaction(transaction: string): Promise<string> {\n ValidationUtils.validateArgument(isString(transaction), 'transaction must be present and valid')\n return rostrumProvider.broadcast(transaction)\n }\n\n /**\n * Sign a message using a specific address from this wallet\n *\n * The message is signed using the private key associated with the given address.\n * This can be used for authentication or to prove ownership of an address.\n *\n * @param message - The message to sign\n * @param addressToUse - The address whose private key should sign the message\n * @returns The signature as a base64-encoded string\n * @throws {Error} If the address is not owned by this wallet\n *\n * @example\n * ```typescript\n * const account = wallet.accountStore.getAccount(0);\n * const address = account.getReceiveAddress();\n * const signature = wallet.signMessage('Hello World', address);\n * ```\n */\n public signMessage(message: string, addressToUse: string): string {\n let msg = new Message(message);\n const addressKey = this.accountStore.findKeyForAddress(addressToUse)\n ValidationUtils.validateArgument(isNil(addressKey), \"You dont own this private key\")\n return msg.sign(addressKey?.key.privateKey!)\n }\n\n /**\n * Verify a message signature against an address\n *\n * This method can verify signatures created by any address, not just addresses\n * owned by this wallet. It's useful for verifying messages from other parties.\n *\n * @param message - The original message that was signed\n * @param signature - The signature to verify (base64-encoded)\n * @param address - The address that supposedly signed the message\n * @returns true if the signature is valid, false otherwise\n * @throws {Error} If any parameters are missing or invalid\n *\n * @example\n * ```typescript\n * const isValid = wallet.verifyMessage(\n * 'Hello World',\n * 'signature_string',\n * 'nexa:address'\n * );\n * console.log('Signature valid:', isValid);\n * ```\n */\n public verifyMessage(message: string, signature: string, address: string): boolean {\n ValidationUtils.validateArgument(!isNil(message), 'message is required')\n ValidationUtils.validateArgument(!isNil(signature), 'signature is required')\n ValidationUtils.validateArgument(!isNil(address), 'address is required ')\n let msg = new Message(message);\n const addressKey = this.accountStore.findKeyForAddress(address)\n ValidationUtils.validateArgument(isNil(addressKey), \"You dont own this private key\")\n return msg.verify(address, signature)\n }\n\n /**\n * Export the wallet data for backup or storage\n *\n * Returns an object containing the wallet's seed phrase, master key, and accounts.\n * This data can be used to restore the wallet later. The seed phrase should be\n * stored securely as it provides full access to the wallet.\n *\n * @returns Object containing wallet data\n * @property {string} phrase - The BIP39 seed phrase (if available)\n * @property {HDPrivateKey} masterKey - The master private key\n * @property {BaseAccount[]} accounts - Array of discovered accounts\n *\n * @example\n * ```typescript\n * const walletData = wallet.export();\n *\n * // Store the seed phrase securely\n * const seedPhrase = walletData.phrase;\n *\n * // Later, restore the wallet\n * const restoredWallet = Wallet.fromSeedPhrase(seedPhrase);\n * ```\n */\n public export(): any {\n return {\n phrase: this.phrase,\n masterKey: this.masterKey,\n accounts: this._accountStore.listAccounts(),\n accountIndexes: this.accountStore.listAccounts().keys()\n }\n }\n\n /**\n * Get the account store for managing wallet accounts\n *\n * The account store provides methods to create, import, and manage accounts\n * within this wallet. Each account has its own set of addresses and keys.\n *\n * @returns The wallet's account store\n *\n * @example\n * ```typescript\n * const accountStore = wallet.accountStore;\n * const accounts = accountStore.listAccounts();\n * const firstAccount = accountStore.getAccount(0);\n * ```\n */\n get accountStore(): AccountStore {\n return this._accountStore;\n }\n\n /**\n * Get the network this wallet is operating on\n *\n * @returns The network object (mainnet, testnet, or regtest)\n *\n * @example\n * ```typescript\n * const network = wallet.network;\n * console.log('Network:', network.name);\n * ```\n */\n get network(): Networkish {\n return this._network;\n }\n}\n","import {ElectrumClient, SubscribeCallback} from \"@vgrunner/electrum-cash\";\nimport {\n BlockTip,\n IFirstUse,\n IListUnspentRecord,\n ITXHistory,\n ITokensBalance,\n ITokenListUnspent,\n ITransaction,\n IUtxo,\n RostrumParams,\n ITokenGenesis,\n RostrumScheme, RostrumTransportScheme\n} from \"../models/rostrum.entities\";\nimport { Balance } from \"../models/wallet.entities\";\n\ntype RPCParameter = string | number | boolean | null;\n\nexport class RostrumProvider {\n\n private client?: ElectrumClient;\n\n public constructor() {}\n\n public async getVersion() {\n return await this.execute<string[]>('server.version');\n }\n\n public async getBlockTip() {\n return await this.execute<BlockTip>('blockchain.headers.tip');\n }\n\n public async getBalance(address: string) {\n return await this.execute<Balance>('blockchain.address.get_balance', address, 'exclude_tokens');\n }\n\n public async getTransactionsHistory(address: string) {\n return await this.execute<ITXHistory[]>('blockchain.address.get_history', address);\n }\n\n public async getFirstUse(address: string) {\n return await this.execute<IFirstUse>('blockchain.address.get_first_use', address);\n }\n\n public async getTransaction(id: string, verbose: boolean = true) {\n return await this.execute<ITransaction>('blockchain.transaction.get', id, verbose);\n }\n\n public async getUtxo(outpoint: string) {\n return await this.execute<IUtxo>('blockchain.utxo.get', outpoint);\n }\n\n public async getNexaUtxos(address: string) {\n return await this.execute<IListUnspentRecord[]>('blockchain.address.listunspent', address, 'exclude_tokens');\n }\n\n public async getTokenUtxos(address: string, token: string) {\n let listunspent = await this.execute<ITokenListUnspent>('token.address.listunspent', address, null, token);\n return listunspent.unspent;\n }\n\n public async getTokensBalance(address: string, token?: string) {\n if (token) {\n return await this.execute<ITokensBalance>('token.address.get_balance', address, null, token);\n }\n return await this.execute<ITokensBalance>('token.address.get_balance', address);\n }\n\n public async getTokenGenesis(token: string) {\n return await this.execute<ITokenGenesis>('token.genesis.info', token);\n }\n\n public async subscribeToAddresses(addresses:string[], callback: SubscribeCallback) {\n for (const addr of addresses) {\n await this.client?.subscribe(callback, 'blockchain.address.subscribe', addr)\n }\n }\n\n public async broadcast(txHex: string) {\n return await this.execute<string>('blockchain.transaction.broadcast', txHex);\n }\n\n public async getLatency() {\n try {\n let start = Date.now();\n let res = await this.getBlockTip();\n if (res) {\n return Date.now() - start;\n }\n return 0;\n } catch {\n return 0;\n }\n }\n\n public async connect(params?: RostrumParams) {\n try {\n if (!params) {\n params = {\n host: 'aus.electrum.nexa.onethirtyseven.dev',\n port: 30004,\n scheme: (RostrumScheme.WSS as RostrumTransportScheme)\n }\n // params = await StorageProvider.getRostrumParams();\n }\n\n this.client = new ElectrumClient(\"com.otoplo.wallet\", \"1.4.3\", params.host, params.port, params.scheme, 30*1000, 10*1000, true);\n await this.client.connect();\n } catch (e) {\n if (e instanceof Error) {\n console.info(e.message);\n } else {\n console.error(e);\n }\n throw e;\n }\n }\n\n public async disconnect(force?: boolean) {\n try {\n return await this.client!.disconnect(force);\n } catch (e) {\n console.log(e)\n return false;\n }\n }\n\n private async execute<T>(method: string, ...parameters: RPCParameter[]) {\n var res = await this.client!.request(method, ...parameters);\n if (res instanceof Error) {\n throw res;\n }\n return res as T;\n }\n}\n\nexport const rostrumProvider = new RostrumProvider();","export type RostrumTransportScheme = 'ws' | 'wss';\n\nexport const RostrumScheme = {\n WS: 'ws',\n WSS: 'wss'\n}\n\nexport interface RostrumParams {\n scheme: RostrumTransportScheme;\n host: string;\n port: number;\n}\n\nexport interface BlockTip {\n height: number;\n hex: string;\n}\n\nexport interface IFirstUse {\n block_hash: string;\n block_height: number;\n height: number;\n tx_hash: string;\n}\n\nexport interface ITokenGenesis {\n decimal_places?: number,\n document_hash?: string;\n document_url?: string;\n group: string;\n height: number;\n name?: string;\n op_return?: string;\n ticker?: string;\n token_id_hex: string;\n txid: string;\n txidem: string;\n op_return_id: number;\n}\n\nexport interface ITokensBalance {\n cursor?: any;\n confirmed: Record<string, bigint | number>;\n unconfirmed: Record<string, bigint | number>;\n}\n\nexport interface ITokenListUnspent {\n cursor?: any;\n unspent: ITokenUtxo[];\n}\n\nexport interface ITokenUtxo {\n group: string;\n height: number;\n outpoint_hash: string;\n token_amount: number | bigint;\n token_id_hex: string;\n tx_hash: string;\n tx_pos: number;\n value: number;\n}\n\nexport interface IListUnspentRecord {\n has_token: boolean;\n height: number;\n outpoint_hash: string;\n tx_hash: string;\n tx_pos: number;\n value: number;\n}\n\nexport interface IUtxo {\n addresses: string[];\n amount: number;\n group: string;\n group_authority: bigint | number;\n group_quantity: bigint | number;\n height: number;\n scripthash: string;\n scriptpubkey: string;\n spent: ISpent;\n status: string;\n template_argumenthash: string;\n template_scripthash: string;\n token_id_hex: string;\n tx_hash: string;\n tx_idem: string;\n tx_pos: number;\n}\n\nexport interface ISpent {\n height: number;\n tx_hash: string;\n tx_pos: number;\n}\n\nexport interface ITransaction {\n blockhash: string;\n blocktime: number;\n confirmations: number;\n fee: number;\n fee_satoshi: number;\n hash: string;\n height: number;\n hex: string;\n locktime: number;\n size: number;\n time: number;\n txid: string;\n txidem: string;\n version: number;\n vin: ITXInput[];\n vout: ITXOutput[];\n}\n\nexport interface ITXInput {\n outpoint: string;\n scriptSig: IScriptSig;\n sequence: number;\n value: number;\n value_satoshi: bigint | number;\n addresses: string[];\n group: string;\n groupAuthority: bigint | number;\n groupQuantity: bigint | number;\n}\n\nexport interface ITXOutput {\n n: number;\n outpoint_hash: string;\n scriptPubKey: IScriptPubKey;\n type: number;\n value: number;\n value_satoshi: bigint | number;\n}\n\nexport interface IScriptSig {\n asm: string;\n hex: string;\n}\n\nexport interface IScriptPubKey {\n addresses: string[];\n argHash: string;\n asm: string;\n group: string;\n groupAuthority: bigint | number;\n groupQuantity: bigint | number;\n hex: string;\n scriptHash: string;\n token_id_hex?: string;\n type: string;\n}\n\nexport interface ITXHistory {\n fee?: number;\n height: number;\n tx_hash: string;\n}\n","import {rostrumProvider} from \"../network/RostrumProvider\";\nimport {AccountIndexes, AccountKeys, AddressKey, Balance} from \"../models/wallet.entities\";\nimport * as Bip39 from 'bip39';\nimport bigDecimal from \"js-big-decimal\";\nimport {ITXHistory, ITXInput, ITXOutput} from \"../models/rostrum.entities\";\nimport {Address, AddressType, HDPrivateKey, Networkish} from \"libnexa-ts\";\n\nimport {isNil} from \"lodash-es\";\nimport {BaseAccount} from \"../wallet/accounts/interfaces/BaseAccountInterface\";\nimport DAppAccount from \"../wallet/accounts/models/DappAccount\";\nimport DefaultAccount from \"../wallet/accounts/models/DefaultAccount\";\nimport VaultAccount from \"../wallet/accounts/models/VaultAccount\";\nimport {TransactionEntity, TxEntityState} from \"../models/transaction.entities\";\nimport {currentTimestamp, isNullOrEmpty} from \"./CommonUtils\";\n\nexport enum TxTokenType {\n NO_GROUP,\n CREATE,\n MINT,\n MELT,\n RENEW,\n TRANSFER\n}\n\nexport enum AccountType {\n NEXA_ACCOUNT,\n VAULT_ACCOUNT,\n DAPP_ACCOUNT,\n}\n\nexport function isValidNexaAddress(address: string, network: Networkish, type = AddressType.PayToScriptTemplate) {\n return Address.isValid(address, network, type);\n}\n\nexport function generateMasterKey(mnemonic: string, passphrase?: string | undefined) {\n const seed = Bip39.mnemonicToSeedSync(mnemonic, passphrase);\n const masterKey = HDPrivateKey.fromSeed(seed);\n return masterKey.deriveChild(44, true).deriveChild(29223, true);\n}\n\nexport function generateAccountKey(masterKey: HDPrivateKey, account: number) {\n return masterKey.deriveChild(account, true);\n}\n\nexport function generateKeysAndAddresses(accountKey: HDPrivateKey, fromRIndex: number, rIndex: number, fromCIndex: number, cIndex: number): AccountKeys {\n if (fromRIndex < 0) {\n throw new Error(`Can not generate keys with fromRIndex ${fromRIndex}. must be >= 0.`);\n }\n if (fromCIndex < 0) {\n throw new Error(`Can not generate keys with fromCIndex ${fromCIndex}. must be >= 0.`);\n }\n let receive = accountKey.deriveChild(0, false);\n let change = accountKey.deriveChild(1, false);\n let rKeys: AddressKey[] = [], cKeys: AddressKey[] = [];\n for (let index = fromRIndex; index < rIndex; index++) {\n let k = receive.deriveChild(index, false);\n let addr = k.privateKey.toAddress().toString();\n rKeys.push({key: k, address: addr, balance: \"0\", tokensBalance: {}});\n }\n for (let index = fromCIndex; index < cIndex; index++) {\n let k = change.deriveChild(index, false);\n let addr = k.privateKey.toAddress().toString();\n cKeys.push({key: k, address: addr, balance: \"0\", tokensBalance: {}});\n }\n return {receiveKeys: rKeys, changeKeys: cKeys};\n}\n\nexport function generateKeyAndAddress(accountKey: HDPrivateKey, rIndex: number): AddressKey {\n let receive = accountKey.deriveChild(0, false);\n let k = receive.deriveChild(rIndex, false);\n let addr = k.privateKey.toAddress().toString();\n return ({key: k, address: addr, balance: \"0\", tokensBalance: {}});\n}\n\nasync function discoverUsedAccountIndexes(deriveKey: HDPrivateKey) {\n let lastUsed = -1, index = 0, toScan = 20;\n\n while (toScan > 0) {\n toScan--;\n let rAddr = deriveKey.deriveChild(index, false).privateKey.toAddress().toString();\n let isUsed = await isAddressUsed(rAddr);\n if (isUsed) {\n lastUsed = index;\n toScan = 20;\n }\n index++;\n }\n // return the last used index, returns -1 if no indexes are used\n return lastUsed;\n}\n\nexport async function discoverNexaAccount(accountKey: HDPrivateKey) {\n\n let receiveKey = accountKey.deriveChild(0, false);\n let changeKey = accountKey.deriveChild(1, false);\n\n let rIndexPromise = discoverUsedAccountIndexes(receiveKey);\n let cIndexPromise = discoverUsedAccountIndexes(changeKey);\n\n let [rIndex, cIndex] = await Promise.all([rIndexPromise, cIndexPromise]);\n\n // get the index that is the last used nexa addr\n let indexes: AccountIndexes = { rIndex: rIndex, cIndex: cIndex };\n\n return indexes;\n}\n\nexport async function discoverNexaAccounts(masterKey: HDPrivateKey) {\n let accounts: DefaultAccount[] = [];\n\n let index = 0;\n while (true) {\n const nexaAccountKey = generateAccountKey(masterKey, index);\n const indexes = await discoverNexaAccount(nexaAccountKey);\n if (indexes.rIndex < 0 && indexes.cIndex < 0)\n {\n break;\n }\n if (indexes.rIndex < 0) {\n indexes.rIndex = 0;\n }\n if (indexes.cIndex < 0) {\n indexes.cIndex = 0;\n }\n // make account after break check, otherwise we might push an empty account\n const nexaAccount = new DefaultAccount(index, indexes, generateKeysAndAddresses(nexaAccountKey, indexes.rIndex + 1, indexes.rIndex + 20, indexes.cIndex + 1, indexes.cIndex + 20))\n await nexaAccount.loadBalances()\n accounts.push(nexaAccount);\n if (index == 0) {\n index = 100;\n }\n else {\n index++;\n }\n }\n if (accounts.length == 0) {\n // default account was unused but we need to populate at least one account,\n // make the default account here\n let defaultNexaAccountKey = generateAccountKey(masterKey, 0);\n // get the last used indexes, -1 means unused\n let defaultIndexes: AccountIndexes = { rIndex: 0, cIndex: 0 };\n const defaultAccount = new DefaultAccount(0, defaultIndexes, generateKeysAndAddresses(defaultNexaAccountKey, defaultIndexes.rIndex, defaultIndexes.rIndex + 20, defaultIndexes.cIndex, defaultIndexes.cIndex + 20))\n await defaultAccount.loadBalances()\n accounts.push(defaultAccount)\n }\n return accounts;\n}\n\nasync function findUsedVaultAccounts(masterKey: HDPrivateKey) {\n // all vaults are in bip44 account 1\n let vaultAccountKey = generateAccountKey(masterKey, 1);\n // all vaults are in the external chain\n let vaultChain = vaultAccountKey.deriveChild(0, false);\n // get the index that is the last used vault\n return await discoverUsedAccountIndexes(vaultChain);\n}\n\nexport async function discoverVaults(masterKey: HDPrivateKey) {\n let accounts: VaultAccount[] = [];\n // all vaults are in bip44 account 1\n let vaultAccountKey = generateAccountKey(masterKey, 1);\n // find the next unused vault\n let lastUsedVaultIndex: number = await findUsedVaultAccounts(masterKey);\n // if all vaults unused, generate at least the first vault account\n if (lastUsedVaultIndex < 0) lastUsedVaultIndex = 0;\n // for each vault found, make the DefaultAccount for that vault\n for (let index = 0; index <= lastUsedVaultIndex; index++)\n {\n const vaultAccount = new VaultAccount(1, index, generateKeyAndAddress(vaultAccountKey, index))\n await vaultAccount.loadBalances();\n accounts.push(vaultAccount);\n }\n return accounts;\n}\n\nasync function findUsedDappAccounts(masterKey: HDPrivateKey) {\n // all dApp accounts are in bip44 account 2\n let dappAccountKey = generateAccountKey(masterKey, 2);\n // all dApp accounts use the external chain\n let dappChain = dappAccountKey.deriveChild(0, false);\n // get the index that is the next unused dApp account\n return await discoverUsedAccountIndexes(dappChain);\n}\n\nexport async function discoverDappAccounts(masterKey: HDPrivateKey) {\n let accounts: DAppAccount[] = [];\n // all dApp accounts are in bip44 account 2\n let dappAccountKey = generateAccountKey(masterKey, 2);\n // find the next unused dapp account\n let lastUsedDappIndex: number = await findUsedDappAccounts(masterKey);\n // if all dapp accounts unused, generate at least the first dapp account\n if (lastUsedDappIndex < 0) lastUsedDappIndex = 0;\n // for each dApp account found, make the DefaultAccount for that dApp account\n // for each vault found, make the DefaultAccount for that vault\n for (let index = 0; index <= lastUsedDappIndex; index++)\n {\n const dappAccount = new DAppAccount(2, index, generateKeyAndAddress(dappAccountKey, index))\n await dappAccount.loadBalances();\n accounts.push(dappAccount);\n }\n return accounts;\n}\n\nexport async function discoverWallet(masterKey: HDPrivateKey) {\n let accounts: BaseAccount[] = [];\n // accounts 0, 100+\n const nexaAccounts = await discoverNexaAccounts(masterKey);\n // vaults in bip44 account 1\n const vaultAccounts = await discoverVaults(masterKey);\n // dApp accounts in bip44 account 2\n const dappAccounts = await discoverDappAccounts(masterKey);\n // 3 - 99 are reserved and will go here when added\n accounts = accounts.concat(nexaAccounts);\n accounts = accounts.concat(vaultAccounts);\n accounts = accounts.concat(dappAccounts);\n return accounts;\n}\n\nasync function isAddressUsed(address: string) {\n try {\n let firstUse = await rostrumProvider.getFirstUse(address);\n return firstUse.tx_hash && firstUse.tx_hash !== \"\";\n } catch (e) {\n if (e instanceof Error && e.message.includes(\"not found\")) {\n return false;\n }\n throw e;\n }\n}\n\nasync function getKeyTokenBalance(key: AddressKey) {\n let tokensBalance = await rostrumProvider.getTokensBalance(key.address);\n let balance: Record<string, Balance> = {};\n\n for (const cToken in tokensBalance.confirmed) {\n if (tokensBalance.confirmed[cToken] != 0) {\n balance[cToken] = { confirmed: BigInt(tokensBalance.confirmed[cToken]).toString(), unconfirmed: \"0\" }\n }\n }\n\n for (const uToken in tokensBalance.unconfirmed) {\n if (tokensBalance.unconfirmed[uToken] != 0) {\n if (balance[uToken]) {\n balance[uToken].unconfirmed = BigInt(tokensBalance.unconfirmed[uToken]).toString();\n } else {\n balance[uToken] = { confirmed: \"0\", unconfirmed: BigInt(tokensBalance.unconfirmed[uToken]).toString() }\n }\n }\n }\n\n return balance;\n}\n\nasync function getAndUpdateAddressKeyBalance(key: AddressKey) {\n let balance = await rostrumProvider.getBalance(key.address);\n key.balance = (BigInt(balance.confirmed) + BigInt(balance.unconfirmed)).toString();\n key.tokensBalance = await getKeyTokenBalance(key);\n\n return balance;\n}\n\nexport async function fetchTotalBalance(keys: AddressKey[]) {\n let promises: Promise<Balance>[] = [];\n keys.forEach(key => {\n let b = getAndUpdateAddressKeyBalance(key);\n promises.push(b);\n });\n\n return await Promise.all(promises);\n}\n\nexport function sumBalance(balances: Balance[]): Balance {\n let confirmed = new bigDecimal(0), unconfirmed = new bigDecimal(0);\n balances.forEach(b => {\n confirmed = confirmed.add(new bigDecimal(b.confirmed));\n unconfirmed = unconfirmed.add(new bigDecimal(b.unconfirmed));\n });\n return {confirmed: confirmed.getValue(), unconfirmed: unconfirmed.getValue()};\n}\n\nexport function sumTokensBalance(balances: Record<string, Balance>[]) {\n let tokensBalance: Record<string, Balance> = {};\n balances.forEach(b => {\n for (const key in b) {\n if (tokensBalance[key]) {\n tokensBalance[key].confirmed = (BigInt(tokensBalance[key].confirmed) + BigInt(b[key].confirmed)).toString();\n tokensBalance[key].unconfirmed = (BigInt(tokensBalance[key].unconfirmed) + BigInt(b[key].unconfirmed)).toString();\n } else {\n tokensBalance[key] = { confirmed: b[key].confirmed, unconfirmed: b[key].unconfirmed };\n }\n }\n });\n\n return tokensBalance;\n}\n\nexport async function fetchTransactionsHistory(addresses: string[], fromHeight: number) {\n let index = 0, i = 0, data = new Map<string, ITXHistory>(), maxHeight = fromHeight;\n\n for (let address of addresses) {\n i++;\n let txHistory = await rostrumProvider.getTransactionsHistory(address);\n if (txHistory && txHistory.length > 0) {\n index = i;\n for (let tx of txHistory) {\n if (tx.height === 0 || tx.height > fromHeight) {\n maxHeight = Math.max(maxHeight, tx.height);\n data.set(tx.tx_hash, tx);\n }\n }\n }\n }\n\n return {index: index, txs: data, lastHeight: maxHeight};\n}\n\nasync function rescanAddressesHistory(addresses: string[]) {\n let index = 0, i = 0, minHeight = Number.MAX_SAFE_INTEGER;\n\n for (let address of addresses) {\n i++;\n let txHistory = await rostrumProvider.getTransactionsHistory(address);\n if (!isNil(txHistory)) {\n index = i;\n let heights = txHistory.filter(tx => tx.height > 0).map(h => h.height);\n if (!isNil(heights)) {\n minHeight = Math.min(minHeight, ...heights);\n }\n }\n }\n\n return {index: (index > 0 ? index + 1 : 0), height: (minHeight == Number.MAX_SAFE_INTEGER ? 0 : minHeight)};\n}\n\nexport async function getNextAccountIndex(accountType: AccountType, masterKey: HDPrivateKey) {\n if (accountType == AccountType.NEXA_ACCOUNT) {\n let defaultNexaAccountKey = generateAccountKey(masterKey, 0);\n const defaultIndexes = await discoverNexaAccount(defaultNexaAccountKey);\n if (defaultIndexes.rIndex < 0 && defaultIndexes.cIndex < 0){\n return 0;\n }\n else {\n // account 0 was not empty\n for (let index = 100; ; index++) {\n const nexaAccountKey = generateAccountKey(masterKey, index);\n const indexes = await discoverNexaAccount(nexaAccountKey);\n if (indexes.rIndex < 0 && indexes.cIndex < 0)\n {\n return index;\n }\n }\n }\n }\n else if (accountType == AccountType.VAULT_ACCOUNT) {\n // find the next unused vault\n const lastUsedVault: number = await findUsedVaultAccounts(masterKey);\n return lastUsedVault + 1;\n }\n else if (accountType == AccountType.DAPP_ACCOUNT) {\n // find the next unused dapp account\n const lastUsedDappAccount: number = await findUsedDappAccounts(masterKey);\n return lastUsedDappAccount + 1;\n }\n else {\n throw new Error(\"Can not get next account index. Invalid accountType.\");\n }\n}\n\nexport async function classifyTransaction(txHistory: ITXHistory, myAddresses: string[]) {\n let t = await rostrumProvider.getTransaction(txHistory.tx_hash);\n\n let outputs = t.vout.filter(utxo => !isNil(utxo.scriptPubKey.addresses));\n\n let isOutgoing = t.vin.length > 0 && myAddresses.includes(t.vin[0].addresses[0]);\n let isIncoming = !isOutgoing || outputs.every(utxo => myAddresses.includes(utxo.scriptPubKey.addresses[0]));\n let isConfirmed = t.height > 0;\n\n let txEntry = {} as TransactionEntity;\n txEntry.txId = t.txid;\n txEntry.txIdem = t.txidem;\n txEntry.height = isConfirmed ? t.height : 0;\n txEntry.time = isConfirmed ? t.time : currentTimestamp();\n txEntry.fee = t.fee_satoshi;\n\n if (isOutgoing && isIncoming) {\n txEntry.state = 'both';\n txEntry.value = \"0\";\n txEntry.payTo = \"Payment to yourself\";\n } else if (isIncoming) {\n txEntry.state = 'incoming';\n let utxos = outputs.filter(utxo => myAddresses.includes(utxo.scriptPubKey.addresses[0]));\n let amount = new bigDecimal(0);\n utxos.forEach(utxo => {\n amount = amount.add(new bigDecimal(utxo.value_satoshi));\n });\n txEntry.value = amount.getValue();\n txEntry.payTo = utxos[0].scriptPubKey.addresses[0];\n } else if(isOutgoing) {\n txEntry.state = 'outgoing';\n let utxos = outputs.filter(utxo => !myAddresses.includes(utxo.scriptPubKey.addresses[0]));\n let amount = new bigDecimal(0);\n utxos.forEach(utxo => {\n amount = amount.add(new bigDecimal(utxo.value_satoshi));\n });\n txEntry.value = amount.getValue();\n txEntry.payTo = utxos[0].scriptPubKey.addresses[0];\n }\n\n let [txType, txGroup, tokenAmount, extraGroup] = classifyTokenTransaction(t.vin, outputs, txEntry.state, myAddresses);\n txEntry.txGroupType = txType;\n txEntry.token = txGroup;\n txEntry.tokenAmount = tokenAmount;\n txEntry.extraGroup = extraGroup;\n\n return txEntry;\n}\n\nfunction classifyTokenTransaction(vin: ITXInput[], vout: ITXOutput[], txState: TxEntityState, myAddresses: string[]): [TxTokenType, string, string, string] {\n let groupInputs = vin.filter(input => !isNullOrEmpty(input.group));\n let groupOutputs = vout.filter(output => !isNullOrEmpty(output.scriptPubKey.group));\n\n if (isNullOrEmpty(groupInputs) && isNullOrEmpty(groupOutputs)) {\n return [TxTokenType.NO_GROUP, \"none\", \"0\", \"none\"];\n }\n\n let myGroupInputs = groupInputs.filter(input => myAddresses.includes(input.addresses[0]));\n let myGroupOutputs = groupOutputs.filter(output => myAddresses.includes(output.scriptPubKey.addresses[0]));\n\n if (isNullOrEmpty(myGroupInputs) && isNullOrEmpty(myGroupOutputs)) {\n return [TxTokenType.NO_GROUP, \"none\", \"0\", \"none\"];\n }\n\n if (isNullOrEmpty(groupInputs)) {\n let group = myGroupOutputs.find(output => BigInt(output.scriptPubKey.groupQuantity) < 0n)?.scriptPubKey.group ?? \"none\";\n return [TxTokenType.CREATE, group, \"0\", \"none\"];\n }\n\n if (isNullOrEmpty(groupOutputs)) {\n if (txState === 'incoming') {\n return [TxTokenType.NO_GROUP, \"none\", \"0\", \"none\"];\n }\n\n let inputs = myGroupInputs.filter(input => BigInt(input.groupQuantity) > 0n);\n if (!isNullOrEmpty(inputs)) {\n let amount = new bigDecimal(0);\n inputs.forEach(utxo => {\n amount = amount.add(new bigDecimal(utxo.groupQuantity));\n });\n let group = inputs[0].group;\n let extraGroup = myGroupInputs.find(input => BigInt(input.groupQuantity) < 0n && inputs[0].group != input.group)?.group ?? \"none\";\n return [TxTokenType.MELT, group, amount.getValue(), extraGroup];\n }\n\n let group = myGroupInputs.find(input => BigInt(input.groupQuantity) < 0n)?.group ?? \"none\";\n let extraGroup = myGroupInputs.find(input => BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? \"none\";\n return [TxTokenType.MELT, group, \"0\", extraGroup];\n }\n\n let tokenInputs = groupInputs.filter(input => BigInt(input.groupQuantity) > 0n);\n let tokenOutputs = groupOutputs.filter(output => BigInt(output.scriptPubKey.groupQuantity) > 0n);\n\n if (isNullOrEmpty(tokenInputs) && isNullOrEmpty(tokenOutputs)) {\n let group = groupInputs.find(input => BigInt(input.groupQuantity) < 0n)?.group ?? \"none\";\n let extraGroup = groupOutputs.find(output => BigInt(output.scriptPubKey.groupQuantity) < 0n && group != output.scriptPubKey.group)?.scriptPubKey.group ?? \"none\";\n return [TxTokenType.RENEW, extraGroup !== 'none' ? extraGroup : group, \"0\", extraGroup !== 'none' ? group : extraGroup];\n }\n\n if (isNullOrEmpty(tokenInputs)) {\n let group = tokenOutputs[0].scriptPubKey.group;\n let amount = new bigDecimal(0);\n tokenOutputs.forEach(utxo => {\n amount = amount.add(new bigDecimal(utxo.scriptPubKey.groupQuantity));\n });\n let extraGroup = groupInputs.find(input => BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? \"none\";\n return [TxTokenType.MINT, group, amount.getValue(), extraGroup];\n }\n\n if (isNullOrEmpty(tokenOutputs)) {\n let group = tokenInputs[0].group;\n let amount = new bigDecimal(0);\n tokenInputs.forEach(utxo => {\n amount = amount.add(new bigDecimal(utxo.groupQuantity));\n });\n let extraGroup = groupInputs.find(input => BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? \"none\";\n return [TxTokenType.MELT, group, amount.getValue(), extraGroup];\n }\n\n let outQuantitySum = tokenOutputs.map(output => BigInt(output.scriptPubKey.groupQuantity)).reduce((a, b) => a + b, 0n);\n let inQuantitySum = tokenInputs.map(input => BigInt(input.groupQuantity)).reduce((a, b) => a + b, 0n);\n\n if (outQuantitySum > inQuantitySum) {\n let group = tokenOutputs[0].scriptPubKey.group;\n let extraGroup = groupInputs.find(input => BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? \"none\";\n return [TxTokenType.MINT, group, (outQuantitySum - inQuantitySum).toString(), extraGroup];\n }\n\n if (inQuantitySum > outQuantitySum) {\n let group = tokenInputs[0].group;\n let extraGroup = groupInputs.find(input => BigInt(input.groupQuantity) < 0n && group != input.group)?.group ?? \"none\";\n return [TxTokenType.MELT, group, (inQuantitySum - outQuantitySum).toString(), extraGroup];\n }\n\n let group = tokenOutputs[0].scriptPubKey.group;\n let amount = \"\";\n if (txState === 'incoming') {\n amount = tokenOutputs\n .filter(output => myAddresses.includes(output.scriptPubKey.addresses[0]))\n .map(output => BigInt(output.scriptPubKey.groupQuantity))\n .reduce((a, b) => a + b, 0n)\n .toString();\n } else if (txState === 'outgoing') {\n amount = tokenOutputs\n .filter(output => !myAddresses.includes(output.scriptPubKey.addresses[0]))\n .map(output => BigInt(output.scriptPubKey.groupQuantity))\n .reduce((a, b) => a + b, 0n)\n .toString();\n } else {\n amount = \"0\";\n }\n\n return [TxTokenType.TRANSFER, group, amount, \"none\"];\n}","import {AccountIndexes, AccountKeys, AddressKey} from \"../../../models/wallet.entities\";\nimport {BaseAccount} from \"../interfaces/BaseAccountInterface\";\nimport {\n AccountType, classifyTransaction,\n fetchTotalBalance,\n fetchTransactionsHistory,\n sumBalance,\n sumTokensBalance\n} from \"../../../utils/WalletUtils\";\nimport {PrivateKey} from \"libnexa-ts\";\nimport {TransactionEntity} from \"../../../models/transaction.entities\";\n\nexport default class DAppAccount extends BaseAccount {\n\n private readonly _accountIndex: number;\n private readonly _accountKey: AddressKey;\n\n constructor(bip44Account: number, accountIndex: number, addressKey: AddressKey) {\n super(bip44Account)\n this._accountIndex = accountIndex;\n this._accountKey = addressKey\n }\n\n // this is used in AccountStore.ts to get the key to be used in the map for this account\n public getAccountStoreKey(): string {\n return String(this._bip44Account + '.' + this._accountIndex);\n }\n\n public getAccountType(): AccountType {\n return AccountType.DAPP_ACCOUNT;\n }\n\n public getNewAddress() {\n return this._accountKey.address;\n }\n\n public getNewChangeAddress(): string {\n return this._accountKey.address;\n }\n\n get accountIndexes(): AccountIndexes {\n return {\n rIndex: this._accountIndex,\n cIndex: 0\n };\n }\n\n get accountKeys(): AccountKeys {\n return {\n receiveKeys: [this._accountKey],\n changeKeys: [this._accountKey]\n };\n }\n\n async loadBalances(): Promise<void> {\n let balances = await fetchTotalBalance([this._accountKey]);\n let tokenBalances = [this._accountKey].map(k => k.tokensBalance);\n super.balance = sumBalance(balances)\n super.tokenBalances = sumTokensBalance(tokenBalances)\n }\n\n getKeyFromAddress(address: string): AddressKey {\n return this._accountKey;\n }\n\n async getTransactions(fromHeight?: number, address?: string): Promise<Map<string, TransactionEntity>> {\n let txPromises:TransactionEntity[] = []\n\n const transactions = await fetchTransactionsHistory([address ?? this._accountKey.address], fromHeight ?? 0)\n for (let tx of transactions.txs.values()) {\n let t = await classifyTransaction(tx, [address ?? this._accountKey.address])\n txPromises.push(t)\n }\n await Promise.all(txPromises)\n for (let txEntity of txPromises){\n this.transactions.set(txEntity.txId, txEntity)\n }\n return this.transactions\n }\n}\n","import {AccountIndexes, AccountKeys, AddressKey, Balance} from \"../../../models/wallet.entities\";\nimport DefaultAccount from \"../models/DefaultAccount\";\nimport bigDecimal from \"js-big-decimal\";\nimport {AccountType} from \"../../../utils/WalletUtils\";\nimport {PrivateKey} from \"libnexa-ts\";\nimport {TransactionEntity} from \"../../../models/transaction.entities\";\n\nexport abstract class BaseAccount {\n get transactions(): Map<string, TransactionEntity> {\n return this._transactions;\n }\n\n set transactions(value: Map<string, TransactionEntity>) {\n this._transactions = value;\n }\n\n protected readonly _bip44Account: number;\n private _balance?: Balance;\n private _tokenBalances?: Record<string, Balance> = {};\n private _transactions : Map<string, TransactionEntity> = new Map<string, TransactionEntity>()\n\n protected constructor(_bip44Account: number) {\n this._bip44Account = _bip44Account;\n this._balance = {\n confirmed: 0,\n unconfirmed: 0\n }\n this._tokenBalances = {};\n }\n\n abstract get accountIndexes(): AccountIndexes;\n abstract get accountKeys(): AccountKeys;\n abstract getNewChangeAddress(): string;\n abstract getNewAddress(): string;\n abstract getAccountStoreKey(): string;\n abstract getAccountType(): AccountType;\n abstract loadBalances(): Promise<void>;\n abstract getKeyFromAddress(address:string): AddressKey;\n abstract getTransactions(fromHeight?: number, address?:string): Promise<Map<string, TransactionEntity>>;\n\n get balance(): Balance {\n return this._balance!;\n }\n\n set balance(value: Balance) {\n this._balance = value;\n }\n\n get tokenBalances(): Record<string, Balance> {\n return this._tokenBalances!;\n }\n\n set tokenBalances(value: Record<string, Balance>) {\n this._tokenBalances = value;\n }\n}\n","import {AccountIndexes, AccountKeys, AddressKey} from \"../../../models/wallet.entities\";\nimport {BaseAccount} from \"../interfaces/BaseAccountInterface\";\nimport {\n AccountType, classifyTransaction,\n fetchTotalBalance,\n fetchTransactionsHistory,\n sumBalance,\n sumTokensBalance\n} from \"../../../utils/WalletUtils\";\nimport {PrivateKey} from \"libnexa-ts\";\nimport {TransactionEntity} from \"../../../models/transaction.entities\";\n\nexport default class DefaultAccount extends BaseAccount {\n\n private readonly _accountIndexes: AccountIndexes; // either a list of indexes or a single bip44 account index\n private _accountKeys: AccountKeys; // either a list of keys or a single key\n\n constructor(bip44Account: number, accountIndexes: AccountIndexes, accountKeys: AccountKeys) {\n super(bip44Account)\n if (accountIndexes.rIndex < 0) {\n throw new Error(`Can not create nexa account with an rindex of ${accountIndexes.rIndex}. must be >= 0.`);\n }\n if (accountIndexes.cIndex < 0) {\n throw new Error(`Can not create nexa account with an cindex of ${accountIndexes.cIndex}. must be >= 0.`);\n }\n this._accountIndexes = accountIndexes;\n this._accountKeys = accountKeys;\n }\n\n // this is used in AccountStore.ts to get the key to be used in the map for this account\n public getAccountStoreKey() {\n return String(this._bip44Account);\n }\n\n public getAccountType(): AccountType {\n return AccountType.NEXA_ACCOUNT\n }\n\n public getNewAddress() {\n return this._accountKeys.receiveKeys[this._accountKeys.receiveKeys.length - 1]?.address ?? '';\n }\n\n public getNewChangeAddress(): string {\n return this._accountKeys.changeKeys[this._accountKeys.changeKeys.length - 1]?.address ?? ''\n }\n\n get accountIndexes(): AccountIndexes {\n return this._accountIndexes;\n }\n\n get accountKeys(): AccountKeys {\n return this._accountKeys;\n }\n\n async loadBalances(): Promise<void> {\n let balances = await fetchTotalBalance(this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys));\n let tokenBalances = this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys).map(k => k.tokensBalance);\n super.balance = sumBalance(balances)\n super.tokenBalances = sumTokensBalance(tokenBalances)\n }\n\n getKeyFromAddress(address: string): AddressKey {\n const allKeys = this._accountKeys.receiveKeys.concat(this._accountKeys.changeKeys)\n const keyFound = allKeys.find(key => key.address === address)\n return keyFound!\n }\n\n async getTransactions(fromHeight?: number, address?: string): Promise<Map<string, TransactionEntity>> {\n\n let receiveAddresses = this.accountKeys.receiveKeys.map(ak => ak.address);\n let changeAddresses = this.accountKeys.changeKeys.map(ak => ak.address);\n let allAddresses = receiveAddresses.concat(changeAddresses);\n\n let rTxs = fetchTransactionsHistory(address != null ? [address]: receiveAddresses, fromHeight ?? 0);\n let cTxs = fetchTransactionsHistory(address != null ? [address] : receiveAddresses, fromHeight ?? 0);\n\n let [rData, cData] = await Promise.all([rTxs, cTxs]);\n\n let txHistory = rData.txs;\n for (let tx of cData.txs.values()) {\n txHistory.set(tx.tx_hash, tx);\n }\n\n let txPromises: TransactionEntity[] = [];\n for (let tx of txHistory.values()) {\n let t = await classifyTransaction(tx, allAddresses);\n txPromises.push(t);\n }\n await Promise.all(txPromises)\n\n for (let txEntity of txPromises){\n this.transactions.set(txEntity.txId, txEntity)\n }\n return this.transactions\n }\n}\n","import {AccountIndexes, AccountKeys, AddressKey} from \"../../../models/wallet.entities\";\nimport {BaseAccount} from \"../interfaces/BaseAccountInterface\";\nimport {\n AccountType, classifyTransaction,\n fetchTotalBalance,\n fetchTransactionsHistory,\n sumBalance,\n sumTokensBalance\n} from \"../../../utils/WalletUtils\";\nimport {PrivateKey} from \"libnexa-ts\";\nimport {TransactionEntity} from \"../../../models/transaction.entities\";\nimport {rostrumProvider} from \"../../../network/RostrumProvider\";\n\nexport default class VaultAccount extends BaseAccount {\n\n private readonly _accountIndex: number;\n private readonly _accountKey: AddressKey;\n\n constructor(bip44Account: number, accountIndex: number, addressKey: AddressKey) {\n super(bip44Account)\n this._accountIndex = accountIndex;\n this._accountKey = addressKey;\n }\n\n // this is used in AccountStore.ts to get the key to be used in the map for this account\n public getAccountStoreKey(): string {\n return String(this._bip44Account + '.' + this._accountIndex);\n }\n\n public getAccountType(): AccountType {\n return AccountType.VAULT_ACCOUNT\n }\n\n public getNewAddress() {\n return this._accountKey.address\n }\n\n public getNewChangeAddress(): string {\n return this._accountKey.address\n }\n\n get accountIndexes(): AccountIndexes {\n return {\n rIndex: this._accountIndex,\n cIndex: 0\n };\n }\n\n get accountKeys(): AccountKeys {\n return {\n receiveKeys: [this._accountKey],\n changeKeys: [this._accountKey]\n };\n }\n\n async loadBalances(): Promise<void> {\n let balances = await fetchTotalBalance([this._accountKey]);\n let tokenBalances = [this._accountKey].map(k => k.tokensBalance);\n super.balance = sumBalance(balances)\n super.tokenBalances = sumTokensBalance(tokenBalances)\n }\n\n getKeyFromAddress(address: string): AddressKey {\n return this._accountKey;\n }\n\n async getTransactions(fromHeight?: number, address?: string): Promise<Map<string, TransactionEntity>> {\n let txPromises:TransactionEntity[] = []\n\n const transactions = await fetchTransactionsHistory([address ?? this._accountKey.address], fromHeight ?? 0)\n for (let tx of transactions.txs.values()) {\n let t = await classifyTransaction(tx, [address ?? this._accountKey.address])\n txPromises.push(t)\n }\n await Promise.all(txPromises)\n for (let txEntity of txPromises){\n this.transactions.set(txEntity.txId, txEntity)\n }\n return this.transactions\n }\n}\n","import bigDecimal from 'js-big-decimal';\nimport { Address, CommonUtils } from 'libnexa-ts';\n\n/** Maximum value for a 64-bit signed integer */\nexport const MAX_INT64: bigint = 9223372036854775807n;\n\n/**\n * Get the current Unix timestamp in seconds\n * \n * @returns Current timestamp as number of seconds since Unix epoch\n * \n * @example\n * ```typescript\n * const now = currentTimestamp();\n * console.log('Current time:', now);\n * ```\n */\nexport function currentTimestamp() {\n return Math.floor(Date.now() / 1000);\n}\n\n/**\n * Check if a value is null, undefined, or empty\n * \n * @param arg - The value to check\n * @returns true if the value is null, undefined, empty string, or empty array\n * \n * @example\n * ```typescript\n * isNullOrEmpty(''); // true\n * isNullOrEmpty([]); // true\n * isNullOrEmpty(null); // true\n * isNullOrEmpty('hello'); // false\n * ```\n */\nexport function isNullOrEmpty(arg?: string | any[] | null): arg is undefined | [] | null | '' {\n return !arg || arg.length === 0;\n}\n\n/**\n * Parse an amount with decimal places and format it for display\n * \n * Converts a raw amount to a human-readable format by dividing by 10^decimals\n * and removing trailing zeros.\n * \n * @param amount - The raw amount to parse\n * @param decimals - Number of decimal places\n * @returns Formatted amount string\n * \n * @example\n * ```typescript\n * parseAmountWithDecimals(1000000, 6); // '1'\n * parseAmountWithDecimals(1500000, 6); // '1.5'\n * parseAmountWithDecimals(1000000n, 6); // '1'\n * ```\n */\nexport function parseAmountWithDecimals(amount: string | number | bigint, decimals: number) {\n let val = new bigDecimal(amount).divide(new bigDecimal(Math.pow(10, decimals)), decimals).getPrettyValue();\n if (val.match(/\\./)) {\n val = val.replace(/\\.?0+$/, '');\n }\n return val;\n}\n\n/**\n * Convert a decimal amount to raw integer format\n * \n * Multiplies the amount by 10^decimals to get the raw integer representation\n * used in transactions.\n * \n * @param amount - The decimal amount to convert\n * @param decimals - Number of decimal places\n * @returns Raw amount as string\n * \n * @example\n * ```typescript\n * getRawAmount('1.5', 6); // '1500000'\n * getRawAmount(1.5, 6); // '1500000'\n * ```\n */\nexport function getRawAmount(amount: string | number | bigint, decimals: number) {\n return new bigDecimal(amount).multiply(new bigDecimal(Math.pow(10, decimals))).getValue();\n}\n\n/**\n * Get the buffer representation of an address\n * \n * @param address - The address string (hex or Nexa address format)\n * @returns Buffer containing the address data\n * \n * @example\n * ```typescript\n * const buffer = getAddressBuffer('nexatest:nqtsq5g5jsdmqqywaqd82lhnnk3a8wqunjz6gtxdtavnnekc');\n * const hexBuffer = getAddressBuffer('a1b2c3d4e5f6');\n * ```\n */\nexport function getAddressBuffer(address: string) {\n if (CommonUtils.isHexa(address)) {\n return Buffer.from(address, 'hex') ;\n }\n return Address.fromString(address).data;\n}\n\n/**\n * Convert a token ID to hex format\n * \n * @param token - The token ID (hex string or Nexa address format)\n * @returns Token ID in hex format\n * \n * @example\n * ```typescript\n * const hexId = tokenIdToHex('nexatest:tq8r37lcjlqazz7vuvug84q2ev50573hesrnxkv9y6hvhhl5k5qqqnmyf79mx');\n * const hexId2 = tokenIdToHex('a1b2c3d4e5f6'); // already hex, returns as-is\n * ```\n */\nexport function tokenIdToHex(token: string) {\n if (CommonUtils.isHexa(token)) {\n return token;\n }\n return getAddressBuffer(token).toString('hex');\n}\n\n\n","import {PrivateKey, TransactionBuilder} from \"libnexa-ts\";\nimport {rostrumProvider} from \"../../network/RostrumProvider\";\nimport {\n buildCreateGroupTransaction,\n populateAndDuplicateTokenAuths,\n populateNexaInputsAndChange,\n populateTokenAuth,\n populateTokenInputsAndChange,\n prepareDeleteTransaction\n} from \"../../utils/TXUtils\";\nimport {BaseAccount} from \"../accounts/interfaces/BaseAccountInterface\";\nimport {AddressKey} from \"../../models/wallet.entities\";\nimport {TransactionCreator} from \"./interfaces/TransactionCreator\";\nimport {keys} from \"lodash-es\";\nimport {PermissionLabel} from \"../../models/transaction.entities\";\n\nexport default class WalletTransactionCreator extends TransactionCreator {\n\n private _keysToSign: PrivateKey[] = [];\n private _account!: BaseAccount;\n\n constructor(fromAccount: BaseAccount, tx?: TransactionBuilder | string | Buffer) {\n super(tx)\n this._account = fromAccount\n this.validateAccount()\n }\n\n public fromAccount(fromAccount: BaseAccount): this {\n this._account = fromAccount\n return this\n }\n\n public parseTxHex(tx: string) {\n this.builder.push(async () => {\n const txBuilder = new TransactionBuilder(tx)\n const newTxBuilder = new TransactionBuilder()\n const oldInputs = txBuilder.transaction.inputs\n for (const input of oldInputs) {\n const utxo = await rostrumProvider.getUtxo(input.outpoint.toString('hex'))\n newTxBuilder.from({\n outpoint: utxo.tx_hash,\n amount: utxo.amount,\n scriptPubKey: utxo.scriptpubkey\n })\n const foundKey = this.findPrivateKeyFromAddress(utxo.addresses[0])\n if(foundKey) {\n this._keysToSign.push(foundKey.key.privateKey)\n }\n\n }\n newTxBuilder.transaction.outputs = txBuilder.transaction.outputs\n\n })\n\n return this\n }\n\n public parseTxBuffer(tx: Buffer) {\n this.builder.push(async () => {\n this.transactionBuilder = new TransactionBuilder(tx);\n })\n\n return this\n }\n\n public mint(token: string, amount: string): this {\n this.builder.push(async() => {\n let toAddr = this._account.accountKeys.receiveKeys.at(-1)!.address;\n this.tokenAction(toAddr, amount, token, 'mint')\n })\n\n return this\n }\n\n public melt(token: string, amount: string): this {\n this.builder.push(async() => {\n let toAddr = this._account.accountKeys.receiveKeys.at(-1)!.address;\n this.tokenAction(toAddr, amount, token, 'melt')\n })\n\n return this\n }\n\n public populate(): this {\n this.validateAccount();\n this.builder.push(async () => {\n let tK: PrivateKey[] = []\n let nK: PrivateKey[] = []\n if(this.tokens.size > 0) {\n for (const tokenAction of this.tokens) {\n if(tokenAction.action == 'mint' || tokenAction.action == 'melt') {\n tK = tK.concat(await populateTokenAuth(this.transactionBuilder, this._account.accountKeys, tokenAction.token!, tokenAction.action))\n } else if (tokenAction.action == 'group') {\n tK = tK.concat(await buildCreateGroupTransaction(this.transactionBuilder, this._account.accountKeys, tokenAction.extraData?.opReturnData!, this.network))\n } else if (tokenAction.action == 'subgroup') {\n tK = tK.concat(await populateTokenAuth(this.transactionBuilder, this._account.accountKeys, tokenAction.parentToken!, 'subgroup', tokenAction.token, this._account.accountKeys.receiveKeys.at(-1)!.address));\n } else if(tokenAction.action == 'renew') {\n tK = tK.concat(await populateAndDuplicateTokenAuths(this.transactionBuilder, this._account.accountKeys, tokenAction.token!, tokenAction.extraData!.perms!, tokenAction.extraData!.address!))\n } else if(tokenAction.action == 'delete') {\n tK = tK.concat(await prepareDeleteTransaction(this.transactionBuilder, this._account.accountKeys, tokenAction.extraData!.outpoint!))\n } else {\n tK = tK.concat(await populateTokenInputsAndChange(this.transactionBuilder, this._account.accountKeys, tokenAction.token!, tokenAction.amount))\n }\n\n this._keysToSign!.concat(tK)\n }\n }\n\n nK = nK.concat(await populateNexaInputsAndChange(this.transactionBuilder, this._account.accountKeys, this.totalValue, this.txOptions))\n this._keysToSign! = tK.concat(nK)\n })\n\n return this\n }\n\n public sign(): this {\n this.builder.push(async () => {\n const blockHeight = await rostrumProvider.getBlockTip()\n this.transactionBuilder.lockUntilBlockHeight(blockHeight.height).sign(this._keysToSign!)\n })\n\n return this\n }\n\n /**\n * Validates that the account has the necessary keys before performing operations\n * @throws Error if account or keys are not properly initialized\n */\n private validateAccount(): void {\n if (!this._account) {\n throw new Error('Account must be set before performing transactions');\n }\n if (!this._account.accountKeys) {\n throw new Error('Account keys are not initialized');\n }\n if (!this._account.accountKeys.receiveKeys || this._account.accountKeys.receiveKeys.length === 0) {\n throw new Error('No receive keys available in account');\n }\n }\n\n private findPrivateKeyFromAddress(addr: string): AddressKey | undefined {\n const keys: AddressKey[] = this._account.accountKeys.receiveKeys.concat(this._account.accountKeys.changeKeys)\n return keys.find(key => key.address === addr)\n }\n}\n","import {rostrumProvider} from '../network/RostrumProvider';\nimport {AccountKeys} from '../models/wallet.entities';\nimport {isNullOrEmpty, MAX_INT64, tokenIdToHex} from './CommonUtils';\nimport {\n Address,\n AddressType,\n GroupToken,\n Networkish,\n PrivateKey,\n Transaction,\n TransactionBuilder,\n UnitUtils,\n UTXO\n} from \"libnexa-ts\";\nimport {PermissionLabel, TxOptions} from \"../models/transaction.entities\";\nimport {dupAuthority, isAuthFit} from \"./TokenUtils\";\n\n/** Maximum number of inputs/outputs allowed in a single transaction */\nconst MAX_INPUTS_OUTPUTS = 250;\n\n/**\n * Populate a transaction with Nexa UTXO inputs and set change output if needed\n *\n * This function automatically selects and adds UTXOs from the provided account keys\n * to satisfy the transaction's Nexa amount requirements. It handles change calculation\n * and can consolidate UTXOs when requested.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys containing receive and change addresses with balances\n * @param totalTxValue - Total amount of Nexa required for the transaction (in satoshis)\n * @param options - Transaction options including consolidation settings and change address\n * @returns Promise resolving to array of private keys needed for signing\n * @throws {Error} If insufficient balance or too many inputs required\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await populateNexaInputsAndChange(\n * txBuilder,\n * keys,\n * 1000000n, // 1 NEXA\n * { isConsolidate: false, feeFromAmount: false }\n * );\n * ```\n */\nexport async function populateNexaInputsAndChange(txBuilder: TransactionBuilder, keys: AccountKeys, totalTxValue: bigint, options: TxOptions): Promise<PrivateKey[]> {\n let rKeys = keys.receiveKeys.filter(k => BigInt(k.balance) > 0n);\n let cKeys = keys.changeKeys.filter(k => BigInt(k.balance) > 0n);\n let allKeys = rKeys.concat(cKeys);\n if (isNullOrEmpty(allKeys)) {\n throw new Error(\"Not enough Nexa balance.\");\n }\n\n let usedKeys = new Map<string, PrivateKey>();\n let origAmount = options.isConsolidate ? 0 : Number(totalTxValue);\n\n for (let key of allKeys) {\n let utxos = await rostrumProvider.getNexaUtxos(key.address);\n for (let utxo of utxos) {\n let input: UTXO = {\n outpoint: utxo.outpoint_hash,\n address: key.address,\n satoshis: utxo.value,\n templateData: options.templateData\n }\n txBuilder.from(input);\n\n if (!usedKeys.has(key.address)) {\n usedKeys.set(key.address, key.key.privateKey);\n }\n\n if (options.isConsolidate) {\n txBuilder.change(options.toChange ?? keys.receiveKeys[keys.receiveKeys.length - 1].address);\n if (txBuilder.transaction.inputs.length > MAX_INPUTS_OUTPUTS) {\n return Array.from(usedKeys.values());\n }\n } else {\n let tx = txBuilder.transaction;\n if (tx.inputs.length > MAX_INPUTS_OUTPUTS) {\n throw new Error(\"Too many inputs. Consider consolidate transactions or reduce the send amount.\");\n }\n\n let unspent = tx.getUnspentValue();\n if (unspent < 0n) {\n continue;\n }\n\n if (unspent == 0n && options.feeFromAmount) {\n let txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n return Array.from(usedKeys.values());\n }\n\n txBuilder.change(options.toChange ?? keys.changeKeys[keys.changeKeys.length - 1].address);\n if (options.feeFromAmount) {\n let hasChange = tx.getChangeOutput();\n let txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n\n // edge case where change added after update\n if (!hasChange && tx.getChangeOutput()) {\n txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n }\n }\n\n // check again after change output manipulation\n if (tx.getUnspentValue() < tx.estimateRequiredFee()) {\n // try to add more utxos to satisfy the minimum fee\n continue;\n }\n return Array.from(usedKeys.values());\n }\n }\n }\n\n if (options.isConsolidate) {\n if (usedKeys.size > 0) {\n return Array.from(usedKeys.values());\n }\n throw new Error(\"Not enough Nexa balance.\");\n }\n\n let err = {\n errorMsg: \"Not enough Nexa balance.\",\n amount: UnitUtils.formatNEXA(txBuilder.transaction.outputs[0].value),\n fee: UnitUtils.formatNEXA(txBuilder.transaction.estimateRequiredFee())\n }\n\n throw new Error(JSON.stringify(err));\n}\n\n/**\n * Populate a transaction with token UTXO inputs and set token change output if needed\n *\n * This function selects and adds token UTXOs from the provided account keys\n * to satisfy the transaction's token amount requirements. It automatically\n * handles token change calculation.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys containing addresses with token balances\n * @param token - The token ID to spend\n * @param outTokenAmount - Amount of tokens required for the transaction\n * @returns Promise resolving to array of private keys needed for signing\n * @throws {Error} If insufficient token balance or too many inputs required\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await populateTokenInputsAndChange(\n * txBuilder,\n * keys,\n * 'token_id_hex',\n * 1000n // Amount of tokens\n * );\n * ```\n */\nexport async function populateTokenInputsAndChange(txBuilder: TransactionBuilder, keys: AccountKeys, token: string, outTokenAmount: bigint): Promise<PrivateKey[]> {\n let tokenHex = tokenIdToHex(token);\n let rKeys = keys.receiveKeys.filter(k => Object.keys(k.tokensBalance).includes(tokenHex));\n let cKeys = keys.changeKeys.filter(k => Object.keys(k.tokensBalance).includes(tokenHex));\n let allKeys = rKeys.concat(cKeys);\n\n if (isNullOrEmpty(allKeys)) {\n throw new Error(\"Not enough token balance.\");\n }\n\n let usedKeys = new Map<string, PrivateKey>();\n let inTokenAmount = 0n;\n\n for (let key of allKeys) {\n let utxos = await rostrumProvider.getTokenUtxos(key.address, token);\n for (let utxo of utxos) {\n if (utxo.token_amount < 0) {\n continue;\n }\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: key.address,\n satoshis: utxo.value,\n groupId: utxo.group,\n groupAmount: BigInt(utxo.token_amount),\n });\n\n inTokenAmount = inTokenAmount + BigInt(utxo.token_amount);\n if (!usedKeys.has(key.address)) {\n usedKeys.set(key.address, key.key.privateKey);\n }\n\n if (inTokenAmount > MAX_INT64) {\n throw new Error(\"Token inputs exceeded max amount. Consider sending in small chunks\");\n }\n if (txBuilder.transaction.inputs.length > MAX_INPUTS_OUTPUTS) {\n throw new Error(\"Too many inputs. Consider consolidating transactions or reduce the send amount.\");\n }\n\n if (inTokenAmount == outTokenAmount) {\n return Array.from(usedKeys.values());\n }\n if (inTokenAmount > outTokenAmount) {\n // change\n txBuilder.to(keys.changeKeys[keys.changeKeys.length - 1].address, Transaction.DUST_AMOUNT, token, inTokenAmount - outTokenAmount);\n return Array.from(usedKeys.values());\n }\n }\n }\n\n throw new Error(\"Not enough token balance\");\n}\n\n/**\n * Build a transaction to create a new token group\n *\n * This function creates a group token by using the first UTXO's outpoint\n * to generate a unique group ID. The group token represents the authority\n * to create fungible tokens within this group.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys to use for funding the transaction\n * @param opReturnData - Optional data to include in the group creation\n * @param network - Network to create the group on\n * @returns Promise resolving to array of private keys needed for signing\n * @throws {Error} If insufficient balance for group creation\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await buildCreateGroupTransaction(\n * txBuilder,\n * keys,\n * 'my_token_data',\n * Networks.mainnet\n * );\n * ```\n */\nexport async function buildCreateGroupTransaction(\n txBuilder: TransactionBuilder,\n keys: AccountKeys,\n opReturnData: string,\n network: Networkish\n): Promise<PrivateKey[]> {\n // TODO validate opreturn data\n const allKeys = keys.receiveKeys.concat(keys.changeKeys)\n let outpoint = '';\n let usedKeys: PrivateKey[] = [];\n let signKey: PrivateKey | undefined = undefined;\n for (let key of allKeys) {\n let utxos = await rostrumProvider.getNexaUtxos(key.address);\n for (let utxo of utxos) {\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: key.address,\n satoshis: utxo.value\n });\n\n if (isNullOrEmpty(outpoint)) {\n outpoint = utxo.outpoint_hash;\n let id = GroupToken.findGroupId(Buffer.from(outpoint, 'hex'), Buffer.from(opReturnData, 'hex'), GroupToken.authFlags.ACTIVE_FLAG_BITS);\n const groupId = new Address(id.hashBuffer, network, AddressType.GroupIdAddress).toString()\n txBuilder.to(keys.receiveKeys.at(-1)!.address, Transaction.DUST_AMOUNT, groupId, GroupToken.authFlags.ACTIVE_FLAG_BITS | id.nonce)\n signKey = key.key.privateKey\n usedKeys.push(signKey);\n return usedKeys\n }\n }\n }\n\n throw new Error(\"Not enough Nexa balance.\");\n}\n\n/**\n * Prepare a transaction to delete/spend a specific UTXO\n *\n * This function adds a specific UTXO as input to the transaction.\n * It's commonly used for spending token authority UTXOs or consolidating specific outputs.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys to find the private key for the UTXO\n * @param outpoint - The outpoint (txid:vout) of the UTXO to spend\n * @returns Promise resolving to array containing the private key for the UTXO\n * @throws {Error} If the UTXO is not found or the associated key is not in the wallet\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await prepareDeleteTransaction(\n * txBuilder,\n * keys,\n * 'txid:0'\n * );\n * ```\n */\nexport async function prepareDeleteTransaction(txBuilder: TransactionBuilder, keys: AccountKeys, outpoint: string): Promise<PrivateKey[]> {\n let utxo = await rostrumProvider.getUtxo(outpoint);\n let address = utxo.addresses[0];\n\n txBuilder.from({\n outpoint: outpoint,\n address: address,\n satoshis: utxo.amount\n });\n\n let allKeys = keys.receiveKeys.concat(keys.changeKeys);\n let addrKey = allKeys.find(k => k.address === address);\n\n if (!addrKey) {\n throw new Error('UTXO associated key not found in the wallet');\n }\n return [addrKey.key.privateKey];\n}\n\n/**\n * Populate a transaction with token authority inputs for specific permissions\n *\n * This function finds and adds token authority UTXOs that have the required\n * permissions for token operations like minting, melting, or creating subgroups.\n * It automatically handles authority renewal if the authority allows it.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys containing addresses with token authorities\n * @param token - The token ID to find authorities for\n * @param perm - The permission type required ('mint', 'melt', 'subgroup', etc.)\n * @param subgroup - Optional subgroup token ID for subgroup operations\n * @param subgroupAddr - Optional address to receive subgroup authority\n * @returns Promise resolving to array of private keys needed for signing\n * @throws {Error} If the required authority is not found\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await populateTokenAuth(\n * txBuilder,\n * keys,\n * 'token_id_hex',\n * 'mint'\n * );\n * ```\n */\nexport async function populateTokenAuth(txBuilder: TransactionBuilder, keys: AccountKeys, token: string, perm: PermissionLabel, subgroup = '', subgroupAddr = ''): Promise<PrivateKey[]> {\n let allKeys = keys.receiveKeys.concat(keys.changeKeys);\n for (let key of allKeys) {\n let utxos = await rostrumProvider.getTokenUtxos(key.address, token);\n for (let utxo of utxos) {\n if (!isAuthFit(utxo.token_amount, perm)) {\n continue;\n }\n\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: key.address,\n satoshis: utxo.value\n });\n\n if (perm === 'subgroup') {\n txBuilder.to(subgroupAddr, Transaction.DUST_AMOUNT, subgroup, dupAuthority(utxo.token_amount, false));\n }\n\n // if renew flag included, we don't want to burn it\n if (GroupToken.allowsRenew(BigInt.asUintN(64, BigInt(utxo.token_amount)))) {\n txBuilder.to(keys.receiveKeys.at(-1)!.address, Transaction.DUST_AMOUNT, token, dupAuthority(utxo.token_amount));\n }\n\n return [key.key.privateKey];\n }\n }\n\n throw new Error(\"The requested authority not found\");\n}\n\n/**\n * Populate a transaction with multiple token authorities and create duplicates\n *\n * This function finds token authority UTXOs for multiple permissions and\n * creates duplicate outputs for each authority. This is useful for complex\n * token operations that require multiple permissions while preserving the authorities.\n *\n * @param txBuilder - The transaction builder to populate\n * @param keys - Account keys containing addresses with token authorities\n * @param token - The token ID to find authorities for\n * @param perms - Array of permission types required\n * @param toAddr\n * @returns Promise resolving to array of private keys needed for signing\n * @throws {Error} If any required authority is not found\n *\n * @example\n * ```typescript\n * const txBuilder = new TransactionBuilder();\n * const keys = await account.getKeys();\n * const privateKeys = await populateAndDuplicateTokenAuths(\n * txBuilder,\n * keys,\n * 'token_id_hex',\n * ['mint', 'melt']\n * );\n * ```\n */\nexport async function populateAndDuplicateTokenAuths(txBuilder: TransactionBuilder, keys: AccountKeys, token: string, perms: PermissionLabel[], toAddr?: string): Promise<PrivateKey[]> {\n let allKeys = keys.receiveKeys.concat(keys.changeKeys);\n let usedKeys: PrivateKey[] = [];\n\n let reqiredPerms = new Set(perms);\n reqiredPerms.add('authorise');\n\n for (let key of allKeys) {\n let utxos = await rostrumProvider.getTokenUtxos(key.address, token);\n for (let utxo of utxos) {\n if (utxo.token_amount > 0) {\n continue;\n }\n\n let found = false;\n for (let perm of reqiredPerms) {\n if (isAuthFit(utxo.token_amount, perm)) {\n reqiredPerms.delete(perm);\n found = true;\n }\n }\n\n if (!found) {\n continue;\n }\n\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: key.address,\n satoshis: utxo.value\n });\n usedKeys.push(key.key.privateKey);\n\n // duplicate\n txBuilder.to(toAddr != null ? toAddr : keys.receiveKeys.at(-1)!.address, Transaction.DUST_AMOUNT, token, dupAuthority(utxo.token_amount));\n\n if (reqiredPerms.size === 0) {\n return usedKeys;\n }\n }\n }\n\n throw new Error(\"The required authorities not found\");\n}\n","import {PermissionLabel} from \"../models/transaction.entities\";\nimport {GroupToken} from \"libnexa-ts\";\n\nexport function isAuthFit(authFlags: bigint | number, permission: PermissionLabel): boolean {\n if (authFlags > 0) {\n return false;\n }\n\n let flags = BigInt.asUintN(64, BigInt(authFlags));\n switch (permission) {\n case 'authorise':\n return GroupToken.allowsRenew(flags);\n case 'mint':\n return GroupToken.allowsMint(flags);\n case 'melt':\n return GroupToken.allowsMelt(flags);\n case 'rescript':\n return GroupToken.allowsRescript(flags);\n case 'subgroup':\n return GroupToken.allowsSubgroup(flags);\n default:\n return false;\n }\n}\n\nexport function dupAuthority(authFlags: bigint | number, withSubgroup = true): bigint {\n if (authFlags > 0) {\n return 0n;\n }\n\n let flags = BigInt.asUintN(64, BigInt(authFlags));\n let newFlags = GroupToken.authFlags.AUTHORITY;\n\n if (GroupToken.allowsRenew(flags)) {\n newFlags |= GroupToken.authFlags.BATON;\n }\n if (GroupToken.allowsMint(flags)) {\n newFlags |= GroupToken.authFlags.MINT;\n }\n if (GroupToken.allowsMelt(flags)) {\n newFlags |= GroupToken.authFlags.MELT;\n }\n if (GroupToken.allowsRescript(flags)) {\n newFlags |= GroupToken.authFlags.RESCRIPT;\n }\n if (GroupToken.allowsSubgroup(flags) && withSubgroup) {\n newFlags |= GroupToken.authFlags.SUBGROUP;\n }\n\n return newFlags;\n}\n\nexport function buildAuthority(perms: PermissionLabel[]): bigint {\n let newFlags = GroupToken.authFlags.AUTHORITY;\n for (let perm of perms) {\n switch (perm) {\n case 'authorise':\n newFlags |= GroupToken.authFlags.BATON;\n break;\n case 'mint':\n newFlags |= GroupToken.authFlags.MINT;\n break;\n case 'melt':\n newFlags |= GroupToken.authFlags.MELT;\n break;\n case 'rescript':\n newFlags |= GroupToken.authFlags.RESCRIPT;\n break;\n case 'subgroup':\n newFlags |= GroupToken.authFlags.SUBGROUP;\n break;\n }\n }\n return newFlags;\n}\n","import {\n Address,\n AddressType,\n GroupToken,\n Networkish,\n Networks, Output, Script,\n ScriptFactory,\n Transaction,\n TransactionBuilder\n} from \"libnexa-ts\";\nimport {PermissionLabel, TokenAction, TxOptions} from \"../../../models/transaction.entities\";\nimport {isValidNexaAddress} from \"../../../utils/WalletUtils\";\nimport {parseInt} from \"lodash-es\";\nimport {MAX_INT64} from \"../../../utils/CommonUtils\";\nimport {rostrumProvider} from \"../../../network/RostrumProvider\";\n\n/**\n * Abstract base class for creating and managing transactions in the NEXA blockchain.\n * Provides common functionality for transaction building including token operations,\n * address validation, and output creation.\n */\nexport abstract class TransactionCreator {\n\n /** The underlying transaction builder instance */\n private _transactionBuilder!: TransactionBuilder;\n /** Set of token actions to be performed in this transaction */\n private _tokens!: Set<TokenAction>;\n /** Array of async functions to execute when building the transaction */\n private _builder: (() => Promise<any>)[] = [];\n /** Total value of NEXA being sent in this transaction */\n private _totalValue: bigint = BigInt(0);\n /** Network this transaction will be broadcast on */\n private _network: Networkish = Networks.mainnet\n /** Transaction options for customizing behavior */\n private _txOptions: TxOptions = {}\n\n /**\n * Creates a new TransactionCreator instance\n * @param tx Optional existing TransactionBuilder, hex string, or buffer\n */\n protected constructor(tx?: TransactionBuilder | string | Buffer) {\n if (tx instanceof TransactionBuilder) {\n this.transactionBuilder = tx;\n }\n this.tokens = new Set<TokenAction>()\n this.transactionBuilder = new TransactionBuilder();\n }\n\n /** Parse transaction from hex string - must be implemented by subclasses */\n public abstract parseTxHex(tx:string): this\n /** Parse transaction from buffer - must be implemented by subclasses */\n public abstract parseTxBuffer(tx: Buffer): this\n\n /**\n * Sets the network for this transaction\n * @param network Network name or Networkish object\n * @returns This instance for chaining\n */\n public onNetwork(network: string | Networkish) {\n this.network = Networks.get(network)!\n return this\n }\n\n /** Gets transaction options */\n get txOptions(): TxOptions {\n return this._txOptions;\n }\n\n /** Sets transaction options */\n set txOptions(value: TxOptions) {\n this._txOptions = value;\n }\n\n /** Gets the network for this transaction */\n get network(): Networkish {\n return this._network;\n }\n\n /** Sets the network for this transaction */\n set network(value: Networkish) {\n this._network = value;\n }\n\n /** Gets the builder function array */\n get builder(): (() => Promise<any>)[] {\n return this._builder;\n }\n\n /** Sets the builder function array */\n set builder(value: (() => Promise<any>)[]) {\n this._builder = value;\n }\n\n /** Gets the underlying transaction builder */\n get transactionBuilder(): TransactionBuilder {\n return this._transactionBuilder;\n }\n\n /** Sets the underlying transaction builder */\n set transactionBuilder(value: TransactionBuilder) {\n this._transactionBuilder = value;\n }\n\n /** Gets the set of token actions */\n get tokens(): Set<TokenAction> {\n return this._tokens;\n }\n\n /** Sets the set of token actions */\n set tokens(value: Set<TokenAction>) {\n this._tokens = value;\n }\n\n /** Gets the total NEXA value being sent */\n get totalValue(): bigint {\n return this._totalValue;\n }\n\n /** Sets the total NEXA value being sent */\n set totalValue(value: bigint) {\n this._totalValue = value;\n }\n\n /**\n * Validates and creates a token action\n * @param toAddr Destination address\n * @param amount Amount to send\n * @param token Token ID\n * @param action Action type (mint, melt, send, etc.)\n * @throws Error if validation fails\n */\n protected tokenAction(toAddr: string, amount: string, token: string, action: string){\n // Validate destination address\n if (!isValidNexaAddress(toAddr, this.network) && !isValidNexaAddress(toAddr, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n\n // Validate amount ranges\n if ((token && BigInt(amount) < 1n) || (!token && parseInt(amount) < Transaction.DUST_AMOUNT)) {\n throw new Error(\"The amount is too low.\");\n }\n if ((token && BigInt(amount) > MAX_INT64) || (!token && parseInt(amount) > Transaction.MAX_MONEY)) {\n throw new Error(\"The amount is too high.\");\n }\n\n // Validate token ID\n if (!isValidNexaAddress(token, this.network, AddressType.GroupIdAddress)) {\n throw new Error('Invalid Token ID');\n }\n\n // Ensure tokens are sent to script template addresses\n if (Address.getOutputType(toAddr) === 0) {\n throw new Error('Token must be sent to script template address');\n }\n\n // Add output to transaction\n this.transactionBuilder.to(toAddr, Transaction.DUST_AMOUNT, token, BigInt(amount))\n\n // Record the token action\n this.tokens.add({\n token: token,\n amount: BigInt(amount),\n action: action\n })\n }\n\n /**\n * Configures transaction to consolidate UTXOs to a single address\n * @param toAddr Address to consolidate funds to\n * @returns This instance for chaining\n */\n public consolidate(toAddr: string): this {\n this.builder.push(async () => {\n if (!isValidNexaAddress(toAddr, this.network) && !isValidNexaAddress(toAddr, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n this._txOptions.isConsolidate = true\n this._txOptions.toChange = toAddr\n })\n return this\n }\n\n /**\n * Configures transaction to deduct fee from the send amount\n * @returns This instance for chaining\n */\n public feeFromAmount(): this{\n this.builder.push(async () => {\n this._txOptions.feeFromAmount = true\n })\n return this\n }\n\n /**\n * Adds a token send operation to the transaction\n * @param toAddr Destination address\n * @param amount Amount of tokens to send\n * @param token Token ID\n * @returns This instance for chaining\n */\n public sendToToken(toAddr: string, amount: string, token: string): this {\n this.builder.push(async () => {\n this.tokenAction(toAddr, amount, token, 'send')\n })\n\n return this;\n }\n\n /**\n * Adds a NEXA send operation to the transaction\n * @param toAddr Destination address\n * @param amount Amount of NEXA to send\n * @returns This instance for chaining\n */\n public sendTo(toAddr: string, amount: string){\n this.builder.push(async () => {\n if (!isValidNexaAddress(toAddr, this.network) && !isValidNexaAddress(toAddr, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n this.transactionBuilder.to(toAddr, amount);\n this.totalValue = BigInt(this.totalValue + amount)\n })\n return this;\n }\n\n /**\n * Adds a token authority renewal operation\n * @param token Token ID to renew authority for\n * @param perms Permissions to renew\n * @param toAddr\n * @returns This instance for chaining\n */\n public renewAuthority(token: string, perms: PermissionLabel[], toAddr?: string): this {\n this.builder.push(async() => {\n if(toAddr != null) {\n if (!isValidNexaAddress(toAddr, this.network) && !isValidNexaAddress(toAddr, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n }\n\n this.tokens.add({\n token: token,\n action: 'renew',\n amount: BigInt(Transaction.DUST_AMOUNT),\n parentToken: undefined,\n extraData: {\n perms: perms,\n address: toAddr\n }\n })\n })\n return this\n }\n\n /**\n * Adds a token authority deletion operation\n * @param token Token ID to delete authority for\n * @param outpoint Outpoint of the authority to delete\n * @returns This instance for chaining\n */\n public deleteAuthority(token:string, outpoint: string): this {\n this.builder.push(async () => {\n this.tokens.add({\n token: token,\n action: 'delete',\n amount: BigInt(Transaction.DUST_AMOUNT),\n parentToken: undefined,\n extraData: {\n outpoint: outpoint\n }\n })\n })\n return this\n }\n\n /**\n * Creates a legacy token (not implemented)\n * @returns This instance for chaining\n */\n public legacyToken(name: string, ticker: string, decimals: number, docUrl: string, docHash: string): this {\n this.builder.push(async () => {\n const opReturn = ScriptFactory.buildTokenDescriptionLegacy(\n ticker,\n name,\n docUrl,\n docHash,\n decimals\n )\n this.transactionBuilder.addData(opReturn, true)\n this.tokens.add({\n action: 'group',\n amount: BigInt(Transaction.DUST_AMOUNT),\n extraData: {\n opReturnData: opReturn.toHex()\n }\n })\n })\n return this\n }\n\n /**\n * Creates a legacy group (not implemented)\n * @returns This instance for chaining\n */\n public legacyGroup(name: string, ticker: string, docUrl: string, docHash: string): this {\n this.builder.push(async () => {\n const opReturn = ScriptFactory.buildTokenDescriptionLegacy(\n ticker,\n name,\n docUrl,\n docHash,\n )\n this.transactionBuilder.addData(opReturn, true)\n this.tokens.add({\n action: 'group',\n amount: BigInt(Transaction.DUST_AMOUNT),\n extraData: {\n opReturnData: opReturn.toHex()\n }\n })\n })\n return this\n }\n\n /**\n * Creates a token with metadata\n * @param name Token name\n * @param ticker Token ticker symbol\n * @param decimals Number of decimal places\n * @param docUrl URL to token documentation\n * @param docHash Hash of token documentation\n * @returns This instance for chaining\n */\n public token(name: string, ticker: string, decimals: number, docUrl: string, docHash: string): this {\n this.builder.push(async () => {\n const opReturn = ScriptFactory.buildTokenDescription(\n ticker,\n name,\n docUrl,\n docHash,\n decimals\n )\n this.transactionBuilder.addData(opReturn, true)\n this.tokens.add({\n action: 'group',\n amount: BigInt(Transaction.DUST_AMOUNT),\n extraData: {\n opReturnData: opReturn.toHex()\n }\n })\n })\n return this\n }\n\n /**\n * Creates an NFT collection with metadata\n * @param name Collection name\n * @param ticker Collection ticker symbol\n * @param docUrl URL to collection documentation\n * @param docHash Hash of collection documentation\n * @returns This instance for chaining\n */\n public collection(name: string, ticker: string, docUrl: string, docHash: string): this {\n this.builder.push(async () => {\n const opReturn = ScriptFactory.buildNFTCollectionDescription(\n ticker,\n name,\n docUrl,\n docHash\n )\n this.transactionBuilder.addData(opReturn, true)\n this.tokens.add({\n action: 'group',\n amount: BigInt(Transaction.DUST_AMOUNT),\n extraData: {\n opReturnData: opReturn.toHex()\n }\n })\n })\n\n return this\n }\n\n /**\n * Creates an NFT within a collection\n * @param parent Parent collection token ID\n * @param zipUrl URL to NFT content ZIP file\n * @param zipHash Hash of NFT content ZIP file\n * @returns This instance for chaining\n */\n public nft(parent: string, zipUrl: string, zipHash: string) {\n this.builder.push(async () => {\n // add op_return for the nft\n let opReturn = ScriptFactory.buildNFTDescription(zipUrl, zipHash);\n this.transactionBuilder.addData(opReturn, true);\n // generate subgroup ID\n const subGroup = GroupToken.generateSubgroupId(parent, opReturn.toBuffer()).toString('hex')\n this.tokens.add({\n token: subGroup,\n parentToken: parent,\n amount: BigInt(Transaction.DUST_AMOUNT),\n action: 'subgroup'\n })\n })\n return this\n }\n\n /**\n * Adds an OP_RETURN output to the transaction\n * @param data Data to include in the OP_RETURN\n * @param isFullScript Whether the data is already a complete script\n * @returns This instance for chaining\n */\n public addOpReturn(data: Buffer | string | Script, isFullScript = false) {\n this.builder.push(async () => {\n let script = isFullScript ? new Script(data) : ScriptFactory.buildDataOut(data);\n let output = new Output(0, script);\n this.transactionBuilder.transaction.addOutput(output);\n })\n\n return this;\n }\n\n /** Populates the transaction with inputs and outputs - must be implemented by subclasses */\n abstract populate(): this\n\n /**\n * Builds the transaction by executing all queued operations\n * @returns Promise resolving to the serialized transaction hex\n */\n public async build(): Promise<string>{\n for (const task of this.builder) {\n await task();\n }\n return this.transactionBuilder.transaction.serialize(({disableAll: true}));\n }\n\n}\n","import bigDecimal from \"js-big-decimal\";\nimport {BaseAccount} from \"./interfaces/BaseAccountInterface\";\nimport {\n AccountType,\n discoverNexaAccount,\n generateAccountKey,\n generateKeyAndAddress, generateKeysAndAddresses,\n getNextAccountIndex\n} from \"../../utils/WalletUtils\";\nimport {HDPrivateKey} from \"libnexa-ts\";\nimport DAppAccount from \"./models/DappAccount\";\nimport VaultAccount from \"./models/VaultAccount\";\nimport DefaultAccount from \"./models/DefaultAccount\";\nimport {AccountIndexes, AddressKey} from \"../../models/wallet.entities\";\n\n/**\n * AccountStore manages a collection of wallet accounts of different types.\n * It provides functionality to create, import, export, and manage accounts\n * including DApp accounts, Vault accounts, and Default NEXA accounts.\n */\nexport default class AccountStore {\n\n /** Map storing all accounts indexed by their unique store key */\n private readonly _accounts: Map<string, BaseAccount>\n\n /**\n * Creates a new AccountStore instance\n * Initializes an empty map to store accounts\n */\n public constructor() {\n this._accounts = new Map<string, BaseAccount>()\n }\n\n /**\n * Generates a unique store key for an account based on its type and index\n * @param accountType The type of account (DAPP, VAULT, or DEFAULT)\n * @param index The account index\n * @returns Unique string key for storing the account\n */\n private getAccountStoreKey(accountType: AccountType, index: number): String {\n switch (accountType){\n case AccountType.DAPP_ACCOUNT:\n // DApp accounts use format: \"2.index\"\n return String(accountType + '.' + index);\n case AccountType.VAULT_ACCOUNT:\n // Vault accounts use format: \"1.index\"\n return String(accountType + '.' + index);\n default:\n // Default accounts use just the index\n return String(index)\n }\n }\n\n /**\n * Creates a new account of the specified type\n * @param accountType Type of account to create (DAPP, VAULT, or DEFAULT)\n * @param masterKey Master HD private key for deriving account keys\n * @returns Promise resolving to the created account\n */\n async createAccount(accountType: AccountType, masterKey: HDPrivateKey): Promise<BaseAccount> {\n // Get the next available index for this account type\n const nextIndex = await getNextAccountIndex(accountType, masterKey);\n const accountStoreKey = this.getAccountStoreKey(accountType, nextIndex)\n \n // Check if account already exists\n const indexExists = this._accounts.get(String(accountStoreKey))\n if(indexExists) {\n return indexExists\n }\n \n switch (accountType){\n case AccountType.DAPP_ACCOUNT:\n // Create DApp account (purpose 2)\n let dappAccountKey = generateAccountKey(masterKey, 2);\n const dAppAccount = new DAppAccount(2, nextIndex, generateKeyAndAddress(dappAccountKey, nextIndex))\n await dAppAccount.loadBalances();\n this._accounts.set(dAppAccount.getAccountStoreKey(), dAppAccount)\n return dAppAccount\n case AccountType.VAULT_ACCOUNT:\n // Create Vault account (purpose 1)\n let vaultAccountKey = generateAccountKey(masterKey, 1);\n const vaultAccount = new VaultAccount(1, nextIndex, generateKeyAndAddress(vaultAccountKey, nextIndex))\n await vaultAccount.loadBalances();\n this._accounts.set(vaultAccount.getAccountStoreKey(), vaultAccount)\n return vaultAccount\n default:\n // Create default NEXA account with receive and change addresses\n let nexaAccountKey = generateAccountKey(masterKey, nextIndex);\n const nexaAccountIndexes: AccountIndexes = { rIndex: 0, cIndex: 0 };\n const nexaAccount = new DefaultAccount(nextIndex, nexaAccountIndexes, generateKeysAndAddresses(nexaAccountKey, nexaAccountIndexes.rIndex + 1, nexaAccountIndexes.rIndex + 20, nexaAccountIndexes.cIndex + 1, nexaAccountIndexes.cIndex + 20))\n await nexaAccount.loadBalances()\n this._accounts.set(nexaAccount.getAccountStoreKey(), nexaAccount)\n return nexaAccount;\n }\n }\n\n /**\n * Finds the private key associated with a given address across all accounts\n * @param address The address to search for\n * @returns The AddressKey containing the private key, or null if not found\n */\n findKeyForAddress(address: string): AddressKey | null {\n // Search through all accounts\n for (const [_, account] of this._accounts.entries()) {\n // Combine receive and change keys for this account\n const allKeys = account.accountKeys.receiveKeys.concat(account.accountKeys.changeKeys)\n \n // Check each key for a matching address\n for(const key of allKeys){\n if(key.address == address) {\n return key\n }\n }\n }\n return null\n }\n\n /**\n * Imports an existing account into the store\n * @param accountData The account data to import\n * @throws Error if an account with the same key already exists\n */\n importAccount(accountData: BaseAccount): void {\n let index: string = accountData.getAccountStoreKey()\n if(this._accounts.get(index)) {\n throw Error('Account already exists!')\n }\n this._accounts.set(String(index), accountData)\n }\n\n /**\n * Exports account data by index\n * @param accountIndex The account index to export\n * @returns The account data\n * @throws Error if the account doesn't exist\n */\n exportAccount(accountIndex: string): BaseAccount {\n if(!this._accounts.get(accountIndex)) {\n throw Error('Cannot find account!')\n }\n\n return this._accounts.get(accountIndex)!\n }\n\n /**\n * Removes an account from the store\n * @param accountIndex The account index to remove\n * @throws Error if the account doesn't exist\n */\n removeAccount(accountIndex: string): void {\n if(!this._accounts.get(accountIndex)) {\n throw Error('Cannot find account!')\n }\n this._accounts.delete(accountIndex)\n }\n\n /**\n * Returns all accounts in the store\n * @returns Map of account store keys to BaseAccount objects\n */\n listAccounts(): Map<string, BaseAccount> {\n return this._accounts\n }\n\n /**\n * Retrieves a specific account by its index\n * @param index The account index to retrieve\n * @returns The account if found, undefined otherwise\n */\n getAccount(index:string): BaseAccount | undefined {\n return this._accounts.get(index)\n }\n}\n","import { isString } from 'lodash-es';\n\n/** Type definition for constructor functions */\ntype Class<T> = new (...args: any[]) => T; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n/**\n * Utility class for validating arguments and state conditions\n * \n * Provides methods to validate function arguments and application state\n * with consistent error handling and messaging.\n */\nexport default class ValidationUtils {\n\n /**\n * Validate that a state condition is true\n * \n * @param condition - The condition to validate\n * @param message - Error message to throw if condition is false\n * @throws {Error} If condition is false\n * \n * @example\n * ```typescript\n * ValidationUtils.validateState(wallet.isInitialized, 'Wallet must be initialized');\n * ```\n */\n public static validateState(condition: boolean, message: string): void {\n if (!condition) {\n throw new Error(`Invalid State: ${message}`);\n }\n }\n\n /**\n * Validate that an argument condition is true\n * \n * @param condition - The condition to validate\n * @param argumentName - Name of the argument being validated\n * @param message - Optional additional error message\n * @throws {Error} If condition is false\n * \n * @example\n * ```typescript\n * ValidationUtils.validateArgument(\n * typeof amount === 'number',\n * 'amount',\n * 'must be a number'\n * );\n * ```\n */\n public static validateArgument(condition: boolean, argumentName: string, message = \"\"): void {\n if (!condition) {\n throw new Error(`Invalid Argument: ${argumentName}. ${message}`);\n }\n }\n\n /**\n * Validate that an argument is of the expected type\n * \n * @param argument - The argument to validate\n * @param type - Expected type (string name or constructor function)\n * @param argumentName - Name of the argument being validated\n * @throws {TypeError} If argument is not of expected type\n * \n * @example\n * ```typescript\n * ValidationUtils.validateArgumentType(buffer, 'Buffer', 'data');\n * ValidationUtils.validateArgumentType(wallet, Wallet, 'wallet');\n * ValidationUtils.validateArgumentType(amount, 'number', 'amount');\n * ```\n */\n public static validateArgumentType<T>(argument: unknown, type: string | Class<T>, argumentName?: string): void {\n argumentName = argumentName || '(unknown name)';\n if (isString(type)) {\n if (type === 'Buffer') {\n if (!Buffer.isBuffer(argument)) {\n throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n }\n } else if (typeof argument !== type) {\n throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n }\n } else {\n if (!(argument instanceof type)) {\n throw new TypeError(`Invalid Argument for ${argumentName}, expected ${type} but got ${typeof argument}`);\n }\n }\n }\n}\n","import {Networkish, Networks, TransactionBuilder} from \"libnexa-ts\";\nimport WatchOnlyTransactionCreator from \"./transactions/WatchOnlyTransactionCreator\";\nimport {rostrumProvider} from \"../network/RostrumProvider\";\nimport {WatchOnlyAddress} from \"../models/wallet.entities\";\nimport {isArray, isBuffer, isNil, isObject, isString} from \"lodash-es\";\nimport ValidationUtils from \"../utils/ValidationUtils\";\nimport {isValidNexaAddress} from \"../utils/WalletUtils\";\nimport {SubscribeCallback} from \"@vgrunner/electrum-cash\";\nimport {isNullOrEmpty} from \"../utils/CommonUtils\";\n\n/**\n * WatchOnlyWallet provides functionality for monitoring and creating transactions\n * for addresses without storing private keys. This allows users to track balances\n * and create unsigned transactions that can be signed elsewhere.\n */\nexport default class WatchOnlyWallet {\n /** The blockchain network this wallet operates on */\n private readonly _network: Networkish\n /** Array of addresses to monitor without their private keys */\n private readonly _addressesToWatch: WatchOnlyAddress[];\n\n /**\n * Creates a new WatchOnlyWallet instance\n * @param addressesToWatch Array of addresses to monitor\n * @param network Optional network name (defaults to mainnet)\n * @throws Error if validation fails\n */\n constructor(addressesToWatch: WatchOnlyAddress[], network?: string) {\n // Validate network parameter\n if (network !== undefined && !isString(network)) {\n throw new Error('Network must be a string');\n }\n\n if (network !== undefined && isString(network)) {\n const n = Networks.get(network)\n if (n === undefined) {\n throw new Error(`Invalid network: ${network}`);\n }\n }\n\n this._network = Networks.get(network) ?? Networks.mainnet;\n // Validate addressesToWatch parameter\n this._addressesToWatch = this.validateAddressesToWatch(addressesToWatch);\n }\n\n /**\n * Validates the addresses to watch array\n * @param addressesToWatch Array of addresses to validate\n * @returns Validated array of WatchOnlyAddress objects\n * @throws Error if validation fails\n */\n private validateAddressesToWatch(addressesToWatch: WatchOnlyAddress[]): WatchOnlyAddress[] {\n if (addressesToWatch === null || addressesToWatch === undefined) {\n throw new Error('addresesToWatch is required');\n }\n \n if (!isArray(addressesToWatch)) {\n throw new Error('addressesToWatch must be an array');\n }\n\n // Check if array is not empty\n if (addressesToWatch.length === 0) {\n throw new Error('addressesToWatch cannot be empty');\n }\n\n // Validate each address object\n const validatedAddresses: WatchOnlyAddress[] = [];\n\n for (let i = 0; i < addressesToWatch.length; i++) {\n const addr = addressesToWatch[i];\n\n // Check if address is an object\n if (!isObject(addr) || isArray(addr)) {\n throw new Error(`addressesToWatch[${i}] must be an object`);\n }\n\n // Check if address property exists and is a string\n if (!addr.hasOwnProperty('address') || !isString(addr.address)) {\n throw new Error(`addressesToWatch[${i}].address must be a string`);\n }\n\n // Check if address is not empty\n if (addr.address.trim() === '') {\n throw new Error(`addressesToWatch[${i}].address cannot be empty`);\n }\n\n // Validate address format\n if (!isValidNexaAddress(addr.address, this._network)) {\n throw new Error(`addressesToWatch[${i}].address is not a valid NEXA address: ${addr.address}`);\n }\n\n // Validate optional xPub property\n if (addr.xPub !== undefined && !isObject(addr.xPub)) {\n throw new Error(`addressesToWatch[${i}].xPub must be a PublicKey object`);\n }\n\n // Validate optional derivationPath property\n if (addr.derivationPath !== undefined && !isString(addr.derivationPath)) {\n throw new Error(`addressesToWatch[${i}].derivationPath must be a string`);\n }\n\n // Check for duplicate addresses\n const isDuplicate = validatedAddresses.some(existingAddr =>\n existingAddr.address === addr.address\n );\n if (isDuplicate) {\n throw new Error(`Duplicate address found: ${addr.address}`);\n }\n\n validatedAddresses.push({\n address: addr.address.trim(),\n xPub: addr.xPub,\n derivationPath: addr.derivationPath\n });\n }\n\n return validatedAddresses;\n }\n\n /**\n * Creates a new transaction creator for this watch-only wallet\n * @param x Optional transaction data - can be a TransactionBuilder, hex string, or Buffer\n * @returns WatchOnlyTransactionCreator configured with wallet's addresses and network\n */\n public newTransaction(x?: TransactionBuilder | string | Buffer): WatchOnlyTransactionCreator {\n let tx: WatchOnlyTransactionCreator;\n\n // Handle different input types for creating transactions\n if (x instanceof TransactionBuilder) {\n // Use existing TransactionBuilder instance\n tx = new WatchOnlyTransactionCreator(x);\n } else if (isString(x)) {\n // Parse transaction from hex string\n tx = new WatchOnlyTransactionCreator().parseTxHex(x);\n } else if (isBuffer(x) && !isNil(x)) {\n // Parse transaction from buffer\n tx = new WatchOnlyTransactionCreator().parseTxBuffer(x);\n } else {\n // Create new empty transaction\n tx = new WatchOnlyTransactionCreator();\n }\n\n // Configure transaction with wallet's addresses and network\n return tx.from(this._addressesToWatch).onNetwork(this._network);\n }\n\n /**\n * Broadcasts a signed transaction to the network\n * @param transaction Hex-encoded signed transaction\n * @returns Promise resolving to transaction ID\n * @throws Error if transaction is invalid or broadcast fails\n */\n public async sendTransaction(transaction: string): Promise<string> {\n ValidationUtils.validateArgument(isString(transaction), 'transaction must be present and valid')\n return rostrumProvider.broadcast(transaction)\n }\n\n public async subscribeToAddressNotifications(callback: SubscribeCallback): Promise<void>{\n await rostrumProvider.subscribeToAddresses(this._addressesToWatch.map(addr => addr.address), callback)\n }\n\n /**\n * Gets the list of addresses being watched\n * @returns Array of watched addresses (copy to prevent mutation)\n */\n public getWatchedAddresses(): WatchOnlyAddress[] {\n return [...this._addressesToWatch];\n }\n}\n","import {\n AddressType,\n TransactionBuilder,\n} from \"libnexa-ts\";\nimport {WatchOnlyAddress} from \"../../models/wallet.entities\";\nimport {TransactionCreator} from \"./interfaces/TransactionCreator\";\nimport {\n watchOnlyBuildCreateGroupTransaction, watchOnlyPopulateAndDuplicateTokenAuths,\n watchOnlyPopulateNexaInputsAndChange,\n watchOnlyPopulateTokenAuth, watchOnlyPopulateTokenInputsAndChange, watchOnlyPrepareDeleteTransaction\n} from \"../../utils/WatchOnlyTXUtils\";\nimport {isString} from \"lodash-es\";\nimport {rostrumProvider} from \"../../network/RostrumProvider\";\nimport {PermissionLabel} from \"../../models/transaction.entities\";\nimport {isValidNexaAddress} from \"../../utils/WalletUtils\";\n\n/**\n * WatchOnlyTransactionCreator extends TransactionCreator to handle transaction creation\n * for watch-only wallets. It manages addresses without private keys and delegates\n * UTXO selection and input population to specialized utility functions.\n */\nexport default class WatchOnlyTransactionCreator extends TransactionCreator {\n\n\n /** Addresses that need to be signed with (populated during transaction building) */\n private _addressesToSignWith: string[] = [];\n /** Available addresses for input selection and change */\n private _availableAddresses: WatchOnlyAddress[] = []\n\n /**\n * Creates a new WatchOnlyTransactionCreator\n * @param tx Optional existing transaction builder or transaction data\n */\n constructor(tx?: TransactionBuilder | string | Buffer) {\n super(tx)\n }\n\n /**\n * Sets the source addresses for transaction inputs\n * @param address Single address string, array of addresses, or WatchOnlyAddress objects\n * @returns This instance for chaining\n */\n public from(address: string | string[] | WatchOnlyAddress[] | WatchOnlyAddress): this {\n if (isString(address)) {\n\n if (!isValidNexaAddress(address, this.network) && !isValidNexaAddress(address, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n // Single address string\n this._availableAddresses.push({address: address});\n } else if(Array.isArray(address)) {\n // Array of addresses or WatchOnlyAddress objects\n address.forEach((addr) => {\n if (isString(addr)) {\n if (!isValidNexaAddress(addr, this.network) && !isValidNexaAddress(addr, this.network, AddressType.PayToPublicKeyHash)) {\n throw new Error('Invalid Address.');\n }\n // String address\n this._availableAddresses.push({address: addr});\n } else if (addr && typeof addr === 'object' && 'address' in addr) {\n // WatchOnlyAddress object\n this._availableAddresses.push(<WatchOnlyAddress>addr);\n }\n })\n } else if(address.address != null) {\n // Single WatchOnlyAddress object\n this._availableAddresses.push(<WatchOnlyAddress>address)\n }\n return this\n }\n\n /**\n * Adds a token minting operation to the transaction\n * @param token Token ID to mint\n * @param amount Amount to mint\n * @param toAddr Destination address for minted tokens\n * @returns This instance for chaining\n */\n public mint(token: string, amount: string, toAddr:string): this {\n this.builder.push(async() => {\n this.tokenAction(toAddr, amount, token, 'mint')\n })\n\n return this\n }\n\n /**\n * Adds a token melting operation to the transaction\n * @param token Token ID to melt\n * @param amount Amount to melt\n * @param toAddr Destination address for melted tokens\n * @returns This instance for chaining\n */\n public melt(token: string, amount: string, toAddr:string): this {\n this.builder.push(async() => {\n this.tokenAction(toAddr, amount, token, 'melt')\n })\n\n return this\n }\n\n /**\n * Populates the transaction with inputs and outputs based on the configured actions.\n * Handles different token operations (mint, melt, group creation, etc.) and\n * populates NEXA inputs for transaction fees.\n * @returns This instance for chaining\n */\n public populate(): this {\n this.builder.push(async () => {\n let tokenAddresses: string[] = []\n let nexaAddresses: string[] = []\n\n // Process token operations if any are configured\n if(this.tokens.size > 0) {\n for (const tokenAction of this.tokens) {\n if(tokenAction.action == 'mint' || tokenAction.action == 'melt') {\n // Handle token minting/melting - requires authority\n tokenAddresses = tokenAddresses.concat(await watchOnlyPopulateTokenAuth(this.transactionBuilder, this._availableAddresses, tokenAction.token!, tokenAction.action))\n } else if (tokenAction.action == 'group') {\n // Handle group token creation\n tokenAddresses = tokenAddresses.concat(await watchOnlyBuildCreateGroupTransaction(this.transactionBuilder, this._availableAddresses, tokenAction.token!, this.network))\n } else if (tokenAction.action == 'subgroup') {\n // Handle subgroup token creation\n tokenAddresses = tokenAddresses.concat(await watchOnlyPopulateTokenAuth(this.transactionBuilder, this._availableAddresses, tokenAction.parentToken!, tokenAction.action, tokenAction.token));\n } else if(tokenAction.action == 'renew') {\n // Handle authority renewal\n tokenAddresses = tokenAddresses.concat(await watchOnlyPopulateAndDuplicateTokenAuths(this.transactionBuilder, this._availableAddresses, tokenAction.token!, tokenAction.extraData!.perms!, tokenAction.extraData?.address!))\n } else if(tokenAction.action == 'delete') {\n // Handle authority deletion\n tokenAddresses = tokenAddresses.concat(await watchOnlyPrepareDeleteTransaction(this.transactionBuilder, this._availableAddresses, tokenAction.extraData!.outpoint!))\n } else {\n // Handle regular token transfers\n tokenAddresses = tokenAddresses.concat(await watchOnlyPopulateTokenInputsAndChange(this.transactionBuilder, this._availableAddresses, tokenAction.token!, tokenAction.amount))\n }\n\n // Accumulate addresses that need signing\n this._addressesToSignWith!.concat(tokenAddresses)\n }\n }\n\n // Populate NEXA inputs for transaction fees and change\n nexaAddresses = nexaAddresses.concat(await watchOnlyPopulateNexaInputsAndChange(this.transactionBuilder, this._availableAddresses, this.totalValue, this.txOptions))\n\n // Combine all addresses that need signing\n this._addressesToSignWith! = tokenAddresses.concat(nexaAddresses)\n })\n\n return this\n }\n\n /**\n * Parse transaction from buffer (not implemented for watch-only)\n * @param tx Transaction buffer\n * @returns This instance for chaining\n * @throws Error indicating method not implemented\n */\n public parseTxBuffer(tx: Buffer): this {\n this.builder.push(async () => {\n this.transactionBuilder = new TransactionBuilder(tx);\n })\n return this\n }\n\n /**\n * Parse transaction from hex string (not implemented for watch-only)\n * @param tx Transaction hex string\n * @returns This instance for chaining\n * @throws Error indicating method not implemented\n */\n public parseTxHex(tx: string) {\n this.builder.push(async () => {\n const txBuilder = new TransactionBuilder(tx)\n const newTxBuilder = new TransactionBuilder()\n const oldInputs = txBuilder.transaction.inputs\n for (const input of oldInputs) {\n const utxo = await rostrumProvider.getUtxo(input.outpoint.toString('hex'))\n newTxBuilder.from({\n outpoint: utxo.tx_hash,\n amount: utxo.amount,\n scriptPubKey: utxo.scriptpubkey\n })\n }\n newTxBuilder.transaction.outputs = txBuilder.transaction.outputs\n this.transactionBuilder = newTxBuilder;\n })\n\n return this\n }\n}\n","import { rostrumProvider } from '../network/RostrumProvider';\nimport { WatchOnlyAddress } from '../models/wallet.entities';\nimport { MAX_INT64, isNullOrEmpty } from './CommonUtils';\nimport {\n Address,\n AddressType,\n GroupToken,\n Networkish,\n Transaction,\n TransactionBuilder,\n UnitUtils,\n UTXO\n} from \"libnexa-ts\";\nimport { PermissionLabel, TxOptions } from \"../models/transaction.entities\";\nimport {dupAuthority, isAuthFit} from \"./TokenUtils\";\n\nconst MAX_INPUTS_OUTPUTS = 250;\n\nexport async function watchOnlyPopulateNexaInputsAndChange(txBuilder: TransactionBuilder, addresses: WatchOnlyAddress[], totalTxValue: bigint, options: TxOptions): Promise<string[]> {\n if (isNullOrEmpty(addresses)) {\n throw new Error(\"Not enough Nexa balance.\");\n }\n\n let usedAddresses = new Set<string>();\n let origAmount = options.isConsolidate ? 0 : Number(totalTxValue);\n\n for (let item of addresses) {\n let utxos = await rostrumProvider.getNexaUtxos(item.address);\n for (let utxo of utxos) {\n let input: UTXO = {\n outpoint: utxo.outpoint_hash,\n address: item.address,\n satoshis: utxo.value,\n templateData: options.templateData\n }\n txBuilder.from(input);\n\n if (!usedAddresses.has(item.address)) {\n usedAddresses.add(item.address);\n }\n\n if (options.isConsolidate) {\n // need to handle change\n txBuilder.change(options.toChange ?? item.address);\n\n if (txBuilder.transaction.inputs.length > MAX_INPUTS_OUTPUTS) {\n return Array.from(usedAddresses.values());\n }\n } else {\n let tx = txBuilder.transaction;\n if (tx.inputs.length > MAX_INPUTS_OUTPUTS) {\n throw new Error(\"Too many inputs. Consider consolidate transactions or reduce the send amount.\");\n }\n\n let unspent = tx.getUnspentValue();\n if (unspent < 0n) {\n continue;\n }\n\n if (unspent == 0n && options.feeFromAmount) {\n let txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n return Array.from(usedAddresses.values());\n }\n\n txBuilder.change(options.toChange ?? item.address);\n if (options.feeFromAmount) {\n let hasChange = tx.getChangeOutput();\n let txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n\n // edge case where change added after update\n if (!hasChange && tx.getChangeOutput()) {\n txFee = tx.estimateRequiredFee();\n tx.updateOutputAmount(0, origAmount - txFee);\n }\n }\n\n // check again after change output manipulation\n if (tx.getUnspentValue() < tx.estimateRequiredFee()) {\n // try to add more utxos to satisfy the minimum fee\n continue;\n }\n return Array.from(usedAddresses.values());\n }\n }\n }\n\n if (options.isConsolidate) {\n if (usedAddresses.size > 0) {\n return Array.from(usedAddresses.values());\n }\n throw new Error(\"Not enough Nexa balance.\");\n }\n\n let err = {\n errorMsg: \"Not enough Nexa balance.\",\n amount: UnitUtils.formatNEXA(Number(totalTxValue)),\n fee: UnitUtils.formatNEXA(txBuilder.transaction.estimateRequiredFee())\n }\n\n throw new Error(JSON.stringify(err));\n}\n\nexport async function watchOnlyPopulateTokenInputsAndChange(txBuilder: TransactionBuilder, addresses: WatchOnlyAddress[], token: string, outTokenAmount: bigint): Promise<string[]> {\n if (isNullOrEmpty(addresses)) {\n throw new Error(\"Not enough token balance.\");\n }\n\n let usedKeys = new Set<string>();\n let inTokenAmount = 0n;\n\n for (let item of addresses) {\n let utxos = await rostrumProvider.getTokenUtxos(item.address, token);\n for (let utxo of utxos) {\n if (utxo.token_amount < 0) {\n continue;\n }\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: item.address,\n satoshis: utxo.value,\n groupId: utxo.group,\n groupAmount: BigInt(utxo.token_amount),\n });\n\n inTokenAmount = inTokenAmount + BigInt(utxo.token_amount);\n if (!usedKeys.has(item.address)) {\n usedKeys.add(item.address);\n }\n\n if (inTokenAmount > MAX_INT64) {\n throw new Error(\"Token inputs exceeded max amount. Consider sending in small chunks\");\n }\n if (txBuilder.transaction.inputs.length > MAX_INPUTS_OUTPUTS) {\n throw new Error(\"Too many inputs. Consider consolidating transactions or reduce the send amount.\");\n }\n\n if (inTokenAmount == outTokenAmount) {\n return Array.from(usedKeys.values());\n }\n if (inTokenAmount > outTokenAmount) {\n // change\n txBuilder.to(item.address, Transaction.DUST_AMOUNT, token, inTokenAmount - outTokenAmount);\n return Array.from(usedKeys.values());\n }\n }\n }\n\n throw new Error(\"Not enough token balance\");\n}\n\nexport async function watchOnlyBuildCreateGroupTransaction(\n txBuilder: TransactionBuilder,\n addresses: WatchOnlyAddress[],\n opReturnData: string,\n network: Networkish\n): Promise<string[]> {\n let outpoint = '', idHex = '';\n let usedKeys: string[] = [];\n for (let item of addresses) {\n let utxos = await rostrumProvider.getNexaUtxos(item.address);\n for (let utxo of utxos) {\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: item.address,\n satoshis: utxo.value\n });\n\n if (isNullOrEmpty(outpoint)) {\n outpoint = utxo.outpoint_hash;\n let id = GroupToken.findGroupId(Buffer.from(outpoint, 'hex'), Buffer.from(opReturnData, 'hex'), GroupToken.authFlags.ACTIVE_FLAG_BITS);\n const groupId = new Address(id.hashBuffer, network, AddressType.GroupIdAddress).toString()\n txBuilder.to(item.address, Transaction.DUST_AMOUNT, groupId, GroupToken.authFlags.ACTIVE_FLAG_BITS | id.nonce)\n idHex = id.hashBuffer.toString('hex');\n usedKeys.push(item.address);\n return usedKeys\n }\n }\n }\n\n throw new Error(\"Not enough Nexa balance.\");\n}\n\nexport async function watchOnlyPrepareDeleteTransaction(txBuilder: TransactionBuilder, addresses: WatchOnlyAddress[], outpoint: string): Promise<string[]> {\n let utxo = await rostrumProvider.getUtxo(outpoint);\n let address = utxo.addresses[0];\n\n txBuilder.from({\n outpoint: outpoint,\n address: address,\n satoshis: utxo.amount\n });\n\n let addrKey = addresses.find(k => k.address === address);\n\n if (!addrKey) {\n throw new Error('UTXO associated key not found in the wallet');\n }\n return [addrKey.address];\n}\n\nexport async function watchOnlyPopulateTokenAuth(txBuilder: TransactionBuilder, addresses: WatchOnlyAddress[], token: string, perm: PermissionLabel, subgroup = ''): Promise<string[]> {\n for (let item of addresses) {\n let utxos = await rostrumProvider.getTokenUtxos(item.address, token);\n for (let utxo of utxos) {\n if (!isAuthFit(utxo.token_amount, perm)) {\n continue;\n }\n\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: item.address,\n satoshis: utxo.value\n });\n\n if (perm === 'subgroup') {\n txBuilder.to(item.address, Transaction.DUST_AMOUNT, subgroup, dupAuthority(utxo.token_amount, false));\n }\n\n // if renew flag included, we don't want to burn it\n if (GroupToken.allowsRenew(BigInt.asUintN(64, BigInt(utxo.token_amount)))) {\n txBuilder.to(item.address, Transaction.DUST_AMOUNT, token, dupAuthority(utxo.token_amount));\n }\n\n return [item.address];\n }\n }\n\n throw new Error(\"The requested authority not found\");\n}\n\nexport async function watchOnlyPopulateAndDuplicateTokenAuths(txBuilder: TransactionBuilder, addresses: WatchOnlyAddress[], token: string, perms: PermissionLabel[], toAddr?: string): Promise<string[]> {\n let usedAddresses: string[] = [];\n\n let reqiredPerms = new Set(perms);\n reqiredPerms.add('authorise');\n\n for (let item of addresses) {\n let utxos = await rostrumProvider.getTokenUtxos(item.address, token);\n for (let utxo of utxos) {\n if (utxo.token_amount > 0) {\n continue;\n }\n\n let found = false;\n for (let perm of reqiredPerms) {\n if (isAuthFit(utxo.token_amount, perm)) {\n reqiredPerms.delete(perm);\n found = true;\n }\n }\n\n if (!found) {\n continue;\n }\n\n txBuilder.from({\n outpoint: utxo.outpoint_hash,\n address: item.address,\n satoshis: utxo.value\n });\n usedAddresses.push(item.address);\n\n // duplicate\n txBuilder.to(toAddr != null ? toAddr : item.address, Transaction.DUST_AMOUNT, token, dupAuthority(utxo.token_amount));\n\n if (reqiredPerms.size === 0) {\n return usedAddresses;\n }\n }\n }\n\n throw new Error(\"The required authorities not found\");\n}\n"],"names":[],"version":3,"file":"index.js.map"}
|