Commit Graph

337 Commits

Author SHA1 Message Date
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
Jason Rhinelander d8662ace7b Add non-blocking isRefreshing(); make height retrieval non-blocking 2021-07-07 18:10:29 -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
Sean Darcy 10057a077f call the staking transferred function if available rather than returning amount 2021-01-19 11:47:36 -04:00
Jason Rhinelander 466a1317d2 Rename lokimq -> oxenmq 2021-01-14 19:35:00 -04:00
Jason Rhinelander 37159b2ba0 Export symbols and strip debug symbols from android static lib
This massively reduces the size.
2021-01-08 18:15:25 -04:00
Sean Darcy ccd712542d executable names changed 2021-01-07 18:40:18 -04:00
Sean Darcy 0912221329 initial loki -> oxen pass 2021-01-07 18:39:01 -04:00
Jason Rhinelander 0dfc63137c
Merge pull request #1376 from jagerman/wallet-api-uint64-stakes
wallet api: Change stake amounts to uint64_t's
2020-12-18 01:47:00 -04:00
Jason Rhinelander bca80dd5a9
Merge pull request #1371 from jagerman/stake-unlock-compilation-fixes
Fix some stake unlock wallet_api code compilation problems
2020-12-18 01:46:42 -04:00
Jason Rhinelander 1b8e80f693 Change stake amounts to uint64_t's
uint32_t's aren't big enough to hold typical stake amounts
2020-12-17 14:29:39 -04:00
Sean Darcy 158c385c86 Clean up stake pending api call
Changed the amount parameter to uint64_t rather than parsing a string
parameter, absorbed the error message into the pending transaction
struct.
2020-12-17 10:31:58 +11:00
Jason Rhinelander 83d07ba55d
Merge pull request #1195 from jagerman/ledger-updates
Ledger updates
2020-12-14 18:26:15 -04:00
Jason Rhinelander fa8ccd4f5d Compilation fixes for windows/mobile 2020-12-14 16:16:19 -04:00
Jason Rhinelander 331b14e8c3 Fix some stake unlock wallet_api code compilation problems
- stake_unlock_result.cpp wasn't actually getting built
- the `ptx()` return value wasn't compiling because there was no way to
convert the low-level pending_tx into a high-level PendingTransaction,
so I added code to make that work.
2020-12-12 13:32:07 -04:00
Sean 07b15542a1
Merge pull request #1356 from darcys22/list-current-stakes
List current stakes
2020-12-08 16:02:57 +11:00
Sean Darcy a19fda0ef2 removed redundant loop on locked stakes 2020-12-08 13:33:26 +11:00
Sean Darcy 682edd86c0 Removed the address_info and subaddress parameters from create_stake_tx 2020-11-21 03:39:36 +00:00
Sean Darcy 657a1cc320 implemented wallet api function 2020-11-21 01:35:32 +00:00
Sean Darcy cdda6fde04 stub for wallet2_api.h method created 2020-11-21 00:40:11 +00:00
Sean Darcy fbf6cab572 return api variables on heap 2020-11-18 10:00:20 +00:00
Sean Darcy 6d0081a955 adjusted implementation of StakeUnlockResult 2020-11-17 10:09:10 +00:00
Sean Darcy a7b60ff282 Add Unstake Methods to the Wallet API
adds both the Unstake methods
    canRequestStakeUnlock(const std::string &sn_key)
    requestStakeUnlock(const std::string &sn_key)

which will be used by the external wallets to interact with service
nodes
2020-11-16 08:20:24 +00:00
Sean Darcy d667324c37 Added new staking commands to wallet api 2020-11-15 12:05:09 +00:00
Jason Rhinelander cd5e49d06e Add tx fee estimate to wallet api
The estimate is crude, based on a 2kB tx size.
2020-11-10 15:46:02 -04:00
Jason Rhinelander f6c4f478f6 Fix long poll thread handling in wallet_api
- The long poll was not cancelled or joined, resulting in a segfault on
  WalletImpl destruction.
- Reduce the 10s timer to 1s, and make it always apply (so that we can't
  end up in a busy loop).
2020-11-04 12:11:20 -04:00
Jason Rhinelander 60d4a3e242 wallet_api: unexpose fs:: in api; remove more deprecations; clean dirt
Using fs:: in wallet2_api is no good as it means dependent code would
have to use it, so instead convert all public paths to be taken as
utf8 string_view's and use fs::u8path(...) in the implementation to
convert them to the fs::path objects we need.

Remove some more deprecated functions (related to being able to import a
password-less wallet).

Modernize error code/string handling to use a pair rather than two
separate parameters methods, and remove the deprecated associated
interfaces.
2020-11-04 12:11:20 -04:00
Jason Rhinelander 78833f9d69 Remove deprecated epee code 2020-10-24 12:46:26 -03:00
Jason Rhinelander 1efe6a0ce9 wallet_api code cleanups
Don't "using namespace std"

Make reference/pointer sigils more consistent.
2020-10-24 12:46:26 -03:00
Jason Rhinelander 63de78d1d0 Rename wallet api namespace Monero:: -> Wallet:: 2020-10-24 12:46:26 -03:00
Jason Rhinelander 1dd98f3dae std::filesystem
Converts all use of boost::filesystem to std::filesystem.

For macos and potentially other exotic systems where std::filesystem
isn't available, we use ghc::filesystem instead (which is a drop-in
replacement for std::filesystem, unlike boost::filesystem).

This also greatly changes how we handle filenames internally by holding
them in filesystem::path objects as soon as possible (using
fs::u8path()), rather than strings, which avoids a ton of issues around
unicode filenames.  As a result this lets us drop the boost::locale
dependency on Windows along with a bunch of messy Windows ifdef code,
and avoids the need for doing gross boost locale codecvt calls.
2020-10-24 12:45:37 -03:00
moneromooo-monero e4b2c3089b Integrate CLSAGs into loki
They are allowed from v16, and MLSAGs are rejected from v16 + 10 blocks.
2020-09-16 20:43:12 -03:00
Jason Rhinelander ef91df6af0 Rename stagenet to devnet 2020-08-17 02:54:43 -03:00
Jason Rhinelander 2083c58d35 wallet_api updates
- updates to use rpc::http_client instead of epee
- simplifies a bunch of json_rpc calls
- removes update checking
- fixes various other random compilation issues
2020-08-07 17:14:03 -03:00
Jason Rhinelander 4f783d3273 De-nest wallet2 structs used externally
This moves the wallet structs that are needed elsewhere (for instance,
in the device drivers) from `tools::wallet2::whatever` to
`wallet::whatever`, allowing them to be included individually via
wallet/whatever.h without needing to include the entire wallet2.h.

What was particularly problematic here is that you couldn't even forward
declare them because they were nested inside the wallet2 class, but
instead had to include the full wallet2.h.
2020-08-07 17:14:02 -03:00
Jason Rhinelander 778cb89620 Post-merge updates: std::optional 2020-07-02 12:52:13 -03:00
Jason Rhinelander 718a9496fb Replace boost chrono & posix_time with stl chrono 2020-07-02 12:52:13 -03:00
Jason Rhinelander 515b96e20b Replace (most) boost::thread with std::thread
This removes some boost thread interruption code, but that code is
highly unlikely to have done anything: you cannot preemptively interrupt
a thread, and pretty much anywhere a thread would get stuck is in I/O,
where boost's (voluntary) thread interruption cannot follow.

It also removes thread attributes because they have really limited
usefulness.  There *was* a reason to introduce them many years ago (when
musl libc ran into a stack limit problem with libunbound) but musl
increased the default stack size long since.
2020-07-02 12:52:13 -03:00
Jason Rhinelander e02545ca4b boost->std: mutex, locks; C++17 lock vars
Changes all boost mutexes, locks, and condition_variables to their stl
equivalents.

Changes all lock_guard/unique_lock/shared_lock to not specify the mutex
type (C++17), e.g.

    std::lock_guard foo{mutex};

instead of

    std::lock_guard<oh::um::what::mutex> foo{mutex};

Also changes some related boost::thread calls to std::thread, and some
related boost chrono calls to stl chrono.

boost::thread isn't changed here to std::thread because some of the
instances rely on some boost thread extensions.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 96354a0e0f boost::optional -> std::optional 2020-07-02 12:52:12 -03:00
Doyle 67727ab6a7 Merge commit 'ac9f7c9' into MergeUpstream3 2020-05-29 13:47:02 +10:00
Doyle abb8dfc48e Merge commit 'c4f75fe' into MergeUpstream3 2020-05-28 15:29:00 +10:00
Doyle 4e8786574e Merge commit '328e9db' into MergeUpstream3 2020-05-28 14:50:12 +10:00
Doyle 296915e4c8 Merge commit 'e23b984' into MergeUpstream3 2020-05-22 12:20:18 +10:00
Doyle 9742c0d91d Merge commit 'dbe31f63e1c96e0f6ad57643ef57454986b5d336' into MergeUpstream3 2020-05-21 16:13:28 +10:00
Doyle 184183f309 Merge branch 'dev' into MergeUpstream2 2020-05-18 12:58:59 +10:00
Jason Rhinelander 0e3f173c7f RPC overhaul
High-level details:

This redesigns the RPC layer to make it much easier to work with,
decouples it from an embedded HTTP server, and gets the vast majority of
the RPC serialization and dispatch code out of a very commonly included
header.

There is unfortunately rather a lot of interconnected code here that
cannot be easily separated out into separate commits.  The full details
of what happens here are as follows:

Major details:
- All of the RPC code is now in a `cryptonote::rpc` namespace; this
  renames quite a bit to be less verbose: e.g. CORE_RPC_STATUS_OK
  becomes `rpc::STATUS_OK`, and `cryptonote::COMMAND_RPC_SOME_LONG_NAME`
  becomes `rpc::SOME_LONG_NAME` (or just SOME_LONG_NAME for code already
  working in the `rpc` namespace).
- `core_rpc_server` is now completely decoupled from providing any
  request protocol: it is now *just* the core RPC call handler.
- The HTTP RPC interface now lives in a new rpc/http_server.h; this code
  handles listening for HTTP requests and dispatching them to
  core_rpc_server, then sending the results back to the caller.
- There is similarly a rpc/lmq_server.h for LMQ RPC code; more details
  on this (and other LMQ specifics) below.
- RPC implementing code now returns the response object and throws when
  things go wrong which simplifies much of the rpc error handling.  They
  can throw anything; generic exceptions get logged and a generic
  "internal error" message gets returned to the caller, but there is
  also an `rpc_error` class to return an error code and message used by
  some json-rpc commands.
- RPC implementing functions now overload `core_rpc_server::invoke`
  following the pattern:

    RPC_BLAH_BLAH::response core_rpc_server::invoke(RPC_BLAH_BLAH::request&& req, rpc_context context);

  This overloading makes the code vastly simpler: all instantiations are
  now done with a small amount of generic instantiation code in a single
  .cpp rather than needing to go to hell and back with a nest of epee
  macros in a core header.
- each RPC endpoint is now defined by the RPC types themselves,
  including its accessible names and permissions, in
  core_rpc_server_commands_defs.h:
  - every RPC structure now has a static `names()` function that returns
    the names by which the end point is accessible.  (The first one is
    the primary, the others are for deprecated aliases).
  - RPC command wrappers define their permissions and type by inheriting
    from special tag classes:
    - rpc::RPC_COMMAND is a basic, admin-only, JSON command, available
      via JSON RPC.  *All* JSON commands are now available via JSON RPC,
      instead of the previous mix of some being at /foo and others at
      /json_rpc.  (Ones that were previously at /foo are still there for
      backwards compatibility; see `rpc::LEGACY` below).
    - rpc::PUBLIC specifies that the command should be available via a
      restricted RPC connection.
    - rpc::BINARY specifies that the command is not JSON, but rather is
      accessible as /name and takes and returns values in the magic epee
      binary "portable storage" (lol) data format.
    - rpc::LEGACY specifies that the command should be available via the
      non-json-rpc interface at `/name` for backwards compatibility (in
      addition to the JSON-RPC interface).
- some epee serialization got unwrapped and de-templatized so that it
  can be moved into a .cpp file with just declarations in the .h.  (This
  makes a *huge* difference for core_rpc_server_commands_defs.h and for
  every compilation unit that includes it which previously had to
  compile all the serialization code and then throw all by one copy away
  at link time).  This required some new macros so as to not break a ton
  of places that will use the old way putting everything in the headers;
  The RPC code uses this as does a few other places; there are comments
  in contrib/epee/include/serialization/keyvalue_serialization.h as to
  how to use it.
- Detemplatized a bunch of epee/storages code.  Most of it should have
  have been using templates at all (because it can only ever be called
  with one type!), and now it isn't.  This broke some things that didn't
  properly compile because of missing headers or (in one case) a messed
  up circular dependency.
- Significantly simplified a bunch of over-templatized serialization
  code.
- All RPC serialization definitions is now out of
  core_rpc_server_commands_defs.h and into a single .cpp file
  (core_rpc_server_commands_defs.cpp).
- core RPC no longer uses the disgusting
  BEGIN_URI_MAP2/MAP_URI_BLAH_BLAH macros.  This was a terrible design
  that forced slamming tons of code into a common header that didn't
  need to be there.
- epee::struct_init is gone.  It was a horrible hack that instiated
  multiple templates just so the coder could be so lazy and write
  `some_type var;` instead of properly value initializing with
  `some_type var{};`.
- Removed a bunch of useless crap from epee.  In particular, forcing
  extra template instantiations all over the place in order to nest
  return objects inside JSON RPC values is no longer needed, as are a
  bunch of stuff related to the above de-macroization of the code.
- get_all_service_nodes, get_service_nodes, and get_n_service_nodes are
  now combined into a single `get_service_nodes` (with deprecated
  aliases for the others), which eliminates a fair amount of
  duplication.  The biggest obstacle here was getting the requested
  fields reference passed through: this is now done by a new ability to
  stash a context in the serialization object that can be retrieved by a
  sub-serialized type.

LMQ-specifics:

- The LokiMQ instance moves into `cryptonote::core` rather than being
  inside cryptonote_protocol.  Currently the instance is used both for
  qnet and rpc calls (and so needs to be in a common place), but I also
  intend future PRs to use the batching code for job processing
  (replacing the current threaded job queue).
- rpc/lmq_server.h handles the actual LMQ-request-to-core-RPC glue.
  Unlike http_server it isn't technically running the whole LMQ stack
  from here, but the parallel name with http_server seemed appropriate.
- All RPC endpoints are supported by LMQ under the same names as defined
  generically, but prefixed with `rpc.` for public commands and `admin.`
  for restricted ones.
- service node keys are now always available, even when not running in
  `--service-node` mode: this is because we want the x25519 key for
  being able to offer CURVE encryption for lmq RPC end-points, and
  because it doesn't hurt to have them available all the time.  In the
  RPC layer this is now called "get_service_keys" (with
  "get_service_node_key" as an alias) since they aren't strictly only
  for service nodes.  This also means code needs to check
  m_service_node, and not m_service_node_keys, to tell if it is running
  as a service node.  (This is also easier to notice because
  m_service_node_keys got renamed to `m_service_keys`).
- Added block and mempool monitoring LMQ RPC endpoints: `sub.block` and
  `sub.mempool` subscribes the connection for new block and new mempool
  TX notifications.  The latter can notify on just blink txes, or all
  new mempool txes (but only new ones -- txes dumped from a block don't
  trigger it).  The client gets pushed a [`notify.block`, `height`,
  `hash`] or [`notify.tx`, `txhash`, `blob`] message when something
  arrives.

Minor details:
- rpc::version_t is now a {major,minor} pair.  Forcing everyone to pack
  and unpack a uint32_t was gross.
- Changed some macros to constexprs (e.g. CORE_RPC_ERROR_CODE_...).
  (This immediately revealed a couple of bugs in the RPC code that was
  assigning CORE_RPC_ERROR_CODE_... to a string, and it worked because
  the macro allows implicit conversion to a char).
- De-templatizing useless templates in epee (i.e. a bunch of templated
  types that were never invoked with different types) revealed a painful
  circular dependency between epee and non-epee code for tor_address and
  i2p_address.  This crap is now handled in a suitably named
  `net/epee_network_address_hack.cpp` hack because it really isn't
  trivial to extricate this mess.
- Removed `epee/include/serialization/serialize_base.h`.  Amazingly the
  code somehow still all works perfectly with this previously vital
  header removed.
- Removed bitrotted, unused epee "crypted_storage" and
  "gzipped_inmemstorage" code.
- Replaced a bunch of epee::misc_utils::auto_scope_leave_caller with
  LOKI_DEFERs.  The epee version involves quite a bit more instantiation
  and is ugly as sin.  Also made the `loki::defer` class invokable for
  some edge cases that need calling before destruction in particular
  conditions.
- Moved the systemd code around; it makes much more sense to do the
  systemd started notification as in daemon.cpp as late as possible
  rather than in core (when we can still have startup failures, e.g. if
  the RPC layer can't start).
- Made the systemd short status string available in the get_info RPC
  (and no longer require building with systemd).
- during startup, print (only) the x25519 when not in SN mode, and
  continue to print all three when in SN mode.
- DRYed out some RPC implementation code (such as set_limit)
- Made wallet_rpc stop using a raw m_wallet pointer
2020-05-11 18:44:45 -03:00
Dusan Klinec e509ede2aa
trezor: adapt to new passphrase mechanism
- choice where to enter passphrase is now made on the host
- use wipeable string in the comm stack
- wipe passphrase memory
- protocol optimizations, prepare for new firmware version
- minor fixes and improvements
- tests fixes, HF12 support
2020-04-27 18:17:56 +02:00
Doyle e7e622e08b Merge commit '459beb5' into MergeUpstream2 2020-04-20 17:25:53 +10:00
Doyle b253994865 Merge commit 'f06c77ab7201605e34b15fa8c409fd4dc49399b4' into MergeUpstream2 2020-04-20 17:13:03 +10:00