Commit Graph

346 Commits

Author SHA1 Message Date
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 4845de2470 Add PrivateKey::fromBase58() 2024-05-01 21:55:25 +02:00
tomFlowee 4f3fd8b5bd Add support for xpriv import on HDMasterKey
This essentially adds support for a derived HDMasterKey to exist.
2024-05-01 21:54:19 +02:00
tomFlowee 2cd73ba4fb Add xpriv creation with derivation path. 2024-04-29 21:13:03 +02:00
tomFlowee 65517840ac Add level() getter 2024-04-26 16:56:44 +02:00
tomFlowee 8da1892995 Add ConstBuffer toHex() methods to get a string out. 2024-04-21 00:11:47 +02:00
tomFlowee 3e9cf0173f Add assert to avoid misuse and mem issues. 2024-04-21 00:11:07 +02:00
tomFlowee 2983c8e7a0 Add txversion getter/setter 2024-03-13 17:02:19 +01:00
tomFlowee 8a0ece8316 Doc fixes 2024-02-14 00:16:39 +01:00
tomFlowee 64fa922605 fix whitespace 2024-02-12 21:16:55 +01:00
tomFlowee 5c4d6a987d Add the missing headers to this combined set 2024-01-24 21:03:58 +01:00
tomFlowee b6958d4ad7 Install the combined header too 2024-01-24 21:03:58 +01:00
tomFlowee 4fe9d69e7b Use more specific define-guards 2024-01-24 21:03:58 +01:00
tomFlowee 98260e15ac Add API docs. 2024-01-13 18:07:39 +01:00
tomFlowee 874c898430 Remove unused include 2024-01-13 18:06:58 +01:00
tomFlowee bc47a700a4 Refactor; wrap BufferPool in shared_ptr
As we moved most of the creation of a BufferPool to be via the
Streaming::pool() method, which uses a thread-local, it makes sense
to start cleaning up the design and make it more modern C++.
The above mentioned method would return a reference and you'd see
loads of places use `auto &pool =` which is less than ideal.

As the number of places where we actually instantiate a BufferPool
goes down, the usage of some sort of smart pointer makes more sense.

This now makes all APIs use BufferPool be wrapped in a shared_ptr.
2023-12-21 15:23:23 +01:00
tomFlowee 391019ce49 Import upstream changes for C++20 compatibility
This simply imports the latest version of these support files from
BCHN and implicitly Core.
2023-12-10 13:00:21 +01:00
tomFlowee f596abe6cd Add ConstBuffer support to PrivateKey 2023-12-05 17:12:26 +01:00
tomFlowee 9a0cf513b5 Add constbuffer constructor 2023-11-24 22:20:40 +01:00
tomFlowee 2d0aec2cd7 Rename file to match class it is in
This follows the coding style guideline that the file that contains a
class should follow the exact name of this (main) class.

key.{h|cpp} -> PrivateKey.{h|cpp}
2023-11-24 22:20:40 +01:00
tomFlowee fce11e8d4f Rename file to match class it is in.
This follows the coding style guideline that the file that contains a
class should follow the exact name of this (main) class.

pubkey.{h|cpp} -> PublicKey.{h|cpp}
pubkey_utils.{h|cpp} -> PublicKeyUtils.{h|cpp}
2023-11-24 22:20:40 +01:00
tomFlowee 1f57aef0df Add comment. 2023-10-24 20:29:31 +02:00
Calin Culianu 49dab048ab Nit: Default "unknown" mnemonic format to BIP39 2023-10-19 17:02:14 +03:00
Calin Culianu 3e05677abf Implemented reviewer suggestion + added unit tests
- Changed API for HDMasterKey::fromMnemonic to use an enum to specify
  BIP39 vs Electrum format phrase
- Added unit test for this class to existing unit tests
2023-10-19 16:13:32 +03:00
Calin Culianu 26c39f58ac Add support for Electrum mnemonic phrases.
These are almost identical to BIP39. They use the same word list except:

- The checksum is calculated differently
- Deriving the master key from them uses a different pbkdf512 salt
  ("electrum" vs "mnemonic")
2023-10-18 20:56:20 +03:00
Calin Culianu 3945e3069a Fix some build issues on macOS + clang 2023-10-17 22:01:20 +03:00
tomFlowee f39953cdc3 Throw properly
off-by-one fix, would not throw when referring to 1 item after the
dataset.
2023-10-16 20:30:42 +02:00
tomFlowee a65284e0ec Add ConstBuffer clear which makes it invalid. 2023-09-04 14:10:35 +02:00
tomFlowee a2bad4e298 Make bufferpool more sturdy.
Calling commit with a negative value now no longer returns a
valid-but-broken buffer. It now returns an invalid buffer.
2023-09-04 14:10:35 +02:00
tomFlowee 8e2f57ddf7 Implement int32/int64 support for protoparser. 2023-09-02 23:14:18 +02:00
tomFlowee 04877ab4b1 Add new method to convert TO cashaddress
Given an output script, convert to a cash-address.

Notice that this only supports p2pkh / p2sh for now.
2023-09-02 19:40:46 +02:00
tomFlowee 30ea4aeb98 api docs 2023-07-20 17:45:37 +02:00
tomFlowee 69562c6767 Finish the method signature, add size. 2023-07-17 21:02:43 +02:00
tomFlowee b4cb8098f9 Add new exported class StringUtils
This uses old methods from the ugly utilstrencodings files
and cleans them up to allow us to install this header file and
use these methods outside of theHub repo.
2023-07-15 12:27:44 +02:00
tomFlowee 33d1bc27f4 Work slowly to fix the disease of unsigned char
There factually is no difference between char and unsigned char
except in very rare cases (like bitshifting). But in APIs they
are incompatible, which is a pain...
2023-07-15 12:24:40 +02:00
tomFlowee ebaccb6fee Move include to cpp file 2023-07-15 11:36:19 +02:00
tomFlowee 10510fcb99 Add ProtoBuilder / ProtoParser classes
Protocol Buffers interaction is just another serialization standard,
while its widespread it has fortunately mostly been kept out of
anything relevant or important. Mostly due to the fact that is
really quite bad from a technical perspective.

This adds simple and basic support for creating and parsing
protocol buffer messages, mostly to allow interoperability.
If you want quality: use the MessagBuilder/MessageParser ones instead.
2023-07-14 11:45:47 +02:00
tomFlowee 1e3a4aeee3 Add out of bounds check for MessageParser 2023-07-09 17:09:07 +02:00
tomFlowee 148720afa5 Remove outdated comment. 2023-06-14 16:47:39 +02:00
tomFlowee c637e66cb1 Make compile on gcc 13 2023-05-06 23:29:34 +02:00
tomFlowee 3becd7aa45 Remove unused log sections and code
Decentralized all things!

But, really, don't put the logging sections for external apps in the
library code.
2023-04-04 15:47:25 +02:00
tomFlowee 805c2d9893 Split out the too-big logging section 'p2pnet'.
This introduces the spv-sync debug section as a child of the p2p lib
logging section.
2023-04-01 22:58:11 +02:00
tomFlowee 1d75226cd6 Add comments 2023-01-30 17:10:12 +01:00
tomFlowee b5b493542b Rework base58 and tests
The unit tests testing base58 encoding were using univalue JSON
parsing, since we deprecatd univalue to be a hub-private lib
this has now been ported to Qts JSON parser.
Which also makes the clunky cmake hack nice to replace with the
QRC files concept.

As I was in there anyway, the base58 methods being global scope
C-style methods has now been fixed by putting them in a namespace.
2022-12-13 11:34:54 +01:00
tomFlowee c63519fa47 Move 3rdparty libraries around.
The leveldb and univalue 3rd party libraries are not installed and
not needed by anyone outside of the Hub.
So move them there, making it easier for 3rd party usage.
2022-12-13 11:34:54 +01:00
tomFlowee 6de770466b Avoid possible references-of-deleted
This sanity check might avoid issues in future code by not assuming a
log channel (or anything it depends on) will avoid using logging at the
moment it is shutting down.
2022-11-25 14:01:05 +01:00
tomFlowee f3fb02a522 Make channel interface available
The manager now has an addChannel() method for anyone wanting to
implement a separate logging channel.
2022-11-24 18:14:14 +01:00
tomFlowee f798bf6fe5 On adding log-file output, instantly open it.
This allows this API to be used in more places and do the expected
thing.
2022-11-11 19:03:57 +01:00
tomFlowee 58afd8ab6a Make compile with older libc 2022-09-13 20:30:38 +02:00