Subject: [bitcoindev] A Fool's Errand or should I try?

From: Fractal Encrypt <[email-masked]>
Date: Sat, 4 May 2024 08:00:07 -0700 (PDT)

TLDR: I'd like to investigate the possibilities of extending 
decoderawtransaction to include the fee (and maybe even sats per v/b).

I'm hoping it will be a good project for me to work on and build at least a 
tiny understanding of bitcoin development.

------------------------------------------------------------------------

I use the createrawtransaction function to create transactions, and before 
broadcasting, I always like to use decoderawtransaction to see if I made 
any mistakes.

I've sometimes messed up on the fee calculation, as I do that myself with a 
calculator.

Unfortunately decoderawtransaction doesn't give me the fee information (for 
a very good reason, it is not aware of the value of the inputs in the tx).

So to double check the fees, instead of using createrawtransaction, I'll 
use createpsbt and then go through the process of finalizing it so I can 
run decodepsbt, which does give the fee along with all the other relevant 
data.

But the createpsbt process is more work for a simple transaction where all 
UTXOs are in the wallet I am creating the rawtx in.

My goal would be to modify decoderawtransaction to perform these additional 
steps:
   
   1. Fetch UTXO details for each input.
   2. Calculate the total input value.
   3. Subtract the total output value to determine the fee.

Additionally there are the considerations about whether the inputs in the 
transaction are in your wallet or not. 

If I run listunspent it gives me the info I need to create the raw tx or 
psbt, and it has the values of the UTXOs that will be used as inputs in my 
tx.

But I understand decoderawtransaction is meant to be used whether or not 
the keys are in your wallet (so I was thinking to make a command argument 
T/F to show the fee value only if keys are in your wallet).

Alternatively if you are running the command in a node with txindex, then 
you have the full chainstate to look up txids (whether unspent or not) - so 
this needs to be addressed too.

Doing this within my own node would be cool enough and I don't necessarily 
need it to go farther than that. However if I do get it working, I'd 
certainly try to submit a PR.

I have no idea if any of this is possible, so I wanted to ask here for some 
guidance and maybe mentorship in this self-interest driven project. Also 
looking for this to be shot down mercilessly if it's just ridiculous.

My abilities and skills are very low. My interest and persistence are high.

Any help or ridicule invited ;)

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/75628135-32ae-4df3-be52-9f7d054bc096n%40googlegroups.com.