| 193 | } |
| 194 | |
| 195 | void WalletFrame::gotoLoadPSBT(bool from_clipboard) |
| 196 | { |
| 197 | std::string data; |
| 198 | |
| 199 | if (from_clipboard) { |
| 200 | std::string raw = QApplication::clipboard()->text().toStdString(); |
| 201 | bool invalid; |
| 202 | data = DecodeBase64(raw, &invalid); |
| 203 | if (invalid) { |
| 204 | Q_EMIT message(tr("Error"), tr("Unable to decode PSBT from clipboard (invalid base64)"), CClientUIInterface::MSG_ERROR); |
| 205 | return; |
| 206 | } |
| 207 | } else { |
| 208 | QString filename = GUIUtil::getOpenFileName(this, |
| 209 | tr("Load Transaction Data"), QString(), |
| 210 | tr("Partially Signed Transaction (*.psbt)"), nullptr); |
| 211 | if (filename.isEmpty()) return; |
| 212 | if (GetFileSize(filename.toLocal8Bit().data(), MAX_FILE_SIZE_PSBT) == MAX_FILE_SIZE_PSBT) { |
| 213 | Q_EMIT message(tr("Error"), tr("PSBT file must be smaller than 100 MiB"), CClientUIInterface::MSG_ERROR); |
| 214 | return; |
| 215 | } |
| 216 | std::ifstream in{filename.toLocal8Bit().data(), std::ios::binary}; |
| 217 | data = std::string(std::istreambuf_iterator<char>{in}, {}); |
| 218 | } |
| 219 | |
| 220 | std::string error; |
| 221 | PartiallySignedTransaction psbtx; |
| 222 | if (!DecodeRawPSBT(psbtx, data, error)) { |
| 223 | Q_EMIT message(tr("Error"), tr("Unable to decode PSBT") + "\n" + QString::fromStdString(error), CClientUIInterface::MSG_ERROR); |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | auto dlg = new PSBTOperationsDialog(this, currentWalletModel(), clientModel); |
| 228 | dlg->openWithPSBT(psbtx); |
| 229 | GUIUtil::ShowModalDialogAsynchronously(dlg); |
| 230 | } |
| 231 | |
| 232 | void WalletFrame::encryptWallet() |
| 233 | { |
nothing calls this directly
no test coverage detected