private void Copay_info(QBitNinjaClient client, WalletClient wallet) { List <BalanceOperation> operations = wallet.GetBalance().Result.Operations; Decimal total_balance = 0; Console.WriteLine("=============================="); Console.WriteLine("All transactions from wallet"); Console.WriteLine("------------------------------"); // print all transactions with their amount, and add theme to get balance foreach (BalanceOperation balance in operations) { Decimal amout = balance.Amount.ToDecimal(MoneyUnit.BTC); total_balance += amout; Console.Write("Transaction ID : "); Console.WriteLine(balance.TransactionId); Console.Write("Amount : "); Console.WriteLine(amout); } Console.Write("Total balance : "); Console.WriteLine(total_balance); Console.WriteLine("=============================="); Console.WriteLine(""); }
public void GetBalanceTest() { var result = client.GetBalance().Result; Debug.WriteLine($"Spandable: {result.Spendable}, SpandableDust: {result.SpendableDust}, Locked: {result.Locked}, Total: {result.Total}"); }
public void GetBalanceTest() { Balance balance = _wallet.GetBalance().Result; Debug.Write(balance.Total); }
private void UpdateSafeHistoryAndBalanceInfo() { AssertSynced(); var balanceOperations = _qBitNinjaWalletClient.GetBalance().Result.Operations; // Find all the operations concerned to one address // address, balanceoperationlist var addressOperationPairs = new HashSet <Tuple <string, BalanceOperation> >(); // address, unconfirmed, confirmed var receivedAddressAmountPairs = new HashSet <Tuple <string, decimal, decimal> >(); var spentAddressAmountPairs = new HashSet <Tuple <string, decimal, decimal> >(); foreach (var operation in balanceOperations) { foreach (var coin in operation.ReceivedCoins) { string address; if (!SafeContainsCoin(out address, coin)) { continue; } var amount = ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC); receivedAddressAmountPairs.Add(operation.Confirmations == 0 ? new Tuple <string, decimal, decimal>(address, amount, 0m) : new Tuple <string, decimal, decimal>(address, 0m, amount)); addressOperationPairs.Add(new Tuple <string, BalanceOperation>(address, operation)); } foreach (var coin in operation.SpentCoins) { string address; if (!SafeContainsCoin(out address, coin)) { continue; } var amount = ((Money)coin.Amount).ToDecimal(MoneyUnit.BTC); spentAddressAmountPairs.Add(operation.Confirmations == 0 ? new Tuple <string, decimal, decimal>(address, amount, 0m) : new Tuple <string, decimal, decimal>(address, 0m, amount)); addressOperationPairs.Add(new Tuple <string, BalanceOperation>(address, operation)); } } var addressOperationsDict = new Dictionary <string, HashSet <BalanceOperation> >(); foreach (var pair in addressOperationPairs) { if (addressOperationsDict.Keys.Contains(pair.Item1)) { addressOperationsDict[pair.Item1].Add(pair.Item2); } else { addressOperationsDict.Add(pair.Item1, new HashSet <BalanceOperation> { pair.Item2 }); } } var addressHistories = addressOperationsDict.Select(pair => new AddressHistory(pair.Key, pair.Value)).ToList(); foreach (var address in Safe.Addresses) { if (!addressHistories.Select(x => x.Address).Contains(address)) { addressHistories.Add(new AddressHistory(address, new List <BalanceOperation>())); } } var addressBalanceInfoList = new List <AddressBalanceInfo>(); foreach (var addressHistory in addressHistories) { var unconfirmed = 0m; var confirmed = 0m; foreach (var record in addressHistory.Records) { if (record.Confirmed) { confirmed += record.Amount; } else { unconfirmed += record.Amount; } } var addressBalanceInfo = new AddressBalanceInfo(addressHistory.Address, unconfirmed, confirmed); addressBalanceInfoList.Add(addressBalanceInfo); } SafeBalanceInfo = new SafeBalanceInfo(Safe, addressBalanceInfoList); SafeHistory = new SafeHistory(Safe, addressHistories); }