mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Create burn argument for createrawtransaction
This commit is contained in:
parent
a904f02fb1
commit
39357ca506
2 changed files with 35 additions and 0 deletions
|
|
@ -458,6 +458,11 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
|
|||
// ELEMENTS: explicit fee outputs
|
||||
CAmount nAmount = AmountFromValue(outputs[name_]);
|
||||
fee_out = CTxOut(asset, nAmount, CScript());
|
||||
} else if (name_ == "burn") {
|
||||
CScript datascript = CScript() << OP_RETURN;
|
||||
CAmount nAmount = AmountFromValue(outputs[name_]);
|
||||
CTxOut out(asset, nAmount, datascript);
|
||||
rawTx.vout.push_back(out);
|
||||
} else {
|
||||
CTxDestination destination = DecodeDestination(name_);
|
||||
if (!IsValidDestination(destination)) {
|
||||
|
|
@ -522,6 +527,7 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
|
|||
" {\n"
|
||||
" \"data\": \"hex\" , (obj, optional) A key-value pair. The key must be \"data\", the value is hex encoded data\n"
|
||||
" \"vdata\": [\"hex\"] (string, optional) The key is \"vdata\", the value is an array of hex encoded data\n"
|
||||
" \"burn\": x.xxx, (obj, optional) A key-value pair. The key must be \"burn\", the value is the amount that will be burned.\n"
|
||||
" },\n"
|
||||
" {\n"
|
||||
" \"fee\": x.xxx (numeric or string, optional) The key is \"fee\", the value the fee output you want to add.\n"
|
||||
|
|
|
|||
|
|
@ -469,6 +469,35 @@ class CTTest (BitcoinTestFramework):
|
|||
assert("value" in outputs[0] and "value" in outputs[1] and "value" in outputs[2])
|
||||
assert_equal(outputs[2]["scriptPubKey"]["type"], 'nulldata')
|
||||
|
||||
# Test burn argument in createrawtransaction
|
||||
raw_burn1 = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress():1, "burn":2})
|
||||
decode_burn1 = self.nodes[0].decoderawtransaction(raw_burn1)
|
||||
assert_equal(len(decode_burn1["vout"]), 2)
|
||||
found_pay = False
|
||||
found_burn = False
|
||||
for output in decode_burn1["vout"]:
|
||||
if output["scriptPubKey"]["asm"] == "OP_RETURN":
|
||||
found_burn = True
|
||||
if output["asset"] != self.nodes[0].dumpassetlabels()["bitcoin"]:
|
||||
raise Exception("Burn should have been bitcoin(policyAsset)")
|
||||
if output["scriptPubKey"]["type"] == "scripthash":
|
||||
found_pay = True
|
||||
assert(found_pay and found_burn)
|
||||
|
||||
raw_burn2 = self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress():1, "burn":2}, 101, False, {"burn":"deadbeef"*8})
|
||||
decode_burn2 = self.nodes[0].decoderawtransaction(raw_burn2)
|
||||
assert_equal(len(decode_burn2["vout"]), 2)
|
||||
found_pay = False
|
||||
found_burn = False
|
||||
for output in decode_burn2["vout"]:
|
||||
if output["scriptPubKey"]["asm"] == "OP_RETURN":
|
||||
found_burn = True
|
||||
if output["asset"] != "deadbeef"*8:
|
||||
raise Exception("Burn should have been deadbeef")
|
||||
if output["scriptPubKey"]["type"] == "scripthash":
|
||||
found_pay = True
|
||||
assert(found_pay and found_burn)
|
||||
|
||||
# TODO: signrawtransactionwith{wallet, key} with confidential segwit input given as previous transaction arg
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue