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

Feature: Enable whitepaper option in Spectrum #32

Open
moneymanolis opened this issue Jan 16, 2023 · 5 comments · May be fixed by #39
Open

Feature: Enable whitepaper option in Spectrum #32

moneymanolis opened this issue Jan 16, 2023 · 5 comments · May be fixed by #39

Comments

@moneymanolis
Copy link
Collaborator

Implementing the getrawtransaction method in Spectrum should make it possible to retrieve the whitepaper from the timechain with Spectrum.

getrawtransaction is already implemented in the ElectrumX API:
https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-transaction-get

@k9ert
Copy link
Contributor

k9ert commented Jan 23, 2023

Seems like #36 was not good enough. @PaarthAgarwal can you have a look?!

In the case of the whitepaper, it's called like this:

            raw_tx = app.specter.rpc.getrawtransaction(
                "54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713",
                False,
                "00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949",
            )

Which creates this stacktrace:

Traceback (most recent call last):
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/server_endpoints/welcome/welcome.py", line 101, in get_whitepaper
    raw_tx = app.specter.rpc.getrawtransaction(
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/rpc.py", line 495, in fn
    r = self.multi([(method, *args)], **kwargs)[0]
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specterext/spectrum/bridge_rpc.py", line 96, in multi
    result = [
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specterext/spectrum/bridge_rpc.py", line 97, in <listcomp>
    self.spectrum.jsonrpc(
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 386, in jsonrpc
    raise e
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 376, in jsonrpc
    res = m(*args, **kwargs)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 53, in wrapper
    return f(*args, **kwargs)
TypeError: Spectrum.getrawtransaction() takes from 2 to 3 positional arguments but 4 were given

@PaarthAgarwal
Copy link
Contributor

PaarthAgarwal commented Jan 24, 2023

Seems like #36 was not good enough. @PaarthAgarwal can you have a look?!

In the case of the whitepaper, it's called like this:

            raw_tx = app.specter.rpc.getrawtransaction(
                "54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713",
                False,
                "00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949",
            )

Which creates this stacktrace:

Traceback (most recent call last):
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/server_endpoints/welcome/welcome.py", line 101, in get_whitepaper
    raw_tx = app.specter.rpc.getrawtransaction(
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specter/rpc.py", line 495, in fn
    r = self.multi([(method, *args)], **kwargs)[0]
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specterext/spectrum/bridge_rpc.py", line 96, in multi
    result = [
  File "/home/kim/src/specter-desktop/src/cryptoadvance/specterext/spectrum/bridge_rpc.py", line 97, in <listcomp>
    self.spectrum.jsonrpc(
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 386, in jsonrpc
    raise e
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 376, in jsonrpc
    res = m(*args, **kwargs)
  File "/home/kim/src/specter-desktop/.env/lib/python3.10/site-packages/cryptoadvance/spectrum/spectrum.py", line 53, in wrapper
    return f(*args, **kwargs)
TypeError: Spectrum.getrawtransaction() takes from 2 to 3 positional arguments but 4 were given

Did some research. I don't know how to test but adding a 4th parameter hex string here might do the trick.

def getrawtransaction(self, txid, verbose=False):

@moneymanolis
Copy link
Collaborator Author

To clarify a bit and give some background: @PaarthAgarwal
In Specter using Bitcoin Core getrawtransaction is called exactly like it is specified here:
https://developer.bitcoin.org/reference/rpc/getrawtransaction.html?highlight=getrawtransaction

00000000000000ecbbff6bafb7efa2f7df05b227d5c73dca8f2635af32a2e949 is the blockhash where the tx with the whitepaper data can be found. This is an optional argument but it speeds up the feature. So I would just add this.

@moneymanolis
Copy link
Collaborator Author

You can test this in the end pretty easily, connect via Spectrum to one of the main chain provider (emzy or Blockstream server).

@PaarthAgarwal
Copy link
Contributor

Thanks for the clarification @moneymanolis. I appreciate that. Will open a PR soon with the fix.
Also, I'm glad to share I just now cleared the screening round of the Summer of Bitcoin!🎉🎉

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

Successfully merging a pull request may close this issue.

3 participants