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

JSON RPC function to add address from private key #502

Open
2 tasks done
rraallvv opened this issue Jun 8, 2019 · 0 comments
Open
2 tasks done

JSON RPC function to add address from private key #502

rraallvv opened this issue Jun 8, 2019 · 0 comments

Comments

@rraallvv
Copy link

rraallvv commented Jun 8, 2019

New issue checklist

Question or Feature Request

Function to add an address to the wallet using the JSON RPC API from the private key. The function could be like this:

    async addAccount(hex) {
        const entropy = new Nimiq.Entropy(Nimiq.BufferUtils.fromBase64(hex));
        const privateKey = new Nimiq.PrivateKey(entropy.serialize());
        const keyPair = Nimiq.KeyPair.derive(privateKey);
        const wallet = new Nimiq.Wallet(keyPair);
        await this._walletStore.put(wallet);
        return this._walletToObj(wallet);
    }

This is useful when moving the backend to a different server where there is already a JSON RPC node running, and therefore creating a new address in the new server could break the application on the client side.

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

1 participant