private void Init(Types.Wallet wallet) { SqlMapper.AddTypeHandler(new DateTimeOffsetHandler()); SqlMapper.AddTypeHandler(new HashHeightPairHandler()); SqlMapper.AddTypeHandler(new CollectionOfuint256Handler()); SqlMapper.AddTypeHandler(new Uint256Handler()); SqlMapper.AddTypeHandler(new MoneyHandler()); SqlMapper.AddTypeHandler(new OutPointHandler()); SqlMapper.AddTypeHandler(new ScriptHandler()); SqlMapper.AddTypeHandler(new CollectionOfPaymentDetailsHandler()); SqlMapper.AddTypeHandler(new PartialMerkleTreeHandler()); this.WalletData = this.GetData(); if (this.WalletData != null) { if (this.WalletData.EncryptedSeed != wallet.EncryptedSeed) { throw new WalletException("Invalid Wallet seed"); } } else { this.SetData(new WalletData { Key = "Key", EncryptedSeed = wallet.EncryptedSeed, WalletName = wallet.Name, WalletTip = new HashHeightPair(this.network.GenesisHash, 0), WalletVersion = WalletVersion }); } }
private void Init(Types.Wallet wallet) { this.repo = new LiteRepository(this.db); this.trxCol = this.db.GetCollection <TransactionOutputData>("transactions"); this.dataCol = this.db.GetCollection <WalletData>("data"); this.trxCol.EnsureIndex(x => x.OutPoint, true); this.trxCol.EnsureIndex(x => x.Address, false); this.trxCol.EnsureIndex(x => x.BlockHeight, false); this.dataCol.EnsureIndex(x => x.Key, true); this.WalletData = this.GetData(); if (this.WalletData != null) { if (this.WalletData.EncryptedSeed != wallet.EncryptedSeed) { throw new WalletException("Invalid Wallet seed"); } } else { this.SetData(new WalletData { Key = "Key", EncryptedSeed = wallet.EncryptedSeed, WalletName = wallet.Name, WalletTip = new HashHeightPair(this.network.GenesisHash, 0) }); } }
public WalletData GetData() { if (this.WalletData == null) { this.WalletData = this.dataCol.FindById("Key"); } return(this.WalletData); }
public WalletData GetData() { if (this.WalletData == null) { this.WalletData = this.sqliteConnection.QueryFirstOrDefault <WalletData>("SELECT *, Id AS Key FROM WalletData WHERE Id = 'Key'"); } return(this.WalletData); }
public WalletData GetData() { if (this.WalletData == null) { using var conn = this.GetDbConnection(); this.WalletData = conn.QueryFirstOrDefault <WalletData>("SELECT *, Id AS Key FROM WalletData WHERE Id = 'Key'"); } return(this.WalletData); }
public void SetData(WalletData data) { var sql = @$ "INSERT INTO WalletData (Id, EncryptedSeed, WalletName, WalletTip, WalletVersion, BlockLocator) VALUES (@Key, @EncryptedSeed, @WalletName, @WalletTip, @WalletVersion, @BlockLocator) ON CONFLICT(Id) DO UPDATE SET EncryptedSeed = @EncryptedSeed, WalletTip = @WalletTip, BlockLocator = @BlockLocator;"; this.sqliteConnection.Execute(sql, data); this.WalletData = data; }
public void SetData(WalletData data) { this.dataCol.Upsert(data); this.WalletData = data; }