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

Empty wallet created when querying transactions on v1 #1949

Closed
alexbarnsley opened this issue Jan 6, 2019 · 8 comments
Closed

Empty wallet created when querying transactions on v1 #1949

alexbarnsley opened this issue Jan 6, 2019 · 8 comments

Comments

@alexbarnsley
Copy link
Member

alexbarnsley commented Jan 6, 2019

Describe the bug
When querying the v1 /api/transactions endpoint, it creates an empty wallet. I have not tested on v2 endpoints

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://dexplorer.ark.io:8443/api/accounts?address=<COLD_WALLET_ADDRESS> - it will return "Account not found"
  2. Go to https://dexplorer.ark.io:8443/api/transactions?recipientId=<COLD_WALLET_ADDRESS>&senderId=<COLD_WALLET_ADDRESS>&orderBy=timestamp:desc&offset=0&limit=50
  3. Go back to https://dexplorer.ark.io:8443/api/accounts?address=<COLD_WALLET_ADDRESS> - it will return a cold wallet object response (see below)
{
  "account": {
    "address": "DLWeBuwSBFYtUFj8kFB8CFswfvN2ht3yKn",
    "publicKey": null,
    "secondPublicKey": null,
    "username": null,
    "balance": "0",
    "unconfirmedBalance": "0",
    "multisignatures": [
      
    ],
    "u_multisignatures": [
      
    ],
    "unconfirmedSignature": 0,
    "secondSignature": 0
  },
  "success": true
}

Expected behavior
The wallet should return "Account not found" still

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 6, 2019

boiled it down to senderId, as running the above queries without it doesn't seem to respond with the template model

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 6, 2019

this.database.manager.findByAddress() might be caching upon conversion from senderId to senderPublicKey

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 6, 2019

    public findByAddress(address) {
        if (!this.byAddress[address]) {
            this.byAddress[address] = new Wallet(address);
        }

        return this.byAddress[address];
    }

Then on subsequent round would not create a new wallet, but return the newly created wallet?

Btw, this is definitely cached behaviour as I tried with the address you provided and is was not found

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 6, 2019

after running the second command but only with senderId, the third command indeed returns a

{
  "account": {
    "address": "DLWeBuwSBFYtUFj8kFB8CFswfvN2ht3yKn",
    "publicKey": null,
    "secondPublicKey": null,
    "username": null,
    "balance": "0",
    "unconfirmedBalance": "0",
    "multisignatures": [],
    "u_multisignatures": [],
    "unconfirmedSignature": 0,
    "secondSignature": 0
  },
  "success": true
}

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 6, 2019

So, from what I can tell: querying legacy with senderId triggers the creation of a Wallet object in this.byAddress of core-database/wallet-manager set to a default. Then, a query to accounts?address=COLD will database.wallets.findById() it and return the empty object, but not before transforming it to fit the v1 spec.

I could be miles off in any of these statements, this is some preliminary detective work for the team.

@tpscrpt
Copy link
Contributor

tpscrpt commented Jan 7, 2019

I will not be fixing this today.

tpscrpt added a commit to tpscrpt/core that referenced this issue Jan 8, 2019
 - When querying for /accounts?address, return error if account.publicKey === null (cold wallet)
 - Add test to check for bug

Ref: ArkEcosystem#1949
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

3 participants