Skip to content
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

Provide a simple way to get the sighash_type for any input in a transaction. #690

Open
iota9star opened this issue May 23, 2024 · 7 comments

Comments

@iota9star
Copy link

Related to issue rust-bitcoin/rust-bitcoin#2788

@apoelstra
Copy link
Member

cc @sanket1729 I think the crux of this issue is that the interpreter API should be better documented?

"List the sighash types used in the transaction" actually seems like a nice example program to add to the docs.

@apoelstra
Copy link
Member

BTW @iota9star can you say more about what you're trying to do here? If you need this information when constructing a transaction, you would be better off extracting it from a PSBT, which is a data structure designed to make such information easily accessible during construction.

If you need this information for an already-complete transaction, that's where the interpreter API comes in. But as far as I'm aware, the only real use for the interpreter API has been debugging Miniscript itself.

@iota9star
Copy link
Author

@apoelstra I want to implement an indexer to analyze on-chain confirmed transactions to determine if they are buy/sell transactions. My idea is to use sighash_type and other conditions to identify such transactions. Do you think this is the correct approach?

@apoelstra
Copy link
Member

If you define "buy" and "sell" purely in terms of sighashes, then sure, it's the right approach. But if you expect these to correspond to some economic reality, then no, you cannot determine this in general since there are many ways that people can do atomic trades on-chain or across chains. And even the sighash-based ways may be "erased" if both parties construct an explicit on-chain transaction then decide instead to publish a 2-of-2 MuSig transaction which cannot be distinguished from any other transaction. (And of course, most trades happen on centralized exchanges with no blockchain footprint.)

This certainly sounds like interesting data in its own right. But if you're hoping to learn something about the Bitcoin markets, I'm doubtful that you'll get much.

Anyway, this is exactly the sort of "blockchain forensics" task that the interpreter API should be good for, and we should document it to help with this usecase.

@iota9star
Copy link
Author

@apoelstra For most on-chain exchanges, the majority of transactions are constructed using single + anyonecanpay. This is sufficient for my purposes. Additionally, I will index other types of data, such as transactions related to the Runes protocol or other protocol transfers and mints.

@iota9star
Copy link
Author

@apoelstra I don't know how to use the interpreter API. Can you provide more information to help me? 🙈

@sanket1729
Copy link
Member

@iota9star, here is an example iterating through all the satisfied signatures in the transactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants