Skip to content

Commit

Permalink
Merge bitcoin-core/gui#469: Load Base64 PSBT string from file
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hebasto committed Jul 15, 2022
2 parents a969b2f + 2c3ee4c commit 6decded
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6decded

Please sign in to comment.