mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
change rpc test witness_program to claim_script
This commit is contained in:
parent
851a30b266
commit
abafbacd82
5 changed files with 16 additions and 16 deletions
|
|
@ -440,7 +440,7 @@ proof = bitcoin.gettxoutproof([txid])
|
||||||
raw = bitcoin.getrawtransaction(txid)
|
raw = bitcoin.getrawtransaction(txid)
|
||||||
|
|
||||||
# Attempt claim!
|
# Attempt claim!
|
||||||
claimtxid = e1.claimpegin(raw, proof, addrs["witness_program"])
|
claimtxid = e1.claimpegin(raw, proof, addrs["claim_script"])
|
||||||
sync_all(e1, e2)
|
sync_all(e1, e2)
|
||||||
|
|
||||||
# Other node should accept to mempool and mine
|
# Other node should accept to mempool and mine
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@ b-cli generate 101
|
||||||
e1-cli getpeginaddress
|
e1-cli getpeginaddress
|
||||||
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
|
# 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
|
# 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
|
# 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,
|
# that is essetially the hash of the sidechain_address and other information,
|
||||||
|
|
@ -320,7 +320,7 @@ e1-cli getpeginaddress
|
||||||
ADDRS=$(e1-cli getpeginaddress)
|
ADDRS=$(e1-cli getpeginaddress)
|
||||||
|
|
||||||
MAINCHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['mainchain_address'])")
|
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
|
#Send funds to unique watchmen P2SH address
|
||||||
TXID=$(b-cli sendtoaddress $MAINCHAIN 1)
|
TXID=$(b-cli sendtoaddress $MAINCHAIN 1)
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,9 @@ try:
|
||||||
# Should fail due to non-matching wallet address
|
# Should fail due to non-matching wallet address
|
||||||
try:
|
try:
|
||||||
pegtxid = sidechain.claimpegin(raw, proof, sidechain.getnewaddress())
|
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:
|
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
|
pass
|
||||||
|
|
||||||
# 12 confirms allows in mempool
|
# 12 confirms allows in mempool
|
||||||
|
|
|
||||||
|
|
@ -2361,7 +2361,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p
|
||||||
// 1) value - the value of the pegin output
|
// 1) value - the value of the pegin output
|
||||||
// 2) asset type - the asset type being pegged in
|
// 2) asset type - the asset type being pegged in
|
||||||
// 3) genesis blockhash - genesis block of the parent chain
|
// 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
|
// 5) serialized transaction - serialized bitcoin transaction
|
||||||
// 6) txout proof - merkle proof connecting transaction to header
|
// 6) txout proof - merkle proof connecting transaction to header
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -3403,7 +3403,7 @@ UniValue getpeginaddress(const JSONRPCRequest& request)
|
||||||
|
|
||||||
"\nResult:\n"
|
"\nResult:\n"
|
||||||
"\"mainchain_address\" (string) Mainchain Bitcoin deposit address to send bitcoin to\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"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getpeginaddress", "")
|
+ HelpExampleCli("getpeginaddress", "")
|
||||||
+ HelpExampleRpc("getpeginaddress", "")
|
+ HelpExampleRpc("getpeginaddress", "")
|
||||||
|
|
@ -3430,10 +3430,10 @@ UniValue getpeginaddress(const JSONRPCRequest& request)
|
||||||
|
|
||||||
UniValue fundinginfo(UniValue::VOBJ);
|
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("mainchain_address", destAddr.ToString());
|
||||||
fundinginfo.pushKV("witness_program", HexStr(witProg));
|
fundinginfo.pushKV("claim_script", HexStr(witProg));
|
||||||
return fundinginfo;
|
return fundinginfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3513,14 +3513,14 @@ UniValue createrawpegin(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||||
throw std::runtime_error(
|
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"
|
"\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"
|
"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"
|
"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"
|
"\nArguments:\n"
|
||||||
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\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"
|
"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"
|
"\nResult:\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" \"transaction\" (string) Raw transaction in hex\n"
|
" \"transaction\" (string) Raw transaction in hex\n"
|
||||||
|
|
@ -3576,7 +3576,7 @@ UniValue createrawpegin(const JSONRPCRequest& request)
|
||||||
std::vector<unsigned char> witnessBytes(ParseHex(request.params[2].get_str()));
|
std::vector<unsigned char> witnessBytes(ParseHex(request.params[2].get_str()));
|
||||||
witnessProgScript = CScript(witnessBytes.begin(), witnessBytes.end());
|
witnessProgScript = CScript(witnessBytes.begin(), witnessBytes.end());
|
||||||
if (!witnessProgScript.IsWitnessProgram(version, witnessProgram) || version != 0) {
|
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);
|
nOut = GetPeginTxnOutputIndex(txBTC, witnessProgScript);
|
||||||
}
|
}
|
||||||
|
|
@ -3681,14 +3681,14 @@ UniValue claimpegin(const JSONRPCRequest& request)
|
||||||
|
|
||||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||||
throw std::runtime_error(
|
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"
|
"\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"
|
"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"
|
"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"
|
"\nArguments:\n"
|
||||||
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\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"
|
"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"
|
"\nResult:\n"
|
||||||
"\"txid\" (string) Txid of the resulting sidechain transaction\n"
|
"\"txid\" (string) Txid of the resulting sidechain transaction\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
|
|
@ -4062,8 +4062,8 @@ static const CRPCCommand commands[] =
|
||||||
{ "wallet", "dumpissuanceblindingkey", &dumpissuanceblindingkey, true, {"txid", "vin"} },
|
{ "wallet", "dumpissuanceblindingkey", &dumpissuanceblindingkey, true, {"txid", "vin"} },
|
||||||
{ "wallet", "dumpwallet", &dumpwallet, true, {"filename"} },
|
{ "wallet", "dumpwallet", &dumpwallet, true, {"filename"} },
|
||||||
{ "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} },
|
{ "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} },
|
||||||
{ "wallet", "claimpegin", &claimpegin, false, {"bitcoinT", "txoutproof", "witness_program"} },
|
{ "wallet", "claimpegin", &claimpegin, false, {"bitcoinT", "txoutproof", "claim_script"} },
|
||||||
{ "wallet", "createrawpegin", &createrawpegin, false, {"bitcoinT", "txoutproof", "witness_program"} },
|
{ "wallet", "createrawpegin", &createrawpegin, false, {"bitcoinT", "txoutproof", "claim_script"} },
|
||||||
{ "wallet", "getaccountaddress", &getaccountaddress, true, {"account"} },
|
{ "wallet", "getaccountaddress", &getaccountaddress, true, {"account"} },
|
||||||
{ "wallet", "getaccount", &getaccount, true, {"address"} },
|
{ "wallet", "getaccount", &getaccount, true, {"address"} },
|
||||||
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, {"account"} },
|
{ "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, {"account"} },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue