Quick way to find transaction

1

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)

Alex

Posted 2015-08-04T19:01:42.397

Reputation: 163

1DecodeRawTransaction(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 2015-08-04T20:43:23.920

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 2015-08-05T01:22:55.613

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 2015-08-05T18:16:59.503

Can't to use GetRawTransaction(transactionID, 1) as get exception "There was a problem deserializing the response from the wallet". Actually I use https://github.com/GeorgeKimionis/BitcoinLib wrapper

Alex 2015-08-05T21:15:18.837

Answers

1

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).

Jonas Schnelli

Posted 2015-08-04T19:01:42.397

Reputation: 5 465

1

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
        }

George Kimionis

Posted 2015-08-04T19:01:42.397

Reputation: 2 824