QBitNinjaClient获得平衡c#

时间:2018-03-28 20:07:54

标签: c# bitcoin

我生成了5个地址

1KmjtM8aibtBqbPiJahYYEwcEAH2Duk9QH
1HV55k5erZrFA3SirFLULf1rTs4sKvvqQg
1B1Tx9wXVVmmySSDSFYekM7cy7xCTybEMg
1Py6rXFPepLa7nacuRhYsJWYcfFLYE6zkw
1GRHuGiHqtuLY3A6roH7fT9bjbbiG1foWM

他们每人都转钱

尝试检查余额

public static void GetBalance(string ssAddress, bool ssIsUnspentOnly, bool ssIsTestNet, out decimal ssBalance, out decimal ssConfirmedBalance)
{
    Network net;
    if (ssIsTestNet)
        net = Network.TestNet;
    else
        net = Network.Main;
    QBitNinjaClient client = new QBitNinjaClient(net);
    var balance = client.GetBalance(new BitcoinPubKeyAddress(ssAddress), ssIsUnspentOnly).Result;
    ssBalance = 0.0M;
    ssConfirmedBalance = 0.0M;
    if (balance.Operations.Count > 0)
    {
        var unspentCoins = new List<Coin>();
        var unspentCoinsConfirmed = new List<Coin>();
        foreach (var operation in balance.Operations)
        {
            unspentCoins.AddRange(operation.ReceivedCoins.Select(coin => coin as Coin));
            if (operation.Confirmations > 0)
                unspentCoinsConfirmed.AddRange(operation.ReceivedCoins.Select(coin => coin as Coin));
        }
        ssBalance = unspentCoins.Sum(x => x.Amount.ToDecimal(MoneyUnit.BTC));
        ssConfirmedBalance = unspentCoinsConfirmed.Sum(x => x.Amount.ToDecimal(MoneyUnit.BTC));
    }
}


decimal addressBalance = 0;
decimal addressBalanceConfirmed = 0;
GetBalance("1Py6rXFPepLa7nacuRhYsJWYcfFLYE6zkw", true, false, out addressBalance, out addressBalanceConfirmed);
前三个地址上的

显示余额,最后两个地址显示余额(balance.Operations.Count = 0)但link1link2

我做错了什么?

0 个答案:

没有答案