Commit graph

13823 commits

Author SHA1 Message Date
Steven Barclay
05ea293595
Activate Segwit DAO hard fork 4 weeks after v1.6.0 release
Push back the (2nd) DAO hard fork activation block height to 680300,
which is 4 weeks after the planned 1.6.0 release around 2021/03/25.
(Also push back the testnet block activation height to 1943000 - 2 weeks
from now assuming an average block time of 10 minutes.)
2021-03-20 21:39:26 +00:00
Steven Barclay
b4ad6bf637
Upgrade jsonrpc4j & Jackson; simplify BitcoindClient
Change jsonrpc4j version from 1.5.3 to 1.6.0.bisq.1, forked to the Bisq
repo from the recent 1.6.0 release. The forked version changes the class
'com.googlecode.jsonrpc4j.HttpException' to be public, instead of (prob.
mistakenly) package private, so we can avoid using reflection to catch
it and re-throw as a 'bisq.network.http.HttpException'. Remove the now
unused constructors from the latter.

As part of this, upgrade Jackson to the latest stable (2.12.1) release,
since jsonrpc4j now depends on a newer version than the previous 2.8.10.
2021-02-04 07:51:38 +00:00
Steven Barclay
e0aa76e440
Rename rpc.dto.RawX to RawDtoX to avoid confusion
Avoid name clashes between the Json RPC client DTOs & the corresponding
raw (un-parsed) DAO state entities. Also prepend the other DTO classes
with 'Dto' for consistency.
2021-01-21 11:14:56 +00:00
Steven Barclay
a8b0863264
Ensure RPC client works with Bitcoin Core 0.21.0
Add missing 'connections_(in|out)' JSON properties to NetworkInfo that
came with the recent 0.21.0 release of Bitcoin Core. Also ensure that
unrecognised JSON properties are ignored, so that future changes to the
RPC API are less likely to break our client.

Also, for the benefit of the tests, change the JSON property order of
RawInput to better match observed 'getblock' responses. (It appears that
in 0.21.0, extra "txinwitness" fields have started appearing in coinbase
inputs, which may be a bug.)
2021-01-21 10:10:32 +00:00
Steven Barclay
1abf4c5d96
Exclude segwit pubkeys by block height instead of a blacklist
Since extraction of segwit pubkeys technically represents a hard fork,
activate it by block height in the same way as the fork defined in
TxOutputParser, instead of relying on the absence of premature segwit
BSQ inputs outside of a blacklist. This also means we no longer need to
exclude all but the first tx input from segwit pubkey extraction to
maintain backwards compatibility, which is a little safer and consistent
with the original behaviour of extracting every available P2PKH pubkey.

Provisionally activate this (2nd) DAO hard fork at block height 672646,
which should be 6 weeks from now, just under 5 weeks from the planned
1.5.5 release on 2021/01/27. (Block 1906689 for testnet - 2 weeks from
now assuming an average block time of 10 minutes, but it's erratic.)
2021-01-21 10:10:31 +00:00
Steven Barclay
4b0711bfcc
Add Bitcoin Core version & health check to RpcService
Make a 'getnetworkinfo' RPC call to bitcoind immediately upon startup,
to check that the node is up (and throw a ConnectException to ensure
that the user is presented with an appropriate warning popup otherwise).
Log a warning if the node version is outside the 0.18.0 - 0.20.1 range.

Additionally, call 'getbestblockhash' to check that the chain tip is not
stale (> 6 hours old). As part of this, make sure the 'getblock' RPC
call works correctly with verbosity < 2, by fixing JSON deserialisation
of the response when the block or txs are in summary (hex string) form.

(These version & health checks are almost identical to the ones done by
the original btcd-cli4j library during RPC client startup.)
2021-01-21 10:10:31 +00:00
Steven Barclay
d595cac477
Add getNetworkInfo & getBestBlockHash RPC client methods
Provide a 'NetworkInfo' DTO class (with associated nested DTO classes),
returned by the 'getnetworkinfo' RPC method call to bitcoind. This will
be used during startup of RpcService to determine if Bitcoin Core is
available and which version it is using. Add a unit test to round-trip a
sample NetworkInfo JSON response.

Also add the missing 'getbestblockhash' RPC method, which will be needed
by RpcService to determine the Bitcoin Core node health.
2021-01-21 10:10:31 +00:00
Steven Barclay
a850adadb6
Make special case for irregular tx with segwit BSQ inputs
Selectively disable pubkey extraction from segwit inputs of a particular
tx at block height 660384 (2020-12-07), which spends spuriously created
segwit BSQ (later burned), to prevent a change in the DAO state hashes
from that point.

(Since a tx with a given ID can only appear on one chain, a fixed global
exclusion list of IDs should not cause any issues on testnet/regtest
versus mainnet. This is simpler than conditioning by block height.)
2021-01-21 10:10:30 +00:00
Steven Barclay
796097abbc
Fix data race in BitcoindDaemonTest
Prevent intermittent test failures, caused by a race between checking
whether the mock socket is closed upon accepting a new connection and
setting 'socketClosed' to true during shutdown. Waiting to accept and
then checking the flag needs to be done in a synchronized block.
2021-01-21 10:10:30 +00:00
Steven Barclay
93b46e3a40
Fix Codacy issues & deduplicate code in RpcService
Factor out shared construction logic to a new 'getBlockFromRawDtoBlock'
method in RpcService. Also add some 'NOPMD' comments in an attempt to
suppress unfixable Codacy warnings about qualified imports.
2021-01-21 10:10:29 +00:00
Steven Barclay
6ca42c0cd1
Enable extraction of segwit pubkeys from raw tx inputs
Factor out a new RpcService.extractPubKeyAsHex method, to take public
keys from the inputs of the raw transactions returned by the RPC client,
when building TxInput objects to incorporate into the DAO state. Enhance
the method to additionally support segwit (P2WPKH & P2SH-P2WPKH) inputs
(but only the first input for backwards compatibility - see code
comment). Also fix a bug when handling non-SIGHASH_ALL input signatures.

This will allow segwit BSQ to be used in proof-of-burn and issuance txs,
which need a public key associated with the tx to establish ownership of
it, when signing messages with a proof-of-burn or staking merit awarded
from a compensation issuance, respectively.

Also add unit tests for the factored-out method and add a missing RawTx
toString() method, to aid debugging the TxInput fields within the
processed block returned by RpcService.
2021-01-21 10:10:29 +00:00
Steven Barclay
8104301b52
Use new Bitcoind(Client|Daemon) & remove btcd-cli4j
Migrate RpcService over to the new block notification daemon and RPC
client based on jsonrpc4j. Drop in own DTO classes in place of the ones
defined by btcd-cli4j and rename requestBtcBlock & addNewBtcBlockHandler
to requestDtoBlock & addNewDtoBlockHandler respectively.

Also remove now redundant filtering from the logback config and update
grade-witness.
2021-01-21 10:10:28 +00:00
Steven Barclay
ac78639656
Improve exception handling in BitcoindDaemon
Wrap any exception that occurs during socket IO or within the supplied
BlockListener with a new 'BlockNotificationException'. This brings the
exception handling more in line with that of the old BtcdDaemonImpl and
makes it easier to match them downstream in FullNode.handleError.
2021-01-21 10:08:24 +00:00
Steven Barclay
4470af8edb
Add missing copyright headers to new files 2021-01-21 10:08:23 +00:00
Steven Barclay
f34231abb6
Factor out failure callback logic into new Utilities method 2021-01-21 10:08:23 +00:00
Steven Barclay
863392bc74
Factor out executor shutdown logic into new Utilities method 2021-01-21 10:08:22 +00:00
Steven Barclay
b7c7eaf1f2
Add replacement bitcoind block notification daemon
Provide a new 'BitcoindDaemon' block notification socket server, to
replace 'com.neemre.btcdcli4j.daemon.BtcdDaemonImpl'. This starts a
single service thread to listen for raw block hashes on localhost port
512*, sent by the specified 'blocknotify' shell/batch script, delegating
to a pool of worker threads to run the supplied BlockListener handler.
Unlike the original BtcdDaemonImpl class, a call to the 'getblock' RPC
method is not made automatically to supply a complete block to the
handler, instead requiring a separate, manual BitcoindClient.getBlock
invocation from within RpcService.

Also provide unit tests using a mock ServerSocket + Socket.

TODO: Use the new Bitcoind(Client|Daemon) implementations in RpcService,
 in place of btcdcli4j Btcd(Client|Daemon)Impl & remove the old library.
2021-01-21 10:08:22 +00:00
Steven Barclay
dbe4953f63
Add replacement bitcoind RPC client using jsonrpc4j
Create a new 'BitcoindClient' interface and a corresponding builder, to
replace the old 'com.neemre.btcdcli4j.core.client.BtcdClientImpl' class
from the btcdcli4j library. This is instantiated by jsonrpc4j using a
dynamic proxy. It provides only a cut down version of the bitcoind RPC
API, exposing the methods 'getblock', 'getblockcount' & 'getblockhash',
as they are the only ones currently being used by RpcService.

Add corresponding Jackson-annotated DTO classes to model the JSON
structures returned by bitcoind, very similar to the classes provided by
btcdcli4j. Note that we use Double instead of BigDecimal to represent
fractional fields (difficulties + coin amounts in BTC), as they have
more consistent Jackson (de)serialisation and appear to be able to
faithfully round-trip numeric fields produced by bitcoind. Also note
that doubles can faithfully represent any valid decimal BTC amount (that
is, with 8 d.p. of precision) up to 21 million.

For now, keep the old BtcdClientImpl instance used by RpcService in
place, as the btcdcli4j block notification daemon is dependent upon it
and would also need to be replaced.

Also add unit tests for BitcoindClient which test against sample regtest
responses, using a mock HttpURLConnection.
2021-01-21 10:08:22 +00:00
Steven Barclay
5990fcf9e7
Bring ScryptType enum up to date with latest bitcoind
Add 'witness_v1_taproot' script type to the enum and proto.pb, so that
it doesn't cause any problems when Taproot is activated and the new
script type starts showing up in RPC getBlock(..) responses (including
possibly BSQ transactions).

Also change the Java enum order (which shouldn't cause any problems as
the ordinal isn't used directly in hashCode calculations) and add the
missing 'witness_unknown' enum value to pb.proto to bring it in sync.
2021-01-21 10:08:15 +00:00
sqrrm
d3971ef7dd
Merge pull request #5072 from chimp1984/persist-and-republish-mailbox-messages
Persist and republish mailbox messages
2021-01-16 20:24:13 +01:00
sqrrm
44cbea886a
Merge pull request #5081 from ghubstan/04-posix-cli-opts+method-help
Use posix-style CLI opts, provide method help
2021-01-16 13:43:18 +01:00
ghubstan
1ad7b351b6
Remove uneeded method 2021-01-15 16:33:52 -03:00
ghubstan
ec9f783eb5
Remove switch(hardcoded enum.name)
There is no need for a switch here, the doc exists or it does not.
2021-01-15 16:25:39 -03:00
chimp1984
5d13fdcdbb
Return early 2021-01-14 20:42:36 -05:00
ghubstan
f2a899917c
Fix default opt values 2021-01-14 19:05:27 -03:00
ghubstan
baf79e2b50
Make opt description more generic 2021-01-14 19:03:49 -03:00
ghubstan
acf2c7c50e
Remove deprecated NegativeNumberOptions
Not needed anymore, and all method opts are posix style.
(The opts parsing lib used to treat negative numbers as opt labels.)
2021-01-14 10:27:47 -03:00
ghubstan
9f0f083cf7
Change CLI opts to posix-style 2021-01-14 10:26:11 -03:00
ghubstan
f4e735faec
Move CLI method enum to it's own class
This helps reduce size of growing CLI class file.
2021-01-14 10:25:08 -03:00
ghubstan
37ad73d4f4
Add posix-style api method option parsers 2021-01-14 10:23:38 -03:00
ghubstan
49a3b46960
Add CoreHelpService gRPC stubs and test case 2021-01-14 10:22:14 -03:00
ghubstan
a067ba1228
Add new CoreHelpService and method help docs
Adds all the gRPC server boilerplate, and a simple help service
that serves method help in man page format.  Help text is maintained
in text files located in core/src/main/resources/help.

Only some of the method help text files are defined in this
change, more to be added.
2021-01-14 10:19:39 -03:00
sqrrm
f838b1a475
Merge pull request #5076 from ghubstan/03-support-trigger-price
Stub out support for OpenOffer's triggerPrice in api
2021-01-14 10:34:29 +01:00
Christoph Atteneder
01bfbe7ca0
Merge pull request #5071 from jmacxx/fix_issue_5067
Show a confirmation of successfully sending BTC or BSQ from wallet
2021-01-14 09:37:20 +01:00
jmacxx
3984e8b3dd
Code review suggestions from @ripcurlx
Disable validation errors when clearing edit fields
Implement spacer field using Region
2021-01-13 21:31:58 -06:00
chimp1984
7ba5ab5a4e
Change prio for mailboxMessageList persitence 2021-01-13 20:48:52 -05:00
chimp1984
541f367e81
Dont log filter content if a filter got updated 2021-01-13 20:39:26 -05:00
sqrrm
685d79749b
Merge pull request #5065 from ghubstan/offer-protection-tools-api-integration
Integrate new protection tools into api's offer & trade services
2021-01-14 00:26:10 +01:00
ghubstan
a8d15d0161
Merge branch 'offer-protection-tools-api-integration' into 03-support-trigger-price 2021-01-13 20:03:03 -03:00
ghubstan
0e779a4bf6
Inject CoreContext into server, then set isApiUser=true
Do not set isApiUser=true based on hardcoded thread name ;-(

For requested change
https://github.com/bisq-network/bisq/pull/5065#pullrequestreview-567708569
2021-01-13 19:55:49 -03:00
ghubstan
9a4e311193
Fix file conflict
The createoffer trigger price was defined as the 0 default value
in the gRPC request object (causing the file conflict with the
main branch).  This line can be removed because a protobuf
long's default value is 0.
2021-01-13 09:31:34 -03:00
sqrrm
fe32c91426
Merge pull request #5063 from ghubstan/fix-cli-negative-opts-parsing
Fix two CLI option parsing bugs
2021-01-13 10:42:08 +01:00
chimp1984
d434cb3022
Sort persisted mail box messages by age and limit total number.
Add size limit.
Add log for number of persisted mailbox msg per day
2021-01-12 22:59:44 -05:00
chimp1984
2fb3bba74d
Use MailboxMessage as param type in sendEncryptedMailboxMessage 2021-01-12 17:47:44 -05:00
chimp1984
c12e239fa5
Refactor: rename method 2021-01-12 17:44:04 -05:00
chimp1984
36657f5532
Use TradeMailboxMessage as type for getMessage in SendMailboxMessageTask 2021-01-12 17:43:27 -05:00
chimp1984
3834785828
Bugfix: Add processing of SendersNodeAddressMessage to
onBundleOfEnvelopes method.

In case we received a SendersNodeAddressMessage
inside a BundleOfEnvelope we did not set the
peers address.
2021-01-12 17:40:40 -05:00
chimp1984
3e69edeb9e
Remove comment 2021-01-12 17:34:54 -05:00
chimp1984
a21d79ad63
Refactor: rename 2021-01-12 17:34:28 -05:00
chimp1984
364a7f524c
Add toString 2021-01-12 16:14:32 -05:00