Added address reuse key 'au' to destdata
Added informative QMessageBox popup warning when user attempts address reuse
Added address reuse key 'au' to destdata
Added informative QMessageBox popup warning when user attempts address reuse
Added address reuse key 'au' to destdata
Added informative QMessageBox popup warning when user attempts address reuse
262 | @@ -263,6 +263,27 @@ void SendCoinsDialog::on_sendButton_clicked() 263 | QStringList formatted; 264 | Q_FOREACH(const SendCoinsRecipient &rcp, currentTransaction.getRecipients()) 265 | { 266 | + // If user is attempting address reuse, show an informative warning 267 | + if (model->isUsed(rcp.address.toStdString())) 268 | + { 269 | + QString reuseWarningText = tr( 270 | + "You have sent to the Bitcoin address %1 already!\n\n" 271 | + "Sending to the same address twice is technically not supported and "
I think the part technically not supported is not correct.
Indeed, it is supported fine, but it is highly discouraged.
It would not be a bug to stop scanning for transactions paying to an address once it has been used. It "works" only by accident.
270 | + "You have sent to the Bitcoin address %1 already!\n\n" 271 | + "Sending to the same address twice is technically not supported and " 272 | + "will reduce your own security as well as the privacy of all Bitcoin users." 273 | + ).arg(rcp.address) + "\n"; 274 | + 275 | + QMessageBox reuseMessage("Warning: address reuse!",
I can't find this constructor in the Qt docs...
273 | + ).arg(rcp.address) + "\n"; 274 | + 275 | + QMessageBox reuseMessage("Warning: address reuse!", 276 | + reuseWarningText, 277 | + QMessageBox::Warning, 278 | + QMessageBox::Yes | QMessageBox::Escape,
Yes | Escape doesn't look like a normal combination?
354 | @@ -355,6 +355,9 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran 355 | 356 | std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest); 357 | 358 | + std::string key = "au"; // "au" prefix = "address used" in destdata
"used" seems more straightforward, but more importantly, this should be moved to a static const in a src/wallet/ header.
593 | @@ -591,6 +594,24 @@ bool WalletModel::isSpent(const COutPoint& outpoint) const 594 | return wallet->IsSpent(outpoint.hash, outpoint.n); 595 | } 596 | 597 | +bool WalletModel::isUsed(const std::string& address) const 598 | +{ 599 | + LOCK2(cs_main, wallet->cs_wallet); 600 | + for (const std::pair<CTxDestination, CAddressBookData>& item : wallet->mapAddressBook)
Instead of looping, would a std::map::find be possible (std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);?
General concept ACK. Am I correct that this patch does not warn for "send-agains" to addresses sent before this patch was active?
Agree that the "technically not supported" is confusing to users. We should just mention "is (highly) discouraged".
Making another update, but in the meantime, I changed the warning message because if there is confusion even here then it needs to be more clear. I also updated the message box code so that it isn't using an obsolete constructor and removed the extra escape.
This warning will only be displayed for addresses which are used after the software has been updated. It would be possible though for someone to add an update later that would scan through the wallet transactions and mark the destinations of those as used. Also the wallet already had a function to read the destdata by using std::map find, but it wasn't being used anywhere as far as I can tell. I replaced the loop with that.
I am going to go through some tests now, but everything is ready to be reviewed again.
Alright I'm happy with the code. Anyone have a problem with the updated warning message?
Code looks good to me. I dislike the "1", but I guess this is just how we have to do it with the flexible per wtx map.
Though I'm unsure about the update path of this feature. If we only mark new destinations, this may result in a false awareness of address reuse because some addresses you may reuse (the old ones before the upgrade) won't show the warning and users may think it's okay to reuse them.
A solution would be, to either A) loop through the transactions that where made before the feature was active or to B) migrate at first start with the new feature (loop through all wtxs, set the used dest data.
I'd like to hear more opinions on that.
I'd prefer B, but it would only allow one reuse before it'd get flagged, right?
Yeah the way it works right now, and with B, the code will only allow tagging on first use. I'm fine switching to B or whatever makes it more clear but 1 = true made sense to me.
On Feb 10, 2017 1:07 AM, "Luke Dashjr" notifications@github.com wrote:
I'd prefer B, but it would only allow one reuse before it'd get flagged, right?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/9722#issuecomment-278892806, or mute the thread https://github.com/notifications/unsubscribe-auth/AHu1NptENp_ak43bJO0zlnipHctySWBlks5rbCjVgaJpZM4L6ce2 .
Any intentions to work this towards the solution "B" (migrate at first start with the new feature (loop through all wtxs, set the used dest data.)?
Yes, I was just waiting for some feedback on that before I went ahead and added the code. Since I think it's a good idea and nobody seems to take issue I'll finish this up next time I have a break.
On Mar 17, 2017 6:47 AM, "Jonas Schnelli" notifications@github.com wrote:
Any intentions to work this towards the solution "B" (migrate at first start with the new feature (loop through all wtxs, set the used dest data.)?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/9722#issuecomment-287357677, or mute the thread https://github.com/notifications/unsubscribe-auth/AHu1Nm20_a6Eq_-MxgEfKp5zebvJ9MU2ks5rmo7ggaJpZM4L6ce2 .
Closing due to inactivity (feel free to reopen once someone takle option B or there is consensus about doing solution A).