Commit Graph

259 Commits

Author SHA1 Message Date
catbref
e6acc92ed0 Fix pom.xml so generated package-info.java files are added to build
This was done automatically by Eclipse but didn't happen with
stand-alone Maven building.
2018-12-13 17:52:34 +00:00
catbref
3ec3c69447 API: wholesale conversion back to Base58
XmlJavaTypeAdapter api.Base58TypeAdapter converts byte[] to Base58.
This XmlAdapter is applied at package-level to all packages inside data and api.models.
So no need to annotate every byte[] property!
Added package-info-maven-plugin to pom.xml to do this.

block-explorer.html fixed to show/use base58 again

Some data objects (e.g. TransactionData) have added XmlElements that
convert public keys to addresses, for convenience.

Several API calls updated to return specifically text/plain instead
of ambiguous application/json and/or text/plain. (Typically
API calls that return a single value, e.g. an integer, like /blocks/height).
2018-12-13 17:25:47 +00:00
catbref
034cf5dee3 API: assets & tidying
Cleaned up responses from /addresses/* endpoints
in that some return text/plain instead of application/json.

Removed need for class-local copy of ApiErrorFactory in
AddressesResource - using getInstance() instead.

Some work still needs to be done on annotating API errors.
API error examples in API UI rendered incorrectly - swagger-ui issue?

Removed repository-accessing code from api.models.*

Added /assets/order/{orderId} for fetching info on specific asset order.

NOTE: AssetRepository.getOrdersTrades() now returns trades where order is
initiating or target. (Previously was initiating order only).
qora.assets.Order.orphan() updated to reflect above change.

block-explorer.html fixed to use new API output.
2018-12-13 12:22:46 +00:00
catbref
dcd19f8e42 Transaction-specific info in API results 2018-12-13 08:44:50 +00:00
catbref
cfd8b53fc1 API, HSQLDB
Added more global parameters to /admin/unused API endpoint (formally /admin/dud)
and also managed to remove /admin/unused from API documentation UI.

Added results slicing to /assets/all

Added /assets/orderbook API call that returns open asset orders

Added /assets/trades that returns successful asset trades

Added POST /assets/issue stub

Unified HSQLDB connectionUrl to public variable inside Controller class.

Can't deploy v1 ATs with isFinished=true flag as that prevents later
transactions sending messages (during import of v1 chain).
Some future hard-fork code will need to set all v1 ATs to "finished".

Changed DB's "TransactionRecipients" to "TransactionParticipants" to
properly support API call to find all transactions 'involving' a
specific address. Support code needed in Block and Transaction with
some transaction-specific overrides for Genesis and AT transactions.

Removed old, deprecated calls from Transaction/TransactionRepository

Moved HSQLDB database properties from connection URL to explicit
SQL statements in HSQLDBDatabaseUpdates. They didn't work in
connection URL during DB creation anyway.

Retrofitted HSQLDB Accounts table with public_key column instead of
rebuilding it later.

Fixed incorrect comments in IssueAssetTransactionTransformer regarding
v1 serialization for signing.

Re-imported v1 chain to test latest changes.
2018-12-12 12:13:06 +00:00
catbref
2aaa199c86 API: basic asset info
Added repository support for asset API calls

Added /utils/seed for returning server-generated 32-byte seed
2018-12-11 13:48:10 +00:00
catbref
3829630b29 API: transaction searching
Converted AddressesResource to full base64, removing base58.
Narrowed range of API errors returnable while there.
Added support for looking up public key of address.
Added support for converting public key TO address.

Added API endpoint for returning a range of block signatures,
to aid block explorers.

Added API support for fetching unconfirmed transactions.
Added API endpoint for searching transactions to meet criteria like:
- participating address (only recipients supported ATM)
- block height range
- transaction type
- result count limit/offset

---

Added storage of account's public key in repository
along with supporting code in AccountData and Account
business object to save public key where possible.
2018-12-10 13:27:41 +00:00
catbref
b5c02f49ce Work on API
Rejigged pom.xml, extracting common dependency versions as properties.
Removed extraneous HSQLDB dependency (v2.4.1) as we're using svn r5836 for now.

Removed calls to Security.checkApiCallAllowed() for all API calls EXCEPT /admin/stop.
Throws error if remote IP is not localhost.

Added 'global' OpenAPI parameters to fake /admin/dud endpoint to save copy&pasting.
This will need more tidying in the future, or at least future support from swagger-core.
Code added in AnnotationPostProcessor to insert global parameters in top-level
  OpenAPI components section.

/block-explorer.html hidden from API UI

BlocksResource now expects Base64 block signatures instead of Base58.
Endpoints that return block data also accept optional "includeTransactions"
    query param which does exactly that.
BlockWithTransactions API model added for above.

Some attempt to get transaction-specific data returned but no luck as yet.
(TransactionData, GenesisTransactionData, PaymentTransactionData touched).
See https://github.com/swagger-api/swagger-core/issues/3046

TransactionsResource now has support for optional query params "limit" and "offset"
    so that only a subset of large results can be requested.

UtilsResource added to provide convenient Base64<->Base58 conversions.

/admin/uptime fixed to return uptime from application launch instead of
    instantiation of AdminResource class!

Controller improved to detect repository and API startup failures.

HSQLDBRepositoryFactory now detects when it can't open database and throws.
(Before it would simply hang).

Removed extraneous import from qora.account.Account
2018-12-07 17:42:31 +00:00
catbref
df2a414cf4 Replace toLocaleString with toUTCString in BlockExplorer due to Chrome bug 2018-12-05 12:18:33 +00:00
catbref
28c2cdaf5b FATJAR packaging + block explorer changes
Switched from maven-assembly-plugin to maven-shade-plugin for
building FATJAR.
When running from FATJAR, class-path is ". .." to help find
log4j2.properties file.

Swagger-UI can now be served direct from inside FATJAR instead
of requiring resources in filesystem.

Default package Start now controller/Controller

block-explorer.html now served via Jetty and modified to use
relative URLs instead of absolute http://localhost:9085/... style

Improved shutdown code in controller

/admin/stop API call disabled for now

Highly permissive settings.json added
2018-12-05 11:32:55 +00:00
catbref
ad9fa9bf9d More work on API plus basic block explorer
Added FATJAR packaging support to pom.xml

Added some "summary" fields to API calls but more need doing.
Corrected path clash from having unnecessary @OpenAPIDefinition annotations.
Added API "tags" to group similar calls (address-based, block-related, etc.)
Fixed addresses/lastreference/{address}
Implemented addresses/lastreference/{address}/unconfirmed
Implemented addresses/assets/{address}
Added /admin/stop and /admin/uptime API calls.
Moved general API info into new src/api/ApiDefinition.java
Added CORS support to ApiService
Added /transactions/address/{address} and /transactions/block/{signature}

Replaced references to test.Common.* to do with repository factory.
 This fixes issues with building FATJAR due to references to test classes
 that are omitted from FATJAR.

Changes to AccountBalanceData, BlockData and TransactionData
 to support JAX-RS rendering to JSON.

Added getUnconfirmedLastReference() to Account.

Added getAllBalances(address) to account repository
 - returns all asset balances for that address.

Added getAllSignaturesInvolvingAddress(address) to account repository
 but currently only uses TransactionRecipients HSQLDB table.
 (And even that wasn't automatically populated).

Included: very basic block explorer to be opened in browser as a file:
block-explorer.html
2018-12-04 16:34:55 +00:00
catbref
9dcdcb0ffe Files missing from previous commit (somehow) 2018-12-03 13:12:52 +00:00
catbref
90094be95a CIYAM-ATv2 can be used with any asset, not just QORA.
Some initial BTC cross-chain support. (Needs more work).

Unified timestamp for V2 switchover to block version 4,
applicable to several transaction types.

Qora-specific interface to CIYAM ATv2 library.

Beware: some areas still work-in-progress!
2018-12-03 13:05:38 +00:00
catbref
eaad565765 Moved tests to outside of src/ path
This allows them to be excluded from final built package.

pom.xml and .classpath updated

Unable to test due to lack of JUnit 5 in Eclipse Neon
2018-11-02 15:52:09 +00:00
catbref
5526f9a7f0 More work on integrating CIYAM AT v2
Now using ATv2 dated 20181101172102

ATData now uses byte[] creatorPublicKey instead of String creator.

TransactionData now has hashCode() and equals() methods,
which is needed for new Transaction Comparator,
used to sort transactions within a block,
AT-first, then timestamp, then signature.

AT-Transactions generate their own signatures using SHA2-256 of serialized data.

Arbitrary Transactions try to clean up their files when orphaned.

Deploy AT Transactions now check creation bytes (even for old v1 ATs).

Deprecated Transaction.getBlock() as it doesn't seem used
and would be better to simply have getHeight() rather than
a method that 'knows too much' about Blocks/BlockData.
Corresponding TransactionRepository.getBlockDataFromSignature()
also deprecated.

Loads more comments.

Tidied up some SQL: mainly correcting case,
moving PRIMARY KEY clauses to end of CREATE TABLE,
removing unnecessary columns from indexes.

Added "type" column to TransactionCreatorIndex so users can find
their transactions and optionally filter by type.

In BlockTransactions table, transaction_signature is now UNIQUE
as a transaction cannot be included in more than one block.

Various AT-related HSQLDB table and index changes.

ArbitraryTransactions transformer fixed to always return a list of payments,
even if empty. (Previously could return null which broke things).

Added simplistic block generator.

NOTE: unit tests broken due to pending upgrade to JUnit 5
2018-11-02 10:30:51 +00:00
catbref
3c8a1713d5
Merge pull request #6 from KaaCee/master
Globalization/translation implementation and switch to JUnit5
2018-10-31 09:46:18 +00:00
catbref
24ae771867
Merge branch 'master' into master 2018-10-31 09:40:27 +00:00
catbref
2c51a0362b Finally syncs with qora1 chain!
ATData no longer needs deploySignature as a link back to DeployATTransaction,
but does need creator and creation [timestamp].
"creation" is critical for ordering ATs when creating/validating blocks.

Similar changes to ATStateData, adding creation, stateHash (for quicker
comparison with blocks received over the network), and fees incurred
by running AT on that block.
Also added more explicit constructors for different scenarios.

BlockData upgraded from simplistic "atBytes" to use ATStateData (above)
which has details on ATs run for that block, fees incurred, and a hash
of the AT's state. atCount added to keep track of how many ATs ran.

ATTransactions essentially reuse the GenesisAccount's publickey as
creator/sender as they're brought into existence by the Qora code
rather than an end user. ATTransactionData updated to reflect this
and the AT's address used as a "sender" field.

Account tidied up with respect to CIYAM ATs and setConfirmedBalance
ensures there is a corresponding record in Accounts (DB table).

Account, and subclasses, don't need "throws DataException" on
constructor any more.

Fixed bug in Asset Order matching where the matching engine
would give up after first potential match instead of trying others.

Lots more work on CIYAM AT, albeit mainly blind importing of old
v1 ATs from static JSON file as they're all dead and new
v2 implementation is not backwards compatible.

More work on Blocks, mostly AT stuff, but also fork-based corruption
prevention using fix from Qora v1.

Payment-related transactions (multipayment, etc.) always expect/use
non-null (albeit maybe empty) list of PaymentData when validating,
processing or orphaning.
Mainly a change in HSQLDBTransactionRepository.getPayments()

Payment.isValid(byte[], PaymentData, BigDecimal, boolean isZeroAmountValid)
didn't pass on isZeroAmountValid to called method - whoops!

Lots of work on ATTransactions themselves.

MessageTransactions incorrectly assumed the optional payment was always
in Qora. Now fixed to use the transaction's provided assetId.

Mass of fixes/additions to HSQLDBATRepository, especially fixing
incorrect reference to Assets DB table!

In HSQLDBDatabaseUpdates, bump QoraAmount type from DECIMAL(19,8)
to DECIMAL(27,8) to allow for huge asset quantities.
You WILL have to rebuild your database!
2018-10-26 17:47:47 +01:00
Kc
01ee7dd7e3 CHANGED: some more method implementations in AddressesResource 2018-10-22 14:59:35 +02:00
Kc
193f8d05c4 CHANGED: implemented AddressResource.getLastReference(..) 2018-10-21 16:32:06 +02:00
Kc
11c8af4b0c ADDED: AddressResource + method stubs 2018-10-21 15:17:37 +02:00
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
catbref
46eee3cbce More work on CIYAM AT support.
ATs can create AT-Transactions which contain payments (of any asset) and/or messages.

Legacy Qora1 DeployATTransactions create AT records in the repository but set to "finished"
so that they never execute.

More repository support for ATs.

In HSQLDB, create a new TYPE called ATStateHash which is used to verify the same AT outcome
on a per-block basis.
Added Accounts.account as a foreign key to AccountBalances with ON DELETE CASCADE.
ATStates now include state_hash and fees on a per-block basis.
ATTransactions now include asset_id.

When transforming DeployATTransactions, don't include any signature when collating bytes for signing!
2018-10-15 15:12:41 +01: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