Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

[GRIN-Wallet][Owner API] testing retrieve payment proof method #34

Closed marekyggdrasil closed 3 years ago

marekyggdrasil commented 3 years ago

Description Testing the retrieve payment proof method from the Owner API

Prerequisites

  1. GRIN-Node
  2. GRIN-Wallet
  3. A complete transaction that have been created with a payment proof.
  4. An incomplete transaction.

Test procedure

  1. Run GRIN-Wallet in Owner API listener mode
  2. Use node.js or python to run a encrypted request to retrieve payment proof method

Expected result:

Check if for completed transaction returns a single, exportable PaymentProof from a completed transaction within the wallet. For the incomplete transaction PaymentProof should not be returned. Check if returns an error if neither the tx_id or tx_slate_id argument are provided, or the function will return an error.

Provide requests and response full payloads as well as wallet and node logs.

mojitoo commented 3 years ago

Prerequisites:

Step 1 (Runs the wallet's local web API)

grin-wallet owner_api
Password: 
20201220 07:55:46.473 WARN grin_wallet_controller::controller - Starting HTTP Foreign API on Owner server at 127.0.0.1:3420.
20201220 07:55:46.473 WARN grin_wallet_controller::controller - Starting HTTP Owner API server at 127.0.0.1:3420.
20201220 07:55:46.473 WARN grin_wallet_controller::controller - HTTP Owner listener started

HTTP Owner successfully started.

retrieving payment proof for a completed transaction (tx_id=22)

Before runnning the script, we need to make sure to edit the configuration.

change to your grin owner_api sercret file

api_sercet_file = '/Users/path/.grin/main/.owner_api_secret'

change to you wallet password

wallet_password = 'xxx'

call this following function at the end of wallet_v3.py

pp.pprint(wallet.retrieve_payment_proof(tx_id=22))

pyhton3 wallet_v3.py
{   'amount': '0',
    'excess': '090807ba55bf1dad1b7e2c4a7c28299788553a384b28d459fb0b0e551e2d5197be',
    'recipient_address': 'grin1jdj2w0fh8haq9pfuvjmjrev5f4gs34n4n7fnsfmuwf7j09x4v9ws79nq8d',
    'recipient_sig': '19c298481cf59c67bcefeba6f20e441af28962c231809ddeaad73211a2a96d7770512c2fda82840bc920e0838c15e628f64f2b2c8711b1216f2e4d87f67fa200',
    'sender_address': 'grin12wktxlyfx62wx48ldn55katd8zm5d6qfa6mupt9r4uul8eqxagsqct3je5',
    'sender_sig': 'ec87438010d654bced2b83fd010be600f7f7bb62c345fc8dc148f01a817fe8d8d7db41ca776994c28478385e389d468e65a5f74d6cf89775510116faf62a120d'}

Test was valid. a completed transaction returns a single, exportable PaymentProof.

retrieving payment proof for an incompleted transaction (tx_id=25)

call this following function at the end of wallet_v3.py

pp.pprint(wallet.retrieve_payment_proof(tx_id=25))

pyhton3 wallet_v3.py
Traceback (most recent call last):
  File "/Users/workstation/Downloads/grin.py", line 462, in <module>
    pp.pprint(wallet.retrieve_payment_proof(tx_id=25)
  File "/Users/workstation/Downloads/grin.py", line 367, in retrieve_payment_proof
    resp = self.post_encrypted('retrieve_payment_proof', params)
  File "/Users/workstation/Downloads/grin.py", line 93, in post_encrypted
    raise WalletError(method, params, response_json["error"]["code"], response_json["error"]["message"])
__main__.WalletError: Callng retrieve_payment_proof with params {'token': '18a0e424eace8329af64a1ae22197c2afe689d08c4ce30f2122a1a56485213ea', 'refresh_from_node': True, 'tx_id': 25, 'tx_slate_id': None} failed with error code -32099 because: PaymentProofRetrieval: Proof does not contain receiver signature 

the function returns an error because no payment proof was retrieved for this incomplete transaction.

marekyggdrasil commented 3 years ago

@mojitoo I forgot to ask, can you please provide version of wallet that has the owner api listener on?

mojitoo commented 3 years ago