Commit Graph

72 Commits

Author SHA1 Message Date
tomFlowee 1b5ae89d31 [Refactor] rename FastTransaction.{h|cpp} -> Tx.* 2021-11-02 11:05:14 +01:00
tomFlowee 50af3dc02c [Refactor] rename FastBlock.{h|cpp} -> Block.* 2021-11-02 10:24:58 +01:00
tomFlowee 6ff0e7c0de [Refactor] FastBlock -> Block 2021-11-02 10:18:24 +01:00
tomFlowee fcb648916d Make pubkey follow coding styleguide 2021-04-19 14:48:18 +02:00
tomFlowee c82766d9c7 Micro optimization 2021-03-27 16:02:49 +01:00
tomFlowee 3e9fe7aa3c Add to the Flowee API: Mining::SubmitBlock
This adds a new API endpoint that allows submitting of a new block to be
validated and possibly appended to the tip of the chain.
2021-03-24 21:00:25 +01:00
tomFlowee c1cdbba72b Add new feature, search a block with script-type
This new flag to the getBlock API call allows us to select
a transaction based on the usage of a certain script opcode.
This uses the new metadata index.
2021-03-24 19:08:25 +01:00
tomFlowee aa57e4bbb2 Merge branch 'blockMetadata' 2021-03-12 14:12:11 +01:00
tomFlowee e9fd6384d5 Fix regression, and improve message
This again fetches the transaction data itself.
2021-03-12 14:08:16 +01:00
tomFlowee 6405ff2bad Finish up some metadata details. 2021-03-12 09:35:27 +01:00
tomFlowee bd5baa7133 Add ability to retrieve fees for a transaction.
This adds an option to the GetTransaction Flowee API to return the fees
for a whole transaction.
Support for this is added in the Blockchain (searcher) and the
RestService components.

Notice that no fees will be returned if the BlockMetaData was not
created properly.
2021-03-12 09:06:06 +01:00
tomFlowee 2a52ee3fe6 Use meta when available for finding tx.
This implements the getrawtransaction API/RPC calls to now use the meta
object, when available, for much faster finding of a transaction by txid.
2021-03-10 20:11:04 +01:00
tomFlowee 0cd6469efa Don't repeat default log section 2021-03-10 18:09:35 +01:00
tomFlowee b697a17168 Add 'validationOnly' option to API 2021-03-04 15:48:56 +01:00
tomFlowee 630b8422ed Upgrade RPC method to take a blockhash
This also moves the code to search linearly in a block onto the
FastBlock class, for reusal.
2021-03-03 10:17:14 +01:00
tomFlowee 4d5e7bfb09 Protect node with user-limits for the API.
This introduces several options for public node operators to limit their
nodes usage by 3rd parties, this is aimed at usage of resource-hungry
areas.

We allow limiting the amount of connections any single IP can keep open
with us.
We limit the amount of reconnects we allow in a short number of seconds.
We allow limiting the number of addresses (or scriptHashes) a peer can
register for the node to scan.
The last one is for both the addressMonitorService as well as for the
getBlock filters.

For node operators these items become available using command line
options or config-file options. By default these limits are unlimited as
we assume default usage to be private.
2021-02-26 15:14:14 +01:00
tomFlowee 85e089b155 Calculate needed space better
We calculate the needed space for the network buffers before we fill them,
as new features are added guestimating ended up short.
Lets do the real calculation.
2021-02-17 17:11:24 +01:00
tomFlowee aea317cf71 Be better at handling bad input.
When the transaction offset is wrong and doesn't parse we turn the
generic runtime_exception into one that goes back to the API caller.
Also catch those generic exceptions on the server level to avoid this
kind of error from disconnecting a peer.
2021-02-16 18:36:40 +01:00
tomFlowee efa23bd2db Extend Live::GetTransaction to search on address too
This allows API users to search the mempool on address or on txid.

This also adds a new unit test testing this functionality
2021-02-11 15:21:54 +01:00
tomFlowee 47702ad4a4 Port getaddress to be a native call. 2021-02-11 14:15:23 +01:00
tomFlowee 3fe98afce9 Minor cleanup
This removes some unused includes from common headers and dead code
from some C++ files.
2021-01-05 22:05:25 +01:00
tomFlowee 9748d3988f Cleanups and improvements. 2020-12-25 23:51:06 +01:00
Justaphf 517db921f9 Add getmempoolinfo RPC wrapper to API 2020-12-24 09:57:30 -05:00
TomZ ff58ae6a36 Implement the first ASync API command
This implements the sendTransaction command using the async framework,
allowing clients to benefit from multi-core systems to process
transactions in parallel when being submitted to the Hub.
2020-10-26 18:21:52 +01:00
TomZ 0293890e80 Add optional async job to Hub API
The current design of the API is that all questions are answered in-
order. This implies that handling of one connection will also just use
one thread.

If we want to improve performance of things like "sendTransaction" we
want an async option, which runs the action and generates the answer
when its done in a separate thread (a new one for each async-request).

This breaks the in-order reply sequence for clients and as such it
requires them to set a new header-option to enable this.
2020-09-29 17:34:06 +02:00
TomZ b033cd8ac4 [API] Add outindex field to mempool address search
When you request matching transactions from the mempool for certain
addreses, the API now returns the matched output-index as a separate
tag, which makes it easier to, for instance, use the 'amount' field in
the reply.
2020-09-18 20:40:11 +02:00
TomZ fcc3b094ef [API] Improve featureset of MempoolSearch
The mempool search now shares its serialization code with the blockchain
transaction fetcher, allowing all the filtering and include flags to work
here too.
This also fixes several bugs and reverts the mempool API change.
Additionally I return the FirstSeenTime for each mempool entry.

There is a slight API breakage in the LiveTransactions service, which as
far as I know is still unused outside of Flowee.
These enum values changed:
Api::LiveTransactions::
  Transaction   20 =>  25
  UnspentState  23 => 26
  OutputScript  24 => 23

The reason for this change is to have the Blockchain namespace in
sync with the LiveTransactions namespace for similar features.
2020-09-14 15:27:15 +02:00
TomZ db9a80f8eb [API] Add support to query the mempool
This allows a search based on TxId or output-script-hash for
mempool transactions.
We include double spend proof info when available in the reply
2020-09-11 14:07:14 +02:00
TomZ 1355c03f63 Fix warnings
This fixes warnings from the compiler and the linter.
2020-09-02 13:47:07 +02:00
TomZ dda576b4bc Fix some warnings
Code cleanliness nitpicking.
2020-07-31 15:58:15 +02:00
TomZ 8e1eefaa81 Improve error message
when user specified wrong offset, send them an error.
2020-07-27 21:26:21 +02:00
TomZ dcff0532dc Improve error message
When missing argument, return to peer a specific message
2020-07-27 12:34:27 +02:00
TomZ f2191ad380 Make UTXO lookup report also the outindex
We have that info, it should be send.
2019-11-30 18:56:25 +01:00
TomZ 79e4974d19 Port API getblock::filter to use script-hash
The API call for GetBlock has a filter-on-address functionality which is
now ported to no longer use ripe160 addresses but instead uses output-
script hashes.
This avoids problems for transactions not using p2pkh and generally is a
cleaner solution.

This also adds a unit test to test this feature.
2019-10-20 22:12:09 +02:00
TomZ 00814e24f9 API: Use hash of outscript instead of address
The usage of a ripe160 for bitcoin addresses in the API and in the
Indexer loses some info, specifically what kind of script it is.
Additionally not all types of scripts fit this mold. At best that means
its not future-proof.

This adds a method to the API in order to select from a Tx the hashed
outscript (thats singlehashed sha256) and refactor the address indexer
to use that instead of the ripe160 address.

The API enums broke a little, so I used the opportunity to break it a
lot and clean up the enums in order to make them more future-proof.
But, yeah, software from before this commit is protocol incompatible
with software after this commit.
2019-10-16 22:57:50 +02:00
TomZ 817682025d API make utxo also react to offsetinblock
Since all the APIs use blockheight/offsetinblock instead of TXID we
should be consistent and allow the UTXO fetch API to use this too.
2019-09-13 16:02:22 +02:00
TomZ c2fe9629c1 Remove dead code. 2019-09-12 15:20:29 +02:00
TomZ c2083fe5b0 Count missing bytes for the tag and length too 2019-08-04 21:19:56 +02:00
TomZ ba213cfe9d Fix optimisation.
It incorrectly assumed all transactions were coinbases.
2019-06-19 22:45:44 +02:00
TomZ 9eb3814103 Stabilize new API 2019-06-17 20:50:17 +02:00
TomZ 4a4a61aeed Add unit test for GetTransaction
This also includes a little blockchain of 114 blocks (the first 100 just
coinbase to reach coin-maturity) with transactions generated by the
txVulcano. So lots of outputs.

I adjusted the BlackBoxTest to load this data into any hub with ease.
2019-06-16 23:04:14 +02:00
TomZ d5750426f4 Avoid sending too much 2019-06-15 19:57:35 +02:00
TomZ 1c27a291d0 Add a way for GetTransaction to only return certain outputs 2019-06-15 16:19:27 +02:00
TomZ 2eba51c5c6 Check message size in debug builds.
Double check our message-calculation is proper by checking the result.
Notice that asserts and logDebug both are turned off in release builds,
so this is just added to debug builds.
2019-06-13 12:30:20 +02:00
TomZ 4b96a30279 Use the chain, not the header for the API 2019-06-11 21:15:23 +02:00
TomZ 3fcd3536ed Clarify coinbase pos in block.
The first field after the header is the number of transactions. This
is a variable-width field of between 1 and 9 bytes.
Coinbase starts after that.
2019-06-11 17:38:30 +02:00
TomZ a310a529ce API cleanup; don't send prevtxhash for coinbases
The prevTxHash and prevOutIndex are irrelevant for coinbases as
the input isn't really an input.
2019-06-11 17:38:30 +02:00
TomZ 0a916c21e9 Add UTXO support to APIs
Generically this looks like this;

IsUnspent
[
  { "txid": "0x111111", "output": 1 },
  { "txid": "0x111111", "output": 11 }
]
IsUnspentReply
[
  { "blockHeight": 1111, "offsetInBlock": 1111, "unspent": true },
  { "unspent": false }
]

GetUnspentOutput
[
  { "txid": "0x111111", "output": 1 },
  { "txid": "0x111111", "output": 0 }
]
GetUnspentOutputReply
[
  { "blockHeight": 1111, "offsetInBlock": 1111, "unspent": true,
    "amount": 1111, "outputscript": "bytearray" },
  { "unspent": false }
]

note: txids are naturally always sha256s.
2019-06-10 21:02:15 +02:00
TomZ 449f91f46d Move solver method to utils lib
The code that detects standard script-types is now available as a
library function, renamed to live in a namespace;
Script::solver()
2019-06-06 22:21:46 +02:00
TomZ 26fda112a0 Fix bug in API for where the answer is a plain bytearray.
This allows RPC wrapper classes to reuse the default implementation also
when the answer is not a uint256
2019-05-23 12:12:25 +02:00