public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* [bitcoindev] A Fool's Errand or should I try?
@ 2024-05-04 15:00 Fractal Encrypt
  2024-05-05 11:55 ` [bitcoindev] " Ali Sherief
  2024-05-06  8:09 ` [bitcoindev] " bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
  0 siblings, 2 replies; 6+ messages in thread
From: Fractal Encrypt @ 2024-05-04 15:00 UTC (permalink / raw)
  To: Bitcoin Development Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 2888 bytes --]

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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/75628135-32ae-4df3-be52-9f7d054bc096n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3554 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bitcoindev] Re: A Fool's Errand or should I try?
  2024-05-04 15:00 [bitcoindev] A Fool's Errand or should I try? Fractal Encrypt
@ 2024-05-05 11:55 ` Ali Sherief
  2024-05-05 15:03   ` Fractal Encrypt
  2024-05-06  8:09 ` [bitcoindev] " bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
  1 sibling, 1 reply; 6+ messages in thread
From: Ali Sherief @ 2024-05-05 11:55 UTC (permalink / raw)
  To: Bitcoin Development Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 3967 bytes --]

Currently the only way you can fetch the previous input addresses and 
amounts is if you use the getblock RPC call with a verbosity of 3. This 
will obviously cause it to print a lot of raw transactions. But since 
decoderawtrasnsaction is independent of the blocks that are actually stored 
on your disk, you'd have to modify it to locate each input inside the 
blocks.dat folder, and then assemble an equivalent "prevout" structure as 
in getblock.

There is also the issue of the txo not actually existing in the blockchain, 
which means that such a prevout structure would not exist in the first 
place.

I think it would be better to create a separate RPC for this, maybe 
'getfulltransaction' or something like that since gettransaction for 
in-walet txs already exists, to implement such functionality.

-Ali

On Saturday, May 4, 2024 at 3:40:24 PM UTC Fractal Encrypt wrote:

> 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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/91d3be30-a672-4407-8d11-902df8ff4f54n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4739 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bitcoindev] Re: A Fool's Errand or should I try?
  2024-05-05 11:55 ` [bitcoindev] " Ali Sherief
@ 2024-05-05 15:03   ` Fractal Encrypt
  0 siblings, 0 replies; 6+ messages in thread
From: Fractal Encrypt @ 2024-05-05 15:03 UTC (permalink / raw)
  To: Bitcoin Development Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 4227 bytes --]

Thanks Ali, I will investigate these avenues you've pointed out. Most 
appreciated! 

On Sunday, May 5, 2024 at 9:30:48 AM UTC-4 Ali Sherief wrote:

> Currently the only way you can fetch the previous input addresses and 
> amounts is if you use the getblock RPC call with a verbosity of 3. This 
> will obviously cause it to print a lot of raw transactions. But since 
> decoderawtrasnsaction is independent of the blocks that are actually stored 
> on your disk, you'd have to modify it to locate each input inside the 
> blocks.dat folder, and then assemble an equivalent "prevout" structure as 
> in getblock.
>
> There is also the issue of the txo not actually existing in the 
> blockchain, which means that such a prevout structure would not exist in 
> the first place.
>
> I think it would be better to create a separate RPC for this, maybe 
> 'getfulltransaction' or something like that since gettransaction for 
> in-walet txs already exists, to implement such functionality.
>
> -Ali
>
> On Saturday, May 4, 2024 at 3:40:24 PM UTC Fractal Encrypt wrote:
>
>> 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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/74ae96f5-4ea4-4afa-8321-e09e4ad9f97an%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 5113 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bitcoindev] A Fool's Errand or should I try?
  2024-05-04 15:00 [bitcoindev] A Fool's Errand or should I try? Fractal Encrypt
  2024-05-05 11:55 ` [bitcoindev] " Ali Sherief
@ 2024-05-06  8:09 ` bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
  2024-05-06 23:51   ` Fractal Encrypt
  1 sibling, 1 reply; 6+ messages in thread
From: bitcoin-dev-ml.void867 via Bitcoin Development Mailing List @ 2024-05-06  8:09 UTC (permalink / raw)
  Cc: bitcoindev

Are you aware of getrawtransaction verbosity=2? Refer to
https://bitcoincore.org/en/doc/27.0.0/rpc/rawtransactions/getrawtransaction/
for the RPC documentation.

-- 
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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/171498296705.6.12161480431860578333.324011415%40slmail.me.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bitcoindev] A Fool's Errand or should I try?
  2024-05-06  8:09 ` [bitcoindev] " bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
@ 2024-05-06 23:51   ` Fractal Encrypt
  2024-05-07  5:15     ` bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
  0 siblings, 1 reply; 6+ messages in thread
From: Fractal Encrypt @ 2024-05-06 23:51 UTC (permalink / raw)
  To: Bitcoin Development Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 1047 bytes --]

I am/was not until now) aware of getrawtransaction verbosity=2.

It appears to be for transactions already in the mempool or confirmed in a 
block. Can it also be used prior to broadcasting a transaction?

I saw the documentation referenced gettransaction but that doesn't seem to 
fit either.

But it's also possible I am totally missing what you are trying to point 
out to me...

On Monday, May 6, 2024 at 5:47:42 AM UTC-4 bitcoin-dev...@slmail.me wrote:

> Are you aware of getrawtransaction verbosity=2? Refer to
>
> https://bitcoincore.org/en/doc/27.0.0/rpc/rawtransactions/getrawtransaction/
> for the RPC documentation.
>
>

-- 
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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/b3f3974f-435c-494e-ba8b-11b42aa21443n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1986 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bitcoindev] A Fool's Errand or should I try?
  2024-05-06 23:51   ` Fractal Encrypt
@ 2024-05-07  5:15     ` bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
  0 siblings, 0 replies; 6+ messages in thread
From: bitcoin-dev-ml.void867 via Bitcoin Development Mailing List @ 2024-05-07  5:15 UTC (permalink / raw)
  Cc: Bitcoin Development Mailing List

> It appears to be for transactions already in the mempool or confirmed in a block. Can it also be used prior to broadcasting a transaction?

To get the fee of a transaction prior to broadcast, you can use
testmempoolaccept. The documentation is at
https://bitcoincore.org/en/doc/27.0.0/rpc/rawtransactions/testmempoolaccept/

Best,
void867

-- 
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 bitcoindev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/171505893035.7.9557558533992806783.324768558%40slmail.me.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-07  8:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-04 15:00 [bitcoindev] A Fool's Errand or should I try? Fractal Encrypt
2024-05-05 11:55 ` [bitcoindev] " Ali Sherief
2024-05-05 15:03   ` Fractal Encrypt
2024-05-06  8:09 ` [bitcoindev] " bitcoin-dev-ml.void867 via Bitcoin Development Mailing List
2024-05-06 23:51   ` Fractal Encrypt
2024-05-07  5:15     ` bitcoin-dev-ml.void867 via Bitcoin Development Mailing List

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox