near / near-cli

General purpose command line tools for interacting with NEAR Protocol
https://docs.near.org
MIT License
193 stars 91 forks source link

Sometimes Key Not Found #1021

Closed hanakannzashi closed 6 months ago

hanakannzashi commented 1 year ago

Describe the bug I do have keypair file in ~/.near-credentials/testnet, but sometimes near call does't work. It shows KeyNotFound. This often happens when I operate frequently. My cli version is 3.4.2

hanakannzashi commented 1 year ago

This also happen when using near-api-js

PierreLeGuen commented 1 year ago

Facing same issue. I do have the key pair in the near-credentials folder.

❯ near send not-this-account.testnet garbage-account.testnet 10
Sending 10 NEAR to garbage-account.testnet from not-this-account.testnet
An error occured
Error: Can not sign transactions for account not-this-account.testnet on network testnet, no matching key pair found in InMemorySigner(MergeKeyStore(UnencryptedFileSystemKeyStore(/Users/---/.near-credentials), UnencryptedFileSystemKeyStore(/Users/---/.near-credentials/testnet/neardev))).
    at Account.signTransaction (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:93:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:118:34
    at async Object.exponentialBackoff [as default] (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24)
    at async Account.signAndSendTransactionV2 (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:117:24)
    at async exports.sendMoney (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/index.js:263:20)
    at async Object.handler (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/utils/exit-on-error.js:52:9)
TypedError: Can not sign transactions for account not-this-account.testnet on network testnet, no matching key pair found in InMemorySigner(MergeKeyStore(UnencryptedFileSystemKeyStore(/Users/---/.near-credentials), UnencryptedFileSystemKeyStore(/Users/---/.near-credentials/testnet/neardev))).
    at Account.signTransaction (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:93:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:118:34
    at async Object.exponentialBackoff [as default] (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24)
    at async Account.signAndSendTransactionV2 (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:117:24)
    at async exports.sendMoney (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/index.js:263:20)
    at async Object.handler (/Users/---/.config/nvm/versions/node/v18.12.1/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) {
  type: 'KeyNotFound',
  context: undefined
}

Key pair present in folder:

~/.near-credentials/testnet
❯ ls | grep not-this   
not-this-account.testnet.json
gagdiez commented 6 months ago

A new version has been released, let us know if the error persists