Skip to content

Commit a4cf810

Browse files
committed
Output proprietary type info in decodepsbt
1 parent aebe758 commit a4cf810

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,16 @@ static RPCHelpMan decodepsbt()
10761076
{RPCResult::Type::ELISION, "", "The layout is the same as the output of decoderawtransaction."},
10771077
}},
10781078
{RPCResult::Type::NUM, "psbt_version", "The PSBT version number. Not to be confused with the unsigned transaction version"},
1079+
{RPCResult::Type::ARR, "proprietary", "The global proprietary map",
1080+
{
1081+
{RPCResult::Type::OBJ, "", "",
1082+
{
1083+
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
1084+
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
1085+
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
1086+
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
1087+
}},
1088+
}},
10791089
{RPCResult::Type::OBJ_DYN, "unknown", "The unknown global fields",
10801090
{
10811091
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
@@ -1138,6 +1148,16 @@ static RPCHelpMan decodepsbt()
11381148
{
11391149
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
11401150
}},
1151+
{RPCResult::Type::ARR, "proprietary", "The input proprietary map",
1152+
{
1153+
{RPCResult::Type::OBJ, "", "",
1154+
{
1155+
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
1156+
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
1157+
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
1158+
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
1159+
}},
1160+
}},
11411161
}},
11421162
}},
11431163
{RPCResult::Type::ARR, "outputs", "",
@@ -1169,6 +1189,16 @@ static RPCHelpMan decodepsbt()
11691189
{
11701190
{RPCResult::Type::STR_HEX, "key", "(key-value pair) An unknown key-value pair"},
11711191
}},
1192+
{RPCResult::Type::ARR, "proprietary", "The output proprietary map",
1193+
{
1194+
{RPCResult::Type::OBJ, "", "",
1195+
{
1196+
{RPCResult::Type::STR_HEX, "identifier", "The hex string for the proprietary identifier"},
1197+
{RPCResult::Type::NUM, "subtype", "The number for the subtype"},
1198+
{RPCResult::Type::STR_HEX, "key", "The hex for the key"},
1199+
{RPCResult::Type::STR_HEX, "value", "The hex for the value"},
1200+
}},
1201+
}},
11721202
}},
11731203
}},
11741204
{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()
11981228
// PSBT version
11991229
result.pushKV("psbt_version", static_cast<uint64_t>(psbtx.GetVersion()));
12001230

1231+
// Proprietary
1232+
UniValue proprietary(UniValue::VARR);
1233+
for (const auto& entry : psbtx.m_proprietary) {
1234+
UniValue this_prop(UniValue::VOBJ);
1235+
this_prop.pushKV("identifier", HexStr(entry.identifier));
1236+
this_prop.pushKV("subtype", entry.subtype);
1237+
this_prop.pushKV("key", HexStr(entry.key));
1238+
this_prop.pushKV("value", HexStr(entry.value));
1239+
proprietary.push_back(this_prop);
1240+
}
1241+
result.pushKV("proprietary", proprietary);
1242+
12011243
// Unknown data
12021244
UniValue unknowns(UniValue::VOBJ);
12031245
for (auto entry : psbtx.unknown) {
@@ -1304,6 +1346,20 @@ static RPCHelpMan decodepsbt()
13041346
in.pushKV("final_scriptwitness", txinwitness);
13051347
}
13061348

1349+
// Proprietary
1350+
if (!input.m_proprietary.empty()) {
1351+
UniValue proprietary(UniValue::VARR);
1352+
for (const auto& entry : input.m_proprietary) {
1353+
UniValue this_prop(UniValue::VOBJ);
1354+
this_prop.pushKV("identifier", HexStr(entry.identifier));
1355+
this_prop.pushKV("subtype", entry.subtype);
1356+
this_prop.pushKV("key", HexStr(entry.key));
1357+
this_prop.pushKV("value", HexStr(entry.value));
1358+
proprietary.push_back(this_prop);
1359+
}
1360+
in.pushKV("proprietary", proprietary);
1361+
}
1362+
13071363
// Unknown data
13081364
if (input.unknown.size() > 0) {
13091365
UniValue unknowns(UniValue::VOBJ);
@@ -1348,6 +1404,20 @@ static RPCHelpMan decodepsbt()
13481404
out.pushKV("bip32_derivs", keypaths);
13491405
}
13501406

1407+
// Proprietary
1408+
if (!output.m_proprietary.empty()) {
1409+
UniValue proprietary(UniValue::VARR);
1410+
for (const auto& entry : output.m_proprietary) {
1411+
UniValue this_prop(UniValue::VOBJ);
1412+
this_prop.pushKV("identifier", HexStr(entry.identifier));
1413+
this_prop.pushKV("subtype", entry.subtype);
1414+
this_prop.pushKV("key", HexStr(entry.key));
1415+
this_prop.pushKV("value", HexStr(entry.value));
1416+
proprietary.push_back(this_prop);
1417+
}
1418+
out.pushKV("proprietary", proprietary);
1419+
}
1420+
13511421
// Unknown data
13521422
if (output.unknown.size() > 0) {
13531423
UniValue unknowns(UniValue::VOBJ);

0 commit comments

Comments
 (0)