Merge bitcoin/bitcoin#32523: wallet: Remove isminetypes
be776a1443wallet: Remove isminetype (Ava Chow)009a69a616wallet: Remove ISMINE_USED (Ava Chow)6a7aa01574wallet: Remove COutput::spendable and AvailableCoinsListUnspent (Ava Chow)620abe985einterfaces, gui: Remove is_mine output parameter from getAddress (Ava Chow) Pull request description: The remaining isminetypes are `ISMINE_SPENDABLE` and `ISMINE_USED`. `ISMINE_USED` is only used as a filter for caching balances and is never actually returned from `IsMine`. Since we do still want this behavior, This PR changes the caching to utilize bools and explicit members variables to account for the avoid_reuse case. This allows us to remove `ISMINE_USED`. `ISMINE_SPENDABLE` and `ISMINE_NO` are the only things that are returned by `IsMine`. This is a bool, so it can be replaced as such. After removing `ISMINE_USED` and `ISMINE_SPENDABLE`, we are able to remove isminetypes altogether. ACKs for top commit: murchandamus: ACKbe776a1443fjahr: reACKbe776a1443davidgumberg: crACK https://github.com/bitcoin/bitcoin/commit/be776a1443fdf1a72e0d363c1566d71cb0cda8b5 enirox001: re-ACKbe776a1jlest01: reACK https://github.com/bitcoin/bitcoin/pull/32523/commits/be776a1443fdf1a72e0d363c1566d71cb0cda8b5 Tree-SHA512: 689759f6a6ba20a1ae988b0c3abacb15424844f29a1ec2fcb2d1ca9d87b44ae68313e8f61d6fd310281b681144f0ade67e90fcfab807e982b52ed99441d9c987
This commit is contained in:
32 files changed
+226
-348
No files matched your search
@@ -270,7 +270,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
// Check for duplicate addresses to prevent accidental deletion of addresses, if you try
|
||||
// to paste an existing address over another address (with a different label)
|
||||
if (walletModel->wallet().getAddress(
|
||||
newAddress, /* name= */ nullptr, /* is_mine= */ nullptr, /* purpose= */ nullptr))
|
||||
newAddress, /*name=*/nullptr, /*purpose=*/ nullptr))
|
||||
{
|
||||
editStatus = DUPLICATE_ADDRESS;
|
||||
return false;
|
||||
@@ -356,7 +356,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||
// Check for duplicate addresses
|
||||
{
|
||||
if (walletModel->wallet().getAddress(
|
||||
DecodeDestination(strAddress), /* name= */ nullptr, /* is_mine= */ nullptr, /* purpose= */ nullptr))
|
||||
DecodeDestination(strAddress), /*name=*/nullptr, /*purpose=*/nullptr))
|
||||
{
|
||||
editStatus = DUPLICATE_ADDRESS;
|
||||
return QString();
|
||||
@@ -429,7 +429,7 @@ bool AddressTableModel::getAddressData(const QString &address,
|
||||
std::string* name,
|
||||
wallet::AddressPurpose* purpose) const {
|
||||
CTxDestination destination = DecodeDestination(address.toStdString());
|
||||
return walletModel->wallet().getAddress(destination, name, /* is_mine= */ nullptr, purpose);
|
||||
return walletModel->wallet().getAddress(destination, name, purpose);
|
||||
}
|
||||
|
||||
int AddressTableModel::lookupAddress(const QString &address) const
|
||||
|
||||
+17
-32
@@ -17,17 +17,12 @@
|
||||
#include <logging.h>
|
||||
#include <policy/policy.h>
|
||||
#include <validation.h>
|
||||
#include <wallet/types.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <QLatin1String>
|
||||
|
||||
using wallet::ISMINE_ALL;
|
||||
using wallet::ISMINE_SPENDABLE;
|
||||
using wallet::isminetype;
|
||||
|
||||
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool)
|
||||
{
|
||||
int depth = status.depth_in_main_chain;
|
||||
@@ -143,8 +138,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
CTxDestination address = DecodeDestination(rec->address);
|
||||
if (IsValidDestination(address)) {
|
||||
std::string name;
|
||||
isminetype ismine;
|
||||
if (wallet.getAddress(address, &name, &ismine, /* purpose= */ nullptr))
|
||||
if (wallet.getAddress(address, &name, /*purpose=*/nullptr))
|
||||
{
|
||||
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
|
||||
strHTML += "<b>" + tr("To") + ":</b> ";
|
||||
@@ -171,7 +165,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
CTxDestination dest = DecodeDestination(strAddress);
|
||||
std::string name;
|
||||
if (wallet.getAddress(
|
||||
dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && !name.empty())
|
||||
dest, &name, /*purpose=*/nullptr) && !name.empty())
|
||||
strHTML += GUIUtil::HtmlEscape(name) + " ";
|
||||
strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>";
|
||||
}
|
||||
@@ -186,7 +180,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
//
|
||||
CAmount nUnmatured = 0;
|
||||
for (const CTxOut& txout : wtx.tx->vout)
|
||||
nUnmatured += wallet.getCredit(txout, ISMINE_ALL);
|
||||
nUnmatured += wallet.getCredit(txout);
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
||||
if (status.is_in_main_chain)
|
||||
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", status.blocks_to_maturity) + ")";
|
||||
@@ -203,19 +197,10 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
}
|
||||
else
|
||||
{
|
||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||
for (const isminetype mine : wtx.txin_is_mine)
|
||||
{
|
||||
if(fAllFromMe > mine) fAllFromMe = mine;
|
||||
}
|
||||
bool all_from_me = std::all_of(wtx.txin_is_mine.begin(), wtx.txin_is_mine.end(), [](bool mine) { return mine; });
|
||||
bool all_to_me = std::all_of(wtx.txout_is_mine.begin(), wtx.txout_is_mine.end(), [](bool mine) { return mine; });
|
||||
|
||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||
for (const isminetype mine : wtx.txout_is_mine)
|
||||
{
|
||||
if(fAllToMe > mine) fAllToMe = mine;
|
||||
}
|
||||
|
||||
if (fAllFromMe)
|
||||
if (all_from_me)
|
||||
{
|
||||
// Debit
|
||||
//
|
||||
@@ -223,8 +208,8 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
for (const CTxOut& txout : wtx.tx->vout)
|
||||
{
|
||||
// Ignore change
|
||||
isminetype toSelf = *(mine++);
|
||||
if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))
|
||||
bool toSelf = *(mine++);
|
||||
if (toSelf && all_from_me)
|
||||
continue;
|
||||
|
||||
if (!wtx.value_map.count("to") || wtx.value_map["to"].empty())
|
||||
@@ -236,10 +221,10 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
strHTML += "<b>" + tr("To") + ":</b> ";
|
||||
std::string name;
|
||||
if (wallet.getAddress(
|
||||
address, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && !name.empty())
|
||||
address, &name, /*purpose=*/nullptr) && !name.empty())
|
||||
strHTML += GUIUtil::HtmlEscape(name) + " ";
|
||||
strHTML += GUIUtil::HtmlEscape(EncodeDestination(address));
|
||||
if(toSelf == ISMINE_SPENDABLE)
|
||||
if(toSelf)
|
||||
strHTML += " (" + tr("own address") + ")";
|
||||
strHTML += "<br>";
|
||||
}
|
||||
@@ -250,7 +235,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + "<br>";
|
||||
}
|
||||
|
||||
if (fAllToMe)
|
||||
if (all_to_me)
|
||||
{
|
||||
// Payment to self
|
||||
CAmount nChange = wtx.change;
|
||||
@@ -271,13 +256,13 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
auto mine = wtx.txin_is_mine.begin();
|
||||
for (const CTxIn& txin : wtx.tx->vin) {
|
||||
if (*(mine++)) {
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet.getDebit(txin, ISMINE_ALL)) + "<br>";
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet.getDebit(txin)) + "<br>";
|
||||
}
|
||||
}
|
||||
mine = wtx.txout_is_mine.begin();
|
||||
for (const CTxOut& txout : wtx.tx->vout) {
|
||||
if (*(mine++)) {
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet.getCredit(txout, ISMINE_ALL)) + "<br>";
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet.getCredit(txout)) + "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,10 +319,10 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
|
||||
for (const CTxIn& txin : wtx.tx->vin)
|
||||
if(wallet.txinIsMine(txin))
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet.getDebit(txin, ISMINE_ALL)) + "<br>";
|
||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet.getDebit(txin)) + "<br>";
|
||||
for (const CTxOut& txout : wtx.tx->vout)
|
||||
if(wallet.txoutIsMine(txout))
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet.getCredit(txout, ISMINE_ALL)) + "<br>";
|
||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet.getCredit(txout)) + "<br>";
|
||||
|
||||
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
|
||||
strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true);
|
||||
@@ -357,12 +342,12 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
if (ExtractDestination(vout.scriptPubKey, address))
|
||||
{
|
||||
std::string name;
|
||||
if (wallet.getAddress(address, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && !name.empty())
|
||||
if (wallet.getAddress(address, &name, /*purpose=*/nullptr) && !name.empty())
|
||||
strHTML += GUIUtil::HtmlEscape(name) + " ";
|
||||
strHTML += QString::fromStdString(EncodeDestination(address));
|
||||
}
|
||||
strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatHtmlWithUnit(unit, vout.nValue);
|
||||
strHTML = strHTML + " IsMine=" + (wallet.txoutIsMine(vout) & ISMINE_SPENDABLE ? tr("true") : tr("false")) + "</li>";
|
||||
strHTML = strHTML + " IsMine=" + (wallet.txoutIsMine(vout) ? tr("true") : tr("false")) + "</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,11 @@
|
||||
#include <chain.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <key_io.h>
|
||||
#include <wallet/types.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
using wallet::ISMINE_NO;
|
||||
using wallet::ISMINE_SPENDABLE;
|
||||
using wallet::isminetype;
|
||||
|
||||
/* Return positive answer if transaction should be shown in list.
|
||||
*/
|
||||
bool TransactionRecord::showTransaction()
|
||||
@@ -39,26 +34,26 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
|
||||
Txid hash = wtx.tx->GetHash();
|
||||
std::map<std::string, std::string> mapValue = wtx.value_map;
|
||||
|
||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||
bool all_from_me = true;
|
||||
bool any_from_me = false;
|
||||
if (wtx.is_coinbase) {
|
||||
fAllFromMe = ISMINE_NO;
|
||||
all_from_me = false;
|
||||
} else {
|
||||
for (const isminetype mine : wtx.txin_is_mine)
|
||||
for (const bool mine : wtx.txin_is_mine)
|
||||
{
|
||||
if(fAllFromMe > mine) fAllFromMe = mine;
|
||||
all_from_me = all_from_me && mine;
|
||||
if (mine) any_from_me = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fAllFromMe || !any_from_me) {
|
||||
if (all_from_me || !any_from_me) {
|
||||
CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
|
||||
|
||||
for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)
|
||||
{
|
||||
const CTxOut& txout = wtx.tx->vout[i];
|
||||
|
||||
if (fAllFromMe) {
|
||||
if (all_from_me) {
|
||||
// Change is only really possible if we're the sender
|
||||
// Otherwise, someone just sent bitcoins to a change address, which should be shown
|
||||
if (wtx.txout_is_change[i]) {
|
||||
@@ -97,7 +92,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
|
||||
parts.append(sub);
|
||||
}
|
||||
|
||||
isminetype mine = wtx.txout_is_mine[i];
|
||||
bool mine = wtx.txout_is_mine[i];
|
||||
if(mine)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -268,7 +268,7 @@ void WalletModel::sendCoins(WalletModelTransaction& transaction)
|
||||
// Check if we have a new address or an updated label
|
||||
std::string name;
|
||||
if (!m_wallet->getAddress(
|
||||
dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr))
|
||||
dest, &name, /*purpose=*/nullptr))
|
||||
{
|
||||
m_wallet->setAddressBook(dest, strLabel, wallet::AddressPurpose::SEND);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user