Commit Graph

362 Commits

Author SHA1 Message Date
tomFlowee 9e3eeaec51 Fix fee-adjustment feature.
Adjusting the fee actually changes the transaction data and as such we
need to redo all the signatures.
This update fixes the method-structure to do this properly.
2024-10-08 19:16:08 +02:00
tomFlowee ed2bb58288 remove unused includes. 2024-10-08 13:22:41 +02:00
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 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 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