Skip to content

Commit

Permalink
Update the RPC with Miner Wallet management.
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Jan 20, 2020
1 parent c0448ab commit 54c6d0c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
3 changes: 0 additions & 3 deletions docs/Development/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ Consensus:

- GasPrice.

- Same Nonce Merit Removals.
- Verify Competing Merit Removals.

Interfaces:

- Add missing methods detailed under the Eventual docs.
Expand Down
6 changes: 5 additions & 1 deletion docs/RPC/Current/Personal.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Personal Module

### `getMiner`

`getMiner` replies with the BLS Private Key of the current Miner Wallet. It takes in zero arguments and the result is a string of the private key.

### `setMnemonic`

`setMnemonic` creates a new Wallet using the passed in Mnemonic and password, and set the Node's Wallet to it. It takes in two arguments:
`setMnemonic` creates a new Wallet using the passed in Mnemonic and password and sets the Node's Wallet to it. It takes in two arguments:
- Mnemonic (string): Optional; creates a new Mnemonic if omitted.
- Password (string): Optional; defaults to "" if omitted, as according to the BIP 39 spec.

Expand Down
13 changes: 12 additions & 1 deletion docs/RPC/Eventual/Personal.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Personal Module

### `setMiner`

`setMiner` creates a new Miner Wallet using the passed in BLS Private Key and sets the Node's Miner Wallet to it. It takes in one argument:
- Private Key (string): Optional; creates a new Private Key if omitted.

The result is a bool of true.

### `getMiner`

`getMiner` replies with the BLS Private Key of the current Miner Wallet. It takes in zero arguments and the result is a string of the private key.

### `setMnemonic`

`setMnemonic` creates a new Wallet using the passed in Mnemonic and password, and set the Node's Wallet to it. It takes in two arguments:
`setMnemonic` creates a new Wallet using the passed in Mnemonic and password and sets the Node's Wallet to it. It takes in two arguments:
- Mnemonic (string): Optional; creates a new Mnemonic if omitted.
- Password (string): Optional; defaults to "" if omitted, as according to the BIP 39 spec.

Expand Down
12 changes: 10 additions & 2 deletions src/Interfaces/RPC/Modules/PersonalModule.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import ../../../lib/Util
#Hash lib.
import ../../../lib/Hash

#Wallet lib.
#Wallet libs.
import ../../../Wallet/Wallet
import ../../../Wallet/MinerWallet

#Transactions lib.
import ../../../Database/Transactions/Transactions
Expand All @@ -25,6 +26,13 @@ proc module*(
): RPCFunctions {.forceCheck: [].} =
try:
newRPCFunctions:
#Get the Node's MinerWallet's private key.
"getMiner" = proc (
res: JSONNode,
params: JSONNode
) {.forceCheck: [].} =
res["result"] = % $functions.personal.getMinerWallet().privateKey

#Set the Node's Wallet's Mnemonic.
"setMnemonic" = proc (
res: JSONNode,
Expand Down Expand Up @@ -143,7 +151,7 @@ proc module*(
try:
res["result"] = % $functions.personal.data(params[0].getStr())
except ValueError:
raise newJSONRPCError(-3, "Invalid data length")
raise newJSONRPCError(-3, "Invalid data length or missing datas")
except DataExists:
raise newJSONRPCError(0, "Data exists")

Expand Down

0 comments on commit 54c6d0c

Please sign in to comment.