Bitcoin Forum
November 18, 2024, 08:38:48 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum CLI - getting the fee and/or transaction size of a transaction  (Read 116 times)
NotATether (OP)
Legendary
*
Offline Offline

Activity: 1792
Merit: 7389


Top Crypto Casino


View Profile WWW
June 29, 2023, 05:42:03 AM
 #1

In the GUI, we see that Electrum tells us all the information about the fees our transactions have paid, and the total size of the transaction, total fees, and so on. Likely because we specify the fees ourselves.

But what about in the case of using the Electrum daemon/CLI to fetch any transaction? There doesn't seem to be a specific method for getting the fee info of a transaction, and gettransction just returns a raw transaction that doesn't contain transaction size (or vsize) and fee paid.

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Abdussamad
Legendary
*
Offline Offline

Activity: 3696
Merit: 1584



View Profile
June 29, 2023, 03:18:42 PM
 #2

Fee paid is total inputs minus total outputs. So you can calculate the fee yourself.
MusaMohamed
Sr. Member
****
Offline Offline

Activity: 1064
Merit: 348



View Profile
June 30, 2023, 03:00:57 AM
 #3

in a terminal it is
Code:
 > getrawtransaction txid

if you use the python console, you need to comply with the python syntax:

Code:
getrawtransaction("txid")  
  (with quotes)

In the gui you can also use the menu: Tools -> Load Transaction -> From the blockchain


Is it what you need

.
Duelbits
▄▄█▄▄░░▄▄█▄▄░░▄▄█▄▄
███░░░░███░░░░███
░░░░░░░░░░░░░
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░░░░███▄█░░░
░░██▌░░███░▀░░██▌
█░██░░███░░░██
█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀
.
REGIONAL
SPONSOR
███▀██▀███▀█▀▀▀▀██▀▀▀██
██░▀░██░█░███░▀██░███▄█
█▄███▄██▄████▄████▄▄▄██
██▀ ▀███▀▀░▀██▀▀▀██████
███▄███░▄▀██████▀█▀█▀▀█
████▀▀██▄▀█████▄█▀███▄█
███▄▄▄████████▄█▄▀█████
███▀▀▀████████████▄▀███
███▄░▄█▀▀▀██████▀▀▀▄███
███████▄██▄▌████▀▀█████
▀██▄█████▄█▄▄▄██▄████▀
▀▀██████████▄▄███▀▀
▀▀▀▀█▀▀▀▀
.
EUROPEAN
BETTING
PARTNER
NotATether (OP)
Legendary
*
Offline Offline

Activity: 1792
Merit: 7389


Top Crypto Casino


View Profile WWW
June 30, 2023, 04:21:02 AM
 #4

Fee paid is total inputs minus total outputs. So you can calculate the fee yourself.

Yes I can calculate the total fee but I would also like to calculate the fee rate in sats/vbyte, and to do this I must measure the size of the transaction in Weight Units or some other measurement, then divide the total fee by vsize.

Some python function that does it without additional libraries would be useful, alternatively just point to some place in bitcoinlib or something where transactions are deserialized and I can rip that part out.

in a terminal it is
Code:
 > getrawtransaction txid

if you use the python console, you need to comply with the python syntax:

Code:
getrawtransaction("txid")  
  (with quotes)

In the gui you can also use the menu: Tools -> Load Transaction -> From the blockchain


Is it what you need

Unfortunately, the raw transaction does not contain information about its fee.

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
nc50lc
Legendary
*
Offline Offline

Activity: 2604
Merit: 6424


Self-proclaimed Genius


View Profile
June 30, 2023, 08:04:52 AM
 #5

But what about in the case of using the Electrum daemon/CLI to fetch any transaction? There doesn't seem to be a specific method for getting the fee info of a transaction, and gettransction just returns a raw transaction that doesn't contain transaction size (or vsize) and fee paid.
Yes, I checked "commands.py" and nothing in it outputs the 'fee rate' or 'transaction size'.
Link: https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

deserialize also do not return with the transaction's fee rate, just the exact data in the raw transaction.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
bitmover
Legendary
*
Online Online

Activity: 2492
Merit: 6321


bitcoindata.science


View Profile WWW
June 30, 2023, 01:48:52 PM
 #6

But what about in the case of using the Electrum daemon/CLI to fetch any transaction? There doesn't seem to be a specific method for getting the fee info of a transaction, and gettransction just returns a raw transaction that doesn't contain transaction size (or vsize) and fee paid.
Yes, I checked "commands.py" and nothing in it outputs the 'fee rate' or 'transaction size'.
Link: https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

deserialize also do not return with the transaction's fee rate, just the exact data in the raw transaction.

I found this. Maybe it helps


https://github.com/spesmilo/electrum/blob/master/electrum/transaction.py
Code:
    def estimated_size(self):
        """Return an estimated virtual tx size in vbytes.
        BIP-0141 defines 'Virtual transaction size' to be weight/4 rounded up.
        This definition is only for humans, and has little meaning otherwise.
        If we wanted sub-byte precision, fee calculation should use transaction
        weights, but for simplicity we approximate that with (virtual_size)x4
        """
        weight = self.estimated_weight()
        return self.virtual_size_from_weight(weight)

NotATether (OP)
Legendary
*
Offline Offline

Activity: 1792
Merit: 7389


Top Crypto Casino


View Profile WWW
June 30, 2023, 02:05:18 PM
 #7

But what about in the case of using the Electrum daemon/CLI to fetch any transaction? There doesn't seem to be a specific method for getting the fee info of a transaction, and gettransction just returns a raw transaction that doesn't contain transaction size (or vsize) and fee paid.
Yes, I checked "commands.py" and nothing in it outputs the 'fee rate' or 'transaction size'.
Link: https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

deserialize also do not return with the transaction's fee rate, just the exact data in the raw transaction.

I found this. Maybe it helps


https://github.com/spesmilo/electrum/blob/master/electrum/transaction.py
Code:
    def estimated_size(self):
        """Return an estimated virtual tx size in vbytes.
        BIP-0141 defines 'Virtual transaction size' to be weight/4 rounded up.
        This definition is only for humans, and has little meaning otherwise.
        If we wanted sub-byte precision, fee calculation should use transaction
        weights, but for simplicity we approximate that with (virtual_size)x4
        """
        weight = self.estimated_weight()
        return self.virtual_size_from_weight(weight)

Oh, OK. So is this an Electrum command exposed to the user, or just a regular function?

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
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!