/// <inheritdoc /> public HdAddress GetUnusedAddress(WalletAccountReference accountReference) { Guard.NotNull(accountReference, nameof(accountReference)); Wallet wallet = this.GetWalletByName(accountReference.WalletName); // get the account HdAccount account = wallet.GetAccountByCoinType(accountReference.AccountName, this.coinType); // validate address creation if (account.ExternalAddresses.Any()) { // check last created address contains transactions. var firstUnusedExternalAddress = account.GetFirstUnusedReceivingAddress(); if (firstUnusedExternalAddress != null) { return(firstUnusedExternalAddress); } } // creates an address account.CreateAddresses(this.network, 1); // persists the address to the wallet file this.SaveToFile(wallet); // adds the address to the list of tracked addresses this.LoadKeysLookup(); return(account.GetFirstUnusedReceivingAddress()); }
/// <inheritdoc /> public List <UnspentOutputReference> GetSpendableTransactionsInAccount(WalletAccountReference walletAccountReference, int confirmations = 0) { Guard.NotNull(walletAccountReference, nameof(walletAccountReference)); Wallet wallet = this.GetWalletByName(walletAccountReference.WalletName); HdAccount account = wallet.GetAccountByCoinType(walletAccountReference.AccountName, this.coinType); if (account == null) { throw new WalletException($"Account '{walletAccountReference.AccountName}' in wallet '{walletAccountReference.WalletName}' not found."); } return(account.GetSpendableTransactions(this.chain.Tip.Height, confirmations)); }