Bitcoin Forum
May 21, 2024, 04:41:37 PM *
News: Latest Bitcoin Core release: 27.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 90 times)
NotATether (OP)
Legendary
*
Online Online

Activity: 1610
Merit: 6752


bitcoincleanup.com / bitmixlist.org


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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Abdussamad
Legendary
*
Offline Offline

Activity: 3612
Merit: 1564



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: 910
Merit: 290



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

R


▀▀▀▀▀▀▀██████▄▄
████████████████
▀▀▀▀█████▀▀▀█████
████████▌███▐████
▄▄▄▄█████▄▄▄█████
████████████████
▄▄▄▄▄▄▄██████▀▀
LLBITCRYPTO
FUTURES
[
1,000x
LEVERAGE
][
.
COMPETITIVE
FEES
][
INSTANT
EXECUTION
]██████
██
██
██
██
██
██
██
██
██
██
██
██████
████████████████████████████████████████████████████████
.
TRADE NOW
.
████████████████████████████████████████████████████████
██████
██
██
██
██
██
██
██
██
██
██
██
██████
NotATether (OP)
Legendary
*
Online Online

Activity: 1610
Merit: 6752


bitcoincleanup.com / bitmixlist.org


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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
nc50lc
Legendary
*
Offline Offline

Activity: 2422
Merit: 5614


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
*
Offline Offline

Activity: 2310
Merit: 5957


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)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
NotATether (OP)
Legendary
*
Online Online

Activity: 1610
Merit: 6752


bitcoincleanup.com / bitmixlist.org


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?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!