Skip to content

Commit

Permalink
Updated the help text for 'getcoldstakingaddress' RPC/cli call (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict authored and alex v committed May 2, 2019
1 parent 96198f9 commit b4a1db5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
55 changes: 29 additions & 26 deletions qa/rpc-tests/getcoldstakingaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def run_test(self):
# Verify the Cold Staking is active
assert(self.nodes[0].getblockchaininfo()["bip9_softforks"]["coldstaking"]["status"] == "active")

# Success cases
# Success cases

# Two valid inputs

address_one = "n1xHh1rPngXNCr2ZbyP9wveFPh4e14YfX2"
address_one = "n1xHh1rPngXNCr2ZbyP9wveFPh4e14YfX2"
address_two = "midAY8TW8TpRY4i8ZEyagSeon3LZFjjMyN"

expected_cold_staking_address = "2afhomfZnhs82Qy1r1MHc4yUnP9jSCvFUdN8vyKR96dbWNEPZ9xyK5bFhSaxe7"
Expand All @@ -45,31 +45,31 @@ def run_test(self):
coldstaking_address_one = self.nodes[0].getcoldstakingaddress(address_one, address_two)

assert(self.nodes[0].validateaddress(coldstaking_address_one)["isvalid"] == True)

assert(coldstaking_address_one == expected_cold_staking_address)

# Things that should fail

## Two of the same address
## Two of the same address

make_addr_fail = True

try:
self.nodes[0].getcoldstakingaddress(address_one, address_one)
make_addr_fail = False
except JSONRPCException as e:
assert("The staking address should be different to the spending address" in e.error['message'])

assert(make_addr_fail)
## Using coldstaking addresses

## Using coldstaking addresses

try:
self.nodes[0].getcoldstakingaddress(coldstaking_address_one, address_one)
make_addr_fail = False
except JSONRPCException as e:
assert("Staking address is not a valid NavCoin address" in e.error['message'])

try:
self.nodes[0].getcoldstakingaddress(address_one, coldstaking_address_one)
make_addr_fail = False
Expand Down Expand Up @@ -108,23 +108,26 @@ def run_test(self):
self.nodes[0].getcoldstakingaddress(address_one)
make_addr_fail = False
except JSONRPCException as e:
assert(("getcoldstakingaddress \"stakingaddress\" \"spendingaddress\"\n"
"Returns a coldstaking address based on two address inputs\n"
"Arguments:\n"
"1. \"stakingaddress\" (string, required) The navcoin staking address.\n"
"2. \"spendingaddress\" (string, required) The navcoin spending address.\n\n"
"Result:\n"
"coldstakingaddress (string) The coldstaking address\n\n"
"Examples:\n\n"
"> navcoin-cli getcoldstakingaddress \"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"\n"
"As a json rpc call:\n") in e.error['message']) # Check if we print out the help docs
# Check if we print out the help docs
assert(("getcoldstakingaddress \"stakingaddress\" \"spendingaddres"
"s\"\nReturns a coldstaking address based on two address input"
"s\nArguments:\n1. \"stakingaddress\" (string, required) The "
"navcoin staking address.\n2. \"spendingaddress\" (string, req"
"uired) The navcoin spending address.\n\n\nExamples:\n> navcoi"
"n-cli getcoldstakingaddress \"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEH"
"fiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"\n\nAs a json rpc"
" call\n> curl --user myusername --data-binary '{\"jsonrpc\": "
"\"1.0\", \"id\":\"curltest\", \"method\": \"getcoldstakingadd"
"ress\", \"params\": [\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\", "
"\"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"] }' -H 'content-type: "
"text/plain;' http://127.0.0.1:5555/\n") in e.error['message'])

assert(make_addr_fail)

## Using invalid addresses
## Using invalid addresses

### Numbers

### Numbers

try:
self.nodes[0].getcoldstakingaddress(123, address_one)
make_addr_fail = False
Expand All @@ -151,7 +154,7 @@ def run_test(self):

assert(make_addr_fail)

### Other strings
### Other strings

try:
self.nodes[0].getcoldstakingaddress("\"test\"", address_one)
Expand All @@ -168,7 +171,7 @@ def run_test(self):
assert(make_addr_fail)

### bitcoin address

bitcoin_address_one = "13EBrRgbPSXwd64MUPaZuWz9aCYq78vpAR"
bitcoin_address_two = "1DdGA8L9sMAz5sXJqcydivxvYicY75VsKa"

Expand All @@ -177,7 +180,7 @@ def run_test(self):
make_addr_fail = False
except JSONRPCException as e:
assert("Staking address is not a valid NavCoin address" in e.error['message'])

try:
self.nodes[0].getcoldstakingaddress(address_one, bitcoin_address_two)
make_addr_fail = False
Expand Down
13 changes: 5 additions & 8 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,17 @@ UniValue getcoldstakingaddress(const UniValue& params, bool fHelp)
"Arguments:\n"
"1. \"stakingaddress\" (string, required) The navcoin staking address.\n"
"2. \"spendingaddress\" (string, required) The navcoin spending address.\n\n"
"Result:\n"
"coldstakingaddress (string) The coldstaking address\n\n"
"Examples:\n\n"
"> navcoin-cli getcoldstakingaddress \"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"\n"
"As a json rpc call:\n"


"\nExamples:\n"
+ HelpExampleCli("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\", \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"")
);

if (!IsColdStakingEnabled(chainActive.Tip(),Params().GetConsensus()))
throw runtime_error(
"Cold Staking is not active yet.");

if (params[0].get_str() == params[1].get_str())
if (params[0].get_str() == params[1].get_str())
throw runtime_error(
"The staking address should be different to the spending address"
);
Expand Down

0 comments on commit b4a1db5

Please sign in to comment.