Transactions attributed to wrong address under certain conditions #689

issue Plaidxx opened this issue on December 7, 2011
  1. Plaidxx commented at 8:53 PM on December 7, 2011: none

    If you receive coins via two or more addresses in the same wallet, where the coins originate from the same sendmany transaction, the sum total of the coins will be attributed to the first receiving address and the others won't show up.

    To reproduce:

    1. Set up testnet in a box
    2. Start bitcoin-qt pointing at datadir 1 (instance 1)
    3. Start bitcoin-qt pointing at datadir 2 (instance 2)
    4. In instance 2, create 2 new receiving addresses labeled Address A and Address B
    5. In instance 1, create a new transaction sending 1 BTC to Address A. Click "Add Recipient" and add a second payment sending 2 BTC to Address B. Send the payment.
    6. In instance 2, it will display that you received 3 BTC via Address A, and Address B will not show up anywhere.
  2. Plaidxx commented at 6:59 AM on December 10, 2011: none

    I haven't had much time to look at the code, but it might be the case that CWallet::AddToWallet() is assuming that a given transaction will only ever have one payment / payment address in it (for this wallet). But when sendmany is used, any given transaction can have more than one payment to separate addresses in this wallet.

  3. laanwj commented at 4:26 PM on December 11, 2011: member

    This is because TransactionRecord::decomposeTransaction, where the bitcoin transactions are decomposed to UI transactions, handles the case where multiple outputs are "mine" by choosing one of the addresses.

                // Received by Bitcoin Address
                sub.type = TransactionRecord::RecvWithAddress;
                BOOST_FOREACH(const CTxOut& txout, wtx.vout)
                {
                    if(wallet->IsMine(txout))
                    {
                        CBitcoinAddress address;
                        if (ExtractAddress(txout.scriptPubKey, wallet, address))
                        {
                            sub.address = address.ToString();
                        }
                        break;
                    }
                }
    

    (I agree it would be better to generate multiple UI transactions in this case, one for each owned target address)

  4. laanwj referenced this in commit 754547fb9f on Feb 5, 2012
  5. laanwj referenced this in commit 69c55227e2 on Feb 5, 2012
  6. laanwj referenced this in commit cf44548c72 on Feb 5, 2012
  7. laanwj commented at 11:06 AM on February 5, 2012: member

    Can you test pull request #800?

  8. laanwj referenced this in commit 4d0b2bcf29 on Feb 6, 2012
  9. laanwj referenced this in commit ab07866c8d on Feb 6, 2012
  10. Matoking referenced this in commit 6ad44a81ee on Feb 8, 2012
  11. Matoking referenced this in commit a5a5d3c445 on Feb 8, 2012
  12. laanwj closed this on Mar 24, 2012

  13. coblee referenced this in commit ac5f7dd5be on Jul 17, 2012
  14. jpentland referenced this in commit 826cba78a5 on Feb 7, 2016
  15. jnewbery referenced this in commit 85e7d06351 on Mar 17, 2020
  16. sipa referenced this in commit 4977ac14d3 on Mar 18, 2020
  17. sipa referenced this in commit 5bf7fb5baa on Mar 18, 2020
  18. sipa referenced this in commit fb2a05e468 on Mar 19, 2020
  19. sipa referenced this in commit 497fad6f09 on Mar 21, 2020
  20. sipa referenced this in commit eae016f117 on Mar 22, 2020
  21. sipa referenced this in commit 4e37a7c2cb on Mar 27, 2020
  22. jnewbery referenced this in commit 9696dea839 on Apr 16, 2020
  23. jnewbery referenced this in commit a541fd0e87 on Apr 19, 2020
  24. sipa referenced this in commit c308759ea5 on Apr 19, 2020
  25. sipa referenced this in commit 4eaec32f1c on May 2, 2020
  26. sipa referenced this in commit ef7117193c on May 22, 2020
  27. sipa referenced this in commit 67f232b5d8 on Jun 9, 2020
  28. stackman27 referenced this in commit 78cde6f8c7 on Jun 26, 2020
  29. MarcoFalke locked this on Sep 8, 2021
  30. hebasto referenced this in commit ff26406b2b on Mar 27, 2023
Contributors
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me