Commit Graph

6591 Commits

Author SHA1 Message Date
jmacxx
9378fe4603
Patch from chimp1984 improving the DaoState persistence 2021-12-23 14:40:11 -06:00
Christoph Atteneder
23d1856a60
Merge pull request #5852 from ghubstan/create-swift-acct-with-api
Support and test creation of Swift accounts via API
2021-12-20 11:49:20 +01:00
KanoczTomas
dfbde480c6
Remove trailing spaces. 2021-12-18 23:41:33 +01:00
KanoczTomas
364560e348
Correct typo in list/array of nodes 2021-12-18 22:37:04 +01:00
KanoczTomas
6969ed7a84
Add @KanoczTomas btc node with onion v3 address 2021-12-14 23:58:07 +01:00
sqrrm
cf81fd451c
Merge pull request #5876 from ghubstan/5-api-bsqswap-simulation-n-docs-update
API BSQ swap simulation script and doc updates #5
2021-12-14 15:47:51 +01:00
Christoph Atteneder
a7c38630e8
Merge branch 'master' of github.com:bisq-network/bisq into release/v1.8.0
Conflicts:
	core/src/main/resources/i18n/displayStrings_pl.properties
2021-12-13 11:51:16 +01:00
chimp1984
97e4ed5a59
Revert usage of File.separator
File.separator doesn't appear to work on Windows. It has to be "/", not "\".
See: https://github.com/bisq-network/bisq/pull/5909#pullrequestreview-827992563
2021-12-09 20:07:21 +01:00
chimp1984
0f65567e1a
In case the BSQ blocks directory does not exist in resources (as in case of REG_TEST)
we do not want to log an error stacktrace but just an info message.

Use `File.separator` instead of "/"
2021-12-09 20:07:20 +01:00
chimp1984
225b78317f
Revert usage of File.separator
File.separator doesn't appear to work on Windows. It has to be "/", not "\".
See: https://github.com/bisq-network/bisq/pull/5909#pullrequestreview-827992563
2021-12-09 13:13:37 -05:00
chimp1984
d74bffb595
In case the BSQ blocks directory does not exist in resources (as in case of REG_TEST)
we do not want to log an error stacktrace but just an info message.

Use `File.separator` instead of "/"
2021-12-09 11:04:55 -05:00
Christoph Atteneder
eb074ac0e2
Merge pull request #5908 from ripcurlx/update-data-stores-for-v1.8.0-again
Update data stores for v1.8.0 (again, again)
2021-12-09 16:03:39 +01:00
chimp1984
444d045c4f
At shutdown the executor can throw a RejectedExecutionException which
is expected as we shut down the executor immediately.
If not thrown at shutdown or exception is not a RejectedExecutionException
we log a warning and re-throw the exception (to avoid change of behaviour
of current version). The exception is likely not handled by callers and goes up to
the uncaught exception handler.
2021-12-09 10:10:06 +01:00
Bisq GitHub Admin
be4cbcdcec
Merge pull request #5901 from chimp1984/handle-RejectedExecutionException-in-RpcService
Add Exception handling at RpcService
2021-12-09 10:09:24 +01:00
Steven Barclay
e07c7b5d4b
Fix BSQ blocks resync from resources on Windows & Linux
Prevent a "URI is not hierarchical" IllegalArgumentException from the
expression, 'new File(dirUrl.toURI())', which occurs on Linux & Windows
when listing the resource directory of BSQ blocks. Adapt a solution from
StackOverflow which uses two separate code paths depending on the
environment, into the new method 'FileUtil::listResourceDirectory'.

The issue is caused by the resource URL taking one of the two forms:

  file:/Users/[USER]/Java/bisq/bisq/p2p/out/production/resources/BsqBlocks_BTC_MAINNET
  jar:file:...p2p.jar!/BsqBlocks_BTC_MAINNET

depending on whether the system is OSX or not.
2021-12-09 09:52:30 +01:00
Christoph Atteneder
601163eeb3
Merge pull request #5900 from stejbac/fix-resync-blocks-from-resources
Fix resync BSQ blocks from resources
2021-12-09 09:51:51 +01:00
Christoph Atteneder
7d66264453
Update data stores for v1.8.0 (again, again) 2021-12-08 21:13:21 +01:00
chimp1984
81d112bdf3
Add null checks
Return early at connection if stopped
Cleanup logs
2021-12-08 19:39:37 +01:00
chimp1984
ee1371276f
Reduce timeouts
Add logs when shutdown starts
2021-12-08 19:39:37 +01:00
chimp1984
d5d60b59cc
Extract duplicated code at shutdown
Move timeout before shutdown sequence starts and use a Timer thread instead of
UserThread to avoid that in case the UserThread gets blocked that the timeout
would not get triggered.
Reduce timeout from 20 sec. to 10 sec.
2021-12-08 19:39:37 +01:00
Christoph Atteneder
ff3809713b
Merge pull request #5905 from chimp1984/improve_shutdown_process
Improve shutdown process
2021-12-08 19:39:22 +01:00
chimp1984
32cd812744
Increase trade protocol timeout from 60 sec to 120 sec 2021-12-08 19:37:41 +01:00
chimp1984
3d40b3bf29
Add null checks
Return early at connection if stopped
Cleanup logs
2021-12-07 21:07:40 -05:00
chimp1984
2474e0daf9
Reduce timeouts
Add logs when shutdown starts
2021-12-07 20:45:02 -05:00
chimp1984
4eb14fb226
Extract duplicated code at shutdown
Move timeout before shutdown sequence starts and use a Timer thread instead of
UserThread to avoid that in case the UserThread gets blocked that the timeout
would not get triggered.
Reduce timeout from 20 sec. to 10 sec.
2021-12-07 20:42:53 -05:00
chimp1984
b5b7e86323
Increase trade protocol timeout from 60 sec to 120 sec 2021-12-07 19:39:22 -05:00
chimp1984
e85e46cb13
At shutdown the executor can throw a RejectedExecutionException which
is expected as we shut down the executor immediately.
If not thrown at shutdown or exception is not a RejectedExecutionException
we log a warning and re-throw the exception (to avoid change of behaviour
of current version). The exception is likely not handled by callers and goes up to
the uncaught exception handler.
2021-12-07 09:58:11 -05:00
Steven Barclay
ec58b26657
Fix BSQ blocks resync from resources on Windows & Linux
Prevent a "URI is not hierarchical" IllegalArgumentException from the
expression, 'new File(dirUrl.toURI())', which occurs on Linux & Windows
when listing the resource directory of BSQ blocks. Adapt a solution from
StackOverflow which uses two separate code paths depending on the
environment, into the new method 'FileUtil::listResourceDirectory'.

The issue is caused by the resource URL taking one of the two forms:

  file:/Users/[USER]/Java/bisq/bisq/p2p/out/production/resources/BsqBlocks_BTC_MAINNET
  jar:file:...p2p.jar!/BsqBlocks_BTC_MAINNET

depending on whether the system is OSX or not.
2021-12-07 11:48:07 +00:00
Christoph Atteneder
75ca2faeb2
Update translations for v1.8.0 (again) 2021-12-07 11:12:29 +01:00
Christoph Atteneder
ed1dac715b
Add missing import 2021-12-07 10:01:24 +01:00
Christoph Atteneder
ce541f6401
Add missing import 2021-12-07 09:51:54 +01:00
Christoph Atteneder
d39820bbcd
Apply suggestions and fix edge case when BSQ legacy payment account offer is duplicated 2021-12-07 09:41:41 +01:00
Christoph Atteneder
f41203858c
Add visual icon for duplicate offer functionality 2021-12-07 09:41:41 +01:00
Christoph Atteneder
4d1ee3fc9b
Add support to duplicate bsq swap offers 2021-12-07 09:41:40 +01:00
Bisq GitHub Admin
5041dc57ef
Merge pull request #5886 from ripcurlx/add-bsq-swap-duplicate-offer-support
Add support to duplicate BSQ swap offers
2021-12-07 09:41:10 +01:00
Steven Barclay
ceb9b9acbd
Code cleanup: proto fields, duplicated expr & null char separator
1. Reorder the PoW fields in the 'Filter' proto by field index, instead
 of contextually.
2. Deduplicate expression for 'pow' & replace if-block with boolean op
 to simplify 'FilterManager::isProofOfWorkValid'.
3. Avoid slightly confusing use of null char as a separator to prevent
 hashing collisions in 'EquihashProofOfWorkService::getChallenge'. Use
 comma separator and escape the 'itemId' & 'ownerId' arguments instead.

(based on PR #5858 review comments)
2021-12-07 09:35:45 +01:00
Steven Barclay
92209c3ed7
Inline predicates to simplify HashCashService & FilterManager
Remove all the 'challengeValidation', 'difficultyValidation' and
'testDifficulty' BiPredicate method params from 'HashCashService' &
'ProofOfWorkService', to simplify the API. These were originally
included to aid testing, but turned out to be unnecessary.

Patches committed on behalf of @chimp1984.
2021-12-07 09:35:45 +01:00
Steven Barclay
772cd74ab2
Store difficulty as floating point in Filter & PoW
Change the type of the 'difficulty' field in the Filter & ProofOfWork
proto objects from int32/bytes to double and make it use a linear scale,
in place of the original logarithmic scale which counts the (effective)
number of required zeros.

This allows fine-grained difficulty control for Equihash, though for
Hashcash it simply rounds up to the nearest power of 2 internally.

NOTE: This is a breaking change to PoW & filter serialisation (unlike
the earlier PR commits), as the proto field version nums aren't updated.
2021-12-07 09:35:44 +01:00
Steven Barclay
266a7ccea4
Add+enable service to mint/verify Equihash proofs of work
Add an abstract base class, 'ProofOfWorkService', for the existing PoW
implementation 'HashCashService' and a new 'EquihashProofOfWorkService'
PoW implementation based on Equihash-90-5 (which has 72 byte solutions &
5-10 MB peak memory usage). Since the current 'ProofOfWork' protobuf
object only provides a 64-bit counter field to hold the puzzle solution
(as that is all Hashcash requires), repurpose the 'payload' field to
hold the Equihash puzzle solution bytes, with the 'challenge' field
equal to the puzzle seed: the SHA256 hash of the offerId & makerAddress.

Use a difficulty scale factor of 3e-5 (derived from benchmarking) to try
to make the average Hashcash & Equihash puzzle solution times roughly
equal for any given log-difficulty/numLeadingZeros integer chosen in the
filter.

NOTE: An empty enabled-version-list in the filter defaults to Hashcash
(= version 0) only. The new Equihash-90-5 PoW scheme is version 1.
2021-12-07 09:35:44 +01:00
Steven Barclay
23252caa3b
Fix method name typo: redoProofOfWorkAndRepublish 2021-12-07 09:35:44 +01:00
Steven Barclay
c3e5dfd19e
Add PoW version(-list) fields to ProofOfWork & Filter
Add a numeric version field to the 'ProofOfWork' protobuf object, along
with a list of allowed version numbers, 'enabled_pow_versions', to the
filter. The versions are taken to be in order of preference from most to
least preferred when creating a PoW, with an empty list signifying use
of the default algorithm only (that is, version 0: Hashcash).

An explicit list is used instead of an upper & lower version bound, in
case a new PoW algorithm (or changed algorithm params) turns out to
provide worse resistance than an earlier version.

(The fields are unused for now, to be enabled in a later commit.)
2021-12-07 09:35:43 +01:00
Steven Barclay
484afbc522
Code cleanup: replace (Bi)Function<..,Boolean> with (Bi)Predicate<..>
Replace 'BiFunction<T, U, Boolean>' with the primitive specialisation
'BiPredicate<T, U>' in HashCashService & FilterManager.

As part of this, replace similar predicate constructs found elsewhere.
NOTE: This touches the DAO packages (trivially @ VoteResultService).
2021-12-07 09:35:41 +01:00
Christoph Atteneder
0a31bf899e
Merge pull request #5858 from stejbac/add-asic-resistant-pow
Provide ASIC resistant PoW scheme for BSQ swaps
2021-12-07 09:34:50 +01:00
Steven Barclay
24d2a7f222
Code cleanup: proto fields, duplicated expr & null char separator
1. Reorder the PoW fields in the 'Filter' proto by field index, instead
 of contextually.
2. Deduplicate expression for 'pow' & replace if-block with boolean op
 to simplify 'FilterManager::isProofOfWorkValid'.
3. Avoid slightly confusing use of null char as a separator to prevent
 hashing collisions in 'EquihashProofOfWorkService::getChallenge'. Use
 comma separator and escape the 'itemId' & 'ownerId' arguments instead.

(based on PR #5858 review comments)
2021-12-06 22:55:14 +00:00
Christoph Atteneder
f5db85bc3d
Merge pull request #5894 from chimp1984/check-recipient-address-only-after-wallet-is-synced
Fix premature validation call
2021-12-06 20:29:27 +01:00
Christoph Atteneder
2cb238318f
Fix broken test 2021-12-06 12:05:34 +01:00
Christoph Atteneder
21f84bcd45
Fix broken test 2021-12-06 12:03:26 +01:00
chimp1984
60b3e1216a
Change max retries from 3 to 12
When doing a resync from genesis the number of blocks is limited to 6000
so that requires lots of requests and with that increases risk of broken
connections. Giving more tolerance for retries avoids that the user has
to restart the app.
2021-12-06 11:52:13 +01:00
chimp1984
c34a019a31
Fixes https://github.com/bisq-network/bisq/issues/5882
When syncing from genesis the number of blocks are limited so we get the
`onParseBlockCompleteAfterBatchProcessing` called each time when the received
 blocks are processed, and as we are not at wallet height we repeat requesting
 blocks. But the new check for the BTC recipient triggers a resync from resource call.
We add now a check that we do this check only once the wallet is synced and our
block height from dao state matches wallet blockheight.
2021-12-06 11:52:12 +01:00
Christoph Atteneder
6e1a805b22
Merge pull request #5875 from chimp1984/fix-incorrect-chainheight
Fix incorrect start height for block request
2021-12-06 11:36:00 +01:00
Christoph Atteneder
e5c70717f8
Merge pull request #5884 from MwithM/patch-1
Substitute Unconfirmed for Processing BSQ swap
2021-12-06 11:29:17 +01:00
chimp1984
e802e68506
Fix handling for genesis height and case when wallet sync is not completed yet.
- At genesis we use the genesis height for request (not height+1)
- If wallet is not synced yet we do not call onParseBlockChainComplete (as it was before)
2021-12-06 11:17:41 +01:00
chimp1984
84cd67f54d
Fix incorrect start height for block request
We added 1 as with the lite monitor mode we persist the most recent block,
thus we request with the start height for the next block.
But that cause a problem at a DAO full mode which has lite monitor mode set
as then the block parsing would not be triggered.

We refactor it so that we take the chainHeight from the dao state
directly and add 1 at the requests.
We add a check if we are at chain tip, and if so we skip requests
and call the onParseBlockChainComplete directly.
2021-12-06 11:17:33 +01:00
Christoph Atteneder
319a9d96a7
Improve BSQ swap success message 2021-12-06 11:04:48 +01:00
Christoph Atteneder
a1ecf35007
Apply suggestions and fix edge case when BSQ legacy payment account offer is duplicated 2021-12-06 11:04:01 +01:00
Christoph Atteneder
ec5f217f2f
Improve warning when BSQ swap offer is removed 2021-12-06 10:43:58 +01:00
Bisq GitHub Admin
b06852be73
Merge pull request #5891 from ripcurlx/improve-remove-bsq-offer-warning
Improve warning when BSQ swap offer is removed
2021-12-06 10:43:26 +01:00
Steven Barclay
981d6ff000
Validate input script types to prevent BSQ swap tx fee underpaying
Add a check of 'scriptTypeId' field, against the output of the spending
tx, to the 'RawTransactionInput::validate' method. Also make the seller
as well as the buyer validate each raw BSQ/BTC input received from the
peer. This prevents either peer from claiming that any of their
non-segwit inputs are segwit in order to underpay the tx fee.
2021-12-04 19:52:07 +01:00
Steven Barclay
efd590b9e7
Fix BSQ swap buyer tx fee theft vulnerability
Prevent the seller from stealing the combined tx fee as change by lying
about the value of one or more of his BTC inputs, which are passed to
the buyer as raw inputs in the 'BsqSwapFinalizeTxRequest' message.

To this end, add a 'RawTransactionInput::validate' method to check the
'value' field against the output value of the respective spending tx and
run it on every seller input in 'ProcessBsqSwapFinalizeTxRequest', so
that the buyer is no longer just trusting those numbers.

Additionally, check that the spending txIds from the raw BTC inputs
supplied by the seller actually match those of his signed inputs in the
accompanying partially signed tx, thus tying the raw input values to the
seller's tx.
2021-12-04 19:52:07 +01:00
Steven Barclay
acad642b53
Fix misleading comment: BSQ swap taker tx fee tolerance
(Actual tolerance by maker of agreed tx fee is 50%, not 10%.)
2021-12-04 19:52:06 +01:00
Christoph Atteneder
628ac27e25
Merge pull request #5889 from stejbac/fix-bsq-swap-tx-fee-theft-vulnerability
Fix BSQ swap buyer tx fee theft vulnerability
2021-12-04 19:50:50 +01:00
jmacxx
4b60be0ebb
Always use fresh address for MULTI_SIG context 2021-12-04 19:49:11 +01:00
chimp1984
d7c9ce462b
Change max retries from 3 to 12
When doing a resync from genesis the number of blocks is limited to 6000
so that requires lots of requests and with that increases risk of broken
connections. Giving more tolerance for retries avoids that the user has
to restart the app.
2021-12-04 11:11:26 -05:00
chimp1984
747916ac2f
Fixes https://github.com/bisq-network/bisq/issues/5882
When syncing from genesis the number of blocks are limited so we get the
`onParseBlockCompleteAfterBatchProcessing` called each time when the received
 blocks are processed, and as we are not at wallet height we repeat requesting
 blocks. But the new check for the BTC recipient triggers a resync from resource call.
We add now a check that we do this check only once the wallet is synced and our
block height from dao state matches wallet blockheight.
2021-12-03 20:09:47 -05:00
chimp1984
c9e0265e13
Fix handling for genesis height and case when wallet sync is not completed yet.
- At genesis we use the genesis height for request (not height+1)
- If wallet is not synced yet we do not call onParseBlockChainComplete (as it was before)
2021-12-03 19:48:17 -05:00
ghubstan
5f7fd6257b
Merge branch 'master' into 6-api-xmr-trading 2021-12-03 13:19:24 -03:00
Christoph Atteneder
ccda66d2c6
Improve warning when BSQ swap offer is removed 2021-12-03 12:21:03 +01:00
Christoph Atteneder
daf762f8fa
Add visual icon for duplicate offer functionality 2021-12-03 12:02:10 +01:00
ghubstan
742a6f441e
Allow mkt price lookup for any altcoin from API 2021-12-02 19:02:03 -03:00
ghubstan
ce8b6df9c5
Adjust API CorePaymentAccountsService for creating XMR accts 2021-12-02 19:00:22 -03:00
Steven Barclay
0517facbc3
Validate input script types to prevent BSQ swap tx fee underpaying
Add a check of 'scriptTypeId' field, against the output of the spending
tx, to the 'RawTransactionInput::validate' method. Also make the seller
as well as the buyer validate each raw BSQ/BTC input received from the
peer. This prevents either peer from claiming that any of their
non-segwit inputs are segwit in order to underpay the tx fee.
2021-12-02 18:25:53 +00:00
ghubstan
b85459d7c6
Refactor api.core side editoffer validation & fix bug
The editoffer validation bug fixes:

- A trigger-price edit forced offer.price-margin=0.00.

	This needs to be checked in new apitest case asserts.

- An activate state (only) edit forced offer.isUseMarketBasedPrice=true.

	The CLI does not have the offer instance, and cannot know the correct
	value of the isUseMarketBasedPrice param sent in the editoffer request.
	The daemon has to figure this out.  If the editType parameter value
	sent to daemon is ACTIVATION_STATE_ONLY, use the current offer.isUseMarketBasedPrice.

The refactoring includes more useful and readable information in core's EditOfferValidator
and MutableOfferPayloadFields toString methods, for debugging with the daemon log. And some
adjustments for allowing edits to XMR offers.
2021-12-02 15:04:38 -03:00
ghubstan
095a49598c
Add more readable toString method to MutableOfferPayloadFields
This makes it easier to compare to EditOfferValidator.toString
2021-12-02 14:51:15 -03:00
Steven Barclay
915a79e627
Fix BSQ swap buyer tx fee theft vulnerability
Prevent the seller from stealing the combined tx fee as change by lying
about the value of one or more of his BTC inputs, which are passed to
the buyer as raw inputs in the 'BsqSwapFinalizeTxRequest' message.

To this end, add a 'RawTransactionInput::validate' method to check the
'value' field against the output value of the respective spending tx and
run it on every seller input in 'ProcessBsqSwapFinalizeTxRequest', so
that the buyer is no longer just trusting those numbers.

Additionally, check that the spending txIds from the raw BTC inputs
supplied by the seller actually match those of his signed inputs in the
accompanying partially signed tx, thus tying the raw input values to the
seller's tx.
2021-12-02 17:19:10 +00:00
Steven Barclay
8d267520c8
Fix misleading comment: BSQ swap taker tx fee tolerance
(Actual tolerance by maker of agreed tx fee is 50%, not 10%.)
2021-12-02 14:54:57 +00:00
Christoph Atteneder
1606439144
Add support to duplicate bsq swap offers 2021-12-02 13:39:11 +01:00
ghubstan
33d976cf79
Calculate offer.makerFee if offer is bsq-swap
V1 offer instances have a makeFee value, but not BSQ swap offers.
This needs to be investigated.
See commit d57d6e9852.
2021-12-01 19:06:01 -03:00
jmacxx
32f057b2ad
Always use fresh address for MULTI_SIG context 2021-12-01 13:27:43 -06:00
ghubstan
e3c40895fe
Use offer instance to determine ownership, not it's id 2021-12-01 16:05:30 -03:00
ghubstan
d57d6e9852
Use calculated offer maker fee, do not re-calculate it 2021-12-01 16:03:31 -03:00
Christoph Atteneder
f224cf7c7c
Add Polish translation 2021-12-01 15:13:57 +01:00
Christoph Atteneder
1f2a3234fe
Add Polish translation 2021-12-01 11:35:25 +01:00
MwithM
7f22ffedf9
Substitute Unconfirmed for Processing BSQ swap
**Unconfirmed** BSQ swap seems like something failed. **Processing** is used by some wallets for unconfirmed transactions and has no negative implications.
2021-12-01 11:25:14 +01:00
ghubstan
946ca460ef
Merge branch 'master' into 5-api-bsqswap-simulation-n-docs-update 2021-11-30 12:46:34 -03:00
jmacxx
cb1998db05
Bugfix: dispute ticket reopened by mailbox message 2021-11-30 10:28:11 +01:00
jmacxx
0025609375
Bugfix: dispute ticket reopened by mailbox message 2021-11-29 09:18:55 -06:00
ghubstan
6b89254588
Adjust core api method help docs for bsq swaps 2021-11-29 11:29:42 -03:00
chimp1984
bfd45d359a
Fix incorrect start height for block request
We added 1 as with the lite monitor mode we persist the most recent block,
thus we request with the start height for the next block.
But that cause a problem at a DAO full mode which has lite monitor mode set
as then the block parsing would not be triggered.

We refactor it so that we take the chainHeight from the dao state
directly and add 1 at the requests.
We add a check if we are at chain tip, and if so we skip requests
and call the onParseBlockChainComplete directly.
2021-11-28 00:27:04 +01:00
ghubstan
64f228d872
Make rpc GetOfferCategory service work for my+avail offers
There are some use cases where the CLI needs to know what kind of offer
is being acted on before the request is made, For example:

There are differences between a BsqSwap 'takeoffer'request, and a v1
'takeoffer' request.

A BsqSwap offer cannot be edited by an 'editoffer' request, and an
attempt should be blocked by the CLI.

- Append isMyOffer GetOfferCategoryRequest rpc msg def.

- Adjust daemon.grpc services for new boolean GetOfferCategoryRequest param.

- Adjust core.api for new boolean GetOfferCategoryRequest param.

- Add validation check in core.api EditOfferValidator to block attempt to
  edit a BsqSwap offer.

- Refactor CoreOffersService get*offer(id) methods to optionally throw
  excpetions.
2021-11-27 14:01:14 -03:00
Steven Barclay
e383edc38a
Inline predicates to simplify HashCashService & FilterManager
Remove all the 'challengeValidation', 'difficultyValidation' and
'testDifficulty' BiPredicate method params from 'HashCashService' &
'ProofOfWorkService', to simplify the API. These were originally
included to aid testing, but turned out to be unnecessary.

Patches committed on behalf of @chimp1984.
2021-11-27 05:59:41 +00:00
jmacxx
670c5418ee
Improve user experience once mediation has been accepted by both parties
Transitions to Trade Step 4 (previously it would close/remove the trade).
2021-11-26 20:55:46 -06:00
Steven Barclay
e0595aa284
Store difficulty as floating point in Filter & PoW
Change the type of the 'difficulty' field in the Filter & ProofOfWork
proto objects from int32/bytes to double and make it use a linear scale,
in place of the original logarithmic scale which counts the (effective)
number of required zeros.

This allows fine-grained difficulty control for Equihash, though for
Hashcash it simply rounds up to the nearest power of 2 internally.

NOTE: This is a breaking change to PoW & filter serialisation (unlike
the earlier PR commits), as the proto field version nums aren't updated.
2021-11-26 04:08:15 +00:00
ghubstan
00a5e2b650
Merge branch 'master' into 2-refactor-api-bsqswap-support 2021-11-25 14:33:48 -03:00
Steven Barclay
0c94e232f8
Add+enable service to mint/verify Equihash proofs of work
Add an abstract base class, 'ProofOfWorkService', for the existing PoW
implementation 'HashCashService' and a new 'EquihashProofOfWorkService'
PoW implementation based on Equihash-90-5 (which has 72 byte solutions &
5-10 MB peak memory usage). Since the current 'ProofOfWork' protobuf
object only provides a 64-bit counter field to hold the puzzle solution
(as that is all Hashcash requires), repurpose the 'payload' field to
hold the Equihash puzzle solution bytes, with the 'challenge' field
equal to the puzzle seed: the SHA256 hash of the offerId & makerAddress.

Use a difficulty scale factor of 3e-5 (derived from benchmarking) to try
to make the average Hashcash & Equihash puzzle solution times roughly
equal for any given log-difficulty/numLeadingZeros integer chosen in the
filter.

NOTE: An empty enabled-version-list in the filter defaults to Hashcash
(= version 0) only. The new Equihash-90-5 PoW scheme is version 1.
2021-11-25 17:17:45 +00:00
Steven Barclay
647fc862d4
Fix method name typo: redoProofOfWorkAndRepublish 2021-11-25 11:45:23 +00:00
jmacxx
dfc7361b04
Add new block listener to update locked balance display 2021-11-25 09:55:04 +01:00
jmacxx
f0efe7175c
Fix exception in Portfolio History screen 2021-11-25 09:54:54 +01:00
Christoph Atteneder
ba6d5e2c73
Merge pull request #5842 from jmacxx/fix_exception_portfolio_history
Bug fixes: Locked Balance display; Portfolio History screen
2021-11-25 09:54:31 +01:00
ghubstan
c177b3b834
Merge branch 'master' into 2-api-bsq-swap-scratch 2021-11-24 13:14:13 -03:00
ghubstan
3aae052813
Refactor core.api trade service implemenentations for BSQ swaps
A minor refactoring to support serving TradeModel instances to CLI.
For example, the CLI 'gettrade' command must return a v1 Trade or
BSQ swap trade.
2021-11-24 13:05:09 -03:00
Steven Barclay
d8d8ec3f97
Add PoW version(-list) fields to ProofOfWork & Filter
Add a numeric version field to the 'ProofOfWork' protobuf object, along
with a list of allowed version numbers, 'enabled_pow_versions', to the
filter. The versions are taken to be in order of preference from most to
least preferred when creating a PoW, with an empty list signifying use
of the default algorithm only (that is, version 0: Hashcash).

An explicit list is used instead of an upper & lower version bound, in
case a new PoW algorithm (or changed algorithm params) turns out to
provide worse resistance than an earlier version.

(The fields are unused for now, to be enabled in a later commit.)
2021-11-24 15:07:42 +00:00
Christoph Atteneder
2fea64cb3a
Update bitcoinj checkpoints for v1.8.0 2021-11-24 11:31:12 +01:00
chimp1984
f93cd7de48
Enforce inclusion of TradeLimits for headless apps
PaymentMethod use an instance of TradeLimits and expect that it
has been injected, which is the case for desktop but not for
headless apps, so we enforce injection in the app base classes
used for headless apps.

The validation of trade statistics use a method in PaymentMethod
where that dependency is required.

Tha hack how the PaymentMethod use TradeLimits is not nice, but
would require more effort for refactoring.
2021-11-24 09:48:00 +01:00
Christoph Atteneder
3570750d0f
Merge pull request #5857 from chimp1984/add-missing-dependency
Enforce inclusion of TradeLimits for headless apps
2021-11-24 09:47:14 +01:00
chimp1984
0620c866fa
Add date for applying filter
We had historically higher trade limits and assets which are not in the
currency list anymore, so we apply the filter only for data after
Nov 1st 2021.
2021-11-24 09:46:04 +01:00
chimp1984
4ec14d3694
Add date for applying filter
We had historically higher trade limits and assets which are not in the
currency list anymore, so we apply the filter only for data after
Nov 1st 2021.
2021-11-23 23:09:42 +01:00
chimp1984
9c18899d66
Enforce inclusion of TradeLimits for headless apps
PaymentMethod use an instance of TradeLimits and expect that it
has been injected, which is the case for desktop but not for
headless apps, so we enforce injection in the app base classes
used for headless apps.

The validation of trade statistics use a method in PaymentMethod
where that dependency is required.

Tha hack how the PaymentMethod use TradeLimits is not nice, but
would require more effort for refactoring.
2021-11-23 21:34:43 +01:00
ghubstan
b65cc9c1f4
Merge branch 'master' into 1-basic-api-bsqswap-support 2021-11-23 17:02:49 -03:00
Christoph Atteneder
4f1f6898b8
Merge pull request #5853 from chimp1984/fix-paymentmethod-lookup
Improve TradeStatistics validation
2021-11-23 09:56:36 +01:00
Christoph Atteneder
19e072795f
Simplify warn logging 2021-11-23 09:54:23 +01:00
chimp1984
236cb2c6f3
Rename getPaymentMethodById to getPaymentMethod 2021-11-23 09:54:05 +01:00
chimp1984
a495072694
Rename getPaymentMethod to getPaymentMethodId 2021-11-23 09:53:56 +01:00
chimp1984
94857a6261
Rename getActivePaymentMethodById to getActivePaymentMethod
Rename variables
2021-11-23 09:53:45 +01:00
chimp1984
c3ea38ec7a
Add warn log 2021-11-23 09:53:37 +01:00
chimp1984
f5ca63f59a
Only apply maxTradeLimit from PaymentMethod if the PaymentMethod is
found in the active list. Otherwise the 2 BTC default is used.
We get TradeStatistics3 objects from old retired PaymentMethods
which are not found in the active list.
2021-11-23 09:53:27 +01:00
Christoph Atteneder
0e1030845a
Simplify warn logging 2021-11-23 09:48:10 +01:00
chimp1984
dc2a12858b
Only try to remove invalid filter from network if it's our own.
This avoids unnecessary/confusing warning logs in data storage.
2021-11-23 09:37:30 +01:00
chimp1984
cb474c57da
Rename getPaymentMethodById to getPaymentMethod 2021-11-23 00:40:59 +01:00
chimp1984
091f82477b
Rename getPaymentMethod to getPaymentMethodId 2021-11-23 00:39:38 +01:00
chimp1984
9569e5a600
Rename getActivePaymentMethodById to getActivePaymentMethod
Rename variables
2021-11-23 00:39:18 +01:00
chimp1984
9d52ddbf96
Add warn log 2021-11-23 00:34:12 +01:00
chimp1984
22c7b2d876
Only try to remove invalid filter from network if it's our own.
This avoids unnecessary/confusing warning logs in data storage.
2021-11-22 22:43:31 +01:00
chimp1984
b6b2d939a1
Only apply maxTradeLimit from PaymentMethod if the PaymentMethod is
found in the active list. Otherwise the 2 BTC default is used.
We get TradeStatistics3 objects from old retired PaymentMethods
which are not found in the active list.
2021-11-22 22:41:32 +01:00
jmacxx
e59596d1a1
Add new block listener to update locked balance display 2021-11-22 09:46:41 -06:00
ghubstan
f129867266
Uncomment support for complex swift-acct creation via API
Swift specific comments are included in the create payment acct json form.
2021-11-22 12:08:08 -03:00
ghubstan
1fcb751d8c
Populate SwiftAccount tradeCurrencies field inside constructor
The API uses reflection to figure out how to build a payment acct json
form, and the tradeCurrencies field needs to be set after reflection
API's onstructor.newInstance() is called.
2021-11-22 12:02:17 -03:00
ghubstan
a113b3ddfb
Overload getAllSortedFiatCurrencies() with Comparator param
The default method sorts by currency name, in come cases we need to
sort by currency code, e.g., swift accounts.  This method allows
sorting by either.
2021-11-22 11:54:12 -03:00
Steven Barclay
5da8df266a
Code cleanup: replace (Bi)Function<..,Boolean> with (Bi)Predicate<..>
Replace 'BiFunction<T, U, Boolean>' with the primitive specialisation
'BiPredicate<T, U>' in HashCashService & FilterManager.

As part of this, replace similar predicate constructs found elsewhere.
NOTE: This touches the DAO packages (trivially @ VoteResultService).
2021-11-21 17:46:15 +00:00
chimp1984
d81875eb98
Add check for trade statistic for max amount and if currency exists in CurrencyUtil 2021-11-21 17:39:46 +01:00
chimp1984
71e40ce1b7
Add check for trade statistic for max amount and if currency exists in CurrencyUtil 2021-11-20 23:04:25 +01:00
Christoph Atteneder
b5c351143a
Update translations for v1.8.0 2021-11-19 18:38:31 +01:00
jmacxx
cd4d98b753
Fix exception in Portfolio History screen 2021-11-18 17:38:26 -06:00
chimp1984
08eb54efbd
Add I2P as enum entry 2021-11-18 18:34:37 +01:00
Christoph Atteneder
b5a43c7f95
Merge pull request #5840 from chimp1984/add-i2p-to-btc-core-networktypes
Add I2P as enum entry
2021-11-18 18:34:17 +01:00
chimp1984
e442283db4
Add I2P as enum entry 2021-11-18 18:00:06 +01:00
Christoph Atteneder
ef7ce109ac
Merge pull request #5834 from jmacxx/dispute_ui_add_penalty
Add penalty calculation to dispute agent UI
2021-11-18 17:57:54 +01:00
jmacxx
5c00e1974e
Add penalty calc to dispute UI 2021-11-18 08:43:06 -06:00
Christoph Atteneder
c05e7a09c0
Merge pull request #5824 from cbeams/gradle-7.3
Upgrade to Gradle 7.3
2021-11-18 09:32:04 +01:00
Christoph Atteneder
a27ac4313b
Merge pull request #5826 from chimp1984/improve-fee-handling
Improve fee handling
2021-11-18 09:23:15 +01:00
Christoph Atteneder
90ea4fc14a
Merge pull request #5813 from jmacxx/fix_locked_funds_display
Fix calculation & display of Locked Funds
2021-11-16 09:35:06 +01:00
chimp1984
f17c2e1234
Rename method 2021-11-15 13:05:40 +01:00
Christoph Atteneder
83c9355931
Merge pull request #5825 from chimp1984/improve-offer-validation
Improve offer validation
2021-11-15 12:03:29 +01:00
ghubstan
4ca878a8e1
Adjust API 'gettrade' for Bsq swaps
- Made several adjustments to CLI's 'gettrade' output related code
  so it can show single trade details for either Bisq v1 trades, or
  BSQ swap trades.

- Did minor refactoring of API's core to retrieve # tx confirmations
  for an addresses and transactions.

- Show # of tx confirmations in bsq swap trade detail.
2021-11-14 13:48:12 -03:00
chimp1984
b00d317e88
Rename getFeeHistorical to calculateFee 2021-11-14 15:07:34 +01:00
chimp1984
5928b44843
Use genesis height in maybeTestFeeFromFilter instead of 0 2021-11-14 15:07:34 +01:00
chimp1984
2e137459dc
Add check for fee from filter
That check is done if:
- If we are after activation time
- If filter is available
- If value in filter is > 0

The check compares the paid fee and the fee value from filter
and requires that paid fee is > 70% of filter value.
See comments in code for more background.
2021-11-14 15:07:34 +01:00
chimp1984
1027b9d7fe
Extract vars
Cleanups
2021-11-14 15:07:33 +01:00
chimp1984
c88addef16
Break up if else clauses (helps for improvements
in later commits)
2021-11-14 15:07:33 +01:00
chimp1984
b427795e4c
Extract minFeeParam
Cleanup
2021-11-14 15:07:33 +01:00
chimp1984
e57c682001
Add blockHeightAtOfferCreation to TxValidator
Used in case of maker fee validation
2021-11-14 15:07:33 +01:00
chimp1984
65285e2c69
Add filterManager to filterManager (will
be used in follow-up commits)
2021-11-14 15:07:33 +01:00
chimp1984
a082fd4a84
Add fee fields to filter 2021-11-14 15:07:32 +01:00
chimp1984
478b7568ee
Add return
Add more info in case it fails
2021-11-14 11:28:25 +01:00
chimp1984
f054c8ae95
Rename 2021-11-14 02:00:54 +01:00
chimp1984
65d3ef4ff5
Add check for isUseMarketBasedPrice 2021-11-14 02:00:00 +01:00
Chris Beams
e09d56b696
Upgrade Mockito to 4.0.0
This fixes the 'Unsupported class file major version 60' problem
documented at mockito/mockito#2065 to allow building Bisq on JDK 16+.
2021-11-13 13:53:38 +01:00
ghubstan
9f01279141
Merge branch 'master' into 1-basic-api-bsqswap-support 2021-11-12 18:56:54 -03:00
ghubstan
564303ac20
Normalize API gRPC bsq-swap related protos & wrappers
This commit refactors the first cut of the BsqSwapTradeInfo and
TradeInfo gRPC proto defs and wrappers.  The change avoids duplication
of fields between BsqSwapTradeInfo and TradeInfo, and adds a
bsqSwapTradeInfo field to the old TradeInfo proto & wrapper.

The immediate goal is moving towards getting the API's 'gettrade'
method to work for both Bisq v1 trades and BSQ swap trades:  the TradeInfo
proto sent to the CLI should represent either a Bisq v1 trade or a BSQ
swap trade.  A mid-term term goal is to also make a new 'gettrades' method
return a List<TradeInfo> to the CLI, where items in the List<TradeInfo>
can be either v1 trades or bsq-swap trades.
2021-11-12 18:48:35 -03:00
Christoph Atteneder
17d4d425a7
Merge pull request #5823 from jmacxx/add_ach_domestic_wire
Add payment methods ACH Transfer and Domestic Wire Transfer
2021-11-12 20:51:46 +01:00
jmacxx
bf311e36fb
Add payment methods ACH Transfer and Domestic Wire Transfer 2021-11-12 11:50:43 -06:00
Christoph Atteneder
3e6bb3bc7f
Merge pull request #5819 from chimp1984/fix-reorg-handling
Fix reorg handling
2021-11-12 10:50:06 +01:00
ghubstan
3dfbf3f6f0
Partially adjust core api for bsq-swap support
- Add core api methods to help CLI determine which type of offer to
  take for a given offerId.  CLI's 'takeoffer` will need to determine
  which gRPC/proto request type to send to server.

- Add implemetations for getBsqSwapTradeRole(), for tradeId or trade.
2021-11-11 13:12:41 -03:00
ghubstan
521495c41d
Add conveniences isFiatOffer(offer), isAltcoinOffer(offer) 2021-11-11 13:07:49 -03:00
ghubstan
713b309f4a
Add String getRole(BsqSwapTrade trade) method 2021-11-11 13:06:23 -03:00
ghubstan
5d63fd7e39
Partially adjust api proto wrappers for bsq-swap support
- Complete BsqSwapTradeInfo impl.
- Merge BsqSwapOfferInfo fields into OfferInfo and remove BsqSwapOfferInfo.
- Change all model builders to private static class Builder.
2021-11-11 13:01:48 -03:00
Christoph Atteneder
9538b538ea
Merge pull request #5821 from jmacxx/add_tikkie_twusd
Add payment methods Tikkie and TransferWise-USD
2021-11-11 11:03:38 +01:00
jmacxx
f72b6c0b0a
Add payment methods Tikkie and TransferWise-USD 2021-11-10 21:48:10 -06:00
jmacxx
5bf7bba0c6
Changes required for GRIN re-listing 2021-11-10 14:23:04 -06:00
chimp1984
0edccd9fe1
Only call parseBlocksOnHeadHeight if our latest block from
persistance is below the chain height of btc core.
With the new handling of dao state hashblocks it can be the
we have persisted the latest block up to the chain height.
Before that change we only had the last snapshot which was at least
20 blocks back persisted.
We want to avoid to get caught in a retry loop at parseBlocksOnHeadHeight
so we filter out that case just at the caller.

At parseBlocksOnHeadHeight we inline the requestChainHeadHeightAndParseBlocks
method as it is not used by other callers anymore.
This case  that we request a block but our local btc core chain hight is below
that might be some edge case when we had a synced dao blocks but we btc core is
resyncing...
2021-11-10 17:41:58 +01:00
chimp1984
42500c0370
Do not call resultHandler in case of a RequiredReorgFromSnapshotException
We trigger a resync from resources if there is a reorg and don't want to
continue to request blocks
2021-11-10 17:36:49 +01:00
chimp1984
450800d101
Remove startReOrgFromLastSnapshot methods in LiteNode
and FullNode

The custom implementations triggered to repeat requests
but we shut down the seed node in case of a reorg and
for desktops we request the user to shutdown.
2021-11-10 13:13:06 +01:00
chimp1984
faa8bd2ab2
Extract code in CommonSetup which uses a timer
to startPeriodicTasks.
Call that from BisqExecutable.onApplicationLaunched

We have created a non-UI timer before for the
printSystemLoadPeriodically as that was called
before the configUserThread was called (where we
define the UI timer for desktop)
2021-11-10 12:26:54 +01:00
chimp1984
d9c509ba53
Fix missing handling for non-mainnet use case 2021-11-09 22:42:37 +01:00
Christoph Atteneder
bb1a1b5170
Merge pull request #5808 from jmacxx/seller_confirm_button
Confirm button state for BTC seller to be disabled in mediation
2021-11-09 21:27:37 +01:00
Christoph Atteneder
1578f45ffc
Merge pull request #5812 from ghubstan/02-cli-console-formatting-api
Deprecate and replace hard-coded CLI console output formatters
2021-11-09 21:21:52 +01:00
chimp1984
8d22904ee3
Fix missing param in test 2021-11-09 20:48:17 +01:00
chimp1984
beb4590ef7
Use static fields for addresses 2021-11-09 20:42:30 +01:00
chimp1984
e2bf77fb59
Fixes https://github.com/bisq-network/bisq/issues/5762
Avoid that outdated donation and fee addresses are used.

In case we get an outdated donation address (RECIPIENT_BTC_ADDRESS)
we trigger a dao resync. The user get a popup for doing a restart
in that case.
For the fee address selection we do not fall back to the
RECIPIENT_BTC_ADDRESS in case no address from filter is provided
but we use the hard coded address of the current fee receiver address.
2021-11-09 20:42:30 +01:00
chimp1984
cf9e49134a
Add shutDown method to ClockWatcher and shut it down at shutdown 2021-11-09 20:00:34 +01:00
chimp1984
87f4444210
Add git lfs support for BsqBlocks in resources
Fix typo
2021-11-09 17:22:35 +01:00
ghubstan
20cc085dc8
Merge branch 'master' into 02-cli-console-formatting-api 2021-11-09 09:20:06 -03:00
chimp1984
1108e98164
Add isEmpty check 2021-11-09 13:01:21 +01:00
chimp1984
c600259267
Fix typo 2021-11-09 13:01:21 +01:00
chimp1984
97e356c79f
Add check that height of last block matches chainHeight from daoState 2021-11-09 13:01:21 +01:00
chimp1984
62b3e51b22
Cleanups, change log levels 2021-11-09 13:01:19 +01:00
chimp1984
3487932f6e
Remove unnecessary sorting
Blocks are always sorted by block height
2021-11-09 13:01:19 +01:00
chimp1984
a3fbdf48d2
Improve log 2021-11-09 13:01:19 +01:00
chimp1984
7c32587453
Persist bsq blocks as buckets of 1000 blocks
Improve logging

Add BsqBlockStore to protobuf

Remove DaoStateMonitoringService field

Do not persist the blocks in daoState anymore.

This improves persistence performance and reduces memory
requirements for snapshots.
2021-11-09 13:01:19 +01:00
chimp1984
699048634b
Avoid unnecessary serialisation/deserialisation cycle
For the snapshot we create a deep clone by protobuf serialisation.
We do not need the deserialisation back to the java object as it is
only kept in memory for later persistence where we need to do protobuf
serialisation again. So we can skip that cycle and safe a bit of
time at creating and persisting snapshots.
2021-11-09 13:01:19 +01:00
chimp1984
b619afa83d
Remove unused field 2021-11-09 13:01:18 +01:00
chimp1984
4d2d0717b5
Add getBlockTimeAtBlockHeight method
Improve getBlockStartDateByCycleIndex method
2021-11-09 13:01:18 +01:00
chimp1984
779bd0cf1e
Remove blockHashes set from daoState
Was only used from one use case which can be done differently.
2021-11-09 13:01:18 +01:00
Christoph Atteneder
65c308f5ed
Merge pull request #5782 from chimp1984/redesign-dao-state-monitoring
Redesign dao state monitoring [4]
2021-11-09 12:12:22 +01:00
chimp1984
7e1696b095
Fix typos, cleanups 2021-11-08 21:49:08 +01:00
Christoph Atteneder
00d7913bc6
Merge pull request #5055 from Jakub-CZ/button-buy-bsq
Add "Buy BSQ" button next to trade fee selector
2021-11-08 11:13:52 +01:00
jmacxx
cea4fb30a2
Fix calculation & display of Locked Funds 2021-11-07 21:24:59 -06:00
ghubstan
edd01418ca
Remove fields/methods/logic for creating redundant bsq-swap accounts
The user's default bsq-swap account is used instead.
2021-11-07 10:36:40 -03:00
ghubstan
531db1eac4
Do not publish altcoin acct age witness data 2021-11-07 10:14:19 -03:00
jmacxx
c1381e4657
Seller confirm button to be disabled during mediation 2021-11-04 09:34:07 -05:00
Christoph Atteneder
12cd88ce32
Fix translations 2021-11-04 13:23:00 +01:00