19 const auto& it = mapValue.find(key);
20 return it != mapValue.end() ? it->second :
"";
25 QList<TransactionRecord>& parts)
37 if (wtx.
tx->HasP2CSOutputs()) {
50 sub.
credit = nCredit - nDebit;
55 int nIndexMN = (int) wtx.
tx->vout.size() - 1;
59 sub.
credit = wtx.
tx->vout[nIndexMN].nValue;
73 QList<TransactionRecord>& parts)
77 if (!wtx.
tx->HasZerocoinSpendInputs()) {
86 for (
unsigned int nOut = 0; nOut < wtx.
tx->vout.size(); nOut++) {
87 const CTxOut& txout = wtx.
tx->vout[nOut];
93 std::string strAddress;
106 sub.
idx = (int) nOut;
116 QList<TransactionRecord>& parts)
118 if (wtx.
tx->HasP2CSOutputs()) {
142 for (
unsigned int nOut = 0; nOut < wtx.
tx->vout.size(); nOut++) {
143 const CTxOut& txout = wtx.
tx->vout[nOut];
147 sub.
idx = (int) nOut;
168 if (wtx.
tx->hasSaplingData()) {
170 for (
int i = 0; i < (int) wtx.
tx->sapData->vShieldedOutput.size(); ++i) {
172 auto opAddr = sspkm->GetOutPointAddress(wtx, out);
175 if (sspkm->IsNoteSaplingChange(out, *opAddr)) {
181 sub.
credit = sspkm->GetOutPointValue(wtx, out);
182 sub.
memo = sspkm->GetOutPointMemo(wtx, out);
183 if (sub.
memo && !sub.
memo->empty()) {
196 const CAmount& nDebit,
bool involvesWatchAddress,
197 QList<TransactionRecord>& parts,
const CWallet* wallet)
203 if (!wtx.
tx->hasSaplingData()) {
215 if (wtx.
tx->sapData->vShieldedSpend.empty()) {
221 auto opAddr = sspkm->GetOutPointAddress(wtx, out);
225 sub.
memo = sspkm->GetOutPointMemo(wtx, out);
230 if (!wtx.
tx->vout.empty()) {
244 sub.
memo = sspkm->GetOutPointMemo(wtx, out);
249 sub.
debit = -(nDebit - nChange);
250 sub.
credit = nCredit - nChange;
257 bool involvesWatchAddress, QList<TransactionRecord>& parts)
260 if (wtx.
tx->sapData->vShieldedOutput.empty()) {
266 for (
int i = 0; i < (int) wtx.
tx->sapData->vShieldedOutput.size(); ++i) {
268 auto opAddr = sspkm->GetOutPointAddress(wtx, out);
270 if (!opAddr || sspkm->IsNoteSaplingChange(out, *opAddr)) {
277 sub.
memo = sspkm->GetOutPointMemo(wtx, out);
278 CAmount nValue = sspkm->GetOutPointValue(wtx, out);
294 const CAmount& nDebit,
bool involvesWatchAddress,
295 QList<TransactionRecord>& parts)
298 if (wtx.
tx->vout.empty() && wtx.
tx->sapData->vShieldedOutput.empty()) {
305 unsigned int txSize = wtx.
tx->GetTotalSize();
309 for (
unsigned int nOut = 0; nOut < wtx.
tx->vout.size(); nOut++) {
310 const CTxOut& txout = wtx.
tx->vout[nOut];
312 if (wallet->
IsMine(txout)) {
320 sub.
idx = (int) nOut;
327 if (wtx.
tx->HasZerocoinMintOutputs())
350 const std::vector<unsigned char> vec =
ParseHex(prop);
381 bool allShieldedSpendsFromMe =
true;
382 for (
const auto& spend : wtx.
tx->sapData->vShieldedSpend) {
384 allShieldedSpendsFromMe =
false;
390 bool allShieldedOutToMe =
true;
391 for (
int i = 0; i < (int) wtx.
tx->sapData->vShieldedOutput.size(); ++i) {
398 return std::make_pair(allShieldedSpendsFromMe, allShieldedOutToMe);
406 QList<TransactionRecord> parts;
427 CAmount nNet = nCredit - nDebit;
443 for (
const CTxIn& txin : wtx.
tx->vin) {
446 if (fAllFromMe > mine) fAllFromMe = mine;
450 for (
const CTxOut& txout : wtx.
tx->vout) {
453 if (fAllToMe > mine) fAllToMe = mine;
457 bool allShieldedSpendsFromMe, allShieldedOutToMe =
true;
458 std::tie(allShieldedSpendsFromMe, allShieldedOutToMe) =
462 if (fAllFromMe && fAllToMe && allShieldedOutToMe && allShieldedSpendsFromMe) {
470 if (fAllFromMe || wtx.
tx->HasZerocoinMintOutputs()) {
482 parts.append(record);
491 addressStr =
"No available address";
507 const CScript* p2csScript =
nullptr;
508 bool isSpendable =
false;
510 for (
const auto &input : wtx.
tx->vin) {
512 if (tx && tx->
tx->vout[input.prevout.n].scriptPubKey.IsPayToColdStaking()) {
513 p2csScript = &tx->
tx->vout[input.prevout.n].scriptPubKey;
547 for (
const auto & txout : wtx.
tx->vout) {
548 if (txout.scriptPubKey.IsPayToColdStaking()) {
558 if (isSpendable && isFromMe) {
561 }
else if (isFromMe){
591 if (
time != nTxTime)
time = nTxTime;
600 bool fConflicted =
false;
602 bool isTrusted = wtx.
IsTrusted(depth, fConflicted);
603 int nBlocksToMaturity = (wtx.
IsCoinBase() || wtx.
IsCoinStake()) ? std::max(0, (
Params().GetConsensus().nCoinbaseMaturity + 1) - depth) : 0;
610 if (wtx.
tx->nLockTime < LOCKTIME_THRESHOLD) {
627 if (nBlocksToMaturity > 0) {
690 return "OpenUntilDate";
692 return "OpenUntilBlock";
694 return "Unconfirmed";
702 return "Not Accepted";
int64_t CAmount
Amount in PIV (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
std::string GetName() const
const Consensus::Params & GetConsensus() const
Serialized script, used inside transaction inputs and outputs.
bool StartsWithOpcode(const opcodetype opcode) const
An input of a transaction.
An output of a transaction.
bool IsZerocoinMint() const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
bool IsFromMe(const CTransactionRef &tx) const
should probably be renamed to IsRelevantToMe
SaplingScriptPubKeyMan * GetSaplingScriptPubKeyMan() const
A transaction with a bunch of additional info that only the owner cares about.
bool HasP2CSInputs() const
checks whether a tx has P2CS inputs or not
CAmount GetShieldedChange() const
CAmount GetChange() const
std::string GetComment() const
const uint256 & GetHash() const
An outpoint - a combination of a transaction hash and an index n into its sapling output description ...
bool IsSaplingNullifierFromMe(const uint256 &nullifier) const
Whether the nullifier is from this wallet.
isminetype IsMine(const CWalletTx &wtx, const SaplingOutPoint &op) const
Return true if the wallet can decrypt & spend the shielded output.
UI model for a transaction.
bool isMNReward() const
Return true if the tx is a MN reward.
static bool decomposeShieldedDebitTransaction(const CWallet *wallet, const CWalletTx &wtx, CAmount nTxFee, bool involvesWatchAddress, QList< TransactionRecord > &parts)
std::string statusToString()
Return transaction status.
static std::string getValueOrReturnEmpty(const std::map< std::string, std::string > &mapValue, const std::string &key)
int idx
Subtransaction index, for sort key.
static void loadHotOrColdStakeOrContract(const CWallet *wallet, const CWalletTx &wtx, TransactionRecord &record, bool isContract=false)
@ RecvWithShieldedAddress
@ SendToSelfShieldToTransparent
@ P2CSDelegationSentOwner
@ SendToSelfShieldedAddress
@ RecvWithShieldedAddressMemo
@ SendToSelfShieldToShieldChangeAddress
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Optional< CAmount > shieldedCredit
bool isCoinStake() const
Return true if the tx is a coinstake.
static void loadUnlockColdStake(const CWallet *wallet, const CWalletTx &wtx, TransactionRecord &record)
TransactionStatus status
Status: can change with block chain update.
void updateStatus(const CWalletTx &wtx, int chainHeight)
Update status from core wallet tx.
int getOutputIndex() const
Return the output index of the subtransaction
static bool decomposeCoinStake(const CWallet *wallet, const CWalletTx &wtx, const CAmount &nCredit, const CAmount &nDebit, QList< TransactionRecord > &parts)
Helpers.
static bool decomposeZcSpendTx(const CWallet *wallet, const CWalletTx &wtx, const CAmount &nCredit, const CAmount &nDebit, QList< TransactionRecord > &parts)
bool isAnyColdStakingType() const
Return true if the tx is a any cold staking type tx.
static bool decomposeCreditTransaction(const CWallet *wallet, const CWalletTx &wtx, QList< TransactionRecord > &parts)
Decompose a credit transaction into a record for each received output.
static bool decomposeDebitTransaction(const CWallet *wallet, const CWalletTx &wtx, const CAmount &nDebit, bool involvesWatchAddress, QList< TransactionRecord > &parts)
Decompose wtx outputs in records.
bool isNull() const
Return true if the tx hash is null and/or if the size is 0.
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
Decompose CWallet transaction to model transaction records.
Optional< std::string > memo
bool statusUpdateNeeded(int blockHeight) const
Return whether a status update is needed.
static bool decomposeP2CS(const CWallet *wallet, const CWalletTx &wtx, const CAmount &nCredit, const CAmount &nDebit, QList< TransactionRecord > &parts)
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
static bool decomposeSendToSelfTransaction(const CWalletTx &wtx, const CAmount &nCredit, const CAmount &nDebit, bool involvesWatchAddress, QList< TransactionRecord > &parts, const CWallet *wallet)
bool countsForBalance
Transaction counts towards available balance.
int cur_num_blocks
Current number of blocks (to know whether cached status is still valid)
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
@ OpenUntilDate
Normal (sent/received) transactions.
@ Unconfirmed
Not yet mined into a block.
@ Immature
Generated (mined) transactions.
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
@ NotAccepted
Mined but not accepted.
@ OpenUntilBlock
Transaction not yet final, waiting for block.
@ Conflicted
Conflicts with other transaction or mempool.
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
std::string sortKey
Sorting key based on status.
CAmount GetColdStakingCredit(bool fUseCache=true) const
isminetype IsMine(const CTxIn &txin) const
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
int64_t GetTxTime() const
const CWalletTx * GetWalletTx(const uint256 &hash) const
CAmount GetCredit(const isminefilter &filter, bool recalculate=false) const
CAmount GetColdStakingDebit(bool fUseCache=true) const
CAmount GetStakeDelegationDebit(bool fUseCache=true) const
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
isminetype
IsMine() return codes.
@ ISMINE_SPENDABLE_SHIELDED
Indicates that we have the spending key of a shielded spend/output.
@ ISMINE_WATCH_ONLY_SHIELDED
Indicates that we don't have the spending key of a shielded spend/output.
@ ISMINE_SPENDABLE_TRANSPARENT
@ ISMINE_SPENDABLE_DELEGATED
Indicates that we have the spending key of a P2CS.
std::string EncodePaymentAddress(const libzcash::PaymentAddress &zaddr)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet, bool fColdStake)
Parse a standard scriptPubKey for the destination address.
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
CAmount nNewMNBlockReward
bool NetworkUpgradeActive(int nHeight, Consensus::UpgradeIndex idx) const
Returns true if the given network upgrade is active as of the given block height.
std::pair< bool, bool > areInputsAndOutputsFromAndToMe(const CWalletTx &wtx, SaplingScriptPubKeyMan *sspkm, bool &involvesWatchAddress)
bool ExtractAddress(const CScript &scriptPubKey, bool fColdStake, std::string &addressStr)
bool IsFinalTx(const CTransactionRef &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time.
std::vector< unsigned char > ParseHex(const char *psz)
bool IsValidUTF8(const std::string &str)
Checks for valid 4-byte UTF-8 encoding in a string.