@ -13,6 +13,7 @@
# include "ui_settings.h"
# include "ui_settings.h"
# include "ui_viewalladdresses.h"
# include "ui_viewalladdresses.h"
# include "ui_validateaddress.h"
# include "ui_validateaddress.h"
# include "ui_viewtransaction.h"
# include "ui_rescandialog.h"
# include "ui_rescandialog.h"
# include "ui_getblock.h"
# include "ui_getblock.h"
# include "rpc.h"
# include "rpc.h"
@ -99,6 +100,9 @@ MainWindow::MainWindow(QWidget *parent) :
// Get Block
// Get Block
QObject : : connect ( ui - > actionGet_Block , & QAction : : triggered , this , & MainWindow : : getBlock ) ;
QObject : : connect ( ui - > actionGet_Block , & QAction : : triggered , this , & MainWindow : : getBlock ) ;
// View tx
QObject : : connect ( ui - > actionView_Transaction , & QAction : : triggered , this , & MainWindow : : viewTransaction ) ;
// Address Book
// Address Book
QObject : : connect ( ui - > action_Address_Book , & QAction : : triggered , this , & MainWindow : : addressBook ) ;
QObject : : connect ( ui - > action_Address_Book , & QAction : : triggered , this , & MainWindow : : addressBook ) ;
@ -903,6 +907,67 @@ void MainWindow::validateAddress() {
} ) ;
} ) ;
}
}
// View tx
void MainWindow : : viewTransaction ( ) {
// Make sure everything is up and running
if ( ! getRPC ( ) | | ! getRPC ( ) - > getConnection ( ) )
return ;
// First thing is ask the user for a txid
bool ok ;
QString txid = QInputDialog : : getText ( this , tr ( " View Transaction " ) ,
tr ( " Enter Transaction ID (txid): " ) , QLineEdit : : Normal , " " , & ok ) ;
if ( ! ok )
return ;
// ignore leading and trailing whitespace
txid = txid . trimmed ( ) ;
QRegExp rx ( " ^[0-9a-f]{64}$ " ) ;
if ( ! rx . exactMatch ( txid ) ) {
DEBUG ( " invalid txid " < < txid ) ;
return ;
}
// ok, we were given a valid txid
getRPC ( ) - > getrawtransaction ( txid , [ = ] ( QJsonValue props ) {
// getRPC()->z_viewtransaction(txid, [=] (QJsonValue props) {
QDialog d ( this ) ;
Ui_ViewTransaction vt ;
vt . setupUi ( & d ) ;
Settings : : saveRestore ( & d ) ;
Settings : : saveRestoreTableHeader ( vt . tblProps , & d , " getblockprops " ) ;
vt . tblProps - > horizontalHeader ( ) - > setStretchLastSection ( true ) ;
vt . lblHeight - > setText ( txid ) ;
QList < QPair < QString , QString > > propsList ;
for ( QString property_name : props . toObject ( ) . keys ( ) ) {
QString property_value ;
DEBUG ( " property " < < property_name < < " = " < < props . toObject ( ) [ property_name ] ) ;
if ( props . toObject ( ) [ property_name ] . isString ( ) ) {
property_value = props . toObject ( ) [ property_name ] . toString ( ) ;
} else if ( props . toObject ( ) [ property_name ] . isDouble ( ) ) {
property_value = QString : : number ( props . toObject ( ) [ property_name ] . toDouble ( ) , ' f ' , 0 ) ;
} else if ( props . toObject ( ) [ property_name ] . isBool ( ) ) {
property_value = props . toObject ( ) [ property_name ] . toBool ( ) ? " true " : " false " ;
} else if ( props . toObject ( ) [ property_name ] . isArray ( ) ) {
DEBUG ( property_name < < " is an array " ) ;
} else if ( props . toObject ( ) [ property_name ] . isObject ( ) ) {
DEBUG ( property_name < < " is an object " ) ;
}
propsList . append ( QPair < QString , QString > ( property_name , property_value ) ) ;
}
ValidateAddressesModel model ( vt . tblProps , propsList ) ;
vt . tblProps - > setModel ( & model ) ;
d . exec ( ) ;
} ) ;
}
// Get block info
// Get block info
void MainWindow : : getBlock ( ) {
void MainWindow : : getBlock ( ) {
// Make sure everything is up and running
// Make sure everything is up and running