0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

Output proprietary type info in decodepsbt

This commit is contained in:
Andrew Chow 2019-10-02 16:58:20 -04:00
parent aebe758e54
commit a4cf810174

View file

@ -1076,6 +1076,16 @@ static RPCHelpMan decodepsbt()
{RPCResult::Type::ELISION, "", "The layout is the same as the output of decoderawtransaction."},
}},
{RPCResult::Type::NUM, "psbt_version", "The PSBT version number. Not to be confused with the unsigned transaction version"},
{RPCResult::Type::ARR, "proprietary", "The global proprietary map",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
}},
}},
{RPCResult::Type::OBJ_DYN, "unknown", "The unknown global fields",
{
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
@ -1138,6 +1148,16 @@ static RPCHelpMan decodepsbt()
{
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
}},
{RPCResult::Type::ARR, "proprietary", "The input proprietary map",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
}},
}},
}},
}},
{RPCResult::Type::ARR, "outputs", "",
@ -1169,6 +1189,16 @@ static RPCHelpMan decodepsbt()
{
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
}},
{RPCResult::Type::ARR, "proprietary", "The output proprietary map",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
}},
}},
}},
}},
{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The transaction fee paid if all UTXOs slots in the PSBT have been filled."},
@ -1198,6 +1228,18 @@ static RPCHelpMan decodepsbt()
// PSBT version
result.pushKV("psbt_version", static_cast<uint64_t>(psbtx.GetVersion()));
// Proprietary
UniValue proprietary(UniValue::VARR);
for (const auto& entry : psbtx.m_proprietary) {
UniValue this_prop(UniValue::VOBJ);
this_prop.pushKV("identifier", HexStr(entry.identifier));
this_prop.pushKV("subtype", entry.subtype);
this_prop.pushKV("key", HexStr(entry.key));
this_prop.pushKV("value", HexStr(entry.value));
proprietary.push_back(this_prop);
}
result.pushKV("proprietary", proprietary);
// Unknown data
UniValue unknowns(UniValue::VOBJ);
for (auto entry : psbtx.unknown) {
@ -1304,6 +1346,20 @@ static RPCHelpMan decodepsbt()
in.pushKV("final_scriptwitness", txinwitness);
}
// Proprietary
if (!input.m_proprietary.empty()) {
UniValue proprietary(UniValue::VARR);
for (const auto& entry : input.m_proprietary) {
UniValue this_prop(UniValue::VOBJ);
this_prop.pushKV("identifier", HexStr(entry.identifier));
this_prop.pushKV("subtype", entry.subtype);
this_prop.pushKV("key", HexStr(entry.key));
this_prop.pushKV("value", HexStr(entry.value));
proprietary.push_back(this_prop);
}
in.pushKV("proprietary", proprietary);
}
// Unknown data
if (input.unknown.size() > 0) {
UniValue unknowns(UniValue::VOBJ);
@ -1348,6 +1404,20 @@ static RPCHelpMan decodepsbt()
out.pushKV("bip32_derivs", keypaths);
}
// Proprietary
if (!output.m_proprietary.empty()) {
UniValue proprietary(UniValue::VARR);
for (const auto& entry : output.m_proprietary) {
UniValue this_prop(UniValue::VOBJ);
this_prop.pushKV("identifier", HexStr(entry.identifier));
this_prop.pushKV("subtype", entry.subtype);
this_prop.pushKV("key", HexStr(entry.key));
this_prop.pushKV("value", HexStr(entry.value));
proprietary.push_back(this_prop);
}
out.pushKV("proprietary", proprietary);
}
// Unknown data
if (output.unknown.size() > 0) {
UniValue unknowns(UniValue::VOBJ);