Multibit-Legacy / multibit-hd

Deprecated Bitcoin Wallet
https://multibit.org/blog/2017/07/26/multibit-shutdown.html
Other
169 stars 124 forks source link

Negative values in EmptyWallet internals #867

Closed jim618 closed 8 years ago

jim618 commented 8 years ago
error report uploaded. Id: 9e81740

MultiBit HD version: 0.2.0
Operating system: 32 6.1 Windows 7

No user notes

Number of stack traces: 1
First stack trace:
java.lang.IllegalArgumentException: Negative values not allowed
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:125) ~[multibit-hd.jar:na]
    at org.bitcoinj.core.TransactionOutput.<init>(TransactionOutput.java:106) ~[multibit-hd.jar:na]
    at org.bitcoinj.core.TransactionOutput.<init>(TransactionOutput.java:90) ~[multibit-hd.jar:na]
    at org.bitcoinj.core.Transaction.addOutput(Transaction.java:828) ~[multibit-hd.jar:na]
    at org.bitcoinj.core.Wallet$SendRequest.to(Wallet.java:3396) ~[multibit-hd.jar:na]
    at org.multibit.hd.core.services.BitcoinNetworkService.appendSendRequest(BitcoinNetworkService.java:749) ~[multibit-hd.jar:na]
    at org.multibit.hd.core.services.BitcoinNetworkService.prepareTransaction(BitcoinNetworkService.java:968) ~[multibit-hd.jar:na]
    at org.multibit.hd.ui.views.wizards.empty_wallet.EmptyWalletWizardModel.prepareTransaction(EmptyWalletWizardModel.java:293) ~[multibit-hd.jar:na]
    at org.multibit.hd.ui.views.wizards.empty_wallet.EmptyWalletWizardModel.showNext(EmptyWalletWizardModel.java:118) ~[multibit-hd.jar:na]
jim618 commented 8 years ago

This IllegalArgumentException is most likely caused by the check in TransactionOutput that the amount if >=0 (note the equality check). In EmptyWalletWizardModel a value of zero is set if no amount is available.

I have added a check into EmptyWalletWizardModel.prepareTransaction so that an event is thrown if there is no bitcoin in the wallet and the prepareWallet fails. This should traverse the user to the report screen. I couldn't replicate this error so this is a probabilistic fix.

Awaiting review and closing

jim618 commented 8 years ago

Pushed a change to fix an NPE in the event creation.

If you now try to empty an already empty wallet you now get this screenshot:

screen shot 2016-03-02 at 16 22 01

Awaiting review and closing

gary-rowe commented 8 years ago

Verified working. Closing.