| 16 | |
| 17 | namespace wallet { |
| 18 | static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue& entry) |
| 19 | { |
| 20 | interfaces::Chain& chain = wallet.chain(); |
| 21 | int confirms = wallet.GetTxDepthInMainChain(wtx); |
| 22 | entry.pushKV("confirmations", confirms); |
| 23 | if (wtx.IsCoinBase()) |
| 24 | entry.pushKV("generated", true); |
| 25 | if (auto* conf = wtx.state<TxStateConfirmed>()) |
| 26 | { |
| 27 | entry.pushKV("blockhash", conf->confirmed_block_hash.GetHex()); |
| 28 | entry.pushKV("blockheight", conf->confirmed_block_height); |
| 29 | entry.pushKV("blockindex", conf->position_in_block); |
| 30 | int64_t block_time; |
| 31 | CHECK_NONFATAL(chain.findBlock(conf->confirmed_block_hash, FoundBlock().time(block_time))); |
| 32 | entry.pushKV("blocktime", block_time); |
| 33 | } else { |
| 34 | entry.pushKV("trusted", CachedTxIsTrusted(wallet, wtx)); |
| 35 | } |
| 36 | uint256 hash = wtx.GetHash(); |
| 37 | entry.pushKV("txid", hash.GetHex()); |
| 38 | UniValue conflicts(UniValue::VARR); |
| 39 | for (const uint256& conflict : wallet.GetTxConflicts(wtx)) |
| 40 | conflicts.push_back(conflict.GetHex()); |
| 41 | entry.pushKV("walletconflicts", conflicts); |
| 42 | entry.pushKV("time", wtx.GetTxTime()); |
| 43 | entry.pushKV("timereceived", int64_t{wtx.nTimeReceived}); |
| 44 | |
| 45 | // Add opt-in RBF status |
| 46 | std::string rbfStatus = "no"; |
| 47 | if (confirms <= 0) { |
| 48 | RBFTransactionState rbfState = chain.isRBFOptIn(*wtx.tx); |
| 49 | if (rbfState == RBFTransactionState::UNKNOWN) |
| 50 | rbfStatus = "unknown"; |
| 51 | else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) |
| 52 | rbfStatus = "yes"; |
| 53 | } |
| 54 | entry.pushKV("bip125-replaceable", rbfStatus); |
| 55 | |
| 56 | for (const std::pair<const std::string, std::string>& item : wtx.mapValue) { |
| 57 | // Skip blinding data which isn't parseable |
| 58 | if (item.first != "blindingdata") { |
| 59 | entry.pushKV(item.first, item.second); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | struct tallyitem |
| 65 | { |
no test coverage detected