Skip to content

Commit 6decded

Browse files
committed
Merge bitcoin-core#469: Load Base64 PSBT string from file
2c3ee4c 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 2c3ee4c shaavan: ACK 2c3ee4c Tree-SHA512: 352b0611693c8989ea7d1b8d494ea58c69dc15cf81b8d62271541832e74b0a0399cb6ed4e686ab7c741cb4e5374527e054a9ecfe7355bc6f77d8fdd13569ab76
2 parents a969b2f + 2c3ee4c commit 6decded

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
@@ -213,6 +213,14 @@ void WalletFrame::gotoLoadPSBT(bool from_clipboard)
213213
}
214214
std::ifstream in{filename.toLocal8Bit().data(), std::ios::binary};
215215
data.assign(std::istream_iterator<unsigned char>{in}, {});
216+
217+
// Some psbt files may be base64 strings in the file rather than binary data
218+
std::string b64_str{data.begin(), data.end()};
219+
b64_str.erase(b64_str.find_last_not_of(" \t\n\r\f\v") + 1); // Trim trailing whitespace
220+
auto b64_dec = DecodeBase64(b64_str);
221+
if (b64_dec.has_value()) {
222+
data = b64_dec.value();
223+
}
216224
}
217225

218226
std::string error;

0 commit comments

Comments
 (0)