Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use personal_sendTransaction on RSK?

Tags:

rpc

rsk

I'm running an RSK node and I'm trying to send a transaction using personal_sendTransaction but I get this error:

The local wallet feature is disabled

How can I fix this? thanks in advance

like image 636
Dul Avatar asked Feb 25 '21 05:02

Dul


2 Answers

You are trying to use personal module and this feature implies importing your account to the node. In the other answer, the account is imported into the node by adding the public key and private key in plain text within RSKj config file, and this is insecure, as obtaining access to the file system is enough to compromise your private key. Thus this approach should probably be only used for convenience, and on Testnet or Regtest only - not for any accounts on Mainnet.

An alternative approach is with the personal module enabled, to use the personal_importRawKey RPC to add new accounts. This way is a bit more secure because the passphrase is not persisted to the file system.

Even if the machine running the node is compromised, and the attacker can read the config file, your private keys would therefore not be compromised as a result.

The full steps are detailed below:

(1) Enable thepersonal module (enabled by default):

rpc {
    modules = [
        ...,
        {
            name: "personal",
            version: "1.0",
            enabled: "true"
        },
        ...
    ]
}

(2) Call the personal_importRawKey RPC to add new accounts:

curl \
  -X POST \
  --data '{"jsonrpc":"2.0","method":"personal_importRawKey","params":["YOUR_RAW_KEY", "YOUR_PASSPHRASE"],"id":1}' \
  --header "Content-Type:application/json" \
  http://localhost:4444/

(3) Prior to signing transactions using this account, you will need to call the personal_unlockAccount for the account that you just created. Note that DURATION is optional, and defaults to 300 (5 minutes).

curl \
  -X POST \
  --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["YOUR_ACCOUNT_ADDRESS", "YOUR_PASSPHRASE", DURATION],"id":1}' \
  --header "Content-Type:application/json" \
  http://localhost:4444/
like image 152
ajlopez Avatar answered Nov 01 '22 07:11

ajlopez


You are trying to use personal module and this feature implies importing your account to the node

NOTE: For security reasons, this approach is not recommended, however, it is possible to do.

In order to do this, you need to configure your node for this in the RSKj config file. This should be main.conf for RSK Mainnet:

(1) Enable thepersonal module (enabled by default):

rpc {
    modules = [
        ...,
        {
            name: "personal",
            version: "1.0",
            enabled: "true"
        },
        ...
    ]
}

(2) Enable wallet and add your account:

wallet {
    enabled = true
    accounts = [
        {
            "publicKey" : "<PUBLIC_KEY>"
            "privateKey" : "<PRIVATE_KEY>"
        }
    ]
}

After this, you will be able to use all of the following RPC methods:

  • personal_sendTransaction
  • personal_importRawKey
  • personal_listAccounts
  • personal_lockAccount
  • personal_newAccount
  • personal_unlockAccount

Example:

curl \
  -X POST \
  --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["password"],"id":1}' \
  --header "Content-Type:application/json" \
  http://localhost:4444
like image 23
Jesse Clark Avatar answered Nov 01 '22 08:11

Jesse Clark