Skip to content

Commit

Permalink
change rpc test witness_program to claim_script
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Nov 6, 2017
1 parent 851a30b commit abafbac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contrib/assets_tutorial/assets_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def sync_all(e1, e2):
raw = bitcoin.getrawtransaction(txid)

# Attempt claim!
claimtxid = e1.claimpegin(raw, proof, addrs["witness_program"])
claimtxid = e1.claimpegin(raw, proof, addrs["claim_script"])
sync_all(e1, e2)

# Other node should accept to mempool and mine
Expand Down
4 changes: 2 additions & 2 deletions contrib/assets_tutorial/assets_tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ b-cli generate 101
e1-cli getpeginaddress
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
# mainchain_address : where you send your bitcoin from Bitcoin network
# witness_program: what script will have to be satisfied to spent the peg-in input
# claim_script: what script will have to be satisfied to spent the peg-in input

# Each call of this takes the pubkeys defined in the config file, adds a random number to them
# that is essetially the hash of the sidechain_address and other information,
Expand All @@ -320,7 +320,7 @@ e1-cli getpeginaddress
ADDRS=$(e1-cli getpeginaddress)

MAINCHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['mainchain_address'])")
SIDECHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['witness_program'])")
SIDECHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['claim_script'])")

#Send funds to unique watchmen P2SH address
TXID=$(b-cli sendtoaddress $MAINCHAIN 1)
Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/pegging.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def sync_all(sidechain, sidechain2):
# Should fail due to non-matching wallet address
try:
pegtxid = sidechain.claimpegin(raw, proof, sidechain.getnewaddress())
raise Exception("Peg-in with non-matching witness_program should fail.")
raise Exception("Peg-in with non-matching claim_script should fail.")
except JSONRPCException as e:
assert("Given witness_program is not a valid v0 witness program" in e.error["message"])
assert("Given claim_script is not a valid v0 witness program" in e.error["message"])
pass

# 12 confirms allows in mempool
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p
// 1) value - the value of the pegin output
// 2) asset type - the asset type being pegged in
// 3) genesis blockhash - genesis block of the parent chain
// 4) witness program - program that script evaluation will be evaluated against
// 4) claim script - script to be evaluated for spend authorization
// 5) serialized transaction - serialized bitcoin transaction
// 6) txout proof - merkle proof connecting transaction to header
//
Expand Down
20 changes: 10 additions & 10 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3403,7 +3403,7 @@ UniValue getpeginaddress(const JSONRPCRequest& request)

"\nResult:\n"
"\"mainchain_address\" (string) Mainchain Bitcoin deposit address to send bitcoin to\n"
"\"witness_program\" (string) The witness program in hex that was committed to. This may be required in `claimpegin` to retrieve pegged-in funds\n"
"\"claim_script\" (string) The claim script in hex that was committed to. This may be required in `claimpegin` to retrieve pegged-in funds\n"
"\nExamples:\n"
+ HelpExampleCli("getpeginaddress", "")
+ HelpExampleRpc("getpeginaddress", "")
Expand All @@ -3430,10 +3430,10 @@ UniValue getpeginaddress(const JSONRPCRequest& request)

UniValue fundinginfo(UniValue::VOBJ);

AuditLogPrintf("%s : getpeginaddress mainchain_address: %s witness_program: %s\n", getUser(), destAddr.ToString(), HexStr(witProg));
AuditLogPrintf("%s : getpeginaddress mainchain_address: %s claim_script: %s\n", getUser(), destAddr.ToString(), HexStr(witProg));

fundinginfo.pushKV("mainchain_address", destAddr.ToString());
fundinginfo.pushKV("witness_program", HexStr(witProg));
fundinginfo.pushKV("claim_script", HexStr(witProg));
return fundinginfo;
}

Expand Down Expand Up @@ -3513,14 +3513,14 @@ UniValue createrawpegin(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
throw std::runtime_error(
"createrawpegin bitcoinTx txoutproof ( witness_program )\n"
"createrawpegin bitcoinTx txoutproof ( claim_script )\n"
"\nCreates a raw transaction to claim coins from the main chain by creating a withdraw transaction with the necessary metadata after the corresponding Bitcoin transaction.\n"
"Note that this call will not sign the transaction.\n"
"If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n"
"\nArguments:\n"
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n"
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n"
"3. \"witness_program\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
"3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
"\nResult:\n"
"{\n"
" \"transaction\" (string) Raw transaction in hex\n"
Expand Down Expand Up @@ -3576,7 +3576,7 @@ UniValue createrawpegin(const JSONRPCRequest& request)
std::vector<unsigned char> witnessBytes(ParseHex(request.params[2].get_str()));
witnessProgScript = CScript(witnessBytes.begin(), witnessBytes.end());
if (!witnessProgScript.IsWitnessProgram(version, witnessProgram) || version != 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Given witness_program is not a valid v0 witness program.");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Given claim_script is not a valid v0 witness program.");
}
nOut = GetPeginTxnOutputIndex(txBTC, witnessProgScript);
}
Expand Down Expand Up @@ -3681,14 +3681,14 @@ UniValue claimpegin(const JSONRPCRequest& request)

if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
throw std::runtime_error(
"claimpegin bitcoinTx txoutproof ( witness_program )\n"
"claimpegin bitcoinTx txoutproof ( claim_script )\n"
"\nClaim coins from the main chain by creating a withdraw transaction with the necessary metadata after the corresponding Bitcoin transaction.\n"
"Note that the transaction will not be relayed unless it is buried at least 102 blocks deep.\n"
"If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n"
"\nArguments:\n"
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n"
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n"
"3. \"witness_program\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
"3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
"\nResult:\n"
"\"txid\" (string) Txid of the resulting sidechain transaction\n"
"\nExamples:\n"
Expand Down Expand Up @@ -4062,8 +4062,8 @@ static const CRPCCommand commands[] =
{ "wallet", "dumpissuanceblindingkey", &dumpissuanceblindingkey, true, {"txid", "vin"} },
{ "wallet", "dumpwallet", &dumpwallet, true, {"filename"} },
{ "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} },
{ "wallet", "claimpegin", &claimpegin, false, {"bitcoinT", "txoutproof", "witness_program"} },
{ "wallet", "createrawpegin", &createrawpegin, false, {"bitcoinT", "txoutproof", "witness_program"} },
{ "wallet", "claimpegin", &claimpegin, false, {"bitcoinT", "txoutproof", "claim_script"} },
{ "wallet", "createrawpegin", &createrawpegin, false, {"bitcoinT", "txoutproof", "claim_script"} },
{ "wallet", "getaccountaddress", &getaccountaddress, true, {"account"} },
{ "wallet", "getaccount", &getaccount, true, {"address"} },
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, {"account"} },
Expand Down

0 comments on commit abafbac

Please sign in to comment.