44// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
66#include < qt/mempooltxtables.h>
7+ #include < qt/clientmodel.h>
78
89#include < qt/guiutil.h>
910#include < qt/bitcoinunits.h> // New include for BitcoinUnits
@@ -18,6 +19,11 @@ MempoolTxTableModel::MempoolTxTableModel(QObject* parent)
1819
1920MempoolTxTableModel::~MempoolTxTableModel () = default ;
2021
22+ void MempoolTxTableModel::setClientModel (ClientModel* client_model)
23+ {
24+ m_client_model = client_model;
25+ }
26+
2127int MempoolTxTableModel::rowCount (const QModelIndex& parent) const
2228{
2329 if (parent.isValid ()) {
@@ -41,6 +47,17 @@ QVariant MempoolTxTableModel::data(const QModelIndex& index, int role) const
4147
4248 const interfaces::WalletTx* wtx = static_cast <const interfaces::WalletTx*>(index.internalPointer ());
4349
50+ // Declare wallets and wallet outside the switch statement
51+ std::vector<std::unique_ptr<interfaces::Wallet>> wallets;
52+ interfaces::Wallet* wallet = nullptr ;
53+
54+ if (m_client_model) {
55+ wallets = m_client_model->node ().walletLoader ().getWallets ();
56+ if (!wallets.empty ()) {
57+ wallet = wallets[0 ].get ();
58+ }
59+ }
60+
4461 const auto column = static_cast <ColumnIndex>(index.column ());
4562 if (role == Qt::DisplayRole) {
4663 switch (column) {
@@ -50,12 +67,29 @@ QVariant MempoolTxTableModel::data(const QModelIndex& index, int role) const
5067 return BitcoinUnits::formatWithUnit (BitcoinUnits::Unit::BTC, wtx->credit - wtx->debit , false , BitcoinUnits::SeparatorStyle::ALWAYS);
5168 case Fee:
5269 {
53- CAmount fee = wtx->debit - wtx->credit - wtx-> change ;
70+ CAmount fee = wtx->debit - wtx->credit ;
5471 return BitcoinUnits::formatWithUnit (BitcoinUnits::Unit::BTC, fee, false , BitcoinUnits::SeparatorStyle::ALWAYS);
5572 }
5673 case Status:
57- // For now, we'll just indicate if it's in the mempool. More detailed status can be added later.
58- return tr (" In Mempool" );
74+ if (!wallet) return tr (" No active wallet" );
75+
76+ interfaces::WalletTxStatus tx_status;
77+ int num_blocks;
78+ int64_t block_time;
79+
80+ if (wallet->tryGetTxStatus (wtx->tx ->GetHash (), tx_status, num_blocks, block_time)) {
81+ if (tx_status.is_in_main_chain && tx_status.depth_in_main_chain > 0 ) {
82+ return tr (" Confirmed" );
83+ } else if (tx_status.depth_in_main_chain == 0 && !tx_status.is_in_main_chain && !tx_status.is_abandoned ) {
84+ return tr (" In Mempool" );
85+ } else if (tx_status.is_abandoned ) {
86+ return tr (" Abandoned" );
87+ } else {
88+ return tr (" Not in Mempool" );
89+ }
90+ } else {
91+ return tr (" Unknown" );
92+ }
5993 default :
6094 return QVariant ();
6195 }
0 commit comments