Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

JSON RPC function to add address from private key #502

@rraallvv

Description

@rraallvv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions