Commit Graph

87 Commits

Author SHA1 Message Date
Kc
ac33b927e6 CHANGED: implemented generating balance and time methods in BlocksResource 2018-10-20 20:58:29 +02:00
Kc
6590863201 CHANGED: simplified API error annotations in API resources
FIXED: ApiErrorFactory used no context path and wrong translation key
CHANGED: renamed parameters in Translator for consistency
2018-10-20 01:29:20 +02:00
Kc
d2aab4b446 CHANGED: removed obsolete API methods from BlocksResource
CHANGED: added missing response schemas
2018-10-19 12:35:15 +02:00
Kc
a075705885 ADDED: Swagger UI for API documentation 2018-10-18 20:29:07 +02:00
Kc
23b8fcc96e CHANGED: implemented more BlocksResource methods
CHANGED: added dependency to javax.mail for because of strange "java.lang.NoClassDefFoundError: javax/mail/internet/MimeMultipart" exception when serializing data objects in API resources.
2018-10-15 15:11:22 +02:00
Kc
aff81c2806 CHANGED: removed double output 2018-10-14 22:00:27 +02:00
Kc
74a49baaf3 CHANGED: removed obsolete comment 2018-10-14 20:49:32 +02:00
Kc
9a3eb186cc CHANGED: translation support for API resources 2018-10-14 20:35:49 +02:00
Kc
2eb808a0b7 CHANGED: added comment
CHANGED: default locale
2018-10-12 08:27:49 +02:00
Kc
2d0ced5a72 CHANGED: finished AnnotationPostProcessor for translating swagger annotations
CHANGED: fixed Translator bug that would ignore all translation templates
2018-10-12 08:21:44 +02:00
Kc
b57881bc50 ADDED: post processor stub for API resource annotations 2018-10-11 08:56:25 +02:00
Kc
af84cc8575 CHANGED: simplified AssertExtensions 2018-10-10 00:16:02 +02:00
Kc
730b5033d1 CHANGED: switched to JUnit5
CHANGED: globalization tests
2018-10-04 22:58:04 +02:00
Kc
aa7bdaf713 CHANGED: read translations from XML files 2018-10-04 16:36:45 +02:00
Kc
d24f1de36a CHANGED: added translation context path normalization 2018-10-04 16:36:45 +02:00
Kc
6bc0eeac4d ADDED: TranslationXmlStreamReader + tests for XML based translation files 2018-10-04 16:36:45 +02:00
catbref
e9d8b3e6e3 Unit test fixes + initial CIYAM AT integration
NB: we're still using HSQLDB svn r5836

Updated README.md

Added log4j2.properties file for logging!

Imported CIYAM-AT jar into project-local Maven repo
CIYAM-AT related:
ATData
ATStateData
ATTransactionData
DeployATTransactionData
AT
DeployATTransaction
ATRepository
HSQLDBATRepository
HSQLDBDeployATTransactionRepository
ATTests
DeployATTransactionTransformer

Fixed Block so correct block hash and timestamps are generated,
especially when previous/next block versions differ.
Added extra call in BlockTransformer to aid this.

Fixed GenesisTransaction.isValid's incorrect amount test.

Fixed comments in TransferAssetTransaction and incorrect use of BlockChain.getVotingReleaseTimestamp()
instead of BlockChain.getAssetsReleaseTimestamp().

Added new TYPEs to HSQLDBDatabaseUpdates, and set LOB granularity to 1KB for AT use.
Added AT_address column to DeployATTransactions in HSQLDB.
Added ATs, ATStates and ATTransactions tables.
(You will need to discard existing database and rebuild).

Fixed incorrect byte array output in IssueAssetTransactionTransformer,
where Asset "references" were not processed correctly.

Added support for BigDecimal serialization to a byte-array size other than the standard 8.
2018-10-04 14:38:59 +01:00
catbref
0aa0796f35
Merge pull request #5 from KaaCee/master
HSQLDB and better help
2018-10-03 16:35:38 +01:00
Kc
1b58bc82e9 CHANGED: moved hsqldb-r5836.jar to local maven repository to fix build 2018-09-29 12:23:49 +02:00
Kc
75adc7453c Better help messages
FIXED: save ApiClient.translator
CHANGED: ApiClient now respects more resource annotations for building help messages (success and error responses)
CHANGED: Added more detailed annotations to BlocksResource
2018-09-28 20:41:41 +02:00
catbref
a85a558923 Removed duplicate HSQLDB dependency from pom.xml after merge from Kc 2018-09-28 12:55:53 +01:00
catbref
e5a32bb7e4
Merge pull request #4 from KaaCee/master
API
2018-09-28 12:32:53 +01:00
catbref
6fa874bc77 Modified Maven pom.xml to use HSQLDB jar in lib/ rather than from repo,
as it has bug fixes we need, applied since HSQLDB v2.4.1.

Modified Eclipse Java formatting settings for better enum layout.
2018-09-28 12:31:02 +01:00
Kc
646462942c ADDED: globalization.Translator - basic globalization support (implementation needed)
ADDED: api.Security (implementation needed)
ADDED: api.APIErrorFactory
CHANGED: added command execution to ApiClient
2018-09-24 00:21:47 +02:00
Kc
19a9a3a98b CHANGED: integrated Swagger/OpenApi
CHANGED: added method stubs and describing annotations to BlocksResource
2018-09-20 23:48:20 +02:00
Kc
4f279fc616 ADDED: ApiClient
ADDED: UsageDescription annotation
ADDED: Start class as entry point

first implementation of annotated resource descriptions
2018-09-18 23:41:37 +02:00
Kc
d63ff02b97 CHANGED: added first API resources with jetty and jersey 2018-09-16 23:24:20 +02:00
Kc
9fb434cdd6 CHANGED: fixed ApiService 2018-09-02 10:35:13 +02:00
Kc
2fc74ac583 Added reference to Jersey for RESTful services.
Added Api package.
Added BlocksResource as first candidate for API implementation.
2018-08-30 07:01:28 +02:00
catbref
ad250e57c8 Fix issues with payments, asset trades and voting.
Some payments don't always initialize the recipient's
last reference, depending on whether the asset is QORA or not and
what type of transaction is being processed.
Calls to Payment.process/orphan now take boolean to indicate
whether recipient's last reference should always be initialized
regardless of asset.
("initialized" here means setting an initial last reference for
an account if the current value is null/empty/missing)

When matching orders to produce trades, it isn't enough to only
sort orders with best price first. Orders with the same price also
need to be further sorted by earliest order first. (This was
implicitly done in Qora v1). Added additional ORDER BY sub-clause
to achieve this and improved the corresponding table index too.

Converted a lot of logging from simplistic System.out/err.println
to Apache log4j2. Added several "trace"-level logging statements
to aid debugging which can be activated given appropriate
configuration in log4j2.properties.

With voting, detection of previous votes was broken during orphan
as previousOptionIndex was set to 0 instead of null when fetching
a VoteOnPollTransaction from the HSQLDB repository. This was due
to lack of null-checking - now fixed.
Corresponding changes made in IssueAsset and Message
transaction HSQLDB repository classes.

v1feeder now syncs up to block 99055. Block 99056 contains DeployAT.
Orphaning back to block 1 and then resync works without issue too.
2018-08-08 17:02:41 +01:00
catbref
e56d8f5e02 HSQLDB issue, resource leak prevention, v1 differences
HSQLDB v2.4.0 had some issue with non-padded, case-insensitive string comparisons.
This is fixed in svn r5836-ish of HSQLDB but yet to be pushed out to new HSQLDB release.
So this commit includes hsqldb-r5836.jar and modified pom.xml/.classpath for now.

No need for duplicate, hidden creatorPublicKey in CancelOrderTransactionData,
CreateOrderTransactionData and CreatePollTransactionData.

Various changes to use more try-with-resources, especially with JDBC objects like
Connection, Statement, PreparedStatement, ResultSet.

Added loads of missing @Override annotations.

Fixed bug in Asset exchange order matching where the matching logic loop
would incorrectly adjust temporary amount fulfilled
by the "want" asset amount (in matchedAmount)
instead of the "have" asset amount (in tradePrice).

Disabled check for duplicate asset name in IssueAssetTransactions for old v1 transactions.

In HSQLDB repository we now use ResultSet.getTimestamp(index, UTC-calendar) to make sure we
only store/fetch UTC timestamps. The UTC-calendar is made using static final TimeZone called
HSQLDBRepository.UTC.

To keep asset IDs in line with v1, Assets.asset_id values are generated on-the-fly in HSQLDB
using a "before insert" trigger on Assets table. Corresponding code
calling HSQLDBRepository.callIdentity() replaced with SELECT statement instead.

Moved most of the HSQLDB connection properties from the connection URL to explicit code in
HSQLDBRepositoryFactory.

Fixed incorrect 'amount' lengths in PaymentTransformer, as used by MultiPayment and Arbitrary
transaction types.

Added support for mangled arbitrary transaction bytes when generating/verifying a v1 transaction signature.
In v1 Arbitrary transactions, bytes-for-signing are lost prior to final payment (but only if there are any payments).
Added corresponding code for multi-payment transactions in the same vein.
2018-08-07 15:44:41 +01:00
catbref
7da84b2b85 Arbitrary Transaction support + various fixes
NOTE: requires HSQLDB built from svn rev 5836 or later

Fixed BuyNameTransactionData constructors not picking up nameReference.

Added new "orphan" tool to regress blockchain back to specified block.

Added new Block constructor for when receiving a block from the network.
Fixed Block generatingBalance/forging code to be compliant with v1.
Added logging of transactions that fail validation during block validation.

Fixed buyer/seller balances not being updated during name purchase.

Generally replace BigDecimal.compareTo expressions with "<operator> 0" form.
e.g. instead of someBigDecimal.compareTo(anotherBigDecimal) == 1
we now have someBigDecimal.compareTo(anotherBigDecimal) > 0

Fix amounts involved in BuyNameTransactions.

Renamed Transaction.calcSignature to .sign

Refactored Transaction.toBytesLessSignature to TransactionTransformer.toBytesForSigning,
which itself calls subclass' toBytesForSigningImpl,
which might override Transaction.toBytesForSigningImpl when special v1 mangling is required.

Corrected more cases of NTP.getTime in transaction processing
which should really be transaction's timestmap instead.

Fixed HSQLDB-related issue where strings were padded with spaces during comparison.
Some column types no longer case-insensitive as that mode of comparison
is done during transaction validation.

Added missing option_index column to CreatePollTransactionOptions which was causing
out-of-order options during fetching from repository and hence signature failures.

Added unit tests for v1-special mangled transaction signature checking.

Removed checks for remaining bytes to ByteBuffer in various transaction transformers'
fromByteBuffer() methods as the buffer underflow exception is now caught in
TransactionTransformer.fromBytes.

Corrected byte-related transformations of CreatePollTransactions that were missing
voter counts (albeit always zero).

Corrected byte-related transformations of IssueAssetTransactions that were missing
duplicate signature/reference (v1-special).

Added "txhex" tool to output transaction in hex form, given base58 tx signature.

Added "v1feeder" tool to fetch blocks from v1 node and process them.
2018-08-02 10:02:33 +01:00
catbref
b401adcc55 Added asset order matching support.
Added isFulfilled property to asset orders so completed orders can be filtered out.

Fixed migrate app by adding dummy name_reference values to UpdateNameTransactions and BuyNameTransactions INSERTS.
Fixed migrate app to use "poll_name" instead of "poll" for column name. Ditto "option_name" instead of "option".

Fixed some other incorrect column names in HSQLDBAssetRepository.

More unit tests but probably need yet more to cover complicated asset order matching with various divisibility settings.
Maybe fuzzing would help here somehow?
2018-07-05 16:24:05 +01:00
catbref
104be89b4e Added MultiPaymentTransaction test 2018-07-04 13:53:20 +01:00
catbref
7536ab37fa More tests and fixes resulting from such
Settings class reworked to allow easier testing

Fix to Payment.orphan() where fee was being incorrectly subtracted instead of added

Added AssetRepository.fromAssetName(String): AssetData

Fixed deleting assets from HSQLDB repository due to broken column name in SQL.

Fixed saving IssueAssetTransactions in HSQLDB repository due to missing column binding.

More TransactionTests!
2018-07-04 12:49:56 +01:00
catbref
2bfb0227ae Added BuyNameTransaction support
Fixed IssueAssetTransactions not being constructed with signature.
Fixed incorrect MessageTransactionData constructors.

Refactored various transactions to remove duplicate code.
e.g. in CancelOrderTransaction.process() use getCreator() instead of explicit repository call.

Added name_reference to BuyNameTransactions HSQLDB table.

Fixed incorrect SQL in HSQLDBMultiPaymentTransactionRepository.

More unit tests!

Fixed wrong data length in CancelOrderTransactionTransformer.
Fixed wrong data length in CreateOrderTransactionTransformer.

Fixed missing payment bytes in MultiPaymentTransactionTransformer.toBytes();
2018-07-03 11:40:24 +01:00
catbref
c8be77e7cc Added CancelNameSaleTransactions + fixed dodgy UTF-8 [d]serialization/getDataLength() 2018-07-02 18:59:11 +01:00
catbref
0fc17d76ae Added SellNameTransactions + tests 2018-07-02 18:09:36 +01:00
catbref
c79bec90bc Added UpdateNameTransaction
* Added more columns/properties to NameData to support updating timestamps, name sales
and reference to last transaction that changed Name (for orphaning support).

* Fixed serialization/deserialization bugs in MessageTransactions

* More tests
2018-07-01 16:35:45 +01:00
catbref
4de2caaa28 Added RegisterNameTransactions
Fixed CreatePollTransaction transformer bugs
2018-07-01 09:34:57 +01:00
catbref
70d25f24ce Fix deleting rows from HSQLDB repository & improve transaction tests 2018-06-29 11:05:15 +01:00
catbref
fe6cb4e366 Added Vote-on-poll transaction
* Added simple genesis block timestamp setting to help testing

* Fixed setting account's last reference

* Moved some Poll constants from CreatePollTransaction to Poll

* HSQLDB: added TYPE PollOptionIndex
* HSQLDB: added previous_option_index to VoteOnPollTransactions table to help orphaning
* HSQLDB: renamed "poll" to "poll_name" in same table
* HSQLDB: PollOptions now has additional option_index column

* Improved TransactionTests to allow for different genesis block timestamps.
* Also added VoteOnPollTransaction test
2018-06-29 10:29:18 +01:00
catbref
9651192a2d Rollout conditional signature serialization to remaining transaction types.
Also added/corrected some JavaDoc.
2018-06-28 08:36:12 +01:00
catbref
05e0fd92b9 Work on Polls
Added CreatePollTransactionData constructor that doesn't need signature (for creating new transactions).

Added missing "published" timestamp support to PollData and Poll.

Removed extraneous timestamp test from Block.isValid.

Corrected inconsistent column names in poll-related tables in HSQLDBDatabaseUpdates.

HSQLDBRepository.checkedExecute(PreparedStatement) now takes extra Object... params
so that values can be bound to placeholders. Code moved from checkedExecute(String, Object...).
This fixes an issue with exists(String, String, Object...) where placeholders weren't having
any values bound to them. (Also removed "ORDER BY NULL" clause which isn't supported by HSQLDB).

HSQLDBVotingRepository method stubs fleshed out with real code.

TransactionTests rejigged but more work needed to test various transactions before/after their feature
release. e.g. testing create poll transactions before & after they supposedly went live.

Could do with a GenesisBlock constructor that takes a timestamp for testing purposes?

CreatePollTransactionTransformer now skips serializing a null signature,
in the same way PaymentTransactionTransformer does, to aid getBytesLessSignature().
This will probably need to be rolled out to all other transaction types.
2018-06-21 12:38:45 +01:00
catbref
795da06505 Refactor stupid getResultSetBytes() method & fix migrate
* Replaced occurances of "this.repository.getResultSetBytes(resultSet.getBinaryStream(index))"
with "resultSet.getBytes(index)"

* Replaced corresponding preparedStatement.setBinaryStream() with preparedStatement.setBytes()

* Fixed migrate app so DB can be rebuilt using old v1 Qora client
2018-06-19 16:49:42 +01:00
catbref
5e674cbaab Added Create Poll Transaction support (untested)
* Moved Asset issue/deissue code from IssueAssetTransaction to Asset business object.
* Added more constructors for Asset using IssueAssetTransactionData or assetId.

* Moved some constants from transaction transfers to business objects (e.g. IssueAssetTransaction)
(They might now make more sense being in Asset)

* Changed some transaction isValid() checks to use transaction's timestamp instead of NTP.getTime()

* New VotingRepository - as yet unimplemented

Really need to rewrite "migrate" and add a ton of unit tests.
2018-06-19 12:30:17 +01:00
catbref
c5a32ffa1c Block/Transaction processing
* Add implementation for Account.getBalance(assetId, numberOfConfirmations)

* Added orphan() code to Block (CIYAM AT not yet supported)

* Added getOrder() 'navigation' method to CreateOrderTransaction

* Added missing transaction-type cases to various switches in Transaction, transformers, repositories, etc.

* Various repository delete() methods added

* Added save/delete support for transaction types that include payments, like multipayment and arbitrary

* Changed "recipient" in HSQLDB SharedTransactionPayments from QoraPublicKey to QoraAddress
2018-06-19 09:50:58 +01:00
catbref
4a1c3821db Progess on block and transaction processing + tidying up
* Code added for calculating an account's generating balance. (CIYAM AT support yet to be added).
* Added associated code in Block for calculating next block's timestamp, generating balance, base target, etc.

* ValidationResult enum added to Block, mostly to aid debugging.
* Block.isValid() now returns ValidationResult instead of boolean.
* Block.isValid() now has added proof-of-stake tests.

* Some blockchain-related constants, like feature release heights/timestamps, moved from Block to BlockChain.

* Added better Block constructor for use when creating a new block.
* Added helpful 'navigation' methods to Block to get to block's parent (or child).

* Changed visibility of block's individual signature calculators to protected, in favour of public sign() method.

* Added asset existence check to Payment.isValid.

* All current transaction objects (qora.transaction.*) now have private subclassed transaction variable to save multiple casts in various methods.
* Also added to above:
* isInvolved(Account) : boolean
* getRecipients() : List<Account>
* getAmount(Account) : BigDecimal

* Added BlockRepository.getLastBlock() to fetch highest block in blockchain.

* Added diagnostics to HSQLDBRepository.close() to alert if there are any uncommitted changes during closure.
(Currently under suspicion due to possible HSQLDB bug!)

* Old "TransactionTests" renamed to "SerializationTests" as that's what they really are.

* New "TransactionTests" added to test processing of transactions. (Currently only a PaymentTransaction).

* PaymentTransformer.toBytes() detects and skips null signature. This was causing issues with Transaction.toBytesLessSignature().
Needs rolling out to other transaction types if acceptable.
2018-06-15 17:16:44 +01:00
catbref
9897981de1 Work on assets/payments
* Created PaymentData transfer objects for (recipient, assetId, amount) tuples
* Created corresponding Payment class for validating, processing and orphaning payment(s)

* Modified OrderData to support isClosed for when an Order is cancelled so no more trades can occur

* Migrated CancelOrderTransactions and MultiPaymentTransactions

* Converted MessageTransactions, PaymentTransactions and TransferAssetTransactions to use new Payment class

Can't use PaymentTransformer in PaymentTransformer or TransferAssetTransformer due to serialization differences.
2018-06-14 16:46:55 +01:00
catbref
2f8c160627 More migration of Assets/Orders and TransferAssetTransactions 2018-06-14 13:09:55 +01:00