internal void ReadAccount() { this.Account = HDAccount.GetAccount(this.conn, this.WalletId, this.AccountIndex); this.AddressCount = HDAddress.GetAddressCount(this.conn, this.WalletId, this.AccountIndex, this.AddressType); this.NextAddressIndex = HDAddress.GetNextAddressIndex(this.conn, this.WalletId, this.AccountIndex, this.AddressType); this.IsWatchOnlyAccount = this.Account.ExtPubKey == null; }
public AddressIdentifier CreateAddress() { HDAddress newAddress = this.conn.Repository.CreateAddress(this.Account, this.AddressType, this.AddressCount); if (!this.conn.IsInTransaction) { // We've postponed creating a transaction since we weren't sure we will need it. // Create it now. // TODO: Perhaps just add it to the tentative collection. this.conn.BeginTransaction(); if (this.processBlocksInfo != null) { this.processBlocksInfo.MustCommit = true; } } // Insert the new address into the database. this.conn.Insert(newAddress); // Update the information in the tracker. this.NextAddressIndex++; this.AddressCount++; return(new AddressIdentifier() { WalletId = newAddress.WalletId, AccountIndex = newAddress.AccountIndex, AddressType = newAddress.AddressType, AddressIndex = newAddress.AddressIndex, ScriptPubKey = newAddress.ScriptPubKey }); }
internal static HdAddress ToHdAddress(this SQLiteWalletRepository repo, HDAddress address) { var pubKeyScript = (address.PubKey == null) ? null : new Script(Encoders.Hex.DecodeData(address.PubKey)); // P2PK var scriptPubKey = new Script(Encoders.Hex.DecodeData(address.ScriptPubKey)); var res = new HdAddress() { Address = repo.ScriptAddressReader.GetAddressFromScriptPubKey(repo.Network, scriptPubKey), Index = address.AddressIndex, HdPath = repo.ToHdPath(address.AccountIndex, address.AddressType, address.AddressIndex), ScriptPubKey = new Script(Encoders.Hex.DecodeData(address.ScriptPubKey)), Pubkey = pubKeyScript }; return(res); }
internal static HdAddress ToHdAddress(this SQLiteWalletRepository repo, HDAddress address, Network network) { Script pubKeyScript = (address.PubKey == null) ? null : new Script(Encoders.Hex.DecodeData(address.PubKey)); // P2PK Script scriptPubKey = new Script(Encoders.Hex.DecodeData(address.ScriptPubKey)); var res = new HdAddress(null) { Address = address.Address, Index = address.AddressIndex, AddressType = address.AddressType, HdPath = repo.ToHdPath(address.AccountIndex, address.AddressType, address.AddressIndex), ScriptPubKey = scriptPubKey, Pubkey = pubKeyScript, Bech32Address = address.Bech32Address }; return(res); }