|
3 | 3 | // Distributed under the MIT software license, see the accompanying
|
4 | 4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
5 | 5 |
|
| 6 | +#include <base58.h> |
6 | 7 | #include <chain.h>
|
7 | 8 | #include <coins.h>
|
8 | 9 | #include <consensus/amount.h>
|
@@ -1075,6 +1076,15 @@ static RPCHelpMan decodepsbt()
|
1075 | 1076 | {
|
1076 | 1077 | {RPCResult::Type::ELISION, "", "The layout is the same as the output of decoderawtransaction."},
|
1077 | 1078 | }},
|
| 1079 | + {RPCResult::Type::ARR, "global_xpubs", "", |
| 1080 | + { |
| 1081 | + {RPCResult::Type::OBJ, "", "", |
| 1082 | + { |
| 1083 | + {RPCResult::Type::STR, "xpub", "The extended public key this path corresponds to"}, |
| 1084 | + {RPCResult::Type::STR_HEX, "master_fingerprint", "The fingerprint of the master key"}, |
| 1085 | + {RPCResult::Type::STR, "path", "The path"}, |
| 1086 | + }}, |
| 1087 | + }}, |
1078 | 1088 | {RPCResult::Type::NUM, "psbt_version", "The PSBT version number. Not to be confused with the unsigned transaction version"},
|
1079 | 1089 | {RPCResult::Type::ARR, "proprietary", "The global proprietary map",
|
1080 | 1090 | {
|
@@ -1225,6 +1235,23 @@ static RPCHelpMan decodepsbt()
|
1225 | 1235 | TxToUniv(CTransaction(*psbtx.tx), uint256(), tx_univ, false);
|
1226 | 1236 | result.pushKV("tx", tx_univ);
|
1227 | 1237 |
|
| 1238 | + // Add the global xpubs |
| 1239 | + UniValue global_xpubs(UniValue::VARR); |
| 1240 | + for (std::pair<KeyOriginInfo, std::set<CExtPubKey>> xpub_pair : psbtx.m_xpubs) { |
| 1241 | + for (auto& xpub : xpub_pair.second) { |
| 1242 | + std::vector<unsigned char> ser_xpub; |
| 1243 | + ser_xpub.assign(BIP32_EXTKEY_WITH_VERSION_SIZE, 0); |
| 1244 | + xpub.EncodeWithVersion(ser_xpub.data()); |
| 1245 | + |
| 1246 | + UniValue keypath(UniValue::VOBJ); |
| 1247 | + keypath.pushKV("xpub", EncodeBase58Check(ser_xpub)); |
| 1248 | + keypath.pushKV("master_fingerprint", HexStr(Span<unsigned char>(xpub_pair.first.fingerprint, xpub_pair.first.fingerprint + 4))); |
| 1249 | + keypath.pushKV("path", WriteHDKeypath(xpub_pair.first.path)); |
| 1250 | + global_xpubs.push_back(keypath); |
| 1251 | + } |
| 1252 | + } |
| 1253 | + result.pushKV("global_xpubs", global_xpubs); |
| 1254 | + |
1228 | 1255 | // PSBT version
|
1229 | 1256 | result.pushKV("psbt_version", static_cast<uint64_t>(psbtx.GetVersion()));
|
1230 | 1257 |
|
|
0 commit comments