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

GraphQL wallet query privateKeyPath #3288

Open
garethtdavies opened this issue Aug 24, 2019 · 2 comments

Comments

@garethtdavies
Copy link
Contributor

commented Aug 24, 2019

When choosing a random private key from the week 4 challenge and running

query {
  wallet(publicKey: "tNciS3X51gg7BNCLwEd4K3LhN9BUQGbU34VHWznrLkaz2uQhQhScztzKvMuH9dhX5MX6PU9Grav4HsRtWKxjEBWq81PESgzGpxDcNQg5Kk6kij4TMbuZAnrgJtYrjkp2ExDKVtR4VrRWLW") {
    publicKey
    balance {
      total
      unknown
    }
    nonce
    receiptChainHash
    delegate
    votingFor
    stakingActive
    privateKeyPath
  }
}

I am returned the following:

{
    "data": {
        "wallet": {
            "publicKey": "tNciS3X51gg7BNCLwEd4K3LhN9BUQGbU34VHWznrLkaz2uQhQhScztzKvMuH9dhX5MX6PU9Grav4HsRtWKxjEBWq81PESgzGpxDcNQg5Kk6kij4TMbuZAnrgJtYrjkp2ExDKVtR4VrRWLW",
            "balance": {
                "total": "20004",
                "unknown": "20004"
            },
            "nonce": "0",
            "receiptChainHash": "A3gpHsZt6P846GPi9upHrFKVAcWENCBDMFLyKwfdXwFwoftdQsXerRhUQKUDNWPzN9skCQyscU4KEZ5qNYUsSjc4wjSaR8ae2cJ6Rf7ykm6ovTD3QLNZoGsCvFYpUrbx8KXmCXnXRERhm",
            "delegate": "tNciS3X51gg7BNCLwEd4K3LhN9BUQGbU34VHWznrLkaz2uQhQhScztzKvMuH9dhX5MX6PU9Grav4HsRtWKxjEBWq81PESgzGpxDcNQg5Kk6kij4TMbuZAnrgJtYrjkp2ExDKVtR4VrRWLW",
            "votingFor": "4ApWCRdGaeF7QXhHYr4EPqxN2Cp7xdcsCmGbtbYSa9L97B2wimh1goXeWX9kD4tDvF3o5x24gTXx3iqATtHFPwF5zYaHpGfnMNf7dJqXfHwAXHLYRUbdwZxoshhWQXHRGadF1e2MFDYYb",
            "stakingActive": false,
            "privateKeyPath": "/home/gareth/.coda-config/wallets/store/tNciS3X51gg7BNCLwEd4K3LhN9BUQGbU34VHWznrLkaz2uQhQhScztzKvMuH9dhX5MX6PU9Grav4HsRtWKxjEBWq81PESgzGpxDcNQg5Kk6kij4TMbuZAnrgJtYrjkp2ExDKVtR4VrRWLW"
        }
    }
}

As I don't possess the private key the fact the privateKeyPath has a file path is somewhat unexpected. Should this not be conditional on whether the private key is known to the daemon or an isKnowntoDaemon (insert a better name) helper method that returns a boolean?

@garethtdavies

This comment has been minimized.

Copy link
Contributor Author

commented Aug 26, 2019

I also noticed stakingActive is local to the daemon i.e. that public key is staking but not from this daemon.

@Schmavery

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2019

Oh thats funny. I guess we construct the path that the file would be regardless of whether it actually exists on disk at that location:

; path= Secrets.Wallets.get_path (Coda_lib.wallets coda) pk } )

let get_path {path; _} public_key =
let pubkey_str =
(* TODO: Do we need to version this? *)
Public_key.Compressed.to_base58_check public_key
|> String.tr ~target:'/' ~replacement:'x'
in
path ^/ pubkey_str

For the stakingActive, we might not be able to work around that (not sure that we can reliably detect that a remote daemon is staking) but maybe a name change would help there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.