Commit Graph

1049 Commits

Author SHA1 Message Date
catbref
3c06d358b7 interim commit with proxy forging repository/transaction support
no block validity/generator support yet
2019-04-12 12:53:44 +01:00
catbref
2dc1720af8 Initial support for account flags + tx (genesis account use only atm) 2019-04-12 12:50:10 +01:00
catbref
85acc4d9df Fix incorrect refunds when cancelling asset orders
Also improved asset tests in that they don't use QORA any more
which takes fees/block rewards out of the picture.

More test assets are issued in the genesis block to
accomplish this:

1m TEST issued to Alice
1m OTHER issued to Bob
1m GOLD issued to Alice
2019-04-12 10:38:25 +01:00
catbref
2f51ced5c0 Fix incorrectly applied price improvement refund.
Also fix broken tests which contributed to this bug slipping by.
2019-04-12 08:44:13 +01:00
catbref
c23f55e6a6 Asset trading: refund saving due to price improvement back to initiator
Added test case to cover the above.

Also improve test harness to properly check balances after orphan back to genesis.
2019-04-11 17:47:12 +01:00
catbref
16dab6972c Fix some asset orders incorrectly matching worse prices. 2019-04-10 15:25:16 +01:00
catbref
cfbf5c12bf Supply extra information fields to various asset-related API calls.
e.g. supply "assetName" in JSON for TRANSFER_ASSET transactions

Also supply have/want asset names, amount asset ID/name, price-pair
and creator address in asset orders.

Show CREATE_ASSET_ORDER amount ID/name & price-pair in correct
format depending on whether transaction was placed before/after
'new' asset pricing took effect. (Orders are always in 'new' form).

Change API call /assets/transfers/{assetid}/{address} to
/assets/transfers/{assetid} with optional "address" query param.
2019-04-10 13:09:30 +01:00
catbref
d5a2e5be19 Bump Eclipse Jetty version to 9.4.12.v20180830 due to CVE 2019-04-10 07:41:46 +01:00
catbref
ed3065f145
Merge pull request #8 from catbref/new-asset-pricing2
New asset pricing scheme (take 2)
2019-04-10 07:19:59 +01:00
catbref
a5e963911d New asset pricing scheme (take 2)
Orders are back to having "amount" and "price".
(No more "unitPrice" or "wantAmount").

Order "amount" is expressed in terms of asset with highest
assetID.
"price" is expressed in (lowest-assetID)/(highest-assetID).

Given an order with two assets, e.g. QORA (0) and GOLD (31),
"amount" is in GOLD (31), "price" is in QORA/GOLD (0/31).

Order's "fulfilled" is in the same asset as "amount".

Yet more tests and debugging.

For simplicity's sake, the change to HSQLDB repository is
assumed to take place when 'new' pricing switch also
occurs.

Don't forget to change "newAssetPricingTimestamp" in
blockchain config JSON file.
2019-04-10 07:18:50 +01:00
catbref
1b45ee85e7 Fix handling of CORS preflight OPTIONS requests.
Typical log entry would be:

2019-04-05 09:47:08 ERROR WadlGeneratorJAXBGrammarGenerator:401 - Failed to generate the schema for the JAX-B elements
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4 counts of IllegalAnnotationExceptions
        at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91) ~[?:1.8.0_191]
2019-04-05 10:56:38 +01:00
catbref
7026c35e73 For API "GET /assets" add optional query param "includeData" 2019-04-04 12:33:12 +01:00
catbref
97142fdde8 Return HTTP 400 code with useful message when a ParamException occurs from API call. 2019-04-04 12:30:28 +01:00
catbref
315ebff61d Add optional API request logging via "apiLoggingEnabled" entry in Settings 2019-04-04 11:33:13 +01:00
catbref
ed94c3c5b3 Fix Crypto.isValidAddress to return false when passed empty string 2019-04-04 10:41:04 +01:00
catbref
d9be12e62f
Merge pull request #7 from catbref/assets
Merge "assets" branch into master
2019-04-04 09:15:28 +01:00
catbref
26e3adb92b Completing work on new asset trading changes
Changed API call GET /assets to NOT return asset "data" fields
as they can be huge. If need be, call GET /assets/info to fetch
a specific asset's data field.

Improve asset trade amount granularity, especially for indivisible
assets, under "new" pricing scheme only.

Added corresponding tests for granularity adjustments.

Fix/unify asset order logging text under "old" and "new"
pricing schemes.

Change asset order related API data models so that old "price" is
now "unitPrice" and add new "return" as in amount of want-asset
to receive if have-asset "amount" was fully matched.
(Affects OrderData, CreateAssetOrderTransactionData)

Some changes to the HSQLDB tables.

Don't forget to add "newAssetPricingTimestamp" to your blockchain config's
"featureTriggers" map.
2019-04-03 18:00:20 +01:00
catbref
60e562566e Interim commit on new asset trading schema
Better order matching, especially in situations
where inexact fractional representations (e.g. 1/12)
or rounding issues might occur. Also better matching
with indivisible assets.

Essentially change ordering from have-amount & price
to have-amount and want-return, leaving unit price
to be calculated internally to a finer degree (in
some cases to 48 decimal points).

Corresponding unit tests to cover both legacy and new
scenarios. Support for tests to switch between
blockchain configs.

"New" pricing schema is its own 'feature trigger'
independent from general qorav2 switch.

Safety checks added during trading process.

HSQLDB schema changes (will probably need
careful conflict resolution on merge).

Still to do:

API changes
etc.
2019-04-02 21:10:16 +01:00
catbref
031657878e Added safety feature to prevent negative balances 2019-03-29 10:56:46 +00:00
catbref
789b311984 Interim commit with newer asset order "price" arg
+ unit test
+ newer unit test harness

but still needs:

BlockChain config support for activating newer "price" arg
New unit test to check old "price" arg usage

Rework existing asset-related unit tests

Check API inputs/output pre/post "price" arg crossover
2019-03-28 16:28:31 +00:00
catbref
d3c1602d9b Adjust Asset data max size to reflect HSQLDB CLOB size
+ fix incorrect logic when calculating issue-asset transaction
data length
2019-03-26 14:36:47 +00:00
catbref
d741580ccf Restore missing minimum fee checks & ValidationResult 2019-03-26 14:36:06 +00:00
catbref
c69f84afab Added ApiExceptionManager to try to trace IllegalAnnotationExceptions 2019-03-26 14:34:45 +00:00
catbref
870646fec8 Correct min/max block times for testing blockchain config 2019-03-26 14:32:51 +00:00
catbref
5f5b847bee Using m2e-aware version of package-info-maven-plugin (v1.0.2-m2e) 2019-03-26 11:03:50 +00:00
catbref
c5e5020369 In API call /assets/balances, change "ordering" to be optional but with default "ASSET_BALANCE_ACCOUNT" 2019-03-25 15:21:10 +00:00
catbref
a4d28d52cc Add variety of results ordering options to API GET /assets/balances 2019-03-25 12:24:22 +00:00
catbref
0fd8ee3547 Add API GET /assets/transfers/{assetid}/{address} 2019-03-25 11:55:03 +00:00
catbref
2a45e27048 Important FIX to payment-related isValid()!
Non-native-coin payments (e.g. transfer-asset) didn't build map
for checking whether sender had enough balance.

Also fixed raw layout description for TRANSFER_ASSET.

Also fixed ISSUE_ASSET deserialization to use empty string (instead
of null) for v1 transactions.
2019-03-25 11:23:18 +00:00
catbref
eb038b8f31 Controller debugging, including logging build version/timestamp 2019-03-25 11:22:57 +00:00
catbref
461c9211da Bump qora-core v2 hard fork timestamp to 00:00:00 June 1st 2019 2019-03-25 11:21:56 +00:00
catbref
315a3c33cf Add API error handler to log unexpected errors/exceptions
Fixed /admin/uptime to return text/plain instead of application/json
 as response is only a simple long.
Ditto /admin/stop.
2019-03-19 10:09:01 +00:00
catbref
048c54fc0a Add API call to support TRANSFER_ASSET + activity summary API call 2019-03-18 11:34:46 +00:00
catbref
91ee505ba9 Fix GET /assets/trades/recent regression + silence Jetty timeout warnings 2019-03-17 13:35:24 +00:00
catbref
76277ae9c3 Increase asset "data" size and make description/data optional in UPDATE_ASSET
Bumped Asset data size from 4K to 400K
2019-03-15 11:22:53 +00:00
catbref
1b3fa5c806 Automatically set/unset account's defaultGroupId + bugfix
FIX: somehow GET /groups/member/{address} HSQLDB's query broke
2019-03-14 13:12:20 +00:00
catbref
d53777f461 Added "data" field to assets, added UPDATE_ASSET tx + fixes 2019-03-13 14:06:52 +00:00
catbref
8f72d9d423 Don't return empty balances when requesting all asset holders. 2019-03-11 13:03:57 +00:00
catbref
cdd1f5e966 API modifications, remove blockchain defaultGroupId, Eclipse/git
GET /assets/trades/recent expanded to allow multiple otherAssetIds

When GET /assets/balances is called with address(es) but no assetIDs
then it will return balances for all assets, including zero balances
for assets the addresses don't own.

GET /addresses/{address} no long fakes a default groupID - in fact
defaultGroupId now removed from blockchain config.

Some Eclipse IDE files now hidden/removed from git repo.
2019-03-11 11:17:34 +00:00
catbref
43eec116b5 Reorder handshake to increase compat with v1 nodes + request remote peers 2019-03-06 10:40:39 +00:00
catbref
bf3f78e718 Add AssetOrders is_closed fix-up to DB updates + minor 2019-03-05 11:12:00 +00:00
catbref
4d69242cdb Added/improved assets-related API calls
Imported Block/BlockChain fixes from "minting" branch to do
with block timestamps.

GET /assets/holders/{assetid}
and
GET /assets/address/{address}
and
GET /assets/balance/{assetid}/{address}
all combined into
GET /assets/balances?address=...&address=...&assetid=...&assetid=...

New GET /assets/trades/recent?assetid=...&assetid=...
that returns most recent two trades for each asset-pair.

GET /assets/orders/{address}/{assetid}/{otherassetid} has
includeClosed and includeFulfilled repurposed as
isClosed (true/false/omitted) and isFulfilled (true/false/omitted).

ALSO, Order.isClosed is now set to true when isFulfilled is set to true
during processing (and correspondingly set to false during orphaning).

AccountBalanceData now includes optional assetName field for use with API
but generally not set for internal use.
2019-03-04 18:53:54 +00:00
catbref
752361ecff Performance fix & other minor fixes
Fixed bug in GenesisBlock which wasn't stripping
out ISSUE_ASSET transactions for v1 blockchains.

Updated blockchain.json for v1 qora blockchain to
fall into line with new BlockChain config
unmarshalling code.

Improved TransactionData.equals when comparing
exact same object.

Improved HSQLDBBlockRepository.getHeightFromTimestamp to use OffsetDateTime
object, which includes time zone info, to fix incorrect SQL full-scan
so that DB now does index-scan instead. Also converted use of MAX(column)
to ORDER BY column DESC as MAX() not optimized when MVCC in effect.

Added corresponding INDEX to Blocks on columns (generation, height);

Similar MAX(column) to ORDER BY column DESC improvement for getBlockchainHeight().

Bumped size of HSQLDB TYPE ATTags from VARCHAR(32) to VARCHAR(80)

Improved reflection-based method calls to rethrow underlying exceptions
like DataException, TransformationException, etc. instead of losing
them in general InvocationTargetException.

Re-added atTransaction.toBytes() method so v1 transactions can be verified.

Fixed extraneous additional copy of voter's public key when serializing
in VoteOnPollTransactionTransformer.toBytes()

Fix-up of v1feeder
2019-03-04 11:41:30 +00:00
catbref
dbf365472f Suppress Reflections log entry using log4j2.properties 2019-02-27 14:43:01 +00:00
catbref
edcbf4f318 Add support for "only one registered name per account" + de-static brokenMD160 blockchain flag 2019-02-27 10:34:25 +00:00
catbref
ec5eba9c60 Fix up some group-approval related issues
UPDATE_NAME requires txGroupId to match original txGroupId used in REGISTER_NAME
UPDATE_GROUP requires txGroupId to match original txGroupId used in CREATE_GROUP

Extraneous JAXB unmarshal code removed from various transaction constructors.
Incorrect, old, groupID vs txGroupId checks removed from various transactions.

Fix bug in UPDATE_GROUP fromBase() method using mismatched column indexes.

Fix bug in API's pending transaction fetch not checking admin is of the same
group as the txGroupId. (Fix actually in HSQLDBTransactionRepository).
Similar fix in GroupApprovalTransaction.
2019-02-26 16:52:22 +00:00
catbref
c7123df79d Better logging for settings/blockchain JSON file parsing 2019-02-26 11:20:44 +00:00
catbref
deae03f1a4 Fix blockchain config logic error 2019-02-26 11:07:44 +00:00
catbref
c80ac9e321 Asset API additions, txGroupId minor fix, testnet blockgen fix
GET /assets/orderbook/{assetid}/{otherassetid} renamed to
GET /assets/openorders/{assetid}/{otherassetid}

Replacement /assets/orderbook/{assetid}/{otherassetid} now
returns aggregated orders, with entries containing only
"price" and "unfulfilled" (amount).

Added /assets/orders/{assetid}/{otherassetid}/{address} to return
orders by specific account, for a specific asset-pair.

Block timestamp validity extracted to separate method so that
BlockGenerator can test timestamp and generate blocks at the usual
rate, even for testnets. This still allows testnets to a way to
generate blocks on demand as Block's isValid skips some timestamp
validity checks if testnet.

txGroupId was sometimes incorrectedly checked for approval-less tx types.
2019-02-26 10:56:19 +00:00
catbref
16c1b13ab2 Proper JSON unmarshalling for settings, blockchain config, genesis block
GenesisBlock (v4) now supports various transaction types (issue-asset, etc.)
 with generated signatures (like genesis transaction signature) and
 missing references inserted.

JUnit reverted back to v4 for Eclipse support (for now).
2019-02-25 13:31:05 +00:00