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

Coin Control #1359

Closed
wants to merge 1 commit into from
Closed

Coin Control #1359

wants to merge 1 commit into from

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented May 19, 2012

Superceding #1017 since @dooglus isn't rebasing it anymore. Also sanitized JSON-RPC changes and did some other cleanup. (#1416 has the coin selection refactoring)

@@ -699,4 +746,28 @@ class CAccountingEntry

bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut);


template<typename T>
class CScopedSendFromAddressRestriction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bah!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more elaborate: why is the coin selection a property of CWallet being set and unset? It should just be passed to the coin selection functions.

@gmaxwell
Copy link
Contributor

I've started testing this some— I think that after some more review (and perhaps some minor cleanups) we should pull this. I've long supported having it— there are some use-cases where it's handy and it fosters a deeper understanding of the Bitcoin system

At the same time I'm concerned that it's quite rough from an interface perspective (the multiselect on another tab driving a text field with undisclosed syntax), and from a core feature set perspective (doesn't appear to be a way to do an inverted select "except theses")… but continuing to forestall pulling this is not going to encourage further development and testing.

So I think after this gets through a bit more review we should pull it and then make it known that if we don't see testing and improvement on it before 0.7.0's release that we'll disable it.

@sipa
Copy link
Member

sipa commented May 19, 2012

I certainly agree we need to have this merged. I think the functionality it adds is limited (it feels like micro-management where more high-level constructions should be used instead), but its educational value is very high. It helps breaking the "bitcoin-transactions-as-a-ledger" abstraction (without txins/txouts/change/keys/blocks) for those who want to learn the inner workings (and at least for us, we all had to learn the inner workings before we trusted the system, no?)

That said - and I should probably have noticed this earlier - I really don't like the coinselection being a CWallet property.

@Diapolo
Copy link

Diapolo commented May 19, 2012

Is this UI-wise harmonized with other used dialogs (e.g. add as many settings as possible into the XML-file and remove code)?

@gmaxwell
Copy link
Contributor

From reports in #bitcoin, it sounds like you just get a Transaction Failed when fees are required when the inputs selected don't have enough coin to pay the fee. (e.g. no fee request dialog or anything). This is a little confusing and should be fixed eventually.

@luke-jr
Copy link
Member Author

luke-jr commented Jun 4, 2012

Rebased on top of #1416 to split Coin Control from selection refactoring.

@dooglus
Copy link
Contributor

dooglus commented Jun 4, 2012

Thanks Luke. Sorry I wasn't able to do that for you.

@ghost
Copy link

ghost commented Jun 8, 2012

I was having trouble using this fork with the bitcoinrpc interface. Problem was, the sendFromAddressRestriction variable in cwallet was never getting set, so I would specify a list of "from" addresses and the system would ignore them, processing my transaction as if I hadn't specified them.

I eventually traced the problem to this line:

CScopedSendFromAddressRestrictionstd::set<std::string >(*pwalletMain, fromAddresses);

The CScopedSendFromAddressRestriction class is constructed without a name, and so is immediately destroyed, and the class's destructor clears sendFromAddressRestriction. I changed the line to this, and now it works for me:

CScopedSendFromAddressRestrictionstd::set<std::string > myAddressRestriction(*pwalletMain, fromAddresses);

@luke-jr
Copy link
Member Author

luke-jr commented Jun 8, 2012

Good catch. Fixed.

@tril0byte
Copy link

Luke, this branch doesn't build on debian squeeze (libqt4-dev 4:4.6.3-4+squeeze1),

In file included from src/qt/sendcoinsdialog.cpp:2:
build/ui_sendcoinsdialog.h: In member function ‘void Ui_SendCoinsDialog::retranslateUi(QDialog_)’:
build/ui_sendcoinsdialog.h:167: error: ‘class QLineEdit’ has no member named ‘setPlaceholderText’
make: *_* [build/sendcoinsdialog.o] Error 1

This is the same problem I reported on coderr's branch, which was fixed on dooglus's (#1017) and seems to have reverted.
#415 (comment)

The goal is to get build/ui_sendcoinsdialog not to have this line (as dooglus's doesn't) and I don't know how:

  •    sendFrom->setPlaceholderText(QApplication::translate("SendCoinsDialog", "Restrict client to only send from these Bitcoin addresses", 0, QApplication::UnicodeUTF8));
    

@luke-jr
Copy link
Member Author

luke-jr commented Jun 15, 2012

@tril0byte That bug is in git master for now, not related to this at all.

<property name="text">
<string/>
</property>
<property name="placeholderText">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should indeed be moved to SendCoinsDialog::SendCoinsDialog() via as it's considered standard to currently not use the placeholderText property in ui-files.

#if (QT_VERSION >= 0x040700)
    /* Do not move this to the XML file, Qt before 4.7 will choke on it */
    ui->sendFrom->setPlaceholderText(tr("Restrict the client to only send from these Bitcoin addresses."));
#endif

@luke-jr
Copy link
Member Author

luke-jr commented Jun 15, 2012

@Diapolo Please post on the pullrequest (you're posting on an old commit). I don't foresee this getting merged any time soon, unless someone steps up to clean it up - including your changes. If you'd prefer, I can merge a patch you make into my branch.

@Diapolo
Copy link

Diapolo commented Jun 15, 2012

@luke-jr It seems I took a route to a dead-end ... dunno how that happened, had no beer yet ^^. If you are willing to teach me the Git magic I need to do to be able to create a patch, you're welcome :). Do I need to fork your repo and create a pull or is there another way?

@luke-jr
Copy link
Member Author

luke-jr commented Jun 15, 2012

@Diapolo

git remote add luke-jr git://gitorious.org/~Luke-Jr/bitcoin/luke-jr-bitcoin.git
git fetch luke-jr
git checkout luke-jr/coincontrol -b coincontrol
# make your changes
git commit -a
git push # however you normally do it!

Then just point me at your branch...

@Diapolo
Copy link

Diapolo commented Jun 17, 2012

luke-jr: I'm going to start here, when some of my last GUI commits get merged or final, okay?

@Diapolo
Copy link

Diapolo commented Jun 18, 2012

Thanks for the git commands, I now have that branch and can start working with :).

@@ -904,7 +927,6 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins) const
vCoins.clear();

{
LOCK(cs_wallet);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this really safely be removed? Is this change directly related to coincontrol?

@Diapolo
Copy link

Diapolo commented Jun 18, 2012

@luke-jr
Copy link
Member Author

luke-jr commented Jun 18, 2012

Rebased with @Diapolo 's changes.

@dooglus
Copy link
Contributor

dooglus commented Jun 19, 2012

Is src/qt/forms/coincontrolpage.ui meant to be in this commit?

qmake complains:
WARNING: Failure to find: src/qt/forms/coincontrolpage.ui

and make errors:
make: *** No rule to make target src/qt/forms/coincontrolpage.ui', needed bybuild/ui_coincontrolpage.h'. Stop.

@luke-jr
Copy link
Member Author

luke-jr commented Jun 19, 2012

Fixed

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

@luke-jr You merged the whole patch ;)?

@luke-jr
Copy link
Member Author

luke-jr commented Jun 19, 2012

Yes, but it doesn't work :(

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

What does not work? You did try it before merging, no?

@dooglus: Yes I added that .ui file. Anything wrong with it?

@dooglus
Copy link
Contributor

dooglus commented Jun 19, 2012

This is what I see:

Program received signal SIGSEGV, Segmentation fault.
0x081d34f4 in OptionsModel::getDisplayUnit() ()
(gdb) where
#0  0x081d34f4 in OptionsModel::getDisplayUnit() ()
#1  0x0809b429 in CoinControlPage::UpdateTable() ()
#2  0x08087113 in BitcoinGUI::gotoCoinControlPage() ()
#3  0x08260af8 in BitcoinGUI::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

Is OptionsModel::getDisplayUnit() the function which starts with that seg-fault?
Did you ever set the display unit via optionsdialog before?

What happens if you comment out in coincontrolpage.cpp:

    if(model)
        unit = model->getDisplayUnit();

@dooglus
Copy link
Contributor

dooglus commented Jun 19, 2012

The .ui file didn't find its way into Luke's branch at first, but it's there now.

The display unit is set to BTC. Changing it causes the amounts shown in other tabs to change as expected.

Commenting out those 2 lines fixes the problem, and then everything seems to work.

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

@dooglus I'm glad this hot-fixes the segfault ... will have to check this in depth later. Strange thing is that does not happen for me on Windows. Thanks for testing my patch. I'm willing to bring this forward now GUI wise and perhaps we can fix the "bad" internals somehow to get this merged in the near future?

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

How can I update my local repo with the now current version?

git fetch luke-jr
git rebase luke-jr/coincontrol

Seems to generate to much merge-conflicts, so I believe there is sth. wrong.

@luke-jr
Copy link
Member Author

luke-jr commented Jun 19, 2012

This will discard all local changes and commits in your current branch and set its HEAD to latest coincontrol:

git reset --hard luke-jr/coincontrol

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

@luke-jr But this should be safe, as you merged my patch and did only some small further changes, right? When I have a new commit, how shall we proceed further?

@luke-jr
Copy link
Member Author

luke-jr commented Jun 19, 2012

I did not merge your changes unrelated to coin control. To see the difference between your current HEAD and my coincontrol, do:

git diff luke-jr/coincontrol

@Diapolo
Copy link

Diapolo commented Jun 19, 2012

@laanwj That post was purely ironic, I want all of them to be 0 to stay consistent, nothing more :).

@Diapolo
Copy link

Diapolo commented Jun 21, 2012

@luke-jr That git diff luke-jr/coincontrol doesn't help, as it's too much difference ... I regularly rebase patches to current master, but coincontrol seems to be not up to date, which makes comparing the branches very hard. My joy to push here fades away, when I don't know what you left out of my patch or changed for yourself. Things you consider unrelated (even if that may be true feature-wise) but I would like to see in that pull (or I would do when opening that pull) make things not better in the end. Any suggestion for this issue?

@luke-jr
Copy link
Member Author

luke-jr commented Jun 21, 2012

Don't put unrelated things in pulls.

Array jsonGrouping;
BOOST_FOREACH(string address, grouping)
{
Array addressInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be an object rather than an array, having trouble deserializing an array of different types. And this makes it match the output of every other command better.

        Object addressInfo;
        addressInfo.push_back(Pair("address",       address));
        addressInfo.push_back(Pair("balance",       ValueFromAmount(balances[address])));
        {
            LOCK(pwalletMain->cs_wallet);
            if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end())
                addressInfo.push_back(Pair("account",       pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second));
        }
        jsonGrouping.push_back(addressInfo);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added an option to hide the groups/addresses that have 0 balance. Might be useful for someone else as well.

Heres a diff, I haven't figured out how to use git yet. :(
http://pastebin.com/YSRxKBqx

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think every progress here is a good thing. Perhaps luke can merge your changes. Have you setup Git on your machine yet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out how to create my own repo, but not much point forking the bitcoin code, the above is about all I have to contribute.

@dooglus
Copy link
Contributor

dooglus commented Jun 25, 2012

I would like this extended to work on individual coins, if possible. Currently I can see the balance at each address, but can't tell how many separate transaction outputs each address balance corresponds to, and can't select individual outputs to spend.

I'd also like it if all the selected inputs (whether addresses or individual 'coins') were summed so I know how the value of the selected coins.

@gmaxwell
Copy link
Contributor

@dooglus I was thinking it would be interesting if it supported a hierarchy— accounts/labels / addresses / inputs, and if you could select groups at each level (e.g. select an account to get all its addresses and all their inputs, select an address to get all its inputs)— with each level showing a subtotal, and there being a total of selected. Also a 'select all', which would then let you go exclude things. But... lots of gui work to do all that.

@dooglus
Copy link
Contributor

dooglus commented Jun 25, 2012

Accounts are something different I think. There's no direct correspondence between addresses and accounts is there? It's possible to move coins from one account to another without creating a transaction.

But it could work with labels. It's possible to have the same label on multiple addresses.

@sipa
Copy link
Member

sipa commented Jun 25, 2012

Receive addresses are associated with an account. Coins that originally arrived via an address that - at the time - was associated with an account, remain associated to that account.

Splitting the available coin list based on account is dangerous I think, as it will re-enforce the notion that coins belong to an account. Splitting per destination address is fine, imho.

@gmaxwell
Copy link
Contributor

@sipa fair enough.

@luke-jr
Copy link
Member Author

luke-jr commented Jul 11, 2012

Rebased with more of @Diapolo 's GUI improvements

@dooglus
Copy link
Contributor

dooglus commented Jul 11, 2012

@luke-jr I just built your rebased version from an hour ago. The coin control tab is now lacking a scrollbar. I can scroll the contents using the right-hand edge of the touchpad (probably that's simulating a mouse's scrollwheel), but the scrollbar itself is missing. It was there the last time I built from your same branch.

I can't see what you've changed because it appears that you've overwritten the previous commit with the new one.

Remember when @Diapolo said:

"can we work with seperate commits until we are final? It's impossible to track changes when it's rebased all the time"

and you replied:

"I suppose separate commits makes sense for this one..."

and I thought that meant we'd be using separate commits for this one?

@Diapolo
Copy link

Diapolo commented Jul 11, 2012

@dooglus As I currently don't work on this (e.g. found it boring to discuss about cosmetic changes that luke refused to accept, no commits, lack of under the hood updates etc.) I can only guess, that perhaps in the UI file scrollbars are disabled?

@dooglus
Copy link
Contributor

dooglus commented Jul 11, 2012

@Diapolo It's a shame. I find it to be a useful feature to have, but after rebasing it over and over I too had to give up on it.

@Diapolo
Copy link

Diapolo commented Jul 11, 2012

@dooglus I put great efforts in improving parts of the GUI client over the last weeks, but I think it could need a few more helping hands. You are absolutely right!

@luke-jr
Copy link
Member Author

luke-jr commented Jul 11, 2012

@dooglus Yes, I see that @Diapolo 's latest changes removed the scrollbar. I'll add it back, I suppose.

As far as just adding commits, I had intended to just pull (fast-forward style) from others. Unfortunately @Diapolo did his own rebasing and merging of his old changes with his new changes, so I had to dig them out and merge them in by hand (so not even cherry-picking would work). And then there's all the completely unrelated changes that @Diapolo insists on keeping in his branch...

@Diapolo I didn't refuse any of your cosmetic changes related to Coin Control at all, until this removal of the scrollbar that I agree with @dooglus makes no sense.

…when sending, and display logical links

Hidden by default, can be enabled through display options dialog
@Diapolo
Copy link

Diapolo commented Jul 11, 2012

@luke-jr I like your feedback most of the time as coding-wise it's valuable ... but most of the time a team-play like here (where you are the master-chief of this patch currently) seems to not work. I rebase all my patches agains the current master in regular intervals, which minimizes merge-conflicts. And coding-style wise we have different points of view.

@jgarzik
Copy link
Contributor

jgarzik commented Aug 1, 2012

Consensus: we like "listaddressgroupings", and request that that be submitted in a new pull request.

The current UI, as proposed, is superceded by the raw transaction RPC API, which permits full coin control, and is accessible via the GUI RPC console.

Full discussion took place on #bitcoin-dev around ~12:30PM EDT August 1.

@jgarzik jgarzik closed this Aug 1, 2012
@rebroad
Copy link
Contributor

rebroad commented Dec 23, 2012

so.. what's happening with this? Is this the best pull to use currently for coin control?

@gmaxwell
Copy link
Contributor

It's closed. There is no current pull. Enough was merged so that you could spend unlinked inputs manually with the raw transaction API— as not a single person was willing to step up to maintain the GUI stuff.

@eldentyrell
Copy link

Enough was merged so that you could spend unlinked inputs manually with the raw transaction API

That's nice, but if the raw transaction API were a substitute for the GUI the client wouldn't have a GUI in the first place.

not a single person was willing to step up to maintain the GUI stuff

Not merging this is causing people to refuse to upgrade. Just keep that in mind.

@gmaxwell
Copy link
Contributor

gmaxwell commented Mar 4, 2013

@eldentyrell Perhaps you are interested in Pull #2343 ?

suprnurd pushed a commit to chaincoin-legacy/chaincoin that referenced this pull request Dec 5, 2017
* Only accept wd's that are more recent or have a higher hash than the current best

* Fix whitespace typo

* Relay current watchdog when lower priority ones are received

* Fix nHashWatchdogCurrent reset conditions

* expire previous current wd when a new one is found in UpdateCurrentWatchdog

* fail to process votes for expired or deleted object
lateminer pushed a commit to lateminer/bitcoin that referenced this pull request May 6, 2020
ecc6499 [Chain] Update zpiv supply in RecalculatePIVSupply (random-zebra)
9f072a9 [Bug] Always filter invalid in UpdateZPIVSupply (random-zebra)

Pull request description:

  df932b8 introduced a bug preventing resync on mainnet due to zerocoin supply recalculation missing.
  ZPIV supply recalculation shouldn't be needed in the first place, if the client is syncing from scratch and correctly filtering invalid mints.
  So, instead of restoring `RecalculateZPIVMinted`/`RecalculateZPIVSpent`, this PR does 2 things:

  - fixes `UpdateZPIVSupply` filtering the invalid mints/spends since the start of zerocoin (not only after `Zerocoin_Block_RecalculateAccumulators`). So, syncing from scratch doesn not trigger any recalculation at the next startup.

  - inserts a call to `UpdateZPIVSupply` directly in `RecalculatePIVSupply`, to be used during init, e.g. by those clients updating from old versions (with wrong supply in the index), or when using `-reindexmoneysupply`.
  This removes the additional I/O operations that were originally required with `RecalculateZPIVMinted` and `RecalculateZPIVSpent` (as blocks are already read inside `RecalculatePIVSupply`, and the relative indexes also already updated there).

ACKs for top commit:
  Fuzzbawls:
    ACK ecc6499
  furszy:
    tested ACK ecc6499

Tree-SHA512: 541b9f60425f3ff17b0b2589e43acc757a2e8385f8f96dd0a764e2f76b134a65c47324acdc482547ef59722c8c88e9f615e6caf6ffc910d8dd344b34e2850954
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants