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.)
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.
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.)
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.
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.
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.
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.
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.
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.
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.
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.
The price feed service throws PriceRequestExceptions when switching
currencies, log those exceptions as warnings in the server and don't
pass them up to the CLI.
The server impl was there, but it is now needed by the trading
sim scripts (CLI) to get the price from the Bisq server instead
of the feed. (The server does not request prices more than
once a minute.)
This server log output was intended as an aid to api devs, but
is no longer needed after the change to posix-sytle method opts
with self explanatory labels (replacing the ambiguous positional
CLI method opts).
Prevent failure of testConvertClearNode() on some machines, caused by
use of InetAddress.getHostName on the mock peer address. This does a
reverse DNS lookup and potentially returns something other than the
expected "192.168.0.1" string.
Also avoid an unnecessary getHostName() call on the SOCKS5 Tor proxy
InetAddress in WalletConfig, by using an alternative InetSocketAddress
constructor.
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.
For all MailboxMessage we want to be sure they have an expire date.
Add getTTL methods and TTL value.
We use 7 days for ChatMessages and 30 days for PrivateNotificationMessages.
All others use default 15 days.
We prefer to keep them explicit and not use a default method in
ExpirablePayload or MailboxMessage.
The value in PrefixedSealedAndSignedMessage will not be used as the
sender use the TTL of the payload and pass that to the MailboxStoragePayload
where we store it in the extraMap. That way we can use different TTL even the
payload message is encrypted and we would not be able to look it up.
instead of decryptedMessageWithPubKey.
Here we change a bit the behaviour as now we check also if the
TradeMessage is a MailboxMessage. As that method is only called
from MailboxMessageService domain we never get a non MailboxMessage
here anyway and it would have been a bug.
Remove removeMailboxMsg(DecryptedMessageWithPubKey decryptedMessageWithPubKey) as not used anymore
different TTL for lower prio mailbox messages like AckMessages.
As we cannot add a field without breaking signatures we
need to use the extraMap in MailboxStoragePayload
Use ReimbursementConsensus.get[Min|Max]ReimbursementRequestAmount in
place of CompensationConsensus.get[Min|Max]CompensationRequestAmount,
which was erroneously copied (it appears) from the very similar
CompensationValidator class.
This ensures the correct upper bound (currently 80,000 BSQ, starting at
10,000 BSQ and doubled in cycles 12, 13 & 14) is placed on reimbursement
requests, instead of the erroneous 100,000 BSQ upper bound for
compensation requests.
This is a feature that will not be included in api v1, but partial
support is added in this change to the server. CLI will pass a
default triggerPrice of 0 (unused) with the createoffer command.
When fully implemented, an optional trigger-price param will be
added to the CLI's createoffer method, and the value will only be
visible to offer owners. New enableoffer and disableoffer
methods will also need to be added.
The confirmation details include amount, recipient address and txId.
Includes a link to open txId details in the user's external block explorer.
@m52go reworded the BSQ conf explanation note.
Added "don't show again" checkbox.
- Injected OfferFilter into CoreOffersService and CoreTradesService.
The filter constrains 'getoffer(s)' results to offers an api user
can take, as the first part of ongoing protection tools / api
integration.
- Created a new CoreContext singleton.
Initially, lets Core*Services know if the user is using the api --
isApiUser=true if the current thread's name is "BisqDaemonMain" or
the name contains "grpc". We do this anticipating future :desktop
dependencies on the core api, and we don't pass hardcoded
isApiUser=true params to lower level domain objects.
We cannot check BisqDaemonMain.class.getSimpleName() because :core
cannot have a circular dependency on :daemon, but there is probably a
better way to do this than depending on the thread name set in
BisqDaemonMain#configUserThread().
- Added @Singleton annotation to all Core*Service classes.
A log statement was mismatching argument placeholders with argument
values because it was formatted as
log.info("msg={}, \n" + args...)
instead of
log.info("msg={}", args...)
Some code formatting was also done to this block, and a closer approximation
of a CLI 'createoffer` param list replaces the following log statement.
Remove unnecessary setPeerType calls. ConnectionState is handling that.
Only PeerManager does the setting of isSeedNode as we do not have the
required dependency in ConnectionState.
Similar to 'getoffers' and 'getoffer', but filters out offers not
created by the user. The new methods are so similar some offer list
filtering and sorting was refactored in CoreOffersService.
Also fixed some createoffer apitest cases in anticipation of a new OfferFilter,
which will filter out offers not matching any user payment account.
Default value is false, so same behaviour as before the change.
If no payment account is setup then we also show all payment methods.
In that case (no payment account) we disable the toggle as well as set it to false.
p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().
p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap() iterates
over all services including the historical data store service. It used the
getMap method which should not be used at historical data store service as
it is not clear if the live data or all data should be accessed.
This change fixes the underlying problems behind five compiler warnings:
"Generating equals/hashCode implementation but without a call to superclass".
Some core classes use @Value and @Data annotations where not necessary, for
example, where equals, hashCode, and toString are implemented by the developer,
and where final class and field modifiers are defined by the developer.
From lombok classes and documents for the shortcut annotations
@Value https://projectlombok.org/features/Value and
@Data https://projectlombok.org/features/Data,
we find some implicit annotations applied by these shortcuts are not needed.
Adjustments are described below.
- Tx Replace @Value with @Getter.
- TxOutput Replace @Data with @Getter and @Setter.
- ChangeParamProposal Replace @Value with @Getter.
- GetInventoryRequest, GetInventoryResponse
An @EqualsAndHashCode(callSuper = false) is added to supress build
warnings.