Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add functions to wallet API #9464

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/wallet/api/transaction_history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ void TransactionHistoryImpl::refresh()
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
ti->m_unlock_time = pd.m_unlock_time;
// not used for payment_details
ti->m_change = 0;
ti->m_tx_state = TransactionInfo::confirmed;
// not used for payment_details
ti->m_double_spend_seen = false;
m_history.push_back(ti);

}
Expand Down Expand Up @@ -193,6 +198,11 @@ void TransactionHistoryImpl::refresh()
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
ti->m_unlock_time = pd.m_unlock_time;
ti->m_change = pd->m_change;
ti->m_tx_state = TransactionInfo::confirmed;
// not used for confirmed_transfer_details
ti->m_double_spend_seen = false;

// single output transaction might contain multiple transfers
for (const auto &d: pd.m_dests) {
Expand Down Expand Up @@ -229,6 +239,11 @@ void TransactionHistoryImpl::refresh()
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = 0;
ti->m_unlock_time = pd.m_tx.unlock_time;
ti->m_change = pd->m_change;
ti->m_tx_state = pd->m_state;
// not used for unconfirmed_transfer_details
ti->m_double_spend_seen = false;
for (const auto &d : pd.m_dests)
{
ti->m_transfers.push_back({d.amount, d.address(m_wallet->m_wallet->nettype(), pd.m_payment_id)});
Expand Down Expand Up @@ -258,6 +273,11 @@ void TransactionHistoryImpl::refresh()
ti->m_label = m_wallet->m_wallet->get_subaddress_label(pd.m_subaddr_index);
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = 0;
ti->m_unlock_time = pd.m_unlock_time;
// not used for pool_payment_details
ti->m_change = 0;
ti->m_tx_state = TransactionInfo::pending_in_pool;
ti->m_double_spend_seen = i->second.m_double_spend_seen;
m_history.push_back(ti);

LOG_PRINT_L1(__FUNCTION__ << ": Unconfirmed payment found " << pd.m_amount);
Expand Down
15 changes: 15 additions & 0 deletions src/wallet/api/transaction_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,19 @@ uint64_t TransactionInfoImpl::unlockTime() const
return m_unlock_time;
}

std::uint64_t TransactionInfoImpl::receivedChangeAmount() const
{
return m_change;
}

int TransactionInfoImpl::txState() const
{
return m_tx_state;
}

bool TransactionInfoImpl::isDoubleSpendSeen() const
{
return m_double_spend_seen;
}

} // namespace
10 changes: 10 additions & 0 deletions src/wallet/api/transaction_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class TransactionInfoImpl : public TransactionInfo
virtual uint64_t confirmations() const override;
virtual uint64_t unlockTime() const override;

std::uint64_t receivedChangeAmount() const override;
int txState() const override;
bool isDoubleSpendSeen() const override;

private:
int m_direction;
bool m_pending;
Expand All @@ -81,6 +85,12 @@ class TransactionInfoImpl : public TransactionInfo
std::vector<Transfer> m_transfers;
uint64_t m_confirmations;
uint64_t m_unlock_time;
// received change amount from outgoing transaction
std::uint64_t m_change;
// enum TxState
int m_tx_state;
// is double spend seen
bool m_double_spend_seen;

friend class TransactionHistoryImpl;

Expand Down
Loading
Loading