vocdoni / vocdoni-node

A set of libraries and tools for the Vocdoni decentralized backend infrastructure, the main ground of our universally verifiable, privacy-centric and scalable digital voting protocol
GNU Affero General Public License v3.0
85 stars 16 forks source link

API: transactions return the account #1370

Closed p4u closed 1 week ago

p4u commented 2 weeks ago

The information returned by the transactions endpoint to get the details of a transaction, the API backend should add a new field "account" which points to the address signing the transaction.

Currently, we do return the signature, so we can extract the address.

Example with: https://api.vocdoni.io/v2/chain/transactions/2414592/0

{
  "tx": {
    "collectFaucet": {
      "txType": "TX_UNKNOWN",
      "faucetPackage": {
        "payload": "CIeH3RkSFA09aBdi+e2pVB+ras+xfFACW2MLGGQ=",
        "signature": "0j0vNTSzJo7NBxDIt++asacf7bW15s6KtzOzHMd8E1M0IIBMVHBUg0AMdMPZhTMevSN2J7wN6gcYDI5TfvsogAE="
      },
      "nonce": 16
    }
  },
  "txInfo": {
    "transactionNumber": 33680,
    "transactionHash": "76057f3845cf9e34e3cc35c5c08d598b61f11d46d4845706bb67f7b3d2612444",
    "blockHeight": 2414592,
    "transactionIndex": 0,
    "transactionType": "collectFaucet"
  },
  "signature": "82bdce114c0399a051d69b9ada79d0ab63d2540bc90025b3fe09cc6d73a3ce4752f00f7e46c01d089327818d4ebf1fb96c692897fe50a7ded9525048c9c021fc1b",
  "account": "0x123456789..."
}

This way, the explorer (@selankon), on each transaction, can show and link the account creating it.

Consider that some transactions (vote) won't have this information.

altergui commented 2 weeks ago

what about naming the new field "signer" instead of "account"? it feels less generic, and with a clear relationship to "signature" above

altergui commented 2 weeks ago
 $ curl -s "http://localhost:9090/v2/chain/transactions/680/0" | jq
{
  "tx": {
    "vote": {
      "nonce": "KHl8qFtyysTnKTp5iSEq+NssO+zBZQDR2ZmaOPsAkO8=",
      "processId": "ZMG4BptbgrvvqBgS2TbztwaQQJ2zYB56NokCAgAAAAA=",
      "proof": {
        "zkSnark": {
          "circuitParametersIndex": 0,
...
      "votePackage": "eyJ2b3RlcyI6WzBdfQ==",
      "nullifier": "HoRsTiFdVaswwacpaNQ8tnjNhDYUp8qAbXDbwFlKVF4=",
      "encryptionKeyIndexes": []
    }
  },
  "txInfo": {
    "transactionNumber": 40,
    "transactionHash": "7d62251ef596ad3dedbd86c6d2efd6c7adbed7d925f54226ff41acf1a90a0146",
    "blockHeight": 680,
    "transactionIndex": 0,
    "transactionType": "vote",
    "transactionSubtype": ""
  },
  "signature": "",
  "account": "0000000000000000000000000000000000000000"
}

how should we best handle the votes? both signature and account (or "signer") as present but empty fields, right? (i'll fix that 000000...)