Skip to content

Feature: Enable whitepaper option in Spectrum #32

Open

Description

@moneymanolis

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

Activity

  1. k9ert commented on Jan 23, 2023

    @k9ert
    Contributor

    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
    
  2. PaarthAgarwal commented on Jan 24, 2023

    @PaarthAgarwal
    Contributor

    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):

  3. moneymanolis commented on Jan 24, 2023

    @moneymanolis
    CollaboratorAuthor

    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.

  4. moneymanolis commented on Jan 24, 2023

    @moneymanolis
    CollaboratorAuthor

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

  5. PaarthAgarwal commented on Jan 24, 2023

    @PaarthAgarwal
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions