]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Send: verify tx outputs match destination addresses
authortobtoht <thotbot@protonmail.com>
Sat, 12 Mar 2022 13:56:03 +0000 (14:56 +0100)
committertobtoht <thotbot@protonmail.com>
Sat, 12 Mar 2022 13:56:03 +0000 (14:56 +0100)
src/MainWindow.cpp

index cd0d85f730786dc3913c5dbeaa40860ce7bd5baf..2b5952311a1a4232082ed643f8f9f6d8f80064c5 100644 (file)
@@ -635,7 +635,25 @@ void MainWindow::onCreateTransactionSuccess(PendingTransaction *tx, const QVecto
         return;
     }
 
-
+    // This is a weak check to see if we send to all specified destination addresses
+    // This is here to catch rare memory corruption errors during transaction construction
+    // TODO: also check that amounts match
+    tx->refresh();
+    QSet<QString> outputAddresses;
+    for (const auto &output : tx->transaction(0)->outputs()) {
+        outputAddresses.insert(output->address());
+    }
+    QSet<QString> destAddresses;
+    for (const auto &addr : address) {
+        destAddresses.insert(addr);
+    }
+    if (!outputAddresses.contains(destAddresses)) {
+        err = QString("%1 %2").arg(err, "Constructed transaction doesn't appear to send to (all) specified destination address(es). Try creating the transaction again.");
+        qDebug() << Q_FUNC_INFO << err;
+        this->displayWalletErrorMsg(err);
+        m_ctx->wallet->disposeTransaction(tx);
+        return;
+    }
 
     m_ctx->addCacheTransaction(tx->txid()[0], tx->signedTxToHex(0));