MetacoSA / QBitNinja

An Open Source and powerful blockchain API
MIT License
68 stars 42 forks source link

QBitNinja adapt for NBitcoin.Altcoins #67

Open darkfriend77 opened 6 years ago

darkfriend77 commented 6 years ago

I would like to adapt QBitNinja to NBitcoinAltcoins.

Can you help with a round up where I shall start and what the important steps are?

NicolasDorier commented 6 years ago

Well I don't think you need to much but important NBitcoin.Altcoins to QBitNinja and make sure you get the right Network instance in the code.

bilalafzal345g commented 6 years ago

I am trying to do the same but no luck.

I have tried to connect the Qbitninja with local node For Litecoin But nothing is working.

bilalafzal345g commented 6 years ago

public void MssGetBalance(string ssAddress, bool ssIsUnspentOnly, out decimal ssBalance, out decimal ssConfirmedBalance) { Network network = NBitcoin.Altcoins.Litecoin.Instance.Testnet;

        QBitNinjaClient client = new QBitNinjaClient("http://127.0.0.1:19332/", network);
        var balance = client.GetBalance(new BitcoinPubKeyAddress(ssAddress,network)).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));
        }
    }
NicolasDorier commented 6 years ago

Sorry I can't help you hosting your own QBitNinja server. Look the README I improved it this week.

bilalafzal345g commented 6 years ago

Dear Nicolas,

Thanks for your precious time :).

Can you please suggest, how to get any Litecoin balance by passing the address and UTXO(unspend transactions) by using Nbitcoin.RPC package.

Kind Regards, Bilal Afzal

On 8 August 2018 at 14:24, Nicolas Dorier notifications@github.com wrote:

Sorry I can't help you hosting your own QBitNinja server. Look the README I improved it this week.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MetacoSA/QBitNinja/issues/67#issuecomment-411344174, or mute the thread https://github.com/notifications/unsubscribe-auth/AoNtKjZbiSTuhWIghE68IPffBsxKTO4cks5uOq5cgaJpZM4VtbVq .

NicolasDorier commented 6 years ago

If your goal is to make a wallet, just use a full node with https://github.com/dgarage/NBXplorer . This is way more lightweight that qbit and support litecoin.

Read https://programmingblockchain.gitbooks.io/programmingblockchain/content/wallet/web-api.html for example.