Author

Topic: Electrum CLI - getting the fee and/or transaction size of a transaction (Read 123 times)

legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
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?
legendary
Activity: 2352
Merit: 6089
bitcoindata.science
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)
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
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.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
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.
sr. member
Activity: 966
Merit: 306
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
legendary
Activity: 3710
Merit: 1586
Fee paid is total inputs minus total outputs. So you can calculate the fee yourself.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
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.
Jump to: