|
@@ -32,6 +32,7 @@ namespace HyperCube.Models
|
|
|
public static Dictionary<string, AccountModel> Loaded = new();
|
|
|
public static AccountModel Current;
|
|
|
public string eth_address { get; set; }
|
|
|
+ public string eth_address1 { get; set; }
|
|
|
/// <summary>
|
|
|
/// ASP Identity ID
|
|
|
/// </summary>
|
|
@@ -61,11 +62,15 @@ namespace HyperCube.Models
|
|
|
|
|
|
public static BigInteger ConvertBalance(string hex)
|
|
|
{
|
|
|
- Console.WriteLine($"ConvertBalance {hex}");
|
|
|
- string newHex = hex.Remove(0, 2);
|
|
|
- var balance = System.Numerics.BigInteger.Parse("0"+ newHex, System.Globalization.NumberStyles.HexNumber );
|
|
|
- Console.WriteLine($"ConvertBalance {hex} {balance}");
|
|
|
- return balance;
|
|
|
+ if (hex != null && hex.Length > 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine($"ConvertBalance {hex}");
|
|
|
+ string newHex = hex.Remove(0, 2);
|
|
|
+ var balance = System.Numerics.BigInteger.Parse("0" + newHex, System.Globalization.NumberStyles.HexNumber);
|
|
|
+ Console.WriteLine($"ConvertBalance {hex} {balance}");
|
|
|
+ return balance;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
public static async void InitializeAccounts()
|
|
@@ -75,6 +80,22 @@ namespace HyperCube.Models
|
|
|
foreach (var acc in Loaded)
|
|
|
{
|
|
|
acc.Value.LoadRoles();
|
|
|
+ var wallets = await MySQLConnector.Instance().SQLSelectComplex($"select * from account_wallets where account_uuid='{acc.Value.UUID}'");
|
|
|
+
|
|
|
+ if (wallets.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var wallet in wallets)
|
|
|
+ {
|
|
|
+ var bc_id = Convert.ToInt32(wallet["blockchain_id"]);
|
|
|
+ var wallet_id = Convert.ToString(wallet["uuid"]);
|
|
|
+ if (bc_id == 0)
|
|
|
+ acc.Value.eth_address = wallet_id;
|
|
|
+ else
|
|
|
+ acc.Value.eth_address1 = wallet_id;
|
|
|
+ Console.WriteLine($"acc {acc.Value.Name} wallet0 {acc.Value.eth_address} wallet1 {acc.Value.eth_address1}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -108,7 +129,7 @@ namespace HyperCube.Models
|
|
|
|
|
|
public async Task<string> GetBalance()
|
|
|
{
|
|
|
- var res = await Blockchain.GetMain().GetBalance(eth_address);
|
|
|
+ var res = await Blockchain.GetMain().GetBalance(this);
|
|
|
var balanceInt = ConvertBalance(res);
|
|
|
string balance = balanceInt.ToString();
|
|
|
//Console.WriteLine($"GetBalance {balance}");
|