Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions test/functional/feature_confidential_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,35 @@ def run_test(self):
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__':
Expand Down