Title: Bitcoin RPC. Get sum of all fees in the mempool. Post by: kroonike on January 18, 2018, 04:21:10 PM 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:%s@127.0.0.1:8332"%(rpc_user, rpc_password)) transactions = rpc_connection.listtransactions("*") Title: Re: Bitcoin RPC. Get sum of all fees in the mempool. Post by: achow101 on January 21, 2018, 03:04:37 AM 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.
Title: Re: Bitcoin RPC. Get sum of all fees in the mempool. Post by: btctousd81 on January 21, 2018, 12:36:12 PM 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. Title: Re: Bitcoin RPC. Get sum of all fees in the mempool. Post by: achow101 on January 22, 2018, 11:35:25 PM to get all fees , you need to get list of all trasnactins in mempool This would only work if OP has txindex enabled on his node.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. Title: Re: Bitcoin RPC. Get sum of all fees in the mempool. Post by: btctousd81 on January 24, 2018, 07:24:47 AM to get all fees , you need to get list of all trasnactins in mempool This would only work if OP has txindex enabled on his node.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. 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. |