Skip to content

Instantly share code, notes, and snippets.

@phyro

phyro/spent.md Secret

Created January 31, 2021 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phyro/c5be06c144defdbfdf3dc511a08d77d9 to your computer and use it in GitHub Desktop.
Save phyro/c5be06c144defdbfdf3dc511a08d77d9 to your computer and use it in GitHub Desktop.
spent outputs

requires beautiful soup parser python3 -m pip install beautifulsoup4.

from urllib.request import urlopen
from bs4 import BeautifulSoup
import time

spent_set = set()
unspent_set = set()


def find_outputs(class_name, soup):
    # class name is either spent_list or unspent_list
    parents = map(lambda x: x.parent, soup.find_all("td", class_name))
    return set(
        parent.find_all("td")[-1].a.contents[0]
        for parent in parents
    )

for height in range(1070549-1000, 1070549-900):
    with urlopen("https://grinscan.net/block/{}".format(str(height))) as conn:
        html_str = conn.read().decode("utf-8")
        soup = BeautifulSoup(html_str)
        spent_outputs = find_outputs("spent_list", soup)
        unspent_outputs = find_outputs("unspent_list", soup)
        spent_set |= spent_outputs
        unspent_set |= unspent_outputs
        print("height: {}, created: {}, spent: {}".format(height, len(spent_outputs) + len(unspent_outputs), len(spent_outputs)))
        time.sleep(0.3)

print("In this block range {} outputs were created out of which {} were spent".format(
    len(spent_set) + len(unspent_set), len(spent_set)
))

Running this outputs for each height the number of created and how many of these were spent and at the end we get:

In this block range 188 outputs were created out of which 44 were spent

If we subtract 100 coinbase outputs which were impossible to spend and don't send to the coinswap, then we get 88 created and 44 spent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment