Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,12 @@ UniValue decodescript(const JSONRPCRequest& request)
UniValue type;
type = find_value(r, "type");

if (type.isStr() && type.get_str() != "scripthash") {
const bool is_asset_type = type.isStr() &&
(type.get_str() == ASSET_TRANSFER_STRING ||
type.get_str() == ASSET_REISSUE_STRING ||
type.get_str() == ASSET_NEW_STRING ||
type.get_str() == "nullassetdata");
if (type.isStr() && type.get_str() != "scripthash" && !is_asset_type) {
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
// don't return the address for a P2SH of the P2SH.
r.push_back(Pair("p2sh", EncodeDestination(CScriptID(script))));
Expand Down
4 changes: 3 additions & 1 deletion test/functional/rpc_decodescript.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def decodescript_script_pub_key(self):
# OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
rpc_result = self.nodes[0].decodescript('76a9' + push_public_key_hash + '88ac')
assert_equal('OP_DUP OP_HASH160 ' + public_key_hash + ' OP_EQUALVERIFY OP_CHECKSIG', rpc_result['asm'])
assert_equal(True, 'p2sh' in rpc_result)

# 3) multisig scriptPubKey
# <m> <A pubkey> <B pubkey> <C pubkey> <n> OP_CHECKMULTISIG
Expand Down Expand Up @@ -186,7 +187,7 @@ def decodescript_assets(self):
assert_equal('new_asset', result['type'])
assert_equal(1, len(result['addresses']))
assert_equal('mkQgP9nSuRocxERXGnPaWr8NPTWtCM4uiN', result['addresses'][0])
assert_equal('2MvanKE2hxx2A5jcFZ5paHZHSb6VPZMEvGe', result['p2sh'])
assert_equal(False, 'p2sh' in result)
assert_equal('TESTASSET', result['asset_name'])
assert_equal(100.0, result['amount'])
assert_equal(8, result['units'])
Expand All @@ -197,6 +198,7 @@ def decodescript_assets(self):
script = "76a91435a8d9b395f1594e2cf3e06e6ec357d1da89736888acc00f72766e6f0a5445535441535345542175"
result = self.nodes[0].decodescript(script)
assert_equal('TESTASSET!', result['asset_name'])
assert_equal(False, 'p2sh' in result)
assert_equal(1, result['amount'])
assert_equal(0, result['units'])

Expand Down