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

What does script.revealed_tx refer to? #56

Closed
crypto-perry opened this issue Mar 2, 2018 · 2 comments
Closed

What does script.revealed_tx refer to? #56

crypto-perry opened this issue Mar 2, 2018 · 2 comments

Comments

@crypto-perry
Copy link

crypto-perry commented Mar 2, 2018

Hi, I am trying to run some blockchain analysis to count how many bitcoins are in unspent outputs secured by public keys that are revealed in some transaction.
I am currently using out.address.script.revealed_tx to identify the outputs which have addresses which are revealed somewhere else. Can you please help me out and let me know if I am on the right path?

Here is my code:

# bitcoins in unspent outputs with addresses revealed in some input
s = []
c = []
for i in range(len(chain)):
    add = 0
    count = 0
    for out in chain[i].outputs.unspent.all:
        try:
            out.address.script.revealed_tx
            count += 1
            add += out.value
        except Exception as e:
            pass
    s.append(add)
    c.append(count)
ss = np.cumsum(s)
cc = np.cumsum(c)
@hkalodner
Copy link
Collaborator

Hi @Dii14,

You're close. The only thing wrong is that out.address.script.revealed_tx returns None when the address has never been spent rather than throwing an Exception so you just want to use

if out.address.script.revealed_tx:
    count += 1
    add += out.value

Also btw you can use for block in chain to iterate over blocks

@crypto-perry
Copy link
Author

I tried that, but I got IndexOutOfBound Exception, so I assumed the field is just not created in the case the address was never spent from. How does this treat multi-sig scripts. What happens if only one of the public keys in a 2 of 3 multisig address is revealed in some input? Where are you populating this field? I tried to find it in the code :)

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

2 participants