I am running bitcoinqt on my server. Each second, I use a .NET API to query the daemon to find new transactions which contain needed addresses. (The addresses are not from the local wallet.)

So, first I do GetRawMemPool() to get list of all new transaction Ids, and then for each id I do GetRawTransaction(transactionID) and DecodeRawTransaction() to get transaction details to find out if it contains needed addresses.

The problem is that this process, querying the daemon for each transaction in the mempool, sometimes takes a lot of time, up to 1 min, since the mempool sometimes has 10-12k transactions in the pool. I think the most CPU intensive is the DecodeRawTransaction() call.

So, this method of confirming a payment is taking far too long, and is currently not acceptable for my application. I need at most 10-20 seconds.

So, is there another way to get this information faster?

(I can't use third party api like blockchain)

  • 1
    DecodeRawTransaction(GetRawTransaction(transactionID)) is the same thing as GetRawTransaction(transactionID, 1). The 1 specifies to decode the result before returning it. That will eliminate 1 RPC call per TX in the mempool, but there are still better ways of doing this. – morsecoder Aug 4 '15 at 20:43
  • Why are you rerunning decoderawtransaction (or gettransaction, for that matter) on transactions you've already looked at? Can't you cache the result? – Nick ODell Aug 5 '15 at 1:22
  • do you propose to save each decoded transaction to db to and before decode new one check if it already exists in db?I think too many transactions, so too many db calls - don't think we can win in performance. – Alex Aug 5 '15 at 18:16
  • Can't to use GetRawTransaction(transactionID, 1) as get exception "There was a problem deserializing the response from the wallet". Actually I use github.com/GeorgeKimionis/BitcoinLib wrapper – Alex Aug 5 '15 at 21:15

If you can self-compile bitcoind/Bitcoin-Qt (or find someone who can compile it for you) you could use REST:

Or maybe have a look at the RPC call getrawmempool true (mind the true for verbose information).

| improve this answer | |

Since you use BitcoinLib you can do this:

        GetRawMemPoolResponse memPool = CoinService.GetRawMemPool(true);

        foreach (GetRawMemPoolVerboseResponse response in memPool.VerboseResponses)
            GetRawTransactionResponse rawTx = CoinService.GetRawTransaction(response.TxId, 1);
            // do something with the raw tx here
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.