Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Connecting QBitNinja with Litecoin #85

Open
TJvrDev opened this issue Nov 21, 2018 · 32 comments
Open

Connecting QBitNinja with Litecoin #85

TJvrDev opened this issue Nov 21, 2018 · 32 comments

Comments

@TJvrDev
Copy link

TJvrDev commented Nov 21, 2018

I've successfully setup QBitNinja using Bitcoin Core. I am having trouble configuring with litecoin. The readme just specifies with Bitcoin Core. Is it safe to assume that i'll need to install litecoin core to use the altcoin capabilities with Litecoin? Would that also mean that if I used an altcoin that I would need to use a different component than Bitcoin Core?

@NicolasDorier
Copy link
Contributor

NicolasDorier commented Nov 22, 2018

If you want Litecoin, you need Litecoin node software; not bitcon core. Chain should be LTC, the rest should be the same. (I have not tried it though, so let me know how it goes)

@TJvrDev
Copy link
Author

TJvrDev commented Nov 23, 2018

I have Litecoin Core [testnet] running in Azure alongside QBitNinja.Listener, but my problem in my app is using clientQBitNinja.GetBalance. The Operations.Count always return 0. The pub key it's using has 10 test coins there and its using that pub key to get the balance. but without this operations count, i'm unable to see the unspentCoins and effectively get the balance.

QBitNinja.Listener will give this output:

QBitNinja.Listener Information: 0 : Start initial indexing
QBitNinja.Listener Information: 0 : Handshaking...
QBitNinja.Listener Information: 0 : Handshaked
QBitNinja.Listener Information: 0 : Current chain at height 864241
QBitNinja.Listener Information: 0 : Dequeuing index jobs
Work remaining in the queue : 0
QBitNinja.Listener Information: 0 : Work finished, updating checkpoints
QBitNinja.Listener Information: 0 : default/balances...
QBitNinja.Listener Information: 0 : default/blocks...
QBitNinja.Listener Information: 0 : default/transactions...
QBitNinja.Listener Information: 0 : default/wallets...
QBitNinja.Listener Information: 0 : default/subscriptions...
QBitNinja.Listener Information: 0 : Checkpoints updated
QBitNinja.Listener Information: 0 : Initial indexing terminated

If it says initial indexing terminated, will QBitNinja continue to work?

@NicolasDorier
Copy link
Contributor

NicolasDorier commented Nov 24, 2018

Please read the doc, after indexing you need: "QBitNinja.Listener.Console.exe --Listen"

@NicolasDorier
Copy link
Contributor

how do you instanciate clientQBitNinja ?

@TJvrDev
Copy link
Author

TJvrDev commented Nov 24, 2018

QBitNinjaClient clientQBitNinja = new QBitNinjaClient(NetworkAPI, m_network);

The NetworkAPI is assigned "http://tapi.qbit.ninja/"
& m_network is assigned NBitcoin.Altcoins.Litecoin.Instance.Testnet

After going back through the readme I was able to get the Listener.Console.exe up and running.
The problem i'm finding is not being able to find operations in the BalanceModel.

@NicolasDorier
Copy link
Contributor

http://tapi.qbit.ninja/ only support BTC you need your to host your own server.

@NicolasDorier
Copy link
Contributor

@TJvrDev
Copy link
Author

TJvrDev commented Nov 25, 2018

Ah, ok i've updated the test network to the web address I use for my azure web application. Now when it runs the task to retrieve the balance, there is a bit of a wait. Then it returns this error:

TaskCanceledException: A task was canceled.
Rethrow as AggregateException: One or more errors occurred.
System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at :0)
System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) (at <e1a80661d61443feb3dbdaac88eeb776>:0) System.Threading.Tasks.Task1[TResult].get_Result () (at :0)
YourBitcoinController.BitCoinController.GetUnspentCoins (NBitcoin.BitcoinAddress _address, System.Boolean _dispatchEvent) (at Assets/YourBitcoinController/Core/Scripts/Controller/BitCoinController.cs:866)
YourBitcoinController.BitCoinController.GetBalance (System.String _privateKey, System.Boolean _dispatchEvent) (at Assets/YourBitcoinController/Core/Scripts/Controller/BitCoinController.cs:835)
YourBitcoinController.BasicManager.CheckBalanceOriginReal () (at Assets/YourBitcoinController/Core/Scripts/View/BasicManager.cs:297)

I'm testing on Esteban's Unity package for bitcoin for testing then ill make the changes in my app.

Do you think the task is just timing out?
I am using a single instance of QBitNinja.Listener.Console without the optional RPCConnectionString.

@TJvrDev
Copy link
Author

TJvrDev commented Nov 25, 2018

I'm having trouble binding RPC at my address. I'm also looking into the possibility that by default my VM on Azure may be blocking RPC communication from the default networking settings.

Did you have to set up an inbound port rule to allow access to the connection?

If that isnt the problem then it may be how I have litecoin.conf set up.
Is there anything you would recommend changing in this?

I do get a message in the debug log:
Binding RPC on address 127.0.0.1 port 19335 failed.

//##
//## litecoin.conf configuration file. Lines beginning with # are comments.
//##

//# IMPORTANT: do not use the daemon's wallet
disablewallet=1

datadir=/ltc

//# Network-related settings:

//# Run on the test network instead of the real lite network.
testnet=1

//# Listening mode, enabled by default except when 'connect' is being used. Port 19335 (TestNet4)
listen=1

//#
//# JSON-RPC options (for controlling a running Litecoin/litecoind process)
//#

//# server=1 tells litecoind to accept JSON-RPC commands
server=1
//# Accept public REST requests (default: 0)
rest=0
//# RPC username or password is not specified, so a cookie is written to the /ltc/testnet4 directory for the CLI to use for auth

@NicolasDorier
Copy link
Contributor

The timeout has nothing to do with this. The front does not connect to RPC. I don't really know how to troubleshoot this. If you can manage to get azure logs for the front it would be good.

@TJvrDev
Copy link
Author

TJvrDev commented Nov 26, 2018

It's strange but when I enabled "Application Logging" for the webapp in Azure, it started working. Even after disabling "Application Logging". My app goes through the flow and I get a Transaction Success result from

BroadcastResponse broadcastResponse = _clientQBitNinja.Broadcast(_customerTransaction).Result;

But the wallets and testnet do not reflect the transaction.
I did retrieve the web server logs from Azure, ill email them to you.

@NicolasDorier
Copy link
Contributor

please do not email, just copy paste here. What is your server url?

@TJvrDev
Copy link
Author

TJvrDev commented Nov 27, 2018

@NicolasDorier
Copy link
Contributor

OK, let's try to solve it, can you try to run the front under visual studio with the same config as the website?

@TJvrDev
Copy link
Author

TJvrDev commented Nov 28, 2018

I started running QBitNinja in Visual Studio with the same config as the website.

@NicolasDorier
Copy link
Contributor

Any exception or anything you can notice? You have the same timeout?

@TJvrDev
Copy link
Author

TJvrDev commented Nov 30, 2018

When reviewing the logs there were a few exceptions, this was one of them:

System.TimeoutException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089The client could not finish the operation within specified timeout. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NBitcoin.Indexer.IndexerClient.&lt;GetChainChangesUntilFork&gt;d__22.MoveNext()
at NBitcoin.Indexer.ChainChangeEntryExtensions.UpdateChain(IEnumerable`1 entries, ChainBase chain)
at QBitNinja.QBitNinjaDependencyResolver.UpdateChain()
at QBitNinja.UpdateChainListener.&lt;Listen&gt;b__10_0(Object _)
at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireQueuedTimerCompletion(Object state)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
System.TimeoutException: The client could not finish the operation within specified timeout.

@NicolasDorier
Copy link
Contributor

I should be able to fix that, can you send me your account storage creds by mail?

@TJvrDev
Copy link
Author

TJvrDev commented Dec 1, 2018

Sent

@NicolasDorier
Copy link
Contributor

@TJvrDev can you verify that your storage account and your front website reside in the same datacenter ? (region)

@TJvrDev
Copy link
Author

TJvrDev commented Dec 2, 2018

It looks like the storage account resides in East US & West US. The website resides in Central. Ill get them in the same region.

@TJvrDev
Copy link
Author

TJvrDev commented Dec 2, 2018

Alright I have Web App residing in East US now. I did have to create a new web app but I applied to updated PublishSettings for QBitNinja and republished it.

@TJvrDev
Copy link
Author

TJvrDev commented Dec 3, 2018

The new server url is:
http://alarisbattlesapp.azurewebsites.net/

@NicolasDorier
Copy link
Contributor

storage account resides in East US & West US a storage account can't live in two different place.
It does not seem to have resolved the issue.

I will try something.

@NicolasDorier
Copy link
Contributor

NicolasDorier commented Dec 3, 2018

Actually it solved, it. It is not timing out now.

@NicolasDorier
Copy link
Contributor

It is quite slow though... Querying on an address take a while.

@NicolasDorier
Copy link
Contributor

Actually timing out. It does not make sense. What is your machine specification for the front? I am wondering if the server does not get restarted because it uses too much memory or something like this. One sec, I check on my servers.

@NicolasDorier
Copy link
Contributor

Ok so this is my tier for the service plan Basic: 1 Large

@TJvrDev
Copy link
Author

TJvrDev commented Dec 3, 2018

My service plan for the web app shows Standard: 1 small. I'll try to change it to match yours.

@TJvrDev
Copy link
Author

TJvrDev commented Dec 3, 2018

Before it had:
100 total ACU
1.75 GB memory

Now has:
400 total ACU
7GB memory

@NicolasDorier
Copy link
Contributor

It is still timing out it seems. That is super strange. Trying to replicate it as much as I can.

@NicolasDorier
Copy link
Contributor

Can you get the applications logs on your server at all? Is it still this timeout?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants