From ba2f3221243abf9570842a1b278c061b0f853b78 Mon Sep 17 00:00:00 2001 From: fekt Date: Mon, 7 Aug 2023 13:04:50 -0400 Subject: [PATCH] Initial commit for viewing getblock info --- silentdragon.pro | 1 + silentdragonx.pro | 1 + src/mainwindow.cpp | 27 ++++++++++++++------------- src/mainwindow.ui | 26 +++++++++++++------------- src/rpc.cpp | 2 +- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/silentdragon.pro b/silentdragon.pro index 31810ca..49790a3 100644 --- a/silentdragon.pro +++ b/silentdragon.pro @@ -89,6 +89,7 @@ HEADERS += \ src/viewalladdresses.h FORMS += \ + src/getblock.ui \ src/mainwindow.ui \ src/qrcode.ui \ src/rescandialog.ui \ diff --git a/silentdragonx.pro b/silentdragonx.pro index 475e391..3fae846 100644 --- a/silentdragonx.pro +++ b/silentdragonx.pro @@ -88,6 +88,7 @@ HEADERS += \ src/viewalladdresses.h FORMS += \ + src/getblock.ui \ src/mainwindow.ui \ src/qrcode.ui \ src/rescandialog.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0b9fff9..9118653 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,6 +14,7 @@ #include "ui_viewalladdresses.h" #include "ui_validateaddress.h" #include "ui_rescandialog.h" +#include "ui_getblock.h" #include "rpc.h" #include "balancestablemodel.h" #include "settings.h" @@ -96,7 +97,7 @@ MainWindow::MainWindow(QWidget *parent) : QObject::connect(ui->actionValidate_Address, &QAction::triggered, this, &MainWindow::validateAddress); // Get Block - //QObject::connect(ui->actionGet_Block, &QAction::triggered, this, &MainWindow::getBlock); + QObject::connect(ui->actionGet_Block, &QAction::triggered, this, &MainWindow::getBlock); // Address Book QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook); @@ -903,27 +904,28 @@ void MainWindow::validateAddress() { } // Get block info -/* void MainWindow::getBlock() { // Make sure everything is up and running if (!getRPC() || !getRPC()->getConnection()) return; - // First thing is ask the user for a blocj height + // First thing is ask the user for a block height bool ok; - auto blockheight = QInputDialog::getText(this, tr("Enter Block Height"), QLineEdit::Normal, "", &ok); + auto blockheight = QInputDialog::getText(this, tr("Enter Block Height"), + QString(" ").repeated(140), // Pad the label so the dialog box is wide enough + QLineEdit::Normal, "", &ok); if (!ok) return; - getRPC()->validateAddress(address, [=] (QJsonValue props) { + getRPC()->getBlock(blockheight, [=] (QJsonValue props) { QDialog d(this); - Ui_ValidateAddress va; - va.setupUi(&d); + Ui_GetBlock gb; + gb.setupUi(&d); Settings::saveRestore(&d); - Settings::saveRestoreTableHeader(va.tblProps, &d, "validateaddressprops"); - va.tblProps->horizontalHeader()->setStretchLastSection(true); + Settings::saveRestoreTableHeader(gb.tblProps, &d, "getblockprops"); + gb.tblProps->horizontalHeader()->setStretchLastSection(true); - va.lblAddress->setText(address); + gb.lblHeight->setText(blockheight); QList> propsList; @@ -942,13 +944,12 @@ void MainWindow::getBlock() { ); } - ValidateAddressesModel model(va.tblProps, propsList); - va.tblProps->setModel(&model); + ValidateAddressesModel model(gb.tblProps, propsList); + gb.tblProps->setModel(&model); d.exec(); }); } -*/ void MainWindow::doImport(QList* keys) { if (rpc->getConnection() == nullptr) { diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e00d850..d2eebe4 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -121,6 +121,7 @@ + 75 true @@ -133,6 +134,7 @@ + 75 true @@ -158,6 +160,7 @@ + 75 true @@ -170,6 +173,7 @@ + 75 true @@ -384,8 +388,8 @@ 0 0 - 1409 - 865 + 1447 + 860 @@ -1210,7 +1214,6 @@ - @@ -1245,7 +1248,6 @@ - @@ -1273,7 +1275,6 @@ - @@ -1281,8 +1282,6 @@ - - @@ -1296,7 +1295,6 @@ - @@ -1391,7 +1389,6 @@ - @@ -1446,7 +1443,6 @@ - @@ -1488,7 +1484,6 @@ - @@ -1549,7 +1544,6 @@ - @@ -1614,7 +1608,7 @@ 0 0 1487 - 24 + 30 @@ -1646,6 +1640,7 @@ &Apps + @@ -1751,6 +1746,11 @@ Validate Address + + + Get Block Info + + diff --git a/src/rpc.cpp b/src/rpc.cpp index 5d58219..c94c1fe 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -375,7 +375,7 @@ void RPC::validateAddress(QString address, const std::function } void RPC::getBlock(QString height, const std::function& cb) { - conn->doRPCWithDefaultErrorHandling(makePayload(height), cb); + conn->doRPCWithDefaultErrorHandling(makePayload("getblock", height), cb); } void RPC::getBalance(const std::function& cb) {