MCPcopy Create free account
hub / github.com/ElementsProject/elements / gotoLoadPSBT

Method gotoLoadPSBT

src/qt/walletframe.cpp:195–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void 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
232void WalletFrame::encryptWallet()
233{

Callers

nothing calls this directly

Calls 7

DecodeBase64Function · 0.85
getOpenFileNameFunction · 0.85
DecodeRawPSBTFunction · 0.85
openWithPSBTMethod · 0.80
GetFileSizeFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected