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

Additional data into RPC Client transaction input reply #208

Open
Sykh opened this issue Jan 13, 2022 · 2 comments
Open

Additional data into RPC Client transaction input reply #208

Sykh opened this issue Jan 13, 2022 · 2 comments

Comments

@Sykh
Copy link

Sykh commented Jan 13, 2022

When you ask the client for a block you get all the transactions, you then call get_transaction to get the inputs and outputs, the inputs don't have an amount tho, you have to look up the input transactions hashes aswell and parse their value - would it be possible to do this client side and just add an amount to inputs too?

That's from block 113:

[1]=>
    array(6) {
      ["txHash"]=>
      string(64) "50c98722129effd52e5ca689139a83031d1311b393c28317efff1e1654b2e252"
      ["fee"]=>
      int(0)
      ["type"]=>
      string(5) "spend"
      ["inputs"]=>
      array(1) {
        [0]=>
        array(10) {
          [0]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "b50fb1596c6341d3f97c7643458129901d142e173084bbbe2148ad3a9c0e1800"
          }
          [1]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "d72c5021a74f71b22a9d7bcd10c966701629ae9d7774e8cefeefdbfc877581ae"
          }
          [2]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "b43beb00f29ba48a698f510fa4d8928f9fd7d87ff1426671c9e6734102bd9010"
          }
          [3]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "d710705081216c4bcafc33494e080cba1d9beff398ae705e633cecb9ae2935a0"
          }
          [4]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "5620235195e1c5df8392356d4367e32b247c9f6579e3b702dfc13b45f7f79067"
          }
          [5]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "fed79ac22f0ca04ae0dba1ebce3c1a7fcea124aa0ede5b7746b3026356c7780c"
          }
          [6]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "9ebbf9b910c556d7b0adb60ed943fd50cb98634d1e33281285af0c2a27ec34e7"
          }
          [7]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "a53741f1df51b2e79f3c2a87e05ab88db95728a8c676bf732dca79f07c136cd6"
          }
          [8]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "c6fcae42bb62c944fbf019a82d1068d7fc178a9cce4bad824c1ad175b5fbe799"
          }
          [9]=>
          array(2) {
            ["fromAddress"]=>
            string(45) "snow:nl6f98t2mxefqaza2ehhc6np56c0s5dm56g9v6u8"
            ["txHash"]=>
            string(64) "5f66df893a5073f896fdc4590c159bc899dbb1b7b8a6d3b04de5b04e81836940"
          }
        }
      }
      ["outputs"]=>
      array(1) {
        [0]=>
        array(2) {
          ["toAddress"]=>
          string(45) "snow:wp00kfn4q4vjdavz4mavp0adqz8nxqhsltqkgxf7"
          ["amount"]=>
          string(9) "500000000"
        }
      }
      ["status"]=>
      array(3) {
        ["heightConfirmed"]=>
        int(113)
        ["confirmations"]=>
        int(334)
        ["confirmed"]=>
        bool(true)
      }
    }
@fireduck64
Copy link
Member

fireduck64 commented Jan 13, 2022

The trouble here is the TransactionInput doesn't always have that data. It can have that data, see:

message TransactionInput {
  bytes spec_hash = 1;
  bytes src_tx_id = 2;
  int32 src_tx_out_idx = 3;
  int64 value = 4; // SIP4 - Optional - if set (non-zero) transaction validation will enforce
                   // this value being accurate.
}

However, most things building transactions don't set that value. So it involves some db look ups to get the input values. It isn't impossible of course but it is slower.

@Sykh
Copy link
Author

Sykh commented Jan 14, 2022

Well either you have to do the db lookups or i have to do them via another rpc call or an internal db...i would prefer having the client doing it :D

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