Commit Graph

9896 Commits

Author SHA1 Message Date
Jason Rhinelander d28c24a176
Rename oaes_lib to oaes_lib_expand
Since all it is now is just the key expansion from oaes_lib
2022-07-21 21:16:17 -03:00
Jason Rhinelander b450affb1a
Slim down oaes_lib
The only thing we use from it is the aes key expansion, so just delete
everything else and change the interface to just do key expansion.
2022-07-21 21:11:44 -03:00
Jason Rhinelander 3015683511
Avoid failure if the trigger doesn't exist
I'm not entirely sure how this happens, but I came across a node that
was failing here because the trigger didn't exist -- possibly from a
partial upgrade?

In any case, the `IF EXISTS` makes it more lenient.
2022-07-19 22:47:57 -03:00
Thomas Winget 1311a20e9f merge dev branch with RPC/wallet3 changes
Incomplete, many things to fix, some annotated with
a comment MERGEFIX
2022-07-11 20:40:50 -04:00
Jason Rhinelander f87dfd0d51
Overhaul print_locked_stakes output
The CLI wallets `print_locked_stakes` was buggy, overly verbose, and
missing pertinent information.  This overhauls it.

Details are below; the quick differences:
- show the staking requirement
- make key image output optional with a +key_images flag on the command
- fix various bugs such as just showing the first contribution as the
  "total" contribution
- add the wallet address of extra contributions, rather than just the
  key image with no other info.
- put your own contributions first, and mark them as such
- show totals of other contributors
- sort service nodes to put unlocking nodes first; among unlocking and
  non-unlocking nodes we sort by hex pubkey string.
- sort locked dereg outputs by unlock height
- considerable reformatting of how things are displayed

---

Output now looks like this:

First we have 1-2 lines of general info:

    Service Node: abcdef123456...
    Unlock Height: 1234567         (omitted if not unlocking)

If there are other contributors then we print a total line such as:

    Total Contributions: 15000 OXEN of 15000 OXEN required

For our own contribution, when we have a single contribution, we use one of:

    Your Contribution: 5000 OXEN (Key image: abcdef123...)
    Your Contribution: 5000 OXEN of 15000 OXEN required (Key image: abcdef123...)

(the second one applies if we are the only contributor so far).

If we made multiple contributions then:

    Your Contributions: 5000 OXEN in 2 contributions:
    Your Contributions: 5000 OXEN of 15000 OXEN required in 2 contributions:

(the second one if we are the only contributor so far).

This is followed by the individual contributions:

        ‣ 4000.5 OXEN (Key image: abcdef123...)
        ‣ 999.5 OXEN (Key image: 789cba456...)

If there are other contributors then we also print:

    Other contributions: 10000 OXEN from 2 contributors:
        • 1234.565 OXEN (T6U7YGUcPJffbaF5p8NLC3VidwJyHSdMaGmSxTBV645v33CmLq2ZvMqBdY9AVB2z8uhbHPCZSuZbv68hE6NBXBc51Gg9MGUGr)
          Key image 123456789...
        • 8765.435 OXEN (T6Tpop5RZdwE39iBvoP5xpJVoMpYPUwQpef9zS2tLL8yVgbppBbtGnzZxzkSp53Coi88wbsTHiokr7k8MQU94mGF1zzERqELK)
          ‣ 7530 OXEN (Key image: 23456789a...)
          ‣ 1235.435 OXEN (Key image: 3456789ab...)

If we aren't showing key images then all the key image details get omitted.

---

Locked key images get overhauled too; it wasn't at all clear from the
output *why* these are locked (i.e. these are locked contributions of
failed SNs):

    Locked Stakes due to Service Node Deregistration:
        ‣ 234.567 OXEN (Unlock height 1234567; Key image: abcfed999...)
        ‣ 5000 OXEN (Unlock height 123333; Key image: cbcfef989...)
2022-07-11 17:21:17 -03:00
Jason Rhinelander efebe83225
Fix empty lines in `print_locked_stakes` output
Fixes #1575

We were appending a newline for every locked stake rather than just this
wallet's locked stakes.
2022-07-11 14:38:56 -03:00
Jason Rhinelander bee13a319c
Merge pull request #1569 from darcys22/pop-blocks-investigation
Pop blocks investigation
2022-07-07 18:20:19 -03:00
Jason Rhinelander cd90b1bf0d
Merge pull request #1571 from jagerman/negative-emissions
Fix negative coinbase emissions
2022-07-07 18:20:01 -03:00
Jason Rhinelander 815b7bdc1f
Fix negative coinbase emissions
With batching, individual blocks can have a negative coinbase emission
because the tx fee gets added to the batch rewards database and not paid
out immediately, which then results in an negative overflow to a value
close to 2^64.  Thus a block with no payout and a tx fee will have an
erroneous huge positive coinbase emission when queried via
`get_coinbase_tx_sum`.  For example block 1094068 queried with:

    {"jsonrpc":"2.0","id":"0","method":"get_coinbase_tx_sum","params":{"height": 1094068, "count": 1}}

returns:

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "burn_amount": 0,
        "emission_amount": 18446744073699378616,
        "fee_amount": 10173000,
        "status": "OK"
      }
    }

This commit fixes it by making the values signed (and also serves as an
example of why unsigned integers are usually the wrong choice):

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "burn_amount": 0,
        "emission_amount": -10173000,
        "fee_amount": 10173000,
        "status": "OK"
      }
    }
2022-07-05 10:24:08 -03:00
Sean Darcy 8566f8b973 nano s plus HID pid 2022-06-29 15:27:22 +10:00
Sean Darcy ed605fc1ac handle big pops 2022-06-23 16:37:21 +10:00
Sean Darcy fa88a104d4 keep add block and pop block for batching database in sync with service node list 2022-06-21 15:14:04 +10:00
Jason Rhinelander b5a5d01b04
Optimization: reuse reward vector
Profiling shows noticeable CPU spend in allocating memory for this
vector (which makes sense, since we are looping through ~1700 nodes and
building a reward vector for each one).  Avoid it by reusing a single
vector that gets cleared (but not reallocated more than a handful of
times).

This reduces batching CPU time in a debug build by about 12%; curiously
I didn't find a noticeable reduction in a release build.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 230b6bdc0d
128 bit optimizations
Use intrinsic 128-bit types when supported by the compiler; the
operations on them are a bit faster than the two-uint64_t
implementations we do not, and this shaves about 7% off the batch
processing time (which makes a lot of mul128_div64 calls).

Also removes a bunch of unused, useless epee crap from int-util.h.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 0f918f46d4
Downgrade upgrade info message 2022-06-19 12:36:40 -03:00
Jason Rhinelander 33a0762563
Batching address string optimizations
Converting between internal addresses and string wallet addresses is
surprisingly expensive (partly because a keccak hash is involved);
normally on the blockchain that doesn't matter because string
conversions are rare, but batching exposed some code paths that do the
conversion a lot.

This makes two optimizations to considerably speed up batching
processing time:

1. Add an address string hash for batch addresses.  We don't see that
   many, but we tend to see the same addresses for *every* block.  By
   caching it we can considerably reduce the time needed to do the
   actual conversions.

2. In many places we don't really need strings at all: we can work just
   with the address_infos (which are cheap).  This eliminates some of
   the places we use addresses and pushes address_infos further through
   the code.

In total, this plus the previous optimization drop batch processing time
by this cuts batch processing CPU time by about 85%, roughly half from
this optimization and roughly half from the store-offsets optimization.

On a debug build, timing mainnet resyncing from just before HF19 to
current:

- neither optimization: 223.60s spent processing batch jobs (of 282s
  total recalculating subsystems).
- just offsets: 131s spent in batch processing
- both optimizations: 33s spent in batch processing (down to 60s total
  recalculating).

On a release build:
- before: 107.35s (4.73s snl; 95.55s batch)
- after: 28.27s (4.66s snl; 0.00s ons; 21.72s batch)
2022-06-19 12:36:40 -03:00
Jason Rhinelander 1ff341a7cf
Store payment_offset in batched_payments_accrued
This drastically increases the speed of processing new blocks because we
can select only the addresses we care about.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 0ed150012e
Fix batch timing reporting; reduce block processing size
Batch timing was being reported as 0s, even though it is taking up the
vast majority of the time as of the HF block.

Reduce the block processing size to 500 blocks at a time rather than
1000.

Change when we print status updates to print once duration passes a 10s
threshold rather than every 10*1000 blocks.

This latter change probably also makes oxend more reliable on
low-powered servers because it also guards the systemd status update
message (which is needed to give us more watchdog time).
2022-06-19 12:34:56 -03:00
Sean Darcy b324193dc3
Keep SNL state correct during resyncing of sqlite submodule
When the sqlite batching database is resyncing it is dependant on the
service node list state being correct at the time the block is added to
the batching database. When syncing a singular module this sometimes is
not the case as the service node list state may be ahead or behind. This
patch simply ensures that when the batching database is behind the
service node list is reset back to that point in time.
2022-06-19 12:34:56 -03:00
Jason Rhinelander 502f88cdc4
Merge pull request #1565 from jagerman/next-height-is-now
Next height is now
2022-06-19 12:34:24 -03:00
Jason Rhinelander f87c9990a2
Merge pull request #1564 from jagerman/remove-log-error
Remove wallet debugging errors
2022-06-19 12:33:57 -03:00
Jason Rhinelander e1c1677c0a
Don't include sub-atomic rows in get_all_accrued_earnings
The RPC call to return accrued balances currently returns some 0s,
because the database has sub-atomic (but non-zero) stored amounts.

This commit skips those when querying accrued earnings.
2022-06-16 13:45:43 -03:00
Jason Rhinelander b4062f37bb
Optimizations
- use pre-prepared queries
- avoid extra copy of addr/amount vectors in get_all_accrued_earnings
2022-06-16 13:43:31 -03:00
Jason Rhinelander f35c1b1707
Make next_payout_height return the next height >= current_height
wallet2 currently exposes a bug where it shows the next payout being +1
interval blocks from now one block too soon (i.e. if I earn a reward on
block 1234 then it should give me 1234 as my next payout height up until
we actually get block 1234 with the payout).

db_sqlite.cpp was already getting this behaviour by passing in height-1,
but that feels like a workaround for an off-by-one in the function
itself.  This fixes the function (and removes the -1 from
db_sqlite.cpp).
2022-06-13 16:58:04 -03:00
Jason Rhinelander 598c174c9c
Rewrite logic to avoid unsigned int overflow
- When calculating the offset the calculation here is overflowing; since
  they are `uint64_t`s where overflow is well-defined that doesn't
  actually break anything (the overflowed value overflows in the other
  direction when added, and works as the intended subtraction), but it
  feels a bit icky.  Rearranging the logic avoids it.

- If given a small height (e.g. 3) the next payout height would come out
  as a large positive number (close to uint64_t max).  The change above
  avoids this as well.
2022-06-13 16:52:36 -03:00
Jason Rhinelander 4bff414f94
Remove wallet debugging errors 2022-06-13 15:34:35 -03:00
Jason Rhinelander 441270b082
Merge pull request #1562 from darcys22/wallet2-batching
Adds batched amounts to simplewallet balances
2022-06-13 11:51:54 -03:00
Jason Rhinelander f487affdd9
Show total staked and unlocking amounts in cli balance
E.g.:

    [wallet T6TSSZ (has locked stakes)]: balance
    Currently selected account: [0] Primary account
    Tag: (No tag assigned)
    Balance: 73541.719401728, unlocked balance: 72339.332202963 (23 block(s) to unlock)
    Total staked: 919.987654321, 0.000000000 unlocking
    Pending SN rewards: 49.419920278,  (next payout: block 10433, in about 26 minutes)
2022-06-10 22:21:13 -03:00
Jason Rhinelander b13b55de98
Simplify; add check for mismatched vector lengths 2022-06-10 22:21:04 -03:00
Jason Rhinelander e56bf13e55
Only request needed fields from SN info
This cuts the size of the response by about 75%.
2022-06-10 20:24:23 -03:00
Jason Rhinelander 53f53f2a51
Expose next payout height via wallet2
wallet2_api needs to provide a way to to get at this.

Also changed the existing wallet_rpc_server and simplewallet code to use
the new wallet2 method.
2022-06-10 19:40:57 -03:00
Jason Rhinelander dedc7d351f
Make accruedBalance address parameter optional
If omitted it looks up the current wallet primary address (which is
usually what we want).
2022-06-10 17:18:58 -03:00
Sean Darcy 90cc745987 Adds batched amounts to wallet2 rpc and simplewallet
This adds detail to the balance command of the CLI wallet to show how
much has been batched for each address and also summarises when the next
payout is.

It also includes additional fields to get_balance rpc endpoint on the
oxen-wallet-rpc so the user can check on the status of their accrued
funds.
2022-06-10 14:15:19 +10:00
Jason Rhinelander b39a118dae
Detect and don't try to parse empty txes
If we pass the blob into parse_and_validate_tx_from_blob we get
`deserialization or varint failed` error logs, which are harmless bug
annoying.  This catches the empty tx blob case earlier and logs at a
lesser severity.
2022-06-01 17:09:04 -03:00
Jason Rhinelander 4d91082acb
Detect on_transaction_relayed failure
If on_transaction_relayed fails to parse, it returns a null_hash, but
that wasn't being detected here.

Also eliminates calling `on_transaction_relayed(tx_blob)` twice.
2022-06-01 17:09:04 -03:00
Jason Rhinelander a6157fe0a9
Fail if tx blob is empty
Some node on the network apparently has a corrupted DB and is spewing
empty tx blobs onto the network.  Detect such a case rather than
broadcasting broken empty txes.
2022-06-01 15:44:24 -03:00
Jason Rhinelander 0db9520ebc
Merge pull request #1561 from jagerman/prefer-system-libs
Prefer system libs
2022-05-30 18:53:51 -03:00
Jason Rhinelander 507a9d22ea
Better version tag generation (from oxenss/lokinet) 2022-05-30 15:16:50 -03:00
Sean Darcy 8c1a5c2d65 add mainnet hardfork details for HF19 2022-05-30 20:06:30 +10:00
Jason Rhinelander d229bc77ed
Merge pull request #1486 from jagerman/wallet-csv-export-fixes
Wallet csv export fixes
2022-05-29 20:30:55 -03:00
Jason Rhinelander 80ca0d770b
Merge pull request #1558 from jagerman/genesis-block-scanning
Add ifdef'd code to scan the genesis block
2022-05-29 20:30:30 -03:00
Jason Rhinelander ad88c57b8a
Fix governance fee calculation
Governance fee wasn't being multiplied by BATCH_REWARD_FACTOR before
being inserted into the rewards table.
2022-05-27 21:40:47 -03:00
Jason Rhinelander 4cd7e629a9
Remove testnet hack 2022-05-27 21:40:36 -03:00
Jason Rhinelander 76f5a9a33c
Add ifdef'd code to scan the genesis block
This code is virtually never needed, except when we reset
testnet/devnet, but is useful to have on hand for such cases.
2022-05-27 16:44:28 -03:00
Jason Rhinelander 3fa9572f42
Reset testnet governance wallet
Uses the same wallet keys and genesis tx as devnet.
2022-05-27 15:52:26 -03:00
Jason Rhinelander f12bb8b3f9
Merge compilation fix 2022-05-27 15:28:54 -03:00
Jason Rhinelander e9e8e93669
Fix wrong change value in outputs sent to self
We figure out, when parsing a blockchain-confirmed transaction, what the
change is but never properly set that in the new
confirmed_transfer_details entry that we create from the
unconfirmed_transfer_details, and the latter only has the *actual*
change but doesn't know about outputs we sent to ourself.

This commit fixes it by updating the change value when such a case
occurs, which fixes a wrong output & running total bug in csv exports.
2022-05-27 15:28:54 -03:00
Jason Rhinelander 69300f0a15
Fix invalid balance in view wallet csv export with imported key images
Received inputs were being handled incorrectly when importing key
images: only the *first* payment received was being removed, but it
can easily happen that we have multiple payments to ourselves in the
same wallet (for example, if we send a fixed amount to ourselves then
almost always send two non-zero amounts to ourself: the amount + the
change).

This would result in (n-1) "in" outputs for the transaction still
showing up in the output, along with the "out" transaction (which
contains the overall net transfer amount).  For example:

- Alice sends 100 + 12.3 change to herself.
- Bob has Alice's view keys, opens a view-only wallet, sees 100 and 12.3
  as two separate inputs from the same transaction.
- Alice provides a key image export to Bob to verify the account
- Bob imports.

Bob's export would now show:

    in 12.3
    out 0

(The inputs of the same transaction are apparently ordered randomly, so
it could also be 'in 100'/'out 0')

and the running total would be 12.3 too high (or 100 too high if the 100
got left instead of the 12.3).

This fixes it by removing *all* matching payments when we import key
images instead of just the first one.
2022-05-27 15:28:54 -03:00
Jason Rhinelander 70954ff373
CSV export-related code and output cleanups
Cleans up some messy code.

Reformats the CSV output to be a little cleaner (in both code and
result), using fmt:
- change second "amount" field to "sent_amount"
- don't unnecessarily quote the subaddr indices field (only quote when
  more than one need to be listed as comma-separated).
- change "checkpoint" field output to "yes"/"no" rather than
  "checkpointed"/"no".
- Adds spacing between fields which makes it a little easier to read and
  should still parse identically.
- Date format also changes somewhat (because fmt is now formatting it)
  and includes " UTC" to clarify.
2022-05-27 15:28:54 -03:00
Jason Rhinelander 184d61bb80
wallet2 code simplifications and cleanups
Miscellanous crap that I couldn't help but cleanup while working in
wallet2 to solve the export csv issues:

- To celebrate the 10 year anniversary of god inventing `auto` we
  replace some obtuse code that was trying to make itself look bigger by
  typing out massive obvious types.
- Remove the single remaining tab in wallet2.cpp to get wallet2.cpp from
  being 99.9993% tab-free too 100.0000000% tab free.
- Fix THROW_WALLET_EXCEPTION_IF calls that checked for not-found *after*
  another check that already dereferenced the iterator.
- Make `get_attribute` interface less stupid by returning an optional
  string instead of a bool with an out string argument.
- Simplify various std::holds_alternative + var::get combinations with a
  single std::get_if.
- Optimize and DRY hex conversion of payment id in make_transfer_view.
  The existing code was duplicated 4 times but also was inefficiently
  performing extra string allocations via multiple substr calls.
- Loki -> Oxen in a wallet error message.
- Initialize confirmed_transfer_details members inline rather than using
  an obtuse constructor.
- Apply some C++17 `if` initializer syntatic sugar.
- Don't use `0 != pointer` to test for null
- Don't use a linear scan of a std::vector to do what an unordered_set
  is meant to to.
- Replace NULL with nullptr
- eliminate boost::format from wallet2
- eliminate boost::lexical_cast from wallet2
2022-05-27 15:28:54 -03:00
Jason Rhinelander f77378da89
Merge pull request #1557 from darcys22/reset-testnet
reset testnet
2022-05-27 15:28:33 -03:00
Jason Rhinelander 34a550b41f
Merge pull request #1556 from darcys22/enforce-atomic-registrations-hf19
enforce atomic registrations in HF19
2022-05-27 15:06:10 -03:00
Jason Rhinelander 48eb4ba138
Revert devnet change
devnet got reset a few days ago already with new rules, don't need to
reset it again.
2022-05-27 15:03:49 -03:00
Jason Rhinelander cc0b90e455
Tweak error message wording for HF19 regs 2022-05-27 14:50:19 -03:00
Sean Darcy d941b581e6
bump uptime proof checks on version 2022-05-27 12:55:48 -03:00
Sean Darcy d63142182c reset testnet 2022-05-27 16:24:56 +10:00
Sean Darcy a1814661d5 enforce atomic registrations in HF19 2022-05-27 16:17:58 +10:00
Sean Darcy 64d9dcae67 change in name between branchs 2022-05-27 11:42:48 +10:00
Sean 7161f42c64
Merge pull request #1472 from jagerman/avoid-integer-truncation
Avoid integer truncation in decoy selection
2022-05-27 11:16:54 +10:00
Sean c5fbf96b7d
Merge pull request #1539 from darcys22/prevent-unlocks-small-holdings
Prevent unlocks small holdings
2022-05-27 11:15:29 +10:00
Sean d77d791d7d
Merge branch 'dev' into batch1000 2022-05-27 11:14:55 +10:00
Sean a65c0c1dbc
Merge pull request #1544 from darcys22/batching-rpc-endpoints
Adds RPC endpoint for accrued batching balances
2022-05-27 11:10:07 +10:00
Sean 5175503098
Merge pull request #1552 from darcys22/coinbase-payouts
Rename miner_reward to coinbase_payouts and fix minor bug
2022-05-27 11:09:20 +10:00
Sean Darcy a218b81bc0 segfault in block_weight due to nullptr sqlite_db 2022-05-27 10:45:15 +10:00
Sean Darcy 5387ca2cf4
test cases for batching 2022-05-26 15:08:32 -03:00
Jason Rhinelander b9f3877ab3
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-26 15:08:08 -03:00
Jason Rhinelander d88d3d0de6
Remove assertion breaking wallet2 on a debug build
wallet2 expects to get back the UINT64_MAX value here for a
fully-reserved service node: if it does, it recognizes the node is full
and goes to look for reserved contribution spots.
2022-05-26 15:08:08 -03:00
Jason Rhinelander c765081946
This is not C. 2022-05-26 15:08:08 -03:00
Jason Rhinelander 902d7afe55
Use an empty vector instead of optional<vector>
We don't do anything differently for a nullopt versus an empty vector,
so just return an empty vector for both not-at-the-hf and no-payments
cases.

(This also fixes a segfault and/or chainsync bug in the previous commit
because the optional is dereferenced without checking when on hf19).
2022-05-26 15:08:08 -03:00
Jason Rhinelander fd4ca4a57c
Ensure we don't produce a HF block with garbage from the db
Fix edge case where the block producer has garbage in the db: the code
that clears it happens when we *accept* the block, but we can end up
here before then, when we produce the block, so just return empty in
such a case.
2022-05-26 15:08:07 -03:00
Jason Rhinelander 4848cacec8
Fix is-service-node detection 2022-05-26 15:08:07 -03:00
Jason Rhinelander c54cbb8394
Reset devnet 2022-05-26 15:08:07 -03:00
Jason Rhinelander a8a3b3dbe6
DEVNET storage port fixes
On devnet we don't have a storage server, and so storage ports are left
uninitialized and effectively become random ports on the network.  This
initializes them to 0, and avoids comparing SS ports for devnet for the
duplicate ip/ports warning.
2022-05-26 15:08:07 -03:00
Jason Rhinelander acf2942859
Fix bugs in thousandths calculations 2022-05-26 15:08:07 -03:00
Jason Rhinelander 589f66f5a4
Fix thousandths tx verification in service_node_list.cpp 2022-05-26 15:08:07 -03:00
Jason Rhinelander a2eb8690ba
Reformatting 2022-05-26 15:08:07 -03:00
Jason Rhinelander e7a6deaf6c
Do more calculations in thousanths
We were converting to thousanths too late; this does it earlier, to
reduce numerical imprecision during reward calculations.
2022-05-26 15:08:07 -03:00
Jason Rhinelander 9584a14b3a
Refactor/DRY reward calculation code
The reward calculation code when adding or subtracting is identical;
this dries it out into a single helper method.
2022-05-26 15:08:05 -03:00
Jason Rhinelander bbdd91a3bb
const lvalue refs
Avoid copying vector arguments
2022-05-26 15:06:38 -03:00
Jason Rhinelander ac26747529
Rename a_b_over_c to mul128_div64
Also uses it in various places that were writing out separate mul128 +
div128_64's.
2022-05-26 15:06:38 -03:00
Jason Rhinelander d3684f6b44
Add iterable `prepared_results<T...>`
This gives back an iterator that lets you step through results as
tuples without having to executeStep() + get<...> yourself.
2022-05-26 15:06:12 -03:00
Jason Rhinelander 02d8e0aefc
Improve prepared interface; fix test suite bug
Add a `prepared_bind` that lets you get a prepared statement and bind
parameters to it in one shot.

Add comments to the prepared_* methods.

Fix test suite bug in sqlite testing wrapper added in the earlier
prepared statement commit: it was selecting values from the current
(new, empty) database rather than the passed-in one.
2022-05-26 13:57:01 -03:00
Jason Rhinelander 7d392dad01
Merge pull request #1540 from darcys22/decom-grace-period
Decom grace period
2022-05-26 11:37:19 -03:00
Sean Darcy 47a9802f83 Rename miner_reward to coinbase_payouts and fix minor bug
After the batching HF we now have a "reward" field in the block header
which is confusingly different to "miner_reward". This renames
miner_reward to coinbase_payouts to clarify that this amount is the
amount actually paid out in the coinbase vs the reward accumulated into
the batching DB.

Also fixes a minor bug where the reward would only show the reward of
the first vout instead of summing all the vouts.
2022-05-26 13:09:04 +10:00
Jason Rhinelander b6fdd9d90f
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-25 23:30:28 -03:00
Jason Rhinelander e7c19d29a8
Move test subclass into tests/ 2022-05-25 20:57:31 -03:00
Sean Darcy 76a585eb41 Add a grace period to deregistrations after a hardfork
It is not uncommon to have nodes get decommissioned after a hardfork,
either due to lack of updating or issues with the release. This
implements a 7 day grace period where nodes that do get decommissioned
will not progress into a deregistration (and being hit with the 30 day
funds locked penalty).
2022-05-25 14:07:55 +10:00
Jason Rhinelander 9a395be641
Make sure we error if given a non-existant payment address 2022-05-24 18:54:52 -03:00
Jason Rhinelander 7b331131d9
Remove debugging 2022-05-24 18:54:52 -03:00
Jason Rhinelander bf1915bd46
SQLite: use prepared statements
Using SQLite::Statement directly requires sqlite to re-prepare the
statement every time it is executed; going via our `prepared_st` wrapper
caches (per thread) and reuses previously prepared statements for better
performance.

(It also, in some cases, simplifies the code a bit).
2022-05-24 18:54:52 -03:00
Jason Rhinelander 1fa71bcc2c
Rename hf19 -> hf19_reward_batching 2022-05-24 18:54:32 -03:00
Jason Rhinelander 2b94af71a9
Add static_assert for hf numeric values 2022-05-24 17:36:24 -03:00
Jason Rhinelander bac9c05162
Fix debug compilation 2022-05-24 17:36:24 -03:00
Jason Rhinelander 34ef746c95
prepare_registration fixes for multi contributors
Adds two slightly different versions of prepare_registration: one that
works with the existing 4-person registrations (used up to the hard
fork), and one that produces HF19 amount-based registrations.

This also overhauls the questions to be a bit nicer to input;
specifically:

- allow "max" and "min" as stake amount options, and make "max" the
  default.
- eliminate the "do you want to contribute the whole stake?" question
  entirely.  We instantly figure that out if you choose "max" (or enter
  the 15000 manually).
- eliminate the "how many contributors?" question.  Instead we just keep
  taking additional contributors until you stop entering them.
- move the fee to later, after you've provided contributor info (if not
  a full stake).

There is, unfortunately, a *huge* amount of duplication here: I copy and
pasted the entire HF18 registration code and just eliminated the
portions parts of it.  This is temporary: as soon as we are into HF19 we
can eliminate the HF18 version entirely.
2022-05-24 17:36:24 -03:00
Jason Rhinelander 377cfecb09
Atomic staking amounts
This adds a new tx registration interpretation for HF19+ by repurposing
the fields of the registration:

- `expiration` becomes `hf_or_expiration`; for "new" registrations it
  contains the hardfork number (e.g. 19 for HF19), but the data layout
  on chain doesn't change: essentially we determine whether it's a new
  registration based on whether the field is <= 255 (interpret as HF) or
  not (interpret as expiration).

Changes in "new" registrations:
- stake amounts are atomic OXEN rather than portions.  This lets us skip
  a whole bunch of fiddling around with amounts that was necessary to
  deal with integer truncation when converting between amounts and
  portions.

- the fee in the registration data is now a value out of 10000 instead
  of a portion (i.e. value out of 2^64-4).  This limits fee precision to
  a percentage with two decimal places instead of ~17 decimal places.
  Internally we still convert this to a portion when processing the
  registration for service_node_states, but this makes the registration
  itself much simpler and easier to work with (as a human).

- HF19+ registrations no longer have an expiry timestamp (though they do
  depend on the hardfork, so they "expire" whenever the next hard fork).
  The expiry timestamp was really only there to avoid a registration
  amount decreasing too much from the dropping staking requirement.

- Both types are registration are still permitted for HF19, but because
  registrations with more than 4 contributors expose bugs in the portion
  transfer code (that results in registrations become invalid),
  old-style registrations are still limited to 4 contributors.

- HF19 will allow both old and new registrations, so that registrations
  generated before the HF will still work, and so that we don't break
  testnet which has various "old" registrations on it.
2022-05-24 17:36:24 -03:00
Jason Rhinelander 5b25671c4f
Split up sqlitedb into a compiled unit
Lessens the compilation load of various things that include the header,
and lets us avoid having to include all of fmt when we include it.
2022-05-24 17:36:24 -03:00
Jason Rhinelander 636ee3f622
Replace boost::endian conversion with oxenc 1.0.3
1.0.3 got some endian fixes that lets us avoid boost::endian everywhere.
2022-05-24 17:35:59 -03:00
Jason Rhinelander 6bb83316dd
Merge pull request #1546 from jagerman/remove-major-ge-minor
Remove minor >= major block requirement for HF19+
2022-05-24 16:04:48 -03:00
Jason Rhinelander be332d3772
Avoid integer truncation in decoy selection
There is a (correct) warning in the calculation that divides by this
value that this code is doing integer division, but then storing in a
float.  This fixes the warning, and the intention.
2022-05-24 16:04:08 -03:00
Jason Rhinelander 1bfa4e64d4
Remove use of deprecated ftime 2022-05-24 11:14:35 -03:00
Jason Rhinelander c3759c67de
Remove minor >= major block requirement for HF19+
Monero perverted the minor version many forks ago; this returns it to
being a minor version, making the blocks reflect our actual minor
version.
2022-05-24 11:07:06 -03:00
Sean dce39ec8ee
Merge branch 'dev' into batching-rpc-endpoints 2022-05-24 11:29:49 +10:00
Sean Darcy 741affa403 Enforce a minimum time period before small contributors can unlock stake
This PR defines contributors to a service node as a small contributor if
they contribute <25% of the nodes locked contributions. If a contributor
is small then they are prevented from unlocking their stake for 30 days
after the node is registered. This was in response to operators getting
frustrated with small contributors immediately unlocking after a node
was registered.

If you imagine the following node contribution structure:

Operator: 25%
Contributor 1: 65%
Contributor 2: 10%
Total: 100%

Node is registered on day 0. On Day 1 both the operator and Contributor
1 will be able to unlock their stake and the node begins its 15 day
unlock period.

Contributor 2 however will be prevented from unlocking until day 30.
At this point they will be able to unlock and begin the nodes 15 day
unlock period.
2022-05-24 10:55:26 +10:00
Thomas Winget 8783349f43 remove erroneous check from wallet3 tx constructor 2022-05-23 19:44:23 -04:00
Thomas Winget a8f4584578 wallet3: fix tx construction (sorted inputs) 2022-05-23 19:44:23 -04:00
Thomas Winget d716b1fde5 cleanup some wallet daemon comms error handling 2022-05-23 19:44:19 -04:00
Thomas Winget f3c0bd79a4 fix wallet3 db overall output count 2022-05-23 19:24:42 -04:00
Thomas Winget 6ed5bba739 small status/error message change 2022-05-23 19:23:40 -04:00
Thomas Winget 8b85d6b850 do not silently allow empty tx input indices 2022-05-23 19:17:50 -04:00
Sean Darcy f45d0588ae Adds RPC endpoint for accrued batching balances
This allows a user to query the daemon and ask for the accrued balance
of oxen rewards that have been batched but not yet paid out.

The endpoint takes in an array of addresses (Strings) and returns an
array of atomic oxen amounts (integers) that reflect the current
database balances for those requested addresses.

For example an address has accrued 2x batch payments of 16.5 oxen but
has not yet been paid out will show 33000000000 being the atomic amount
in the database.
2022-05-23 08:47:18 +10:00
Jason Rhinelander 26869869aa
Remove stupid typedef 2022-05-20 18:30:55 -03:00
Jason Rhinelander dfe566480b
Remove cryptonote_config macros
- Replace all cryptonote_config macros with constexpr variables.  Some
  become integer types, some become chrono types.
  - generally this involved removing a "CRYPTONOTE_" prefix since the
    values are now in the `cryptonote` namespace
  - some constants are grouped into sub-namespaces (e.g.
    cryptonote::p2p)
  - deprecated constants (i.e. for old HFs) are in the `cryptonote::old`
    namespace.
  - all the magic hash key domain separating strings are now in
    cryptonote::hashkey::WHATEVER.
- Move some economy-related constants to oxen_economy.h instead
- Replaced the BLOCKS_EXPECTED_IN_DAYS constexpr functions with more
  straightforward `BLOCKS_PER_DAY` value (i.e.  old
  `BLOCKS_EXPECTED_IN_DAYS(10)` is now `BLOCKS_PER_DAY * 10`.
- Replaced `network_version` unscoped enum with a scoped enum
  `cryptonote::hf`, replacing all the raw uint8_t values where it was
  currently accepted with the new `hf` type.
- Made `network_type` a scoped enum so that it now has to be qualified
  (network_type::TESTNET) and can't be arbitrarily/unintentionally
  converted to/from an int.
- HARDFORK_WHATEVER macros have become cryptonote::feature::WHATEVER
  constexpr hf values.
- Add `revision` to rpc hard_fork_info response
- Don't build trezor code at all (previously we were pointlessly
  building an empty dummy lib).
2022-05-16 20:37:07 -03:00
Jason Rhinelander c8d5dfa597
Remove unused macros 2022-05-16 15:16:26 -03:00
Jason Rhinelander 8014cf6a6c
Undo 19.1 version for Session testing 2022-05-13 01:25:11 -03:00
Jason Rhinelander dd814da1ad
Reword registration command to include the operator wallet 2022-05-12 15:32:45 -03:00
Jason Rhinelander 4dad19fb7d
Add pubkey to prepare_registration summary 2022-05-12 15:20:58 -03:00
Jason Rhinelander fd020fcd83
Fix min operator amount, rejigger math
A fixed 3750 amount won't work on testnet (and also was set to 3750
atomic units instead of 3750 coins).

This refactor the math a bit so that the amount falls out of the portion
constant when making a registration.
2022-05-12 13:47:49 -03:00
Sean Darcy f652aa09bc review notes 2022-05-12 10:32:57 +10:00
Sean 73e0a9eb61
Update src/cryptonote_core/service_node_list.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2022-05-12 09:29:08 +10:00
Sean Darcy 9edc2bb52d
Increase max number of contributors to 10
This requires the operator to still contribute 25% of the service node
but another 9 nodes will be allowed to stake to the node makeing 10
contributors total rather than our previous 4.
2022-05-10 18:48:20 -03:00
Sean Darcy f82be89478 hardfork 19.1 2022-05-10 13:52:19 +10:00
Sean Darcy 866691d9d8 Batching of service node rewards
This updates the coinbase transactions to reward service nodes
periodically rather than every block. If you recieve a service node
reward this reward will be delayed x blocks, if you receive another
reward to the same wallet before those blocks have been completed it
will be added to your total and all will be paid out after those x
blocks has passed.

For example if our batching interval is 2 blocks:

Block 1 - Address A receives reward of 10 oxen - added to batch
Block 2 - Address A receives reward of 10 oxen - added to batch
Block 3 - Address A is paid out 20 oxen.

Batching accumulates a small reward for all nodes every block

The batching of service node rewards allows us to drip feed rewards
to service nodes. Rather than accruing each service node 16.5 oxen every
time they are pulse block leader we now reward every node the 16.5 /
num_service_nodes every block and pay each wallet the full amount that
has been accrued after a period of time (Likely 3.5 days).

To spread each payment evenly we now pay the rewards based on the
address of the recipient. This modulus of their address determines which
block the address should be paid and by setting the interval to our
service_node_batching interval we can guarantee they will be paid out
regularly and evenly distribute the payments for all wallets over this
2022-04-29 09:51:14 +10:00
Thomas Winget a0bce0e762 tx constructor, check fetched decoy values for our real input 2022-04-26 13:01:22 -04:00
Thomas Winget 1c65de2866 set correct amount on tx construction
also tiny refactor and some correctness checks
2022-04-26 13:01:22 -04:00
Thomas Winget 3be2dc8551 sort tx inputs by key image
the existing tx construction code does this, but it may not be necessary.
sorting copied from existing code.
2022-04-26 13:01:22 -04:00
Thomas Winget 1ce7a92ea8 refactor return-by-reference 2022-04-26 13:01:14 -04:00
Thomas Winget f3a3399723 fix wallet3 db output fetch 2022-04-26 12:30:49 -04:00
Thomas Winget b7e5715d7b add pop_block function and block removal trigger to wallet3 db 2022-04-26 12:30:05 -04:00
Thomas Winget eaf29ac687 add not-equal operator to rct::key 2022-04-26 12:28:38 -04:00
Jason Rhinelander 81a1c1e50e
Merge pull request #1535 from jagerman/prepare-reg-dust
Fix prepare_registration dust
2022-04-21 19:57:20 -03:00
Jason Rhinelander d9f19ca463
Include SN status info info list_current_stakes()
Adds unlock height, funded, and decommissioned info to returned stake
info.
2022-04-21 18:27:45 -03:00
Jason Rhinelander 711c7462c3
Fix prepare_registration dust
We could get a rounding error in the contributor spots that would make
the registration fail when passed to oxend.  This fixes it by restoring
the missing logic that was accidentally dropped in the
prepare_registration refactor.
2022-04-19 22:48:16 -03:00
Jason Rhinelander a91c491111
Merge pull request #1531 from jagerman/aux-pubkey-checks
Add ed25519_pubkey field to SS & lokinet pings
2022-04-18 21:18:01 -03:00
Jason Rhinelander 0fdaeff95d
Merge pull request #1532 from jagerman/checkpoint-vote-delay
Delay checkpoints by a block
2022-04-18 21:17:46 -03:00
Jason Rhinelander 9a6c4a93a0
Merge pull request #1530 from jagerman/prepare-reg-disp-fix
Prepare registration fixes and improvements
2022-04-18 21:17:07 -03:00
Jason Rhinelander 882ba4820a
Fix StakeUnlockResult non-virtual destructor
We destruct a subclass via base class instance pointer, which requires a
base class virtual destructor.
2022-04-18 15:06:38 -03:00
Jason Rhinelander a73002747a
Add is-stake to wallet api
Mobile wallet needs this to determine when a transaction is a stake
rather than a transfer, otherwise it shows all stakes as outgoing
transfers of 0.
2022-04-18 11:18:12 -03:00
Jason Rhinelander f46884c5f1
Delay checkpoints by a block
Testnet has shown that it is virtually impossible to route around a
checkpoint for a block that had to be rendered unacceptable because it
accepts the future checkpoint which then prevents an alternate block
from being generated at all.

This mitigates it in two ways:

- Don't accept new checkpoint votes before we receive the block
- Delay checkpoint voting & vote distribution by one block (e.g. nodes
  will vote on block 12345 only once 12346 is received).

The first allows a manual pop_blocks to remove checkpoints that won't
get re-added (e.g. if the checkpointed block has become unacceptable, as
occurs sometimes in testnet/devnet, but could theoretically occur on
mainnet if we have to do a block reversal).

The second minimizes the number of rejected votes that will occur since
nodes will almost always have the block now when the checkpoint arrives.
2022-04-17 12:59:36 -03:00
Jason Rhinelander 50a41e63de
Add ed25519_pubkey field to SS & lokinet pings
Allows lokinet & storage server to feed the ed25519 key back to oxend so
that oxend makes sure everyone is on the same key.
2022-04-17 11:16:45 -03:00
Jason Rhinelander d51c4466cf
Overhaul prepare_registration page
Reorders the way questions are asked to flow better.  Previously the way
questions was asked was sort of awkward.

The old order, for instance staking a partially open node:

- entire stake?
- fee?
- reserve more?
- how many more?
- operator address?
- operator stake size?
- contributor address?
- how much for contributor?
- more contributors, if any
- not filled okay?
- confirm everything?

where there are related values (e.g. operator addr & stake) intermingled
with around other things (e.g. fee & number of contributors).

With this commit the order is rewritten to:

- operator address?
- entire stake?
- operator stake size?
- fee?
- reserve more?
- how many more?
- contributor 1 addr
- contributor 1 amnt
- more contributors, if any
- not filled okay?
- confirm everything?

Additional changes:
- substantially DRY out the code.  There was a huge amount of repeated
  code in this section.

- highlight OXEN amounts in cyan.

- I rewrote much of the language to make it clearer and more grammatical

- reformatted the summary table to look a bit better

- the fee in the final summary is highlighted yellow.

- if there are multiple open spots this is now more clearly indicated in
  the output and the final summary screen.

Example:

```
$ oxend prepare_registration
2022-04-15 20:11:29.211	I Oxen 'Audacious Aurochs' (v9.2.0-0b38bd982-dev)
Current staking requirement: 15000 OXEN
Enter the OXEN address of the Service Node operator (C/Cancel):
LDoptfyQB3YHbS9cnt2wHdTTj2wtZGPuM48evCFwZpomVajQw4eJ6mDCpXeUNTxsqbTiYytnqEDQNin3XGwp3nReMooMaWG

Will the operator contribute the entire stake? (Y/Yes/N/No/B/Back/C/Cancel): n

The operator contribution must be between 3750 OXEN and 15000 OXEN to meet the staking requirements.

How much OXEN does the operator want to stake? (B/Back/C/Cancel): 5555

Enter operator fee as a percentage of earned rewards [0-100]% (B/Back/C/Cancel):  4.567

Do you want to reserve stakes for specific contributors? (Y/Yes/N/No/B/Back/C/Cancel): y

Number of additional contributors [1-3] (B/Back/C/Cancel): 2

Enter the OXEN address of contributor 1 (B/Back/C/Cancel):
L6JasonXTGW6juHrJgsXTxXH1Jh9u94H8NQ9m4rMwz5a9SZGr2e1cXw9MqnVH6Qx5bTgL5wf7qfvHeNPdwyC63AzMixU5ad

The next contribution must be between 3148.333333333 OXEN and 9445 OXEN to meet the staking requirements.

How much OXEN does contributor 1 want to stake? (B/Back/C/Cancel): 5555

Enter the OXEN address of contributor 2 (B/Back/C/Cancel):
L7jC35E9MnQZu2dS1n8wCqbvVBFpGHJt7iNHgAuEy5is57dzX2uQZDASv4KvwzruxXARxa4omafN6i19QBY7KAcSH1Xz7ZL

The next contribution must be between 1945 OXEN and 3890 OXEN to meet the staking requirements.

How much OXEN does contributor 2 want to stake? (B/Back/C/Cancel): 3000

Total reserved contributions: 14110 OXEN

The total reserved amount (14110 OXEN) is less than the required full stake (15000 OXEN).
The remaining stake (890 OXEN) will be open to contribution from 1 public contributor.
The Service Node will not activate until the full contribution has been filled.

Is this acceptable? (Y/Yes/N/No/B/Back/C/Cancel): y

Registration Summary:

Operator fee (as % of Service Node rewards): 4.567%

 Contributor       Address          Contribution  Contr. %
_____________   _____________  _________________  ________

   Operator     LDoptfyQB..WG     5555.000000000    37.03%
Contributor 1   L6JasonXT..ad     5555.000000000    37.03%
Contributor 2   L7jC35E9M..ZL     3000.000000000    20.00%
    (open)          (any)          890.000000000     5.93%

Is the staking information above correct? (Y/Yes/N/No/B/Back/C/Cancel):
```

For a open node with 3 open spots the summary table looks like this:

```
 Contributor       Address          Contribution  Contr. %
_____________   _____________  _________________  ________

   Operator     L6JasonXT..ad     6789.000000000    45.26%
    (open)          (any)       >=2737.000000000  >=18.25%
    (open)          (any)
    (open)          (any)
```
2022-04-15 17:54:04 -03:00
Jason Rhinelander 44da471153
Remove unused decimal point arg; add format_money()
- The decimal point argument isn't used anywhere.

- change `get_unit()` to return `OXEN` instead of `oxen`

- Add a "strip_zeros" option to print_money that lets you remove
  trailing insignificant 0's from the returned amount.

- Add format_money that does print_money (with 0s stripped by default) +
  get_unit().  E.g. it returns `"45.67 OXEN"`.
2022-04-15 17:54:03 -03:00
Jason Rhinelander 63ede5ec4d
Make cryptonote::parse_amount return an optional
Replace a gross non-const uint64_t& argument + bool return with an
std::optional<uint64_t> return value.
2022-04-15 17:54:03 -03:00
Jason Rhinelander d5551009f9
Fix cursor line overwriting in prepare_registration
When I issue a `prepare_registration` command the cursor gets positioned
at the beginning of the line instead of the end of the line, so typing
things in results in overwriting the text that I was asked.

E.g.:

```
Current staking requirement: 15000.000000000 oxen
yill the operator contribute the entire stake? (Y/Yes/N/No/C/Cancel):
`-- the y I typed replaced the "W"
```
or:
```
Enter the oxen address for the solo staker (B/Back/C/Cancel):
```
and because the cursor is positioned at the beginning, my address
overwrites the prompt as I type/paste it:
```
L6JasonXTGoxen address for the solo staker (B/Back/C/Cancel):
```

This is caused because we were suspending the readline buffer *after*
printing things out, and something (perhaps local config, or perhaps an
update to libreadline) repositions to cursor at column 0.

This commit suspends the readline handler *before* we print the message,
which makes it sane again:
```
Enter the oxen address for the solo staker (B/Back/C/Cancel): L6JasonXTG
```
2022-04-15 17:54:03 -03:00
Jason Rhinelander 1cf48a28c3
Silence false maybe-unused warning
This variable does always get set via the lvalue parameter in the call
below, but it's far enough away that gcc isn't sure of it.
2022-04-15 13:51:58 -03:00
Jason Rhinelander 5e578069d6
Remove redundant size checks
These were needed with oxenmq::is_hex a long time ago, but have been
redundant for quite a while.
2022-04-15 13:51:58 -03:00
Jason Rhinelander 4fa12395ef
More epee purging
Remove misc_language.h: Half of it is unused, half of it is crap doesn't
need to be used, and the two useful things (median calculator and a
scope exit caller) were poorly written.

Rewrote median from scratch and moved it out of epee.

Simplified the scope exit handler and moved it to its own small header
in epee.
2022-04-15 13:51:57 -03:00
Jason Rhinelander bf5162efdb
Remove now-unused ascii output magic 2022-04-15 13:51:57 -03:00
Jason Rhinelander b0cc711606
Replace stale seed node with new ones 2022-04-15 13:51:57 -03:00
Jason Rhinelander 5e95cef882
Remove openssl, unbound, expat, OpenAlias
openssl is a miserable dependency to fight with, especially for
iOS/Android, and we use it for very little:

- it gets (mis)used to write base64 data to a file in wallet2 for things
  like multisig data.  However this mode is *not* enabled by default,
  basically completely unknown, completely unused, only exists in the
  cli wallet, and is just dumb.  (Honestly the justification given in
  the PR is that "Windows users might want it", presupposing that there
  exists Windows users who are capable of generating a multisig wallet
  in a CLI-only application and yet are incapable of dealing with binary
  files).

- it's a dependency of unbound (in order to do dnssec, I believe).
  Unbound itself is fairly useless for Oxen, so I've removed it too:
    - it does OpenAlias lookups, which are a Monero thing that has never
      been used outside Monero, doesn't work reliably (because it fails
      if the result isn't DNSSEC validated) and is pointless when we
      have ONS.

    - it does DNS resolution on seed nodes, but we have never set seed
      nodes by name and just use seed node IPs instead (which seems a
      bit better anyway since the DNS lookup leaks some metadata).

- it *was* being used for sha256, but an earlier commit in this PR
  already replaced that with libsodium (entirely coincidentally).

- for static deps, it enables HTTPS support for the wallet.  However
  only the CLI wallet actually supports this (the GUI and mobile wallets
  don't), and since oxend hasn't support this for a while I have strong
  doubts it is being used anywhere.  (Plus wallet3 will do everything
  encrypted using zmq/libsodium, so doesn't need this to be secure).
  Note here that it is *only* removed by this commit for static builds:
  if doing a system build that links to libcurl supporting HTTPS then
  HTTPS support will still work.

Libexpat is also gone because it was only there for libunbound.
2022-04-15 13:51:57 -03:00
Jason Rhinelander a4ab3a7a7d
Silence clang warning 2022-04-14 14:34:50 -03:00
Jason Rhinelander c86a7a2a28
Replace epee base64 with oxen-encoding 2022-04-14 14:34:50 -03:00
Jason Rhinelander a66fc8ae61
Replace epee hex with oxen-encoding
- Aside from converting code, this commit also:

- Cleans out a bunch of epee garbage that this code touches.

- Removes some of the wipeable_string usage from wallet2 added by
  upstream Monero, because that usage was worse than useless: every
  instance removed uses a wipeable_string but then *copies the value
  into a std::string*, which makes the entire thing useless.

  It is, however, *worse* than useless because it is deceptive: a casual
  observer would think that the values are being wiped, when in
  actuality it only added an extra intermediate buffer that gets wiped
  while the final destination doesn't.  This deception is worse than
  nothing, and so I've removed it.

- Removes epee md5 code.  It is entirely unused, and was depending on
  the removed hex code.

- Removes a bunch of useless functions from
  epee/storages/parserse_base_utils.h: in particular the
  exception-to-bool wrappers were only being used in the test suite
  (which was dumb: the test suite is perfectly capable of a "does not
  throw" assertion).

- De-templatizes the parsing code in parserse_base_utils.h that was only
  ever called with a `const char*` "It" (except for one place in the
  test suite was which easily fixed), and moved the implementation into
  a .cpp file.
2022-04-14 14:34:50 -03:00
Jason Rhinelander 2821f5f4ef
Remove unused variable 2022-04-14 14:34:50 -03:00
Jason Rhinelander 47ff596533
Remove UPnP support
We have disabled uPnP by default for nearly a year now (#1423) with no
adverse affects; this commit finishes it off entirely, removing it from
the codebase.

Fixes #1419 -- see discussion in that issue for why UPnP really doesn't
add much utility to Oxen.
2022-04-14 14:34:49 -03:00
Jason Rhinelander 6fcfd0b8ba
Update oxenmq to latest oxen-mq+oxen-encoding
All the encoding parts move to oxen-encoding recently; this updates to
the latest version of oxen-mq, adds oxen-encoding, and converts
everything to use oxenc headers rather than the oxenmq compatibility
shims.
2022-04-14 14:32:01 -03:00
Jason Rhinelander 83ac88e8ab
Replace openssl sha256 implementation with libsodium
Also completely remove the default OPENSSL_init_ssl() call; openssl has
known how to call that itself since 2016.
2022-04-14 14:32:01 -03:00
Jason Rhinelander 82cb6460ac
Merge pull request #1526 from jagerman/wallet2-api-stake-fix
Only return own contributions in listCurrentStakes()
2022-04-14 14:30:17 -03:00
Jason Rhinelander 39e6fdecfc
Merge pull request #1516 from darcys22/wallet2-import-outputs-remove-macro-and-goto
Removes macro and goto code in wallet2::import_outputs function
2022-04-13 20:42:17 -03:00
Jason Rhinelander b5276f0648
Only return own contributions in listCurrentStakes()
This is currently returning all contributions in all service nodes you
are staked to, which causes the mobile wallet to list everyone's stakes
in multi-contribution service nodes as your own.
2022-04-13 19:34:20 -03:00
Thomas Winget 827cb3fe6c lots of minor wallet 3 fixes, rct signing still failing verification 2022-04-04 22:14:08 -04:00
Thomas Winget 676aa56bbb very basic tx construction, signing, and submission should be working
still def needs (much) testing
2022-03-28 22:24:29 -04:00
Sean Darcy 3d3765f1ae key image generates correctly 2022-03-28 22:24:29 -04:00
Sean Darcy 14b53da014 some align! 2022-03-28 22:24:29 -04:00
Sean Darcy 54910dae5c more stuff 2022-03-28 22:24:29 -04:00
Sean Darcy d1b7d7bb0b check output of sign transaction 2022-03-28 22:24:29 -04:00
Sean Darcy b1d4921e24 Loads in real data to test if the transaction is signing correctly
The wallet needs to be fed a single output plus a sufficient number of
decoys. This transaction was run on the testnet and details were copied
into the test file.
2022-03-28 22:24:29 -04:00
Thomas Winget eb8f4a51a6 add daemon comms submit tx endpoint
TODO: more complete response handling
2022-03-28 22:24:29 -04:00
Thomas Winget e42cc7c79b fix wallet3 Output type mismatch 2022-03-28 22:24:29 -04:00
Thomas Winget aa5bd8ba26 add key derivation for outputs to scanner 2022-03-28 22:24:29 -04:00
Thomas Winget 56aa4f8caa transfer request parsing and some request syntax fixup
transfer request is a bit jank but unfortunately cannot be changed
in service of backwards compatibility.  epee strikes again...
2022-03-28 22:24:29 -04:00
Thomas Winget f67c0f8c4b refactor wallet3 db usage
db usage all now abstracted rather than having sql lying around everywhere.

fix a couple minor bugs in tx construction logic.
2022-03-28 22:24:29 -04:00
Thomas Winget e65cfb8ab6 wallet3 rpc initial commit
omq rpc intitialization; needs parameters

legacy rpc call definitions, descriptions, boilerplate, and addition
to omq rpc registry
2022-03-28 22:24:29 -04:00
Thomas Winget a6c88e3a18 move and refactor common RPC code 2022-03-28 22:24:29 -04:00
Sean Darcy 37c213d7a6 SD review notes 2022-03-25 15:45:58 +11:00
Sean Darcy bb82585f71 amend wallet2 and simple wallet to use bt-rpc definitions
This goes through the remaining code in wallet2 that needed updating to
utilise our newly defined json_rpc methods rather than epee
serialisation to call rpc methods.
2022-03-25 10:42:16 +11:00
Sean Darcy 44f565f085 basic structure for signing transactions
The keyring structure contains functions that will take a pending
transaction and fill out the cryptonote::transaction member with
the relevant signature fields ready for serialization.
2022-03-02 08:51:06 +11:00
Sean Darcy 842fe39d83 some lingering references to Loki 2022-02-17 12:02:44 +11:00
Sean Darcy f7bf4be664 Removes macro and goto code in wallet2::import_outputs function
This simply replaces a confusing code section and replaces an odd
macro/goto combination with a more reasonable if statment.
2022-02-11 14:44:50 +11:00
Sean 3a1dfe3ea3
Merge pull request #1508 from darcys22/transaction-creation-select-decoys
Transaction creation select decoys
2022-01-24 15:44:57 +11:00
Sean Darcy 9b2265e408 decoy range 2022-01-05 14:24:23 +11:00
Sean Darcy e109ac6f49 review notes 2022-01-05 13:26:30 +11:00
Sean Darcy d7fe7646fc initial commit for decoy selection 2021-12-14 15:37:57 +11:00
Sean f5d39a841e
Merge pull request #1504 from jagerman/avoid-temporary
Rewrite logic to avoid warning about binding a temporary
2021-12-07 13:52:53 +11:00
Sean Darcy ae61454692 ffs 2021-12-07 13:13:39 +11:00
Sean Darcy 0ac65075eb Calculate the fee based on the current pending transaction.
When building the pending transaction we can call GetFee() to calculate
how much the transaction will cost. It takes a single parameter for the
number of inputs because we will want to specify how many when
estimating.

We then build a list of the potential fees for up to 300 inputs and pass
that to our output selection function which will use it to determine if
the outputs selected will be sufficient to cover the fees. This allows
us to know in advance how much the fees will be rather than trial and
error.
2021-12-07 13:10:32 +11:00
Jason Rhinelander ca1121c850
Rewrite logic to avoid warning about binding a temporary
The for loop here is converting them binding to that temporary,
producing a compiler warning.  Clean it up.
2021-12-06 18:41:12 -04:00
Thomas Winget b85c01ba60 rename wallet3 functions to be more in line with the rest of the codebase 2021-12-06 16:04:11 -05:00
Sean Darcy 25c4fd8a82 initial tx creation
The Transaction Constructor will be used to generate pending
transactions, depending on the type of transaction the pending
transaction class will allow the user to modify items such as tx type
(ONS for example) add additional data to the tx extra field, modify burn
amount etc before finalising the transaction which will select the
necessary outputs, mixins and calculate fees and change amounts. Once
finalised the pending transaction will be forwarded to a signing
structure for further action.
2021-12-02 08:59:05 +11:00
Thomas Winget ecb62e8fab Wallet3 squashed initial commit
tx scanning for basic transactions working
  - TODO: subadresses.  The scanning code is there, but it does not
  currently know/care about any subaddresses.

daemon comms for basic syncing working

(multi-)wallet sync more or less working properly
  - seem to have a dangling shared_ptr somewhere when removing a wallet from
  daemon comms, so not working perfectly yet.

Lots of TODOs and cleanup needed, as well as further features of course.
2021-11-30 16:31:54 -05:00
Sean 9588055440
Merge pull request #1467 from jagerman/ledger-speculos
Ledger emulator (speculos) support
2021-11-17 15:58:36 +11:00
Sean Darcy 09aefc37c1 move nlohmann all to rpc 2021-11-15 16:11:18 +11:00
Sean Darcy 43489af3b5 ONS_OWNERS_TO_NAMES 2021-11-15 13:34:13 +11:00
Sean Darcy 8b3d2371bb GET_OUTPUT_HISTOGRAM 2021-11-15 10:38:37 +11:00
Sean Darcy 4013cb5115 GET_ALTERNATE_CHAINS 2021-11-12 15:59:40 +11:00
Sean Darcy e206fd12ed GET_QUORUM_STATE 2021-11-12 13:38:34 +11:00
Sean Darcy aa0427dbdb GET_SERVICE_NODE_REGISTRATION_CMD_RAW 2021-11-11 16:02:01 +11:00
Sean Darcy cf8ecd2d17 delete bootstrap daemon 2021-11-11 14:35:17 +11:00
Sean Darcy 285e89ecda GET_BLOCK 2021-11-11 13:37:15 +11:00
Sean Darcy 129e6f204c GET_BLOCK_HEADER_BY_HEIGHT 2021-11-11 11:16:40 +11:00
Sean Darcy 32179ddd3e GET_BLOCK_HEADERS_RANGE 2021-11-11 10:13:30 +11:00