aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-11-12 16:09:54 -0500
committerAndrew Chow <achow101-github@achow101.com>2022-04-27 23:36:06 -0400
commit2c3ee4c347838ecadb17a011932dffc077e46630 (patch)
treefbe2e79296b9c42212acf2612f10adb76496ea58
parentf0a834e2f10a0aa60c7cc76e9f3eb090168a32e5 (diff)
downloadbitcoin-2c3ee4c347838ecadb17a011932dffc077e46630.tar.xz
gui: Load Base64 PSBT string from file
Some .psbt files may have the PSBT as a base64 string instead of in binary. We should be able to load those files.
-rw-r--r--src/qt/walletframe.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp
index dc4e25a02b..abeb6a827b 100644
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -215,6 +215,14 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
}
std::ifstream in{filename.toLocal8Bit().data(), std::ios::binary};
data.assign(std::istream_iterator<unsigned char>{in}, {});
+
+ // Some psbt files may be base64 strings in the file rather than binary data
+ std::string b64_str{data.begin(), data.end()};
+ b64_str.erase(b64_str.find_last_not_of(" \t\n\r\f\v") + 1); // Trim trailing whitespace
+ auto b64_dec = DecodeBase64(b64_str);
+ if (b64_dec.has_value()) {
+ data = b64_dec.value();
+ }
}
std::string error;