New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type data to TxOut #2609
Comments
There are methods on |
@apoelstra thanks, that would make things simpler. It looks like |
If we add additional fields to |
We would also likely want to populate those fields on construction and deserialization, which could be a perf cost that all users would need to pay regardless of whether they cared about this new data. |
Instead of a new field then, maybe just a net new method on TxOut or Script which shouldn't be a breaking change. That method would examine Script to determine the type and then either return Weight or InputWeightPrediction for the predicated weight of the corresponding TxIn (The TxIn that consumes this TxOut)? |
Or a free function that takes TxOut as an argument and returns the predicted weight of the corresponding TxIn perhaps.. |
Actually, a free function that takes Script as an argument and returns the predicated weight of spending/redeeming the script would be great. Maybe I'll try to hack something like that together I guess since it doesn't exists AFAIK |
s/exists/exist |
We could create a non-exhaustive enum that covers all the output template types that we support. But several give us no useful input weight prediction (notably p2sh and p2tr). I'm not entirely opposed to it, but it's overlapping with miniscript functionality. |
You can create an Address from Txout via Address::from_script and then get the AddressType . Somewhat indirect, but works. |
Oh, lol, if we already have that enum we ought to stick a method onto cc @TomBriar who was also asking for something like this recently |
Thanks @sanket1729 , although rust-bitcoin predict_weight doesn't seem to glue together very well currently with the type returned from AddressType AFAICT.
@apoelstra using mini script sounds good, I forgot there was the |
You can parse a bitcoin script to We have something similar in the But intuitively yes, we should have a method that does this. Even if it sometimes fails if it's missing information. |
Hmm ok. I'm reading through |
If you don't have enough information to create a descriptor, you don't have enough information to infer the satisfaction weight. |
Is it possible to add a type field to
TxOut
which describes the type of output(P2WPKH, P2PKH..
? That way, we can know the predicted weight if the TxOut is used in a new transaction as TxIn by usingInputWeightPrediction
.InputWeightPrediction
can't be used if the type isn't known AFAIK. Is this not implemented because it's not possible for some reason or breaks some design pattern? I know there are other things more pressing things rn but mostly just inquiring if this is a possibility in a future revision?The text was updated successfully, but these errors were encountered: