Bitcoin Forum
April 25, 2024, 04:56:18 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin RPC. Get sum of all fees in the mempool.  (Read 171 times)
kroonike (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
January 18, 2018, 04:21:10 PM
 #1

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("*")
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
1714020978
Hero Member
*
Offline Offline

Posts: 1714020978

View Profile Personal Message (Offline)

Ignore
1714020978
Reply with quote  #2

1714020978
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 21, 2018, 03:04:37 AM
Merited by ABCbits (1)
 #2

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.

btctousd81
Sr. Member
****
Offline Offline

Activity: 434
Merit: 270


View Profile WWW
January 21, 2018, 12:36:12 PM
Merited by ABCbits (1)
 #3

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.

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 22, 2018, 11:35:25 PM
 #4

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.

btctousd81
Sr. Member
****
Offline Offline

Activity: 434
Merit: 270


View Profile WWW
January 24, 2018, 07:24:47 AM
Last edit: January 24, 2018, 03:04:48 PM by btctousd81
 #5

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!