Merge #19555: rpc: deduplicate WriteHDKeypath() used in decodepsbt

55057ffc51 rpc: deduplicate WriteHDKeypath() used in decodepsbt (Sebastian Falbesoner)

Pull request description:

  The functionality is already provided in the BIP32 utility library `util/bip32.h` with the exact same name and function signature.

ACKs for top commit:
  achow101:
    ACK 55057ffc51
  instagibbs:
    utACK 55057ffc51
  jonatack:
    ACK 55057ffc51

Tree-SHA512: 074c1a71ffb32908926bf07f0c5428a46309f6e0d21e7c20b1008197c820b97776a441736d0b6fd8ab0c0852522a0b5a5ddb26a1e4a1100ca02aabc65a07a018
This commit is contained in:
fanquake 2020-07-21 08:32:45 +08:00
commit f5000ae66c
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -28,6 +28,7 @@
#include <script/signingprovider.h>
#include <script/standard.h>
#include <uint256.h>
#include <util/bip32.h>
#include <util/moneystr.h>
#include <util/strencodings.h>
#include <util/string.h>
@ -938,25 +939,6 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
return result;
}
static std::string WriteHDKeypath(std::vector<uint32_t>& keypath)
{
std::string keypath_str = "m";
for (uint32_t num : keypath) {
keypath_str += "/";
bool hardened = false;
if (num & 0x80000000) {
hardened = true;
num &= ~0x80000000;
}
keypath_str += ToString(num);
if (hardened) {
keypath_str += "'";
}
}
return keypath_str;
}
UniValue decodepsbt(const JSONRPCRequest& request)
{
RPCHelpMan{"decodepsbt",