Commit Graph

810 Commits

Author SHA1 Message Date
catbref
5f4b66e5b0 Save public keys from CHAT transactions so they can be fetched via API. 2020-05-20 15:53:43 +01:00
catbref
9c48343581 Potential fix for rare HSQLDB "serialization failure" in Transaction.importAsUnconfirmed() 2020-05-20 07:33:21 +01:00
catbref
219f82f562 Modify API call GET /chats/active/{address} to return info on all joined groups.
Previously GET /chats/active/{address} would only return an active group chat
entry where 'address' was a member AND there was an existing CHAT
transaction with the same tx_group_id (and no recipient).

Now the response contains entries for ALL groups where 'address' is a member,
regardless of an existing CHAT transactions, omitting the 'timestamp' entry
if there are none.
2020-05-19 17:12:41 +01:00
catbref
51bfd49e25 Re-add missing senderName & recipientName to output of API call GET /chat/messages 2020-05-19 15:29:12 +01:00
catbref
7102f4a727 Fix for incorrect amounts reported by API 2020-05-19 15:20:20 +01:00
catbref
28991a926f Fix incorrect getDataLength() in RegisterNameTransactionTransformer 2020-05-19 14:55:26 +01:00
catbref
74f89af841 Enforce version 2+ for DEPLOY_AT 2020-05-19 08:35:25 +01:00
catbref
b4284515e7 Unify transaction NAME_NOT_LOWER_CASE checks to Unicode NAME_NOT_NORMALIZED version 2020-05-19 08:31:36 +01:00
catbref
032c5d0d07 Add missing fee check to TRANSFER_PRIVS 2020-05-19 08:25:53 +01:00
catbref
72100fe1d8 Refactor Unicode 'reduced' name code from side-effects into 'data' objects.
CREATE_GROUP, ISSUE_ASSET, REGISTER_NAME and UPDATE_NAME transactions affected.

The code to actually generate 'reduced' name was called inside isValid() and
relied on setting the corresponding transaction data object field so that it would
be saved by isValid()'s caller. Although this worked, it wasn't a very clean
solution.

Now the 'reduced' name is generated by transaction data object's constructors so
it is always present.

Also removed name/group/asset reduceName(String) methods as they were all the
same single-line call to Unicode.sanitize().
2020-05-19 08:08:21 +01:00
catbref
ed178e744d Merge branch 'asset-unicode' into launch 2020-05-19 07:57:06 +01:00
catbref
94f7079c2e Unicode homoglyph support to Assets 2020-05-19 07:56:17 +01:00
catbref
f1638aa9d9 Removed "owner" from CREATE_GROUP and added Unicode homoglyph support.
Group owner now derived from CREATE_GROUP transaction creator's public key.

Added 'reduced' group name to GroupData, with corresponding change to DB.
Renamed GroupData.getIsOpen() to simply isOpen().

Tidied up CreateGroupTransactionData, adding 'reduced' group name.
Renamed getIsOpen() to simply isOpen().
Added code to generated reduced group name when building genesis block.

Added Group.MIN_NAME_SIZE of 3.

DB tables changed to add reduced_group_name where appropriate,
removing owner where necessary.

Added GroupRepository.reducedGroupNameExists(String).

Fixed up test blockchain configs in src/test/resources/test-chain-v2*.json.
2020-05-18 17:27:32 +01:00
catbref
a7b9215ace Merge branch 'message-wo-recipient' into launch 2020-05-18 10:12:54 +01:00
catbref
956ad7bfa8 Merge branch 'asset-fixes' into launch 2020-05-18 10:12:42 +01:00
catbref
4baf442cb8 Merge branch 'name-fixes' into launch 2020-05-18 10:12:31 +01:00
catbref
24eb7c6933 Allow MESSAGE transactions to have no recipient.
This allows on-chain messages to a group, including NO_GROUP / groupID zero.

No-recipient messages cannot have an amount - where would it go?

Changed MESSAGE serialization layout to add boolean indicating
whether recipient is present.

Changed MESSAGE serialization layout so assetID is after amount,
and only present if amount is non-zero.

Changed DB table structures to cover above.

Added unit tests to cover above.
2020-05-18 09:09:35 +01:00
catbref
38a2af8cd5 Tidy up Assets by removing 'owner' from ISSUE_ASSET.
Owner now derived from issuer's public key.
Maximum asset name length reduced to 40 characters.

Repository table changes.

"owner" removed from test blockchain configs and "issuerPublicKey" used instead
where applicable.

Some getters in the form of "getIs___()" renamed to simply "is____()".
2020-05-15 16:22:13 +01:00
catbref
7447ab20a9 Add index for finding Registered Names using 'reduced' form 2020-05-15 14:18:51 +01:00
catbref
197c742ce7 Major work on Registered Names
Changes include:

* Allowing renaming
* Tracking last-updated timestamps
* More stringent Unicode processing
* Way more unit tests
* Max name length reduction to 40 chars

Note: HSQLDB repository table changes
2020-05-15 14:08:46 +01:00
catbref
f6ed3388a4 BTC tidy-up 2020-05-15 07:45:24 +01:00
catbref
c61690f3e6 BTC class does not need to extend Thread! 2020-05-14 13:18:44 +01:00
catbref
9a94873d0e Fix broken Long vs Long comparison in Block.areAtsValid() 2020-05-14 13:18:17 +01:00
catbref
5c8bda37d1 Rework BTC class for better startup & shutdown.
Controller no longer starts up BTC support during main startup.
This does mean that BTC startup is deferred until first BTC-related
action, and that the first BTC-related action will take much longer
to complete.

Added tests to cover startup/shutdown.

This also fixes splash logo stuck on-screen and broken Controller
shutdown when using REGTEST bitcoin network AND there is no
local regtest bitcoin server running.
2020-05-14 12:52:26 +01:00
catbref
fbb73ee88e Suppress extraneous bitcoinj logging output 2020-05-14 12:52:08 +01:00
catbref
fa08041696 BlockTransformer should skip AT transactions when calculating block length 2020-05-14 12:51:44 +01:00
catbref
f01a34a461 Throw an API error for inappropriate calls on OFFER-state cross-chain ATs.
P2SH-related API calls under /crosschain/ aren't applicable for
cross-chain ATs that are still in OFFER state, only TRADE state.
2020-05-14 12:48:41 +01:00
catbref
c0242fe78b Correct comment and example Windows dirname entry in log4j2.properties 2020-05-14 11:42:22 +01:00
catbref
ef790a8cb1 Fix missing groupId 0 entry in output from API call GET /chat/active/{address} 2020-05-13 16:30:28 +01:00
catbref
cea0cee9a8 Names: fixes to allow name change and tests to cover 2020-05-13 15:07:36 +01:00
catbref
d9f784ed2b Registered names: changing 'owner' and allowing renaming.
REGISTER_NAME has an "owner" field which can be different from the actual
registrant (transaction creator's public key, used for signing transaction).

This allowed people to register names to be owned by someone else, thus breaking
the whole "one name per account" aspect.

So now "owner" is removed from REGISTER_NAME, and the actual owner address is
derived from transaction creator's public key, as you would expect.

Similarly, UPDATE_NAME has a corresponding "newOwner" field which has been removed.

In addition, UPDATE_NAME now allows users to change their registered name using a new
"newName" field.

Various changes made to DB, Name class, etc. to accomodate above, along with some minor
bug-fixes and comment improvements/corrections.

Needs new unit tests to cover both new functionality and old!
2020-05-13 10:19:56 +01:00
catbref
f29ae656b9 More work on CHAT
Always add group 0 info to output of API call GET /chats/active/{address}.
No groupName entry as it's "no group" or "group-less" or "not group related".
Timestamp also might be omitted if no message found.

Fix output of POST /chats/compute so it doesn't include zeroed 64-byte signature.
2020-05-12 20:27:09 +01:00
catbref
a9852e5305 More work on CHAT API / support.
Renamed GET /chats/search to /chats/messages.

Added GET /chats/active/{address} to return lists of group chats
and direct chats involving {address}, where a chat message exists.
2020-05-12 14:28:41 +01:00
catbref
32470fa641 Improve CHAT API and repository support.
Change CHAT API call GET /chat/search to better support the two
main scenarios of:

group-based chatting: supply txGroupId only
private chatting: supply 2 'involving' addresses only

Added some DB indexes to cater for above.

GET /chat/search now returns specialized ChatMessage objects
instead of ChatTransactions. This is to reduce unnecessary fetching
of data from repository, and onward sending to API client.
2020-05-12 10:02:41 +01:00
catbref
0d1c08bf96 Add index on DB Names.owner to help find names by owner 2020-05-12 10:02:26 +01:00
catbref
026c904ce4 Change processing of network TRANSACTION_SIGNATURES message.
Previously Controller would loop through the transaction signatures,
discard those already known, and then requesting the full transaction
via peer.getResponse(). This would tie up a networking thread for some
time and also potentially cause repository deadlocks, although the latter
could have been fixed another way.

However, the code after peer.getResponse() was identical to the code
processing an incoming TRANSACTION message. Now instead of requesting
and waiting for then processing each transaction, Controller simply
sends the peer a GET_TRANSACTION for each unknown transaction signature.

As the peer responds with corresponding TRANSACTION messages, these can
be processed individually with shorter period of locking.
2020-05-12 08:03:11 +01:00
catbref
59ae070c83 Fix API call POST /peers so it returns "false" for existing peer, instead of throwing / Internal Server Error 2020-05-11 12:59:56 +01:00
catbref
2ab695f308 NTP: don't call shutdownNow() on null instanceExecutor
When using fixed NTP offset, e.g. via "testNtpoffset" in settings.json,
Controller calls NTP.shutdownNow() which throws a NPE because
NTP.instanceExecutor is null.
2020-05-11 12:59:45 +01:00
catbref
f0ff77cd31 Fix ChatTransaction w.r.t. txGroupId meaning. Relax no-QORT PoW difficulty. 2020-05-11 12:58:46 +01:00
catbref
e241d9fa67 Split CHAT compute into separate API call to help UI 2020-05-11 12:58:05 +01:00
catbref
5e9b0cd03c Fix GroupInvites.expires_when in DB to re-allow NULL 2020-05-11 12:55:58 +01:00
catbref
a5c437913f Transaction.isValidTxGroupId() changed from private to protected - needed so ChatTransaction can override 2020-05-11 12:55:22 +01:00
catbref
3fa7da5115 Fix for incorrect blocksMinted count. Added test to cover 2020-05-08 08:51:56 +01:00
catbref
6d8f41ab05 Fix long overflow in Block.distributeBlockRewardToQoraHolders()
Sadly no native 128bit integer support in Java 11 so resorting to using
BigInteger.

Added/improved unit tests to cover.
2020-05-07 16:37:40 +01:00
catbref
c7c419a3cd Bump version in pom.xml to v1.1.0 ready for launch 2020-05-07 13:30:34 +01:00
catbref
3094ec3c26 Massive clean-up of DB & conversion to long for timestamps
Collated all development changes to DB so now we build
initial DB structure directly with final layout.
i.e. no ALTER TABLE, etc.

Reordered HSQLDB 'CREATE TYPE' statements into alphabetical order
for easier maintainability.

Replaced TIMESTAMP WITH TIME ZONE with simple BIGINT ("EpochMillis").
Timezone conversion is now a presentation task, rather than having
pretty values in database.

Removed associated conversion methods, like toOffsetDateTime(),
fromOffsetDateTime() and getZonedTimestampMilli().

Renamed some DB columns to make them more obviously timestamps, like:
Names.registered is now Names.registered_when.

Removed IFNULL(balance, 0) from HSQLDBAccountRepository as balances
are never null, or actually never 0 either.

Added more tests to increase API call, and hence repository, coverage.

Removed unused "milestone block" from Transactions.
2020-05-07 12:16:22 +01:00
catbref
359a35931e Fix broken Transaction.getUnconfirmedTransactions() and getInvalidTransactions() 2020-05-07 12:15:09 +01:00
catbref
9e0001c4f6 Improved comments, variable names, etc. for some repository interfaces 2020-05-07 10:22:44 +01:00
catbref
53112709fe Improve comment & tidy annotation in GroupData 2020-05-07 10:11:35 +01:00
catbref
d1bc500ab9 Correct two unit tests from BigDecimal to long/int. 2020-05-06 15:03:41 +01:00