Commit Graph

1013 Commits

Author SHA1 Message Date
Christoph Atteneder
5f51af4866
Bump version number for v1.2.6 2020-02-06 11:55:08 +01:00
sqrrm
6a9f340c20
Trade process refresh (#3922)
* Add keyboard shortcut for trade process refresh, fix #3905

Trades have been getting stuck in the `Wait for payment` state, perhaps
due to lost mailbox messages, but it's hard to know for sure. There is
currently no way to get out of this state except going to mediation.

With ctrl+R the seller can ask the buyer to refresh the current trade
state and the buyer will resend the
`CounterCurrencyTransferStartedMessage` if they are in the phase
FIAT_SENT.

* Disallow more than one trade refresh per day

* Add refresh button for seller step 2, fix #3905

A seller can ask to refresh the trade process once every 24 hours. This
step has been a problem causing a lot of mediation lately so this is a
way to ask the buyer to resend the CounterCurrencyTransferStartedMessage

This fixes the problem when a mailbox message was lost. To test the
seller need to not get the first CounterCurrencyTransferStartedMessage
sent by the buyer, for example by letting the seednode drop it instead
of sending to the seller. When button is pressed
- a RefreshTradeStateRequest is sent from seller to buyer
- the buyer receives the RefreshTradeStateRequest and
 - ignores it if it's not in FIAT_SENT phase
 - responds with a CounterCurrencyTransferStartedMessage if in FIAT_SENT
   phase and has already sent a CounterCurrencyTransferStartedMessage

* Fix codacy remarks

Move incoming message handling method to the right section

* Add refresh button info text

Hide refresh section when not available rather than graying out

Added info text:
Sometimes P2P network messages acknowledging payment are not delivered,
causing trades to get stuck. Hit the button below to make your peer
resend the last message.

* Fix codacy issues
2020-02-04 15:54:47 +01:00
sqrrm
afac8e5a30
Add dumpDelayedPayoutTxs config option 2020-01-30 15:40:23 +01:00
Christoph Atteneder
4243236107
Merge pull request #3909 from stejbac/fix-silent-sound-player-resource-leak
Fix potential resource leak in AvoidStandbyModeService
2020-01-27 15:51:11 +01:00
Christoph Atteneder
a29d4903a6
Merge pull request #3890 from dmos62/dao-facts-and-figures-outlier-resistance
Improve readability of the daily burnt BSQ chart
2020-01-23 15:18:46 +01:00
Christoph Atteneder
c403ee7723
Minor code cleanups 2020-01-22 11:34:15 +01:00
Steven Barclay
a073dbf13b
Fix potential resource leak in AvoidStandbyModeService
Replace tail recursion of the play() method with an ordinary loop, to
prevent a new open JAR resource InputStream + sound file OutputStream
(which were created every 4 minute playback) from accumulating on the
stack, closing them inside the loop instead. (This also prevents
eventual stack overflow.)

Also tidy up FileUtil.resourceToFile and put the JAR URL InputStream in
a try-with-resources block, to ensure that it doesn't leak either.
2020-01-22 10:01:34 +00:00
Chris Beams
dd5690fe2a
Fix code quality issues
Per Codacy report at
https://app.codacy.com/gh/bisq-network/bisq/pullRequest?prid=4835062

Note that the items claiming that bisq.common.config.Config.* is an
unused import are false positives. These imports are in fact used in
every case.
2020-01-20 16:47:54 +01:00
Chris Beams
37b669c710
Make Config option fields public and inline accessors
See updated Config Javadoc for rationale.
2020-01-20 16:47:54 +01:00
Chris Beams
4ac46e4717
Reorder a few of the most important options
There is currently no explicit rule for how option-related elements are
ordered in the code, but it is important to understand that the order in
which options are registered via parser.accept() calls is the order in
which they appear in --help output.

It would be nice to group options together into sections and separate
them in the --help output with section headers similar to the way that
Bitcoin Core's help output does it, but this is not a built-in option
with the JOpt Simple library, and not worth trying to hack into place at
the moment.
2020-01-20 16:47:53 +01:00
Chris Beams
d5abc97b04
Document Config and related types 2020-01-20 16:47:53 +01:00
Chris Beams
fe506098af
Introduce Config testing facilities
Previously ConfigTests constructed Config instances with string-based
options, e.g.:

    Config config = new Config("--appName=My-Bisq");

The advantage here is clarity, but the downside is repetition of the
option names without any reference to their corresponding Config.*
constants.

One solution to the problem would be to format the option strings using
constants declared in the Config class, e.g.:

    Config config = new Config(format("--%s=My-Bisq", APP_NAME));

but this is verbose, cumbersome to read and write and requires repeating
he '--' and '=' option syntax.

This commit introduces the Opt class and the opt() and configWithOpts()
methods to ConfigTests to make testing easier while using constant
references and preserving readability. e.g.:

    Config config = configWithOpts(opt(APP_NAME, "My-Bisq"));

In the process of making these changes a bug was discovered in the
monitor submodule's P2PNetworkLoad class and that has been fixed here as
well.

This change also required introducing several option name constants that
had not previously been extracted in order to be referenced within
ConfigTests. For consistency and completeness, all additional option
names that did not previously have a contstant now have one.
2020-01-20 16:47:53 +01:00
Chris Beams
63489c13f2
Throw if --configFile value does not exist
Previously (as of the prior commit), a warning was issued if a
non-default config file path was specified at the command line, and then
the default config file path was used as a fallback. On review, however,
it would be better to halt execution immediately if the config file does
not exist. There is no risk of breaking backward compatibility by doing
this as Bisq never had a --configFile option before the recent commits
that introduce it. Furthermore, there is no clear benefit to the
fallback approach. If the user specifies a given config file and it does
not exist, they may not see the warning message in the log, and they may
be left with the impression that they are running against their custom
config file when in fact they are running against the default (which may
be empty or non-existent itself). Thus throwing an exception as is now
done in this commit should make everything more explicit and clear.
2020-01-20 16:47:53 +01:00
Chris Beams
3d991e009a
Qualify relative --configFile value with appDataDir
This behavior had already been implemented prior to this commit, but has
now been tested and improved with refactoring and logging messages.

Note that this approach emulates Bitcoin Core's own behavior. When
running, for example, `bitcoind -conf=rel/path/to/bitcoin.conf`, the
relative path is prefixed / fully qualified by the value of the
`datadir` option. So if `datadir` equals `~/Library/Application
Support/Bitcoin`, then the `conf` option value above would be fully
qualified as

    ~/Library/Application Support/Bitcoin/rel/path/to/bitcoin.conf

If the argument to `-conf` is an absolute path, e.g.
`/tmp/bitcoin.conf`, then that absolute path is used without further
modification or qualification. It is assumed that the rationale for this
behavior is to avoid accidentally running against the wrong conf file
because `bitcoind` was invoked in a different directory than usual or
because a malicious actor replaced the relative conf file with their own
version.

Bisq's new `--configFile` option works (and is now tested to work) in
the same way: relative paths get prefixed by the value of
Config.getAppDataDir(), and absolute paths are processed unmodified.
2020-01-20 16:47:52 +01:00
Chris Beams
e1f54e95b1
Rename and reorder test for nonexistent --configFile
This test is now named consintently and sorted next to other config file
tests.
2020-01-20 16:47:52 +01:00
Chris Beams
94603768cb
Move Config.getOsUserDataDir to BisqExecutable.osUserDataDir
This method is used only by BisqExecutable and so has been moved there,
made private and documented accordingly.
2020-01-20 16:47:52 +01:00
Chris Beams
876b91e1be
Introduce LocalBitcoinNode and tests
This new class encapsulates all functionality related to detecting a
local Bitcoin node and reporting whether or not it was detected.
Previously this functionality was spread across the Config class
(formerly BisqEnvironment) with its mutable static
isLocalBitcoinNodeRunning property and the BisqSetup class with its
checkIfLocalHostNodeIsRunning method. All of this functionality now
lives within the LocalBitcoinNode class, an instance of which is wired
up via Guice and injected wherever necessary.

Note that the code for detecting whether the node is running has been
simplified, in that it is no longer wrapped in its own dedicated Thread.
There appears to be no performance benefit from doing so, and leaving it
in place would have made testing more difficult than necessary.

Several methods in BisqSetup have also been refactored to accept
callbacks indicating which step should be run next. This has the effect
of clarifying when the step2()-step5() methods will be called.
2020-01-20 16:47:52 +01:00
Chris Beams
4ea3290608
Introduce and document static Config.appDataDir()
See Javadoc added in this change and the previous commit message for
further detail and context.
2020-01-20 16:46:58 +01:00
Chris Beams
42a037e19f
Introduce and document static Config.baseCurrencyNetwork()
Previously this static property had been managed within
BaseCurrencyNetwork itself and was accessed directly by callers. Now it
is managed within Config, made private and accessed only via the
new and well-documented baseCurrencyNetwork() method. The same goes for
baseCurrencyNetworkParameters().

It is unfortunate that we must retain these mutable static fields and
accessors, but after trying to eliminate them entirely, this approach is
the lesser of two evils; attempting to use a Config instance and
instance methods only ends up being quite cumbersome to implement,
requiring Config to be injected into many more classes than it currently
is. Getting access to the BaseCurrencyNetwork is basically a special
case, and treating it specially as a static field is in the end the most
pragmatic approach.
2020-01-20 16:46:58 +01:00
Chris Beams
3a6b0ce9d8
Normalize creation of appDataDir and subdirs
Prior to this commit, the way that the appDataDir and its subdirectories
were created was a haphazard process that worked but in a fragile and
non-obvious way. When Config was instantiated, an attempt to call
btcNetworkDir.mkdir() was made, but if appDataDir did not already exist,
this call would always fail because mkdir() does not create parent
directories. This problem was never detected, though, because the
KeyStorage class happened to call mkdirs() on its 'keys' subdirectory,
which, because of the plural mkdirs() call ended up creating the whole
${appDataDir}/${btcNetworkDir}/keys hierarchy. Other btcNetworkDir
subdirectories such as tor/ and db/ then benefited from the hierarchy
already existing when they attempted to call mkdir() for their own dirs.
So the whole arrangement worked only because KeyStorage happened to make
a mkdirs() call and because that code in KeyStorage happened to get
invoked before the code that managed the other subdirectories.

This change ensures that appDataDir and all its subdirectories are
created up front, such that they are guaranteed to exist by the time
they are injected into Storage, KeyStorage, WalletsSetup and TorSetup.
The hierarchy is unchanged, structured as it always has been:

    ${appDataDir}
    └── btc_mainnet
        ├── db
        ├── keys
        ├── wallet
        └── tor

Note that the tor/ subdirectory actually gets deleted and re-created
within the TorSetup infrastructure regardless of whether the directory
exists beforehand.
2020-01-20 16:46:57 +01:00
Chris Beams
174d2a98e6
Add comments to Config and reorder a few things
This adds a few basic comments to help understand the structure of the
Config class and also reorders several assignments and statements for
clarity.
2020-01-20 16:46:57 +01:00
Chris Beams
a02eea9410
Extract Config.APP_DATA_DIR constant 2020-01-20 16:46:57 +01:00
Chris Beams
e67746b0a4
Remove TestConfig in favor of reworked Config ctors 2020-01-20 16:46:57 +01:00
Chris Beams
47794174a1
Remove ConnectionConfig console output 2020-01-20 16:46:57 +01:00
Chris Beams
b5503a5aa4
Replace HelpRequested exception with Config.isHelpRequested() 2020-01-20 16:46:57 +01:00
Chris Beams
3f605f873f
Remove now unused BisqExecutable option handling
Option handling is now the responsibility of the Config class. JOpt's
OptionParser is no longer passed down to BisqExecutable subclasses'
doExecute method, as they can now rely on the Config abstraction.
2020-01-20 16:46:56 +01:00
Chris Beams
7382344618
Catch ConfigException as contingency, Throwble as fault
Previously the code under bisq.common.config threw a mix of
ConfigException and IllegalArgumentException. It now throws
ConfigException consistently such that it may be caught and dealt with
as an anticipated contingency, and such that any other Throwable may be
caught and dealt with as a fault, i.e. an unexpected error that probably
represents a bug in the code.

The https://bisq.network/issues link presented to the user when a fault
occurs is a redirect added to the website by PR
https://github.com/bisq-network/bisq-website/pull/316.

For background on contingency vs. fault nomenclature, see:
https://www.oracle.com/technical-resources/articles/enterprise-architecture/effective-exceptions-part3.html
2020-01-20 16:46:56 +01:00
Chris Beams
022b5f1908
Make ConfigException extend BisqException
To avoid the need to manually use String.format during construction.
2020-01-20 16:46:56 +01:00
Chris Beams
75ab51de1a
Replace use of Spring's StringUtils 2020-01-20 16:41:20 +01:00
Chris Beams
2c7829948b
Replace uses of Spring CollectionUtils
See Javadoc in new bisq.common.util.CollectionUtils class.
2020-01-20 16:41:19 +01:00
Chris Beams
f5a1854762
Remove now unused BisqEnvironment class
In previous commits, BisqEnvironment functionality has been fully ported
to the new, simpler and more type-safe Config class. This change removes
BisqEnvironment and all dependencies on the Spring Framework Environment
interface that it implements.

The one exception is the pricenode module, which is separate and apart
from the rest of the codebase in that it is a standalone, Spring-based
HTTP service.
2020-01-20 16:41:19 +01:00
Chris Beams
15c492b5b4
Finish moving 'daoActivated' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
aadf7c76aa
Move 'genesisTotalSupply' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
ca5b260806
Move 'genesisBlockHeight' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
6ea146444f
Move 'genesisTxId' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
519259b752
Move 'fullDaoNode' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
2995bc27bd
Move 'dumpBlockchainData' option handling to Config 2020-01-20 16:40:31 +01:00
Chris Beams
9a7eedb250
Move 'rpcBlockNotificationHost' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
3841e6b1dd
Move 'rpcBlockNotificationPort' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
86e1ae1008
Move 'rpcPort' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
182f472394
Move 'rpcHost' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
b4d4ca4fbe
Move 'rpcPassword' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
80754ed3d5
Move 'rpcUser' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
99cf8c9596
Move 'numConnectionsForBtc' option handling to Config
Note that this change makes the user-facing change of renaming
the 'numConnectionForBtc' (singular 'Connection') to
'numConnectionsForBtc' (plural 'Connections'). It is presumed that not
many users are relying on this option for day-to-day operations, and the
singular version was pretty clearly a typo / oversight.
2020-01-20 16:40:29 +01:00
Chris Beams
c8d739ded5
Move 'userAgent' option handling to Config 2020-01-20 16:39:36 +01:00
Chris Beams
97cafaf61e
Move 'useAllProvidedNodes' option handling to Config 2020-01-20 16:39:35 +01:00
Chris Beams
b7889dd994
Move 'socks5DiscoverMode' option handling to Config 2020-01-20 16:39:35 +01:00
Chris Beams
90031543b9
Move 'useTorForBtc' option handling to Config 2020-01-20 16:39:35 +01:00
Chris Beams
5271d4d574
Move 'btcNodes' option handling to Config 2020-01-20 16:39:35 +01:00
Chris Beams
4fb60a33ac
Finish moving 'ignoreLocalBtcNode' option handling to Config 2020-01-20 16:39:35 +01:00