public void Setup() { // by pre-caching wallets we make the tests do lot less work Parallel.ForEach(WalletTypes.Union(WalletTypes), walletType => { Context cachedWallet = new Context(walletType); _cachedWallets.TryAdd(walletType, cachedWallet); _wallets.Add(cachedWallet); }); }
public static IWallet GetWallet(Guid id, Guid owner, WalletTypes type, string name, bool useRPC, string baseURL, int port) { switch (type) { case WalletTypes.Bitcoin: return(null); break; case WalletTypes.Neblio: return(new NeblioWallet(id, owner, name, useRPC, baseURL, port)); break; } return(null); }
public Wallet(String name, WalletTypes newWalletType, int money, Boolean isLootable) : base(isLootable, name) { gold += money; walletType = newWalletType; if (newWalletType == WalletTypes.LEATHER) { maxGold = 1000; } else if (newWalletType == WalletTypes.OVERSIZE) { maxGold = 5000; } else { maxGold = 10000; } isLootable = true; }
protected Wallet CreateOrUpdateWallet(WalletTypes type, int id = 0, decimal amount = 0) { Wallet wallet; if (id > 0) { var inttype = (int)type; wallet = Get <Wallet>(w => w.Id == id && w.WalletType == inttype); if (wallet == null) { throw new BillingNotFoundException($"кошелек {id} type {type} не найден"); } } else { wallet = new Wallet(); wallet.WalletType = (int)type; Add(wallet); } wallet.Balance = amount; SaveContext(); return(wallet); }
public override async Task <string> UpdateWallet(Guid id, Guid ownerid, string walletName, WalletTypes type, string urlBase, int port, IDbConnectorService dbservice) { //IDbConnectorService dbservice = new DbConnectorService(); if (EconomyMainContext.Wallets.TryGetValue(id.ToString(), out var wallet)) { wallet.Name = walletName; if (ownerid != Guid.Empty) { wallet.Owner = ownerid; } wallet.Type = type; wallet.BaseURL = urlBase; wallet.ConnectionPort = port; Console.WriteLine($"New wallet connection address: {wallet.ConnectionAddress}"); if (EconomyMainContext.WorkWithDb) { if (!dbservice.SaveWallet(wallet)) { Console.WriteLine("Cannot save Node to the db!"); return("Cannot save Node to the db!"); } } return("OK"); } else { if (string.IsNullOrEmpty(id.ToString())) { id = Guid.NewGuid(); } if (string.IsNullOrEmpty(ownerid.ToString())) { ownerid = Guid.NewGuid(); } var wall = WalletFactory.GetWallet(id, ownerid, type, walletName, EconomyMainContext.WorkWithQTRPC, urlBase, port); if (wall != null) { wall.NewTransaction += Wall_NewTransaction; wall.NewConfirmedTransactionDetailsReceived += WalletHandler_NewTransactionDetailsReceived; EconomyMainContext.Wallets.Add(wall.Id.ToString(), wall); if (EconomyMainContext.WorkWithDb) { if (!dbservice.SaveWallet(wall)) { log.Error("Cannot save wallet to the Db!"); return("Cannot save wallet to the Db!"); } } } return("OK"); } }
public abstract Task <string> UpdateWallet(Guid id, Guid ownerid, string walletName, WalletTypes type, string urlBase, int port, IDbConnectorService dbservice);