diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-07-15 21:11:39 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-07-15 21:18:58 +0100 |
commit | 6decdedaf9306d6362e19c20ed70033343bcdb9e (patch) | |
tree | cbed2ee9f6d1ff24ba67160248bfa7669095d359 /src/qt | |
parent | a969b2fcd389363fb8add03b063f31357f0f79e1 (diff) | |
parent | 2c3ee4c347838ecadb17a011932dffc077e46630 (diff) |
Merge bitcoin-core/gui#469: Load Base64 PSBT string from file
2c3ee4c347838ecadb17a011932dffc077e46630 gui: Load Base64 PSBT string from file (Andrew Chow)
Pull request description:
Some .psbt files may have the PSBT as a base64 string instead of in binary. We should be able to load those files.
ACKs for top commit:
jarolrod:
tACK 2c3ee4c347838ecadb17a011932dffc077e46630
shaavan:
ACK 2c3ee4c347838ecadb17a011932dffc077e46630
Tree-SHA512: 352b0611693c8989ea7d1b8d494ea58c69dc15cf81b8d62271541832e74b0a0399cb6ed4e686ab7c741cb4e5374527e054a9ecfe7355bc6f77d8fdd13569ab76
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/walletframe.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 6b38e207d3..8dc97e66a2 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -213,6 +213,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; |