Author

Topic: Bitcoin RPC. Get sum of all fees in the mempool. (Read 201 times)

sr. member
Activity: 434
Merit: 270
to get all fees , you need to get list of all trasnactins in mempool

getrawmempool will give you all transactions "txid" in mempool.

then you need to run

getrawtransaction "txid" 1

it will give you detailed transaction in json.

from that you can get

"vin"

"vout"

fees = vin - vout

do this for all transactions and you will get fees of all transactions in mempool.

hope this helps.
This would only work if OP has txindex enabled on his node.

no, txindex is required only if op wants to query old tx which are in block, but he only wants to query which are in mempool.,

so imho txindex is not required just to query tx in mempool.


Quote
By default -txindex=0 Bitcoin Core doesn't maintain any transaction-level data except for those

in the mempool or relay set
pertinent to addresses in your wallet
pertinent to your "watch-only" addresses


ref:  https://bitcoin.stackexchange.com/a/37979/10603

or maybe i am missing something.,
sorry for my bad english.
staff
Activity: 3458
Merit: 6793
Just writing some code
to get all fees , you need to get list of all trasnactins in mempool

getrawmempool will give you all transactions "txid" in mempool.

then you need to run

getrawtransaction "txid" 1

it will give you detailed transaction in json.

from that you can get

"vin"

"vout"

fees = vin - vout

do this for all transactions and you will get fees of all transactions in mempool.

hope this helps.
This would only work if OP has txindex enabled on his node.
sr. member
Activity: 434
Merit: 270
to get all fees , you need to get list of all trasnactins in mempool

getrawmempool will give you all transactions "txid" in mempool.

then you need to run

getrawtransaction "txid" 1

it will give you detailed transaction in json.

from that you can get

"vin"

"vout"

fees = vin - vout

do this for all transactions and you will get fees of all transactions in mempool.

hope this helps.
staff
Activity: 3458
Merit: 6793
Just writing some code
listtransactions is a wallet RPC, it will only give you information about the transactions in your wallet, not the mempool or anything else. The RPC call that you actually want is getrawmempool with the verbose parameter set to true.
newbie
Activity: 19
Merit: 0
I'm trying to get a number of total fees in the bitcoin mempool (live, in BTC) using python.

I was able to connect bitcoinrpc, but stil struggle with commands and a proper way of acquiring the number. One way of doing this would be to get information on all unconfirmed transactions in the bitcoin mempool and sum their fees, however running the code below returns me an empty list.


from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

rpc_user = 'xxx'
rpc_password = 'xxx'
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332"%(rpc_user, rpc_password))

transactions = rpc_connection.listtransactions("*")
Jump to: