1543 Commits

Author SHA1 Message Date
tomFlowee 08d79cecab Make the iterator work properly for partial tx
This allows the iterator to work properly when the number of inputs
and/or the number of outputs are zero.
2024-10-04 15:11:27 +02:00
tomFlowee 75faaf9ce1 Improve anonimized sorting to support fees and tokens
The recent features of fee adjusting an output and adding a token to an
output now also work when the transaction is sorted for bip69 style
anonimizing.
2024-10-04 15:10:06 +02:00
tomFlowee fc60f8c396 Move fee calculation into the TransactionBuilder
This adds the feature to take a transaction that has no or very low fee
and telling the TransactionBuilder class to use a certain output to
pay needed fees from.

On the call to createTransaction money will be taken from the specified
output based on the specified fee-per-byte (default 1sat/byte).
2024-10-04 12:09:55 +02:00
tomFlowee c7192dff41 Add text-limit argument to writeHex
The BufferPool::writeHex() method takes a string-pointer, we add an int
max-number-of-chars to be parsed on that string.
This allows us to not just stop at the first non-hex char, but also
after a set number of characters.

This effectively allows us to use non-zere-terminated strings as
argument too.
2024-10-03 14:07:10 +02:00
tomFlowee be89f191e9 Add todo 2024-09-16 23:18:47 +02:00
tomFlowee a674a3fb7c Change returning of 'target' to be a bytearray.
This affects both the BlockChain/GetBlockHeaderReply and the
BlockChain/GetBlockVerboseReply calls.
The field with id 75 was confusingly called 'bits', but this is really
the blocktarget from the blockheaders. We renamed this.

This field is a int-encoded-floating point value and as such it makes no
sense to send it as a simple int. It is now a byte-array.
Notice that the documentation always listed it as a byte-array so we
actually fixed the implementation to follow the spec.
2024-09-16 23:18:34 +02:00
tomFlowee e5986f6199 remove unused include 2024-09-10 19:14:01 +02:00
tomFlowee 9bb8311a5f Minor clarifications.
Rename variable to talk about message instead of package (which probably
was meant to be packet anyway).
Make log message of exception we caught a little more useful.
2024-09-10 19:06:07 +02:00
tomFlowee dd07d8540d unit test for the token API on TransactionBuilder 2024-09-07 19:38:43 +02:00
tomFlowee a85a0f7ad9 Linter tip: add assignment operator
Since there already is a copy constructor.
2024-09-07 19:38:26 +02:00
tomFlowee 135a43c625 Add implementation for building token txs
This includes a small refactor to move the writeCompactSize method
from P2PBuilder internally to a public namespace in StreamingUtils
2024-09-07 12:13:43 +02:00
tomFlowee efeb517cbd Add cashTokens API to TransactionBuilder
This allows adding, actually using the data for new transactions is
still missing.
2024-09-07 12:13:43 +02:00
tomFlowee 020e6afbd3 Improve API for the bitfield.
The CashToken bitfield now is more usable without magic numbers and we
have a bunch of documentation about what the fields mean.

Also remove unused variable.
2024-09-07 12:13:43 +02:00
tomFlowee bd4ea09582 Add docs and make p2sh API easier.
This makes the p2sh push method more sane, this takes a hash and as such
we should have a proper argument for that.
This also adds support for p2sh32.
2024-09-06 20:42:29 +02:00
tomFlowee 82e2309c2a Merge branch 'TxTokenIterator' 2024-09-06 18:19:34 +02:00
tomFlowee da8cec3147 Improve API docs comment 2024-09-05 11:52:31 +02:00
tomFlowee 1da099618d Add cashToken support to Tx::Output
This makes the Tx::nextOutput() and similar methods work properly when a
cashToken is encoutered.
For now we just add a simple bool on the output, this may be replaced
with more rich data if that turns out to be needed by the API users.
2024-09-01 21:51:35 +02:00
John Galt 9d4b32e497 Upgrade Tx::Iterator to support CashTokens
This code is written by Telegram user @John_Galts_Gulch.
2024-09-01 21:50:51 +02:00
tomFlowee a3fc0aecdc Add full starting date/time loglines
Turns out, when reading through log files it is quite useful to list the
time AND date on when an app started.
Additionally, make clear that the logging is in UTC.
2024-08-26 22:04:01 +02:00
tomFlowee b060064d45 Cleanups 2024-08-21 19:45:32 +02:00
tomFlowee 3a25af6f0e Complete the new SSL connections in networkmanager
This completes the API and makes the unit test pass.
2024-08-21 17:58:45 +02:00
tomFlowee 7fcecedd76 Make handshake of ssl connection work. 2024-08-21 16:55:01 +02:00
tomFlowee 69b3d78e19 Making the ssl unit test work. 2024-08-20 22:46:48 +02:00
tomFlowee af5a76f9aa Add server functionality to ssl connections. 2024-08-13 22:56:24 +02:00
tomFlowee 87d771ba8f Merge branch 'master' into sslNetworkManager 2024-08-13 22:55:47 +02:00
tomFlowee 2879587a64 OnDisconnected now shows it is disconnected
The onDisconnected callback is moved to later in the process after the
internal state has been updated so calling 'isConnected()' is what you'd
expect.
2024-08-11 20:32:32 +02:00
tomFlowee 69e275ae4c Add connection-id in debug output
In the networkmanager it may get confusing to see lines without knowing
which connection actually created it. So we add the connection id.
2024-08-11 20:32:32 +02:00
tomFlowee 8c31f8d004 Revert "Make simpler"
This reverts commit e28b5e1823.

The port number is again passed through the dns lookup, which is
weird as fuck but needed to get the actual resulting iterator still
have the port numebr we wanted to connect to.
2024-08-11 19:37:21 +02:00
tomFlowee b84a934977 comments 2024-08-11 18:49:35 +02:00
tomFlowee 93c413a004 Make simple (plain) stuff work again. 2024-08-11 18:49:35 +02:00
tomFlowee f0d426dc90 make compile 2024-08-11 18:49:35 +02:00
tomFlowee d2ce7e61d2 Refactor socket to live in a wrapping class. 2024-08-11 18:49:35 +02:00
tomFlowee 712dcdb3a6 Start to implement the ssl server. 2024-08-11 18:49:35 +02:00
tomFlowee b4e90cf945 Add ssl lib to networkmanager 2024-08-11 18:49:35 +02:00
tomFlowee 210fef16cc Start making space for an ssl backend. 2024-08-11 18:49:35 +02:00
tomFlowee 85a6e20e1a Have better spread checkpoints and adjust the unit test
This updates the unit test to move the tiny chain it tests to match the
new checkpoint location.
2024-07-06 22:00:34 +02:00
tomFlowee 9008b4a312 Update checkpoints
The checkpoints were formerly copied from the full node, so based
on possible fork-events.
That seems less useful nowadays and since we want to be able to
allow starting a blockchain instance from any checkpoint it makes
sense to spread them out more evenly.
Based on the concept that the BCH chain generates around 50K blocks
a year, we simply use that interval.

This removes various very old ones meaning that the total count is
roughly equal.
2024-06-29 20:26:35 +02:00
tomFlowee 0838a4cc93 Add more support for checkpoint based chains.
This improves the docs, adds a getter and last it makes the
blockHeightAtTime() more secure by not returning a value below the
checkpoint. As this would throw if used directly in the block() method.
2024-06-29 11:52:29 +02:00
tomFlowee 4acc8ee883 Fix check for chain integrity. 2024-06-26 21:57:07 +02:00
tomFlowee c2ae326620 More sanity checks for creating partial chain. 2024-06-25 23:01:59 +02:00
tomFlowee 3b91e503ff Fix binary search on smaller chain
When a chain starts from a checkpoint instead of '1', we should limit
our search to that in order to avoid codepaths that throw.
2024-06-25 23:00:51 +02:00
tomFlowee 073e133ec7 Improve readability of warning 2024-06-25 22:59:36 +02:00
tomFlowee 68cf4ae48f Fix ConstBuffer::indexOf constness
This method is now const, as it should be.
2024-06-11 21:34:41 +02:00
tomFlowee 6a84a262cc Add more ConstBuffer helper methods
This adds endsWith() and an extra startsWith() overload.

We also added tests for the case when either the argument or the object
are empty and specify the behavior. I copied the behavior of QString.

See unit tests that specify the behavior with empties.
2024-06-11 17:57:17 +02:00
tomFlowee dc3545857d [p2pnet] Add Blockchain::replaceStatichain()
This public method allows an application to replace the static-
header files in a life-situation. Without needing to restart the app.

The idea is that a static chain starts at a checkpoint, and we extend
it into the past to start at an earlier checkpoint. This suddenly
makes available a larger amount of history without changing anything
of the data that was already there.
2024-06-02 21:22:37 +02:00
tomFlowee 5ada583bd1 Fixlets in code and comments. 2024-06-02 11:58:05 +02:00
tomFlowee dcaddcca7c Remove unused include 2024-06-01 19:22:27 +02:00
tomFlowee 7ecd46ba1c Make checkpoints available via method call.
This also adds docs.
And this moves away from the map which isn't worth the code complexity
with the low number of entries.
2024-05-31 13:05:38 +02:00
tomFlowee 422822530b Add Blockchain::dataSources() getter
The blockchain object holds all block-headers, the backing store for
this class is now being exposed more to allow understanding what we have
or not have available. And also what the source of that info is.
2024-05-28 10:51:52 +02:00
tomFlowee 4845de2470 Add PrivateKey::fromBase58() 2024-05-01 21:55:25 +02:00