Commit Graph

9896 Commits

Author SHA1 Message Date
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
Sean Darcy 7d8189f7bb RELAY_TX 2021-11-09 13:19:53 +11:00
Sean Darcy 09d4baf63e GET_SERVICE_NODE_BLACKLISTED_KEY_IMAGES 2021-11-09 11:29:08 +11:00
Sean Darcy c749c4b3e1 GET_SERVICE_PRIVKEYS 2021-11-08 16:26:32 +11:00
Sean Darcy 133e022aca GET_SERVICE_KEYS 2021-11-08 16:10:06 +11:00
Sean Darcy a16a2d3949 GET_STAKING_REQUIREMENT 2021-11-08 15:42:56 +11:00
Sean Darcy eedb23c545 GET_CHECKPOINTS 2021-11-08 14:54:43 +11:00
Sean Darcy 95f6c02d55 SETBANS 2021-11-08 10:16:42 +11:00
Sean Darcy 6651fdd33a GETBANS 2021-11-05 16:19:11 +11:00
Sean Darcy d476f216cc GET_BLOCK_HEADER_BY_HASH 2021-11-05 15:21:38 +11:00
Sean Darcy 445fab4ac5 GET_LAST_BLOCK_HEADER 2021-11-05 14:12:29 +11:00
Sean Darcy f549e3ffad Add entire range of udev rules 2021-11-05 09:39:16 +11:00
Jason Rhinelander 972fe0de73 Stop using legacy ledger usb product id 2021-11-04 01:35:46 -03:00
Jason Rhinelander 06a9251f15 Add LedgerTCP hardware wallet support
This communicates with the Ledger over TCP, which is what the ledger
emulator requires.

To use, specify:

    --hw-device LedgerTCP --hw-device-address localhost:9999

to the wallet command-line arguments.
2021-11-04 01:35:46 -03:00
Jason Rhinelander b8ecb6724c device: C++ cleanups and modernization
- Clean up a bunch of not very nice C and older C++ code in the
`device/` tree.

- Rename device/device_io_* source files to io_*, and remove their `_io`
suffix from the class names (since they are *already* inside an `io`
namespace).
2021-11-04 01:35:44 -03:00
Jason Rhinelander 7f7caadf4e Add short_duration for single-unit time printing 2021-11-04 01:33:42 -03:00
Thomas Winget 18016ded02 rebase fixups 2021-11-01 17:27:44 -04:00
Jason Rhinelander 040dcdd2db Various formatting fixes
- `/p`s should be `\p`s
- wrap long lines in new doc comments
- fix some grammar
- remove some duplicate comments
2021-11-01 17:08:57 -04:00
Sean Darcy d5cb4a0ae7 FLUSH_CACHE 2021-11-01 17:08:57 -04:00
Sean Darcy 60db8271a9 TEST_TRIGGER_UPTIME_PROOF TEST_TRIGGER_P2P_RESYNC REPORT_PEER_STATUS 2021-11-01 17:08:57 -04:00
Sean Darcy 88904bc9a3 GET_SN_STATE_CHANGES 2021-11-01 17:08:57 -04:00
Sean Darcy 8f999ec785 PRUNE_BLOCKCHAIN 2021-11-01 17:08:57 -04:00
Sean Darcy 0fb605746a STORAGE_SERVER_PING and LOKINET_PING 2021-11-01 17:08:56 -04:00
Sean Darcy 8d1e9985f9 POP_BLOCKS 2021-11-01 17:08:56 -04:00
Sean Darcy ef44031b79 OUT_PEERS and IN_PEERS 2021-11-01 17:08:56 -04:00
Sean Darcy b16a744bf8 GET_BASE_FEE_ESTIMATE 2021-11-01 17:08:56 -04:00
Sean Darcy 53890cc1bc GET_COINBASE_TX_SUM 2021-11-01 17:08:56 -04:00
Sean Darcy 3b65462f40 GET_VERSION to new rpc 2021-11-01 17:08:56 -04:00
Sean Darcy 6f3f6a4836 FLUSH_TRANSACTION_POOL to new rpc format 2021-11-01 17:08:56 -04:00
Sean Darcy bd56d537f5 BANNED to new RPC format 2021-11-01 17:08:56 -04:00
Sean Darcy 2a4ca2a50f make_request template instead of try_running 2021-11-01 17:08:56 -04:00
Sean Darcy 1c2a798bc9 set_log_level and set_log_categories to use new RPC 2021-11-01 17:08:56 -04:00
Jason Rhinelander 7551f5c137 Remove p2p rpc_port; p2p code clean-ups
The public rpc port code from Monero is not used on Oxen (we have no
ability to enable it because we didn't want it), but still carried
around and printed pointlessly.  This removes it entirely.

Along the way I ran into some really nasty p2p code using templates for
absolutely no reason at all, so I fixed that crap, and moved some p2p
serialization out of headers into a .cpp file.  (This only scratches the
surface, but as we're going to replace the p2p code entirely eventually
I don't want to waste time trying to polish a turd).
2021-11-01 17:08:56 -04:00
Jason Rhinelander 6c54ca6abd fix 2021-11-01 17:08:56 -04:00
Jason Rhinelander ff0c76d7f3 RPC: +peerlist, -publicnodes
Updates GET_PEER_LIST to new RPC.

Removes GET_PUBLIC_NODES because we don't use this option at all in
oxend.  (At the point where we need a decentralized public node
repository we'll almost certainly want to use the service node network
to do it, not the p2p layer).
2021-11-01 17:08:56 -04:00
Jason Rhinelander e1ef4a44e4 Remove external block generation/submission support
We have no need for any of this, so just remove it rather than convert
it.

(This doesn't drop block generation support, which we can still do via
start/stop mining calls, but rather just the ability to hook up an
external miner, which we are unlikely to ever need again).
2021-11-01 17:08:56 -04:00
Jason Rhinelander c70545b18a RPC: GET_BLOCK_HASH updated
This endpoint has bizarre inputs and outputs, so this breaks
compatibility to make them sane.

Old:

    "height": [h]

where h must be exactly 1 height (yes, that 1 single height must be in a
list), and output is the raw hash as a string (no dict, etc. around it).

New in:

    "heights": [123, 456, ...]

Result:

    {
        "123": "hash123",
        "456": "hash456",
        "status": "OK"
    }
2021-11-01 17:08:56 -04:00
Jason Rhinelander 671a8ba0fe RPC: SUBMIT_TRANSACTION new rpc update
- Rename endpoint from "send_raw_transaction" to "submit_transaction"
  and rename the RPC struct similarly.

- Rename tx_as_hex to just tx, and start accepting it as hex, base64, or
  raw bytes.  (Transactions formats are consistent enough that we can
  easily tell which one we have from the first couple bytes).

- Drop `do_not_relay` parameter as I can see no purpose to ever
  submitting a transaction to a daemon that shouldn't be relayed.  (The
  only use I can see would be to try to exploit a PoW network with
  double-spends).

- Drop `do_sanity_checks` parameter; the checks done here should be (and
  are!) done by the wallet, not the oxend receiving the completed
  transaction.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 59359b315e Zero-initialize RPC
Add some initializers and also make sure we zero initialize in case they
are forgotten in the future.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 6729cb2da8 RPC: IS_KEY_IMAGE_SPENT
New RPC.

Also adds the ability to look up more than one key image at a time, and
shows errors through a proper fail_msg_writer().
2021-11-01 17:08:56 -04:00
Jason Rhinelander 17869887c8 Split core_rpc_server_commands_defs into 2
Keep the current one for the json/bt RPC endpoints, and move all the
binary endpoints into a new .h/.cpp.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 5b4fb35919 Remove useless GET_TRANSACTION_POOL_BACKLOG endpoint
Not only is this endpoint not used anywhere, but it returns (invalid)
cancerous json output when invoked in current stable oxend:

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "backlog": "l\u0007\u0000\u0000\u0000\u0000\u0000\u0000�\u001f�\u0000\u0000\u0000\u0000\u0000Y�������",
        "status": "OK",
        "untrusted": false
      }
    }

where that cancer in the backlog field is the raw bytes copied out from
under a struct with 3 uint64_t's.  (It's also invalid json because those
unprintable characters are \xff, which isn't valid UTF-8 encoding, and
thus isn't valid JSON).

Just nuke the whole thing since nothing uses it (probably because it is
such cancer).
2021-11-01 17:08:56 -04:00
Jason Rhinelander 7bb3bb1807 RPC: GET_LIMIT, SET_LIMIT
Updates to new RPC interface.

Removes distinct `limit`, `limit_up`, `limit_down` command and makes
them all go through `limit` by allowing limit to take the down and up
parameters.

    limit_up 123
    limit_down 456

becomes

    limit 0 123
    limit 456 0

or to set both at once:

    limit 456 123

Also improves documentation, and allows "default" to be specified for
either limit to return the limit to its default.  (-1 is also accepted
for this, but is a pain because on the command line it produces an
invalid option error unless you also prefix the command with `--` to
stop further arg parsing).

Also makes the command actually print an error (instead of nothing at
all) when given invalid arguments.  Whoa such innovation!
2021-11-01 17:08:56 -04:00
Jason Rhinelander 91f327db06 Wire up start_mining command
Also remove some old autodetect handling which doesn't exist anymore.
2021-11-01 17:08:56 -04:00
Jason Rhinelander fe376e184d RPC: add support for fetching transaction pool
This drops the dedicated GET_TRANSACTION_POOL endpoint entirely and
folds the txpool fetching into GET_TRANSACTIONS via a new `memory_pool`
parameter.  (This is backwards incompatible, of course, but the results
may not be too harmful: the wallet doesn't actually use this endpoint,
so it mainly affects internal oxend commands (fixed here) and the block
explorer (which is fairly easily fixed).

This also removes some of the useless GET_TRANSACTIONS bits such as
decode_as_json.

`fee` and `burned` are now always provided in the return (for both
specific requested transactions and mempool transactions).

As a side effect, this code ventured deep into core/blockchain in terms
of dealing with missed transactions: previously they were always
returned (via lvalue ref) as a vector, and always had to be specified.
This changes to take via pointer to an unordered_set, which can be null
if you don't care about the missed ones.  This reduces several calls
that indeed didn't care about collecting the missed values, and improved
virtually all the places that *did* care which need to query which ones
were missed rather than needing a specific order.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 27683554e4 RPC: GET_TRANSACTIONS
Various cleanups.

Moves RPC-specific logic out of tx_pool and into the rpc code.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 0fa54cb507 Make operator_fee in millionths
This makes it consistent with the value returned in the tx extra details
in the get transactions rpc call.
2021-11-01 17:08:56 -04:00
Jason Rhinelander 61f87e42a6 RPC: HARD_FORK_INFO
Implements new RPC for hard_fork_info, which `oxend status` (most
notably, but there are others) requires.
2021-11-01 17:08:54 -04:00
Jason Rhinelander 7e6097d312 RPC: GET_TRANSACTION_POOL_STATS improvements/tweaks
- Take the "include_unrelayed" as a parameter instead of switching on on
  the admin context; there isn't likely to be anything sensitive there,
  and it makes little sense for a wallet to get *different* results just
  because it happens to be talking to a localhost oxend.
- Change the histogram code so that it always returns a fixed size
- Various improvements to histogram output; most notably printing a more
  useful indication of what the histogram outputs are (e.g. instead of:

             Age             Txes       Bytes
             now                0           0
       8.0 minutes ago          0           0
       16.1 minutes ago         0           0
       24.1 minutes ago         0           0
       32.2 minutes ago         0           0
       40.2 minutes ago         0           0
       48.3 minutes ago         0           0
       56.3 minutes ago         0           0
       64.3 minutes ago         0           0
       72.4 minutes ago         2        4559

  it now displays the ranges:

                  Age                Txes       Bytes
           now - 10.6min ago          0           0
       10.6min - 21.3min ago          0           0
       21.3min - 32.0min ago          0           0
       32.0min - 42.6min ago          0           0
       42.6min - 53.2min ago          0           0
       53.2min - 63.9min ago          0           0
       63.9min - 74.6min ago          0           0
       74.6min - 85.2min ago          0           0
       85.2min - 1.6hr ago            0           0
         1.6hr - 1.8hr ago            2        4559
2021-11-01 17:08:22 -04:00
Jason Rhinelander 7b871e97fc Add fmtlib::fmt backport of C++20 std::format
Because I'm tired of waiting for std::format.
2021-11-01 17:03:47 -04:00
Jason Rhinelander 0e260256b2 Push RPC response serialization down into handlers
Rather than serializing in the `invoke` call, we now return a variant
(bt, json, or string) from invoke and let the RPC server deal with it.

This significantly simplifies the JSON RPC interface because it lets us
move json objects around, which is particularly useful for building a
json_rpc response and lets us avoid the vector of strings hack that was
needed for epee json serialization.

This also lets the RPC caller decide what it wants to accept -- so the
OMQ RPC can deal with anything (bt, json, binary), while the http
json_rpc handler only accepts json, and the http/legacy binary handlers
accepts json or strings, but not bt_value.

This also fixes a but in the json_rpc handler that failed when given an
"id" value that wasn't a string (such as a number).
2021-11-01 16:59:01 -04:00
Jason Rhinelander 3415733996 RPC overhaul: SYNC_INFO 2021-11-01 16:59:01 -04:00
Jason Rhinelander bdccca82dd Remove debugging & superfluous 'return;'s 2021-11-01 16:59:01 -04:00
Jason Rhinelander 5c413592aa Return tx pool hashes as potential binary
We can assign hashes directly now and get binary for bt-rpc, hex for
json.
2021-11-01 16:59:01 -04:00
Jason Rhinelander 8bb9d56f96 Fix mining status commands 2021-11-01 16:59:01 -04:00
Jason Rhinelander 6d7428b0e1 Add `invoke_simple` for invoking simple RPC calls
Simple here means no arguments and no return aside from the "status":
"OK" field.  For commands like stop_mining, stop_daemon, save_bc.
2021-11-01 16:58:59 -04:00
Jason Rhinelander 8ad7eb1509 Remove "support_flags" from p2p protocol
It does nothing.  This keeps a stub that returns zero so that other
nodes can still query us, which can be removed after the next HF.
2021-11-01 16:58:04 -04:00
Jason Rhinelander c2f39b6541 RPC update: get_connections
- add documentation
- change download/upload speed values to B/s instead of KiB/s
- return times as milliseconds instead of seconds, and rename those
  fields from ..._time to ..._ms.
- Code cleanup of state strings
- remove completely unused peer state "idle"
2021-11-01 16:58:01 -04:00
Jason Rhinelander ef3686ccf3 Remove hide_hr, show_hr commands, part 2 2021-11-01 14:59:27 -04:00
Jason Rhinelander 86a8de6403 Add generic concat and concat-with-delimiter string utils 2021-11-01 14:59:27 -04:00
Jason Rhinelander 7bb53551e3 Apply some lipstick to a pig
Some small random epee improvements.
2021-11-01 14:59:21 -04:00
Jason Rhinelander ad79059b74 Move tx pool stats struct out of rpc code
It makes no sense for the definition to be there (except that it was
for epee serialization purposes), so move it into tx_memory_pool where
it belongs, and convert it to json on the fly for the rpc method that
wants it.
2021-11-01 14:54:21 -04:00
Jason Rhinelander 4c141e1e4a START_MINING fixes
- parse args
- make it compile
- fix the slow_mining parameter not being passed through to the miner
2021-11-01 14:54:21 -04:00
Jason Rhinelander 5dcb2c2b56 Remove parse_request() overloads for no-args endpoints
Inheriting from NO_ARGS lets you rely on the no-input
parse_request(NO_ARGS&, rpc_input) rather than needing to add an empty
one.
2021-11-01 14:54:21 -04:00
Jason Rhinelander b9755af4b4 Remove useless junk from miner: autodetect, miner_conf.json
Autodetect is not that useful in the first place, even if we weren't
PoS, but is especially useless now.

miner_conf.json is this probably-never-used feature to load some extra
crap into the tx_extra.  Just kill it.

Remove the ability (and RPC endpoint) to print the hashrate periodically
to stdout because that is pretty dumb.
2021-11-01 14:54:21 -04:00
Jason Rhinelander 109b7b81e4 Eviscerate epee timing garbage
Removes a bunch of epee garbage and replaces it with std::chrono.

In particular:

- TIME_MEASURE_* macros are gone because they are garbage.
- epee::get_tick_count() is gone because it is garbage.
- epee::get_ns_count() is gone because it is garbage.
- TIME_MEASURE_NS_* macros are gone because they are unused and garbage.
- PROFILE_FUNC_* macros are gone because they are unused and garbage.
- profile_tools::local_call_account is gone because it is unused and
  garbage.
- various places passing around ints (which could be seconds,
  milliseconds, or nanoseconds) changed to pass std::chrono duration
  types.
2021-11-01 14:54:21 -04:00
Jason Rhinelander 1f16daf109 Replace epee C date crap with C++20 date backport 2021-11-01 14:54:18 -04:00
Jason Rhinelander 63a6cd6a13 get_outputs - finish, backwards compat, add results as tuple
- Make it compile/work
- Take outputs as a list of output indices.  We never need "amount" in
  Oxen (it will always be 0).
- Add backwards compatibility to still take outputs as
  [{"amount":0,"index":n},...] when making a json request.
- Add an "as_tuple" bool parameter: if specified then you get results in
  a much denser tuple form rather than a dict, which can make a huge
  difference in the response size when requesting many outputs.
2021-11-01 14:53:56 -04:00
Jason Rhinelander 02f1b5b982 Add nlohmann-json submodule 2021-11-01 14:53:52 -04:00
Jason Rhinelander 2b568f02d2 Add support for loading from various container types
- Supports loading into tuples, std::arrays, std::pairs from a list of
  the correct size.
- Supports loading into vectors of arbitrary types (include vector,
  tuples, binary types, etc.)
- Removes system_clock type as we aren't using it (and because it won't
  be recursively handled nicely when nested, especially for json).
2021-11-01 14:53:10 -04:00
Sean Darcy 71fb298b3a parse params of get_outputs 2021-11-01 14:53:10 -04:00
Sean Darcy 533b319fff define parsers, returning correct types 2021-11-01 14:53:10 -04:00
Jason Rhinelander a8b36efd4c Update doc formatting style
Use `- \p paramname Description` rather than `\arg \c paramname
Description`.

\arg is for compatibility with some particular doc format and is
equivalent to - except that - can be nested while \arg cannot.

\c and \p are equivalent, but \p is explicitly intended for parameters.
2021-11-01 14:53:10 -04:00
Jason Rhinelander 9a0e23ca05 get_service_node *client* updates
Updates the internal callers of get_service_nodes to properly deal with
the new request format/fields.

Note that this also introduces some significant changes to the
`print_sn` output:

- contributor formats are more compact (one line per contributor), show
  reserved amounts (if != contributed amouont), and show the stake %.
- reworded "Operator Cut (% of Fee Reward)" to "Operator Fee"
- checkpoint/pulse vote format is completely overhauled to list voted
  and missed heights separately.
- pulse votes now show the pulse round for non-zero round results.
- timestamp checks renamed to Quorumnet tests
- qnet & timesync results now just print the number of successes/fails
  rather than a list of true/false values.
2021-11-01 14:53:10 -04:00
Jason Rhinelander ebc8bc79e5 RPC: GET_SERVICE_NODES & GET_SERVICE_NODE_STATUS
Converts request parsing and result generation for get_service_nodes and
get_service_node_status.

Note that there are some significant changes here (due to no longer
having to be under epee's output constraints) that significantly reduce
the size of an all-service-nodes request by nearly half, most notably in
a significantly more compact representation of vote/participation
results.

- added a "decomm_reasons" which decomposes the reason codes into string
  values such as:

    "decomm_reasons": {
        "all": ["uptime"],
        "some": ["pulse", "lokinet"]
    }
- reworded/fixed/expanded various field descriptions
- Various Loki currency references changed to OXEN
- added "operator_fee" which is a rounded operator fee expressed as
  thousanths of a percent (e.g.  100000 means 100%, 4567 means 4.567%).
  This is inaccurate but much easier to deal with than the raw
  portions_for_operator value (especially because the value *usually*
  exceeds what can be stored in a double, and thus is not safe with
  various JSON parsers).
- added "swarm" which is a hex string representation of the swarm_id,
  because swarm_id also isn't double-storage safe.
- reserved and total_reserved fields are now only included if they are
  actually different from the amount/total_contributed values.
- various uptime-proof-dependent values (like versions, public ip,
  ports) are now omitted if we haven't received an uptime proof yet.
- Flipped inverted descriptions of timestamp participation / synced
  values in the RPC documentation.
- checkpoint/pulse/timecheck/timesync participations data is completely
  redesigned to be less bloated; the names are now changed to
  "checkpoint_votes" and "pulse_votes" and information is returned much
  more compactly using lists of lists and/or plain values rather than
  lists of dicts that repeat a ton of fields.
- Renamed timestamp_participation in the RPC to quorumnet_tests since,
  although we're doing the test for time checking, the main purpose of
  the participation is to see that we can reach them.  As above, the
  result value is significantly more compact: [SUCCESS,FAILS] instead of
  an array of dicts.
- Similarly renamed timesync_status to timesync_tests ("status" was
  fine, but changing the value completely to [SUCCESS,FAILS] warrants a
  name change).
- dropped the "as_json" field because it is asking oxend to
  double-encode json, and that is retarded.
- also applies all the same refactoring to get_service_node_status
  (which is really just a shortcut for getting the current node's status
  out of get_service_nodes).
- overhauled how "fields" works to take a list of field names (the dict
  is name: bool values is still supported for backwards compatibility).
  Also extended fields to handle "locked_contributions" as a supported
  field (so that you can easily omit it, since it often isn't cared
  about).
2021-11-01 14:53:10 -04:00
Jason Rhinelander 4317feb7d6 Promote critical startup errors to MFATAL
At MERROR they don't print at the default --log-level=0, so you get
output such as:

    2021-08-06 18:04:08.073	I Starting up oxend services...
    2021-08-06 18:04:08.073	I Starting core
    2021-08-06 18:04:08.073	F Failed to start core
    2021-08-06 18:04:08.173	I Deinitializing daemon objects...

with no actual error displayed as to why it failed to start.  With this
change you get:

    2021-08-06 18:04:14.004	F Please specify an IPv4 public address which the service node & storage server is accessible from with: '--service-node-public-ip <ip address>'
    2021-08-06 18:04:14.004	F IMPORTANT: One or more required service node-related configuration settings/options were omitted or invalid; please fix them and restart oxend.
    2021-08-06 18:04:14.004	F Failed to start core
2021-11-01 14:53:10 -04:00
Jason Rhinelander de3f9a103f Move json binary handling code; teach it about vectors
- Moves the json binary handling code into new rpc_binary.h

- Adds support for storing/loading vectors of binary types
  (crypto::hash, etc.), and vectors of strings.
2021-11-01 14:53:10 -04:00
Jason Rhinelander e8cbf6352d using nlohmann::json
Simplify things by not require full qualification everywhere.
2021-11-01 14:53:10 -04:00
Jason Rhinelander 1ea9791ca4 Add a version of tools::join that also transforms
Also add a missing <cassert> header needed for elsewhere in the header.
2021-11-01 14:53:10 -04:00
Jason Rhinelander ea8292703f print_money: allow trimming unused decimals
This lets the caller get a value of 15000 or 4.56 instead of
15000.000000000 or 4.560000000 by passing a true second argument to
print_money().
2021-11-01 14:53:10 -04:00
Jason Rhinelander 5330069421 Remove dumb configurable decimal place support
*Nothing* calls `print_money()` with a decimal place value, for good
reason: it's a stupid thing to want to do.  Similarly nothing gives a
decimal places argument to `get_unit()`.

This removes the dumb unused decimal place argument.
2021-11-01 14:53:10 -04:00
Jason Rhinelander a3547c8467 Simplify participation structures
- make checkpoint and pulse participation distinct types
- make the container act a little more like an stl container
- replace check_participation() with a failures() method that just
  returns the number of failures (so the caller can decide whether that
  is bad or not).
- As a consequence of the above, failures now trigger on N+1 failures,
  while previously they required N+1 failures *and* 8 total responses.
  There is no need to wait for all 8 as far as I can see since we will
  be failing no matter what the next 3 responses are.
- Removed the serialization code (hopefully this doesn't break
  everything outside the RPC code).
- Simplify/DRY the code that records participation
2021-11-01 14:53:10 -04:00
Jason Rhinelander 41c01efadf Add int-to-string converter (from storage server) 2021-11-01 14:53:10 -04:00
Sean Darcy c7ab69b4f9 Convert RPC functions to new format:
MINING_STATUS, GET_TRANSACTION_POOL_HASHES, GET_TRANSACTION_POOL_BACKLOG, GET_TRANSACTION_POOL_STATS, GET_CONNECTIONS
2021-11-01 14:53:10 -04:00
Sean Darcy 434ca35c7e New RPC formats for STOP_MINING, SAVE_BC, STOP_DAEMON, GETBLOCKCOUNT 2021-11-01 14:53:10 -04:00
Sean Darcy ced01dfb16 START_MINING and GET_OUTPUTS to new RPC format 2021-11-01 14:53:09 -04:00
Sean Darcy b3f125bfdf GET_NET_STATS - To new RPC format 2021-11-01 14:53:09 -04:00
Jason Rhinelander d350e2a664 Remove old code 2021-11-01 14:53:09 -04:00
Jason Rhinelander 4a8023ade6 Make RPC more flexible & add bt-encoding
The bt-encoding, in particular, is aimed at more efficient wallet3 rpc
interactions with a daemon.

This removes the rigidity from RPC request responses, making it easier
to return useful constructs that the current epee code doesn't support
(like lists of lists), and also adds support for bt-encoded RPC requests
(intended to eventually replace the ".bin" endpoints with Monero NIH
binary encoding).

Instead endpoints now set a nlohmann::json response object with whatever
arbitrary values they want without having to add a bunch of limited epee
serialization macro hell.

So, for example, to set the value "foo" to 20, you use:

    rpc.response["height"] = 20;

Binary values (for things like hashes) are handled by going through a proxy object:

    rpc.response_hex["hash"] = hash; // hash is a crypto::hash

which, for json, is equivalent to:

    rpc.response["hash"] = tools::type_to_hex(hash);

but when the response is to be bt-encoded it leaves it as binary for
more efficient transfers.

There is also a `response_b64` that converts json-destined values to
base64 instead of hex (and again leaves bt-destined values as binary).

Parsing of incoming requests now moves to a new
core_rpc_server_command_parser file, which does free-form parsing from a
nlohmann::json or bt_dict_consumer, and has various templated helper
functions to make this easier.

This is preliminary: this builds the basic infrastucture for handling
requests, and converts three endpoints:

- get_info
- get_height
- ons_resolve

Currently only `make daemon` builds (there is code in the wallet that
hasn't been updated yet), and the other RPC interfaces are disabled by
this commit (until they get converted to the new style).
2021-11-01 14:53:05 -04:00
Jason Rhinelander d66e72fcea friendly_duration: show 0s for exactly 0 rather than 0ns 2021-11-01 14:19:27 -04:00
Jason Rhinelander 0ff6d3f491 Minor api improvement: return pair instead of two output params 2021-11-01 14:19:27 -04:00
Jason Rhinelander c3c90a48f7 Code simplification 2021-11-01 14:19:27 -04:00
Jason Rhinelander 25285dacc1 Use fs::path instead of std::filesystem
This uses the ghc filesystem backport when targetting older mac, and
std::filesystem everywhere else.
2021-10-27 10:36:51 -03:00
Jason Rhinelander e312e30f12
Merge pull request #1494 from tewinget/sqlitedb
fix bugs in initial implementation of sqlitedb abstraction
2021-10-19 12:34:33 -03:00
Jason Rhinelander 5a73ec194a
Merge pull request #1495 from jagerman/remove-uselessness
Remove useless atomic calculations
2021-10-19 12:33:35 -03:00
Jason Rhinelander 340c99b524 Set up aes flags properly for cn-turtle compilation 2021-10-18 22:23:01 -03:00
Thomas Winget a255889286 minor fixups in sqlitedb wrapper 2021-10-16 22:32:32 -04:00
Jason Rhinelander ce6050c3d9 And no optimization for apple, too.
It also doesn't compile, because who knows BS with how apple handles
aes, and I hate this cn turtle code.
2021-10-15 20:57:18 -03:00
Jason Rhinelander 290984257f Disable broken intel-optimized build on i386
It doesn't compiler and I can't be arsed to fix it; if someone really
needs 32-bit they probably don't care about performance of turtle
hashing in oxend anyway, so the portable one is fine.
2021-10-15 20:54:12 -03:00
Jason Rhinelander 45e03a4575 Disable LTO for cncrypto on gcc-11
The cn_turtle_hash code makes GCC misoptimization in multiple ways under
LTO, so just force it off for GCC-11 (Hopefully the bugginess gets fixed
by GCC-12).
2021-10-15 20:42:11 -03:00
Jason Rhinelander 62ef3f64b1 Remove useless functions 2021-10-15 19:42:19 -03:00
Thomas Winget e12f8dc518 fix some bugs in sqlitedb abstraction.
also set BUSY timeout for internal sqlite lib to 5 seconds
2021-10-15 17:21:44 -04:00
Jason Rhinelander ee62a23550 Fix x86 arch detection
We were *always* falling back to the software implementation because
this define isn't set here.
2021-10-15 15:19:49 -03:00
Jason Rhinelander 7a70914e15 Split up turtle arch branches
Try to make the code a little more followable.
2021-10-15 14:52:23 -03:00
Jason Rhinelander 69ad37daee Remove useless atomic calculations
These are useless and not used anywhere.  Hurray!
2021-10-15 12:46:32 -03:00
Thomas Winget 640adb7aca fix missing include in sqlitedb
also add "maybe get" function to Database class
2021-10-13 20:29:35 -04:00
Thomas Winget 73e787a9ec sqlitecpp cmake nonsense 2021-10-06 19:36:46 -04:00
Thomas Winget df07ae3e40 require sqlite foreign_key ON 2021-10-04 22:26:33 -04:00
Thomas Winget 435c189a9b sqlitecpp 2021-10-04 20:33:24 -04:00
Sean 578c1c235f
Merge pull request #1484 from jagerman/disable-mms-light
Disable MMS and light wallet support by default
2021-09-06 13:45:16 +10:00
Jason Rhinelander 03add6ebe3 Move operator== into namespace
Argument-dependent lookup will find these if in the same namespace as
Proof itself.
2021-09-03 02:17:07 -03:00
Jason Rhinelander e3999ccb26 Rearrange proof/service node forward declarations to help gcc-8
gcc-8's unique_ptr apparently isn't okay with a forward declared type.
This reverses how proof and service_node_list include/fwd declare each
other to get around it.
2021-09-03 02:15:37 -03:00
Jason Rhinelander 9782155c81
Merge pull request #1481 from jagerman/drop-integration-tests
Drop unmaintained integration test code
2021-09-03 00:28:49 -03:00
Jason Rhinelander e2a7391fb3
Merge pull request #1482 from darcys22/initialise-uptime-proof-info
Initialise uptime proof info
2021-09-03 00:28:30 -03:00
Jason Rhinelander 5759c41291
Merge pull request #1480 from jagerman/logger-rebrand-updates
Fix missing logger rebrand updates
2021-09-03 00:26:34 -03:00
Jason Rhinelander eefd42f93f Add fmtlib::fmt backport of C++20 std::format
Because I'm tired of waiting for std::format.
2021-09-02 17:25:13 -03:00
Jason Rhinelander ff8e2dd09d Disable MMS and light wallet support by default
This aren't used or supported by anyone in Oxen land (as far as I know)
and have not been maintained since the beginning, so hide them behind
disabled-by-default cmake options.

This cuts about 10% off the wallet2 compilation time and 3% off the
simplewallet compilation time, plus gets rid of the page of mms crap in
the cli wallet's "help" screen.
2021-09-02 14:03:19 -03:00
Sean Darcy 36a86af3fc more uptime proof initialisations 2021-08-20 15:42:24 +10:00
Sean Darcy 302259ce69 Uninitialised variables 2021-08-20 15:04:07 +10:00
Jason Rhinelander 5f1bd2f1e4 Drop integration test code.
This code is bitrotting, doesn't compile, and isn't being maintained
anymore.

The integration test suite was an interesting idea, in early Loki days,
but is no longer being maintained and is quite cumbersome to run (for
instance, it is not possible to run it via CI because it depends on
xterm to actually run).  The code to actually run it (in doy-lee's
loki-integration-testing repository) is also a large burden of "janky"
code that isn't worth maintaining.

Remove this from the code; if someone wants to pick it back up in the
future reverting this commit shouldn't be too difficult (though I'd
suggest that a much better approach to integration testing would be to
run different daemons/wallets via rpc commands, as the network-tests do,
rather than trying to feed stdin and parse stdout from running
individual oxends/wallets).
2021-08-19 16:42:15 -03:00
Jason Rhinelander 5b95224c39 Fix some missing LOKI -> OXEN logger defines
Various ones were unchanged in epee.

Also found a couple very old MONERO -> OXEN changes as well.
2021-08-19 16:03:32 -03:00
Jason Rhinelander 16c15c5d26
Merge pull request #1466 from jagerman/wallet-api-refresh-locks
Add locks around the refresh thread
2021-08-09 22:39:46 -03:00
Sean Darcy ff1b25c961 Explanatory message for workaround 2021-07-09 16:02:13 +10:00
Jason Rhinelander 381a3a4ecd Fix hard_fork_info rpc returning wrong earliest_height
With multiple forks on the same major version `get_hard_fork_heights`
was returning the last one instead of the first one.
2021-07-09 02:55:47 -03:00
Sean Darcy 84f6d08baa Allow HF18 to be used earlier
The get earliest version returns HF 18.1 and this means that our blink
fees that were enabled in HF18 are no longer accepted. Push through to
allow the fees to be used 4000 blocks earlier (current height)
2021-07-09 15:29:06 +10:00
Jason Rhinelander d8662ace7b Add non-blocking isRefreshing(); make height retrieval non-blocking 2021-07-07 18:10:29 -03:00
Jason Rhinelander e09b23a143 Make pointer const 2021-07-07 11:05:17 -03:00
Jason Rhinelander 81eddcd26a Add locks around the refresh thread
Wallet API is really messy with threads -- the refresh thread can run at
any time and change internal wallet state which breaks just about
everything.

This puts all non-trivial wallet access from wallet_api behind a lock of
the refresh thread to lock it out from refresh while other operations
are underway.
2021-07-07 11:05:17 -03:00
Jason Rhinelander 4f6f67d151 Fix segfault triggered in test suite on macos
It seems that the `m_tinfo` can be null, sometimes, when `m_cursors ==
&m_wcursors` is true, and the upstream Monero code (which is pure macro)
doesn't touch the bool in such a case.

For some reason this started segfaulting now, only on macos, only on a
release build because of the access into `m_tinfo`.

The workaround (which is indeed a correct fix) appears to avoid the
segfault, but the segfault could retrigger if that invariant doesn't
hold (and it isn't immediately obvious why that invariant *should*
hold).

This, like pretty much all of the LMDB code, is garbage.
2021-07-06 17:37:01 -03:00
Jason Rhinelander 74171b8128 Finalize mainnet soft fork for July 13. 2021-07-06 00:06:26 -03:00
Jason Rhinelander 58cb24b9df Bump required lokinet version to 0.9.5 2021-07-05 23:51:54 -03:00
Jason Rhinelander de3340e5c8 Test suite fixes 2021-07-05 23:48:18 -03:00
Jason Rhinelander a841886e62 Fix copyright statement
Though this statement seems dubious since "The Oxen Project" is no a
legal entity.  Should perhaps be "Oxen Privacy Tech Foundation"?  Or
alternatively we could have a statement somewhere that "The Oxen
Project" refers to the OPTF + code contributed by Oxen community members
through github, etc.

Okay enough copyright law.
2021-06-21 09:50:57 -03:00
Jason Rhinelander 3644861971 lokinet/SS minimum proof versions; 9.2.0 version bump
Remove support for old (non-bt) proofs with the 9.2.0 snode revision
block (I'm not 100% sure on what to call this; "snode revision"? "soft
fork"? "spork"?).

Also bumps the working version to 9.2.0; this likely isn't release
ready, but allows for testing of this on testnet.
2021-06-19 15:13:57 -03:00
Jason Rhinelander ead4819fec Minor code simplification
Eliminates a pointless local variable and a pointless block.
2021-06-19 15:13:57 -03:00
Jason Rhinelander e5ec5ae76d Fix compiler warning in debug builds 2021-06-19 15:13:57 -03:00
Jason Rhinelander 7b00cb251b Add snode revision soft forks & drop hard fork voting code
Snode revisions are a secondary version that let us put out a mandatory
update for snodes that isn't a hardfork (and so isn't mandatory for
wallets/exchanges/etc.).

The main point of this is to let us make a 9.2.0 release that includes
new mandatory minimums of future versions of storage server (2.2.0) and
lokinet (0.9.4) to bring upgrades to the network.

This slightly changes the HF7 blocks to 0 (instead of 1) because,
apparently, we weren't properly checking the HF value of the
pre-first-hf genesis block at all before.  (In practice this changes
nothing because genesis blocks are v7 anyway).

This also changes (slightly) how we check for hard forks: now if we skip
some hard forks then we still want to know the height when a hard fork
triggers.  For example, if the hf tables contains {7,14} then we still
need to know that the HF14 block height also is the height that
activates HF9, 10, etc.
2021-06-19 15:13:57 -03:00
Jason Rhinelander b665b2f0b1
Merge pull request #1459 from jagerman/lokinet-reachability
Lokinet reachability testing
2021-06-10 16:03:52 -03:00
Jason Rhinelander 41ba779834 Increase minimum versions for SS/lokinet 2021-06-10 15:32:50 -03:00
Jason Rhinelander 821837368e
Merge pull request #1463 from jagerman/ons-lookup-fix
ONS backup owner lookup fixes
2021-06-10 15:09:41 -03:00
Jason Rhinelander 138dfeb023
Merge pull request #1461 from jagerman/ons-counts
Add registered active ONS registrations counts to get_info RPC
2021-06-10 15:09:08 -03:00
Jason Rhinelander c2d6e095b2 Don't enforce lokinet reachability yet
This makes reachability testing activate at HF19.  We probably want to
come back and update this before HF19, but for now we just check but
don't enforce lokinet reachability.
2021-06-10 14:47:17 -03:00
Jason Rhinelander f5c5f7e9f8 Remove obsolete (pre-HF18) code paths 2021-06-10 12:13:33 -03:00
Jason Rhinelander bbb8bdb1af Add lokinet reachability to quorum testing
It works just like storage server testing.

Renames the report_peer_storage_server_status to report_peer_status, and
repurposes the code to handle both SS and lokinet.

This *doesn't* need a HF by design because the reason bit field was
deliberately designed so that we can add reason fields (older clients
will just ignore unknown bits).
2021-06-10 12:13:33 -03:00
Jason Rhinelander 5b1ca27e2e Fix cli wallet showing wrong Owner value for backup owner
When doing a lookup by owner in simplewallet (`ons_by_owner`) the wallet
was always writing "Owner: ..." for whatever owner row was requested,
*not* the actual Owner row returned.

In particular, when we get back a record where WalletX is the backup
owner and WalletA is the primary owner then when looking up ons records
by owner for WalletX it would print:

Owner: WalletX
BackupOwner: WalletX

Instead of properly showing the record owner details of:

Owner: WalletA
BackupOwner: WalletX

This fixes it.
2021-06-10 12:01:36 -03:00
Jason Rhinelander 7fbe15e96b Fix handling of ONS names when a backup owner
When looking up the ONS names by owner (e.g. ons_by_owner in the cli
wallet) the oxend RPC method returns an error for any records that get
returned where the looked up owner is a backup owner, because it tries
to map (only) the primary owner to a response index and fails if it got
back a record from the database that wasn't in the list of requested
addresses.

This fixes the RPC method to properly check both owner and backup owner.
2021-06-10 12:00:48 -03:00
Jason Rhinelander 470bca770e
Merge pull request #1452 from jagerman/debug-build-fix
Fix SN info upgrade in debug build
2021-06-10 10:43:39 -03:00
Jason Rhinelander 8a2078b51e Fix broken index
This index was being created on a column that doesn't exist, and
apparently because it was quoted (until the commit earlier in this PR),
sqlite was apparently treating it as a string literal.

Cursed AF.

Drop the old name and recreate the index.
2021-06-09 22:07:22 -03:00
Jason Rhinelander a0047a1321 Remove unneeded raw string literals
Without identifier quoting we don't need this anymore.
2021-06-09 15:27:18 -03:00
Jason Rhinelander 740daddb1e Remove superfluous SQL identifier quoting
SQL identifiers are generally meant to be used unquoted, with quoting
only used when strictly necessary (e.g. to avoid keyword conflicts).
2021-06-09 14:02:56 -03:00
Jason Rhinelander 2aebfc4bce Add missing unique index
This index was only getting created on upgraded (from v7, I think)
databases but not new ones.

Also adds a comment about what the "prune" queries actually do (because
the `>=` seems really counterintuitive to me until I figured out that
they are only meant for handling a rollback).
2021-06-09 13:55:07 -03:00
Jason Rhinelander 5de150a475 Add registered ons entry counts to get_info RPC 2021-06-09 13:55:07 -03:00
javabudd e32cbcbccd
Check if SN has a ping from lokinet and the storage server before registration (#1457)
* Make preparing registration fail if lokinet or the storage server have not received a ping yet

* Add prepare_registration boolean default

* Add signature override for get_human_time_ago to accept an optional uint64. Add stricter comparisons to ping checks

* Remove duplicate logic

* Remove method override and assign/cast last_lokinet_ping/last_storage_server_ping

* Use auto definition and static_cast res.last_lokinet_ping
2021-05-20 21:59:21 -03:00
Sean 3ddcf4879b
Merge pull request #1454 from darcys22/local-devnet
local devnet script
2021-05-18 13:24:21 +10:00
Sean Darcy 2ddf644844 local devnet scripts 2021-05-18 09:50:17 +10:00
Jason Rhinelander f287d3d614 Remove STACK_TRACE option
This option is incredibly misguided: exceptions are a normal part of C++
error handling that are used *as intended* in lots of places in the
code.  Spewing massive amounts of output every time any exception is
thrown anywhere (even when caught!) is terrible.

More than that, we don't ever build with it enabled (for the above
reasons) so this is all just unused code.
2021-05-12 11:59:22 -03:00
Jason Rhinelander c789fd5d77 Remove dead DEPENDS code
We dropped the contrib/depends build system quite a while ago (because
it was nasty), but there are still various DEPENDS checks scattered
through cmake that are just dead code now.  This removes them.
2021-05-12 10:46:57 -03:00
Jason Rhinelander c5143f0a31 9.1.2 hotfix -- fix proofs for older nodes with both pubkeys
bt-encoded proofs have a bug for nodes with different legacy/ed25519
pubkeys that isn't easily solvable (it needs a fix on *both* sender and
receiver ends).  That fix is in here (in uptime_proof.cpp) but that
isn't enough to solve it immediately.

This works around the issue by submitting old-style proofs if we are a
node with different legacy/ed25519 pubkeys.
2021-04-29 21:23:16 -03:00
Jason Rhinelander 730b3c7142 Fix SN info upgrade in debug build
The v7 info doesn't need anything done, but it fails the assert() here
for a debug build.
2021-04-29 13:12:17 -03:00
Jason Rhinelander d3a35c42cc Don't use timestamp from proof
The timestamp inside the proof is only for signature validation, but we
were using it in some places as the uptime proof time, but not updating
it everywhere we needed to.  This fixes it by using our own timestamp
for all local timed events (e.g. when we received it, when the node is
not sending proofs, etc.) to fix the issue.
2021-04-23 02:41:41 -03:00
Jason Rhinelander 422d82e205
Merge pull request #1447 from darcys22/version-bump-9.1.0
Version bump 9.1.0
2021-04-22 03:13:35 -03:00
Sean Darcy c07b713cd5 Mainnet hardfork 18 block and timestamp 2021-04-22 14:06:31 +10:00
Sean Darcy 2f12e84938 Bump versions and minimum versions for uptime proofs 2021-04-22 14:01:56 +10:00
Sean Darcy 411af23b4b Creates a new ons pay_type for show_transfers
The displaying of ONS transactions in show_transfers and
export_transfers previously showed the dummy destination address which
contained zero bytes and converted to a nonsense address. Created a new
ONS type for the display functions and removed the displaying of the destination
address.

In addition refactored how we determine that a transaction was either a
staking, ons or output transaction as we were previously parsing the
tx_extra where the data was already in the
cryptonote::transaction::type.

Finally renamed the wording for staking rewards. Previously "miner" now
"reward"
2021-04-21 15:37:55 +10:00
Sean Darcy 435c187ca0 initialise version and pretty print if no version 2021-04-20 16:22:00 +10:00
Jason Rhinelander dfb3f29bfe Add warning if restoring an ed25519 key to a file name .../key
A couple people have messaged me now because they tried transferring
keys and used the `restore` command on their legacy `key` file, but it
restored an ed25519 key.

This adds a red warning if attempting to restore an ed key to a filename
ending in `/key` with a note about probably wanting the restore-legacy
command instead.
2021-04-20 00:27:48 -03:00
Sean 89f1850355
Merge pull request #1441 from jagerman/testnet-fee-sync-fix
Fixes testnet sync problem caused by retroactivitly dropping the ONS fees
2021-04-20 13:26:57 +10:00
Sean Darcy f151386cbe Serialise extra fields for participation checks 2021-04-20 13:21:22 +10:00
Jason Rhinelander ec5f548db5 Add hack to fix testnet sync
PR #1433 getting merged changed the fees within HF18 on testnet, which
broke syncing/ONS rescanning because the per-merged testnet has higher
fee ONS txes on it.

This adds a hack to allow wrong fees for blocks before yesterday.
2021-04-20 00:20:21 -03:00
Jason Rhinelander fd7c35801f Increase various potentially fatal error log levels
MERROR doesn't come through at default low-logging level so promote them
to MFATAL so it's more obvious where things are failing when they fail.
2021-04-20 00:16:20 -03:00
Sean 2047edcd79
Merge pull request #1439 from jagerman/macos-time-fix
macOS build fix
2021-04-19 15:48:15 +10:00
Sean cdcf7f251b
Merge pull request #1438 from jagerman/swarmid-fix
Swarm id fix
2021-04-19 15:48:06 +10:00
Jason Rhinelander 8e39c84e70 Add a virtual destructor to http_server_base
Clang warns about http_server having a non-virtual destructor; we aren't
actually doing anything that would cause problems, but the warning is
legit and a correct thing to fix.
2021-04-19 01:22:50 -03:00
Jason Rhinelander d205bc4400 Fix time_t conversion on macos
macOS's system_clock apparently only has microsecond resolution while
steady_clock has nanosecond, so the conversion here was failing (because
time_point conversions are only implicit when converting to a more
precise type).
2021-04-19 01:18:14 -03:00
Jason Rhinelander 2c96fa0f6c Don't sort an already-sorted vector
The swarm_ids are std::map keys, which means they are already sorted.

Put an assert in just to be paranoid.
2021-04-19 00:14:47 -03:00
Jason Rhinelander 1fb10d8b1d Fix get_new_swarm_id() returning MAX_ID/2 when single swarm
The important part here is removing this line:

    if (swarm_to_snodes.size() == 1) return MAX_ID / 2;

because, if we end up in a case where we have only one swarm and it
*already* has that ID (e.g. create 2, which will be [MAX/2,0] then drop
0) then this returns a swarm_id that already exists, which is bad
because then we fail to insert the new swarm, a service node gets left
with an unassigned swarm id, and that then causes issues in SS because
that node thinks it is deactivated because it doesn't have a swarm id
(yet it *is* in the active nodes list, so other network members still
try to talk to it).
2021-04-18 23:47:22 -03:00
Jason Rhinelander 7ecef1529d print_sn display tweaks
- decrease indent
- show lokinet address
2021-04-18 22:20:10 -03:00
Jason Rhinelander 33bcf7e70c Add missing lokinet/ss versions to RPC 2021-04-18 22:20:10 -03:00
Jason Rhinelander bdebfda9f8 Re-do how SS ping tests are handled
This moves all the responsibility of ping testing (deciding when it's
unreachable, etc.) into oxend, allowing for better reporting on SS ping
results and eliminating some edge cases that can lead to oxend and
storage server getting "stuck" thinking each is in a different state.
2021-04-18 22:20:10 -03:00
Jason Rhinelander 3b4c8f4a5d Make get_human_time_ago use `seconds` rather than ints 2021-04-18 22:20:10 -03:00
Jason Rhinelander eda03d1590
Merge pull request #1432 from jagerman/ss-updates
Storage server RPC updates
2021-04-18 22:19:13 -03:00
Sean Darcy 137ba14ea3 reduce ONS fee 2021-04-19 09:45:18 +10:00
Sean Darcy 5041dd7726 reduce fees 2021-04-19 09:45:10 +10:00
Sean Darcy 440c4ca7c4 initialise mapping_value 2021-04-16 13:40:35 +10:00
Sean 53602f5a45
Merge pull request #1434 from darcys22/misc-fixes
Misc fixes
2021-04-15 16:47:47 +10:00
Sean Darcy cb8a7d4a43 Use fs::exists from common tools 2021-04-15 15:47:45 +10:00
Sean Darcy d05f514c1f Wrong constant name 2021-04-15 14:23:36 +10:00
Sean 7b882ac5ae
Merge pull request #1386 from darcys22/api-list-stakes
Api for staked amount on pending transactions
2021-04-15 11:21:00 +10:00
Jason Rhinelander 9e9830da0e Remove limit on burned fee
The reason behind the limit is that the burn amount was supposed to be
encoded using varint encoding and therefore the limit was to make sure
that once we figured out the final burn amount and put it in, we were
guaranteed not to be making the TX extra any bigger (just in case that
could end up making the overall tx get a couple bytes bigger and break
the tx size limit).

However, it never actually *used* varint encoding: instead it is encoded
as a raw, full size uint64_t value of 8 bytes regardless of the value,
so this check is not actually doing anything.  (And if we changed it
to a varint we'd break the protocol, so just leave it).

It also turns out that this comment was wrong:

    This value (~4398 OXEN) was chosen because it's unlikely to ever be
    needed to be burned in a single transaction

Also I hear that some users really do need more than 640kB RAM. ;-)
2021-04-15 10:58:03 +10:00
Jason Rhinelander 563a4984e4 Make extra burn apply to any tx type, not just blink/ONS 2021-04-15 10:58:03 +10:00
Jason Rhinelander 56088ba274 Switch burn= parsing to use parse_amount 2021-04-15 10:58:03 +10:00
Sean Darcy 71ab07f032 merge conflicts 2021-04-15 10:58:03 +10:00
Sean b4c483b9bf
Merge pull request #1403 from darcys22/1402-ons-names-for-transfers
Support for ONS wallet mappings
2021-04-15 10:49:51 +10:00
Sean Darcy 3993e6594c rename ons_owners_by_names merge wallet and session name check 2021-04-14 17:25:53 +10:00
Sean 4dd3825e66
Update src/cryptonote_core/oxen_name_system.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2021-04-14 16:28:55 +10:00
Sean 1c730d9084
simplify encrypted wallet length check
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2021-04-14 16:28:30 +10:00
Sean Darcy 961e14f50b refactor wallet decrypting 2021-04-14 16:27:23 +10:00
Sean Darcy 3f38d00796 Remove magic numbers and enforce nettype for is_valid_address 2021-04-14 15:12:29 +10:00
Sean 4e147ea863
Update src/cryptonote_core/oxen_name_system.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2021-04-14 14:12:36 +10:00
Sean Darcy ffa94f306a to readable value shows wallet address 2021-04-14 12:00:32 +10:00
Sean Darcy 3765e4e91f ONS purchase guesses wallet if the value is address 2021-04-12 15:10:24 +10:00