Skip to content

Commit 2c3ee4c

Browse files
committed
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.
1 parent f0a834e commit 2c3ee4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/qt/walletframe.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
215215
}
216216
std::ifstream in{filename.toLocal8Bit().data(), std::ios::binary};
217217
data.assign(std::istream_iterator<unsigned char>{in}, {});
218+
219+
// Some psbt files may be base64 strings in the file rather than binary data
220+
std::string b64_str{data.begin(), data.end()};
221+
b64_str.erase(b64_str.find_last_not_of(" \t\n\r\f\v") + 1); // Trim trailing whitespace
222+
auto b64_dec = DecodeBase64(b64_str);
223+
if (b64_dec.has_value()) {
224+
data = b64_dec.value();
225+
}
218226
}
219227

220228
std::string error;

0 commit comments

Comments
 (0)