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

too many new addresses created receiving split transaction #302

Open
dooglus opened this issue Jan 18, 2017 · 1 comment
Open

too many new addresses created receiving split transaction #302

dooglus opened this issue Jan 18, 2017 · 1 comment

Comments

@dooglus
Copy link
Collaborator

dooglus commented Jan 18, 2017

I just made a new wallet and deliberately set the keypool to be small, since I'll only be using it for staking. I put this in clam.conf:

keypool=10

Then I sent some coins to the wallet. I split the coins into 99 separate outputs, all going to the same address. When the transaction was received I saw this in the wallet's debug.log:

2017-01-18 06:55:49 AddToWallet 062cca235a943d88d4e4a49b4007f50195071e012242f5d3a01813376961a201  new
2017-01-18 06:55:50 keypool added key 12, size=11
2017-01-18 06:55:50 keypool reserve 2
2017-01-18 06:55:50 keypool keep 2
2017-01-18 06:55:50 keypool added key 13, size=11
2017-01-18 06:55:50 keypool reserve 3
2017-01-18 06:55:50 keypool keep 3
2017-01-18 06:55:50 keypool added key 14, size=11
2017-01-18 06:55:50 keypool reserve 4
2017-01-18 06:55:50 keypool keep 4
[...]
2017-01-18 06:56:18 keypool added key 108, size=11
2017-01-18 06:56:18 keypool reserve 98
2017-01-18 06:56:18 keypool keep 98
2017-01-18 06:56:19 keypool added key 109, size=11
2017-01-18 06:56:19 keypool reserve 99
2017-01-18 06:56:19 keypool keep 99
2017-01-18 06:56:19 keypool added key 110, size=11
2017-01-18 06:56:19 keypool reserve 100
2017-01-18 06:56:19 keypool keep 100

ie. it looks like it created 99 new addresses in the wallet. I understand that the wallet wants to create a new receiving address when the previous one was used, but it shouldn't be creating more than one of them since only one address was used.

Edit: I should mention that this was using the unreleased code on the master branch, with the 'reindex' fixes, etc.

@dooglus
Copy link
Collaborator Author

dooglus commented Jan 18, 2017

In wallet.cpp:

    if (!fHaveGUI) {
        // If default receiving address gets used, replace it with a new one
        if (vchDefaultKey.IsValid()) {
            CScript scriptDefaultKey;
            scriptDefaultKey.SetDestination(vchDefaultKey.GetID());
            BOOST_FOREACH(const CTxOut& txout, wtx.vout)
            {
                if (txout.scriptPubKey == scriptDefaultKey)
                {
                    CPubKey newDefaultKey;
                    if (GetKeyFromPool(newDefaultKey))
                    {
                        SetDefaultKey(newDefaultKey);
                        SetAddressBookName(vchDefaultKey.GetID(), "");
                    }
                }
            }
        }
    }

So if we were to break; after SetAddressBookName() that would fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant