Commit graph

499 commits

Author SHA1 Message Date
warptangent d045dfa7ce
Fix transfers (without mixins)
Fix Blockchain::get_tx_outputs_gindexs() to return amount output
indices.

Implement BlockchainLMDB::get_tx_amount_output_indices() and call it
from the function instead of BlockchainLMDB::get_tx_output_indices()

Previously, Blockchain::get_tx_outputs_gindexs() was instead returning
global output indices, which are internal to LMDB databases.

Allows bitmonerod RPC /get_o_indexes.bin to return the amount output
indices as expected.

Allows simplewallet refresh to set correct amount output indices for
incoming transfers. simplewallet can now construct and send valid
transactions (currently only without mixins).

This is a fix that doesn't require altering the structure of the
current LMDB databases.

TODO:

This can be done more efficiently by adding another LMDB database
(key-value table).

It's not used during regular transaction validation by bitmonerod. I
think it's currently used only or mainly by simplewallet for just its
own incoming transactions. So the current behavior is not a primary
bottleneck.

Currently, it's using the "output_amounts" database, walking through a
given amount's list of values, comparing each one to a given global
output index. The iteration number of the match is the desired result:
the amount output index. This is done for each global output index of
the transaction.

A tx's amount output indices can be stored in various other ways
allowing for faster lookup. Since a tx is only written once, there are
no special future write requirements for its list of indices.
2015-01-09 16:34:12 -08:00
Thomas Winget 429a740562
throw inline functions need to keep exception type
As it is useful for functions calling BlockchainDB functions to know
whether an exception is expected (attempting to get a block that doesn't
    exist and counting it missing if not, to save time checking if it
    does, for example), the inline functions throw{0,1} need to keep the
exception type information.

Slight comment update due to copy/paste failure.
2015-01-09 07:29:05 -05:00
Thomas Winget 14555eefd5
Fixes segfault in Blockchain::handle_alternative_block
This commit should fix the segfault in
Blockchain::handle_alternative_block, and also updates a few comments
that were either incorrect or incomplete.
2015-01-09 05:56:51 -05:00
Riccardo Spagni 24ddfa792e
Merge pull request #206
1b46226 std::atomic_flag has no copy/move constructor, can't have a vector (Thomas Winget)
df53c0a small typo in previous commit (Thomas Winget)
4a53898 DNS seed timeout and fallback (Thomas Winget)
2015-01-08 12:18:00 +02:00
Riccardo Spagni 7de1a2d57a
previous hash added to GBT 2015-01-06 18:37:10 +02:00
Thomas Winget 7374b81b23 Merge pull request #19 from warptangent/fix_tx_output
Obtain tx hash and tx output index from amount and output offset
2015-01-04 19:39:44 -08:00
warptangent c5c100c69b Obtain tx hash and tx output index from amount and output offset
Fixes problem of obtaining incorrect outputs used for tx input.

Reverts to earlier intended behavior that was fixed in previous
commit's split of get_output_tx_and_index into two functions.
2015-01-04 19:39:43 -08:00
moneromooo-monero ad8200a573 db_lmdb: fix global index calculation off by 1
This finally fixes raw tx being accepted by the daemon.
2015-01-04 19:39:43 -08:00
Thomas Winget c50cd95674 Fixes a bug with getting output metadata from BlockchainDB
Thanks to moneromooo-monero for spotting the bug.
2015-01-04 19:39:43 -08:00
moneromooo-monero 57b80c541e db_lmdb: remove redundant checks 2015-01-04 19:39:43 -08:00
Thomas Winget c3fa07b44b update comments to reflect changed code 2015-01-04 19:39:43 -08:00
moneromooo-monero 1362846dd7 blockchain_converter: add --testnet for converting testnet blockchain 2015-01-04 19:39:43 -08:00
moneromooo-monero 59d2b0ed1c db_lmdb: do not give the group database write permissions 2015-01-04 19:39:43 -08:00
moneromooo-monero 4c2a45288a db_lmdb: catch attempt to remove block from an empty blockchain
It would probably have thrown when not finding a block at
height 2^64-1, but better make things clear.
2015-01-04 19:39:43 -08:00
moneromooo-monero 3a3459d59b db_lmdb: factor all the log+throw code paths 2015-01-04 19:39:42 -08:00
moneromooo-monero 3fcb8daf6e db_lmdb: factor the MDB_val setup code
It makes the code simpler, avoids possible copy/paste errors
(wrong sizeof, etc), and generally unclutters the calling code.
2015-01-04 19:39:42 -08:00
moneromooo-monero 609cf7fc92 blockchain_converter: a bit more user friendly output 2015-01-04 19:39:42 -08:00
moneromooo-monero 2b9f737872 blockchain_converter: only call data path function once 2015-01-04 19:39:42 -08:00
moneromooo-monero 1860658eec blockchain: do not append "testnet" to the data directory
It is already there (unless overridden via command line).
2015-01-04 19:39:42 -08:00
moneromooo-monero 1c578ad3f8 db_lmdb: remove block timestamp too when removing a block 2015-01-04 19:39:42 -08:00
moneromooo-monero c93a186637 db_lmdb: do not cast const away 2015-01-04 19:39:42 -08:00
moneromooo-monero 198368b2e1 blockchain: fix wallet syncing from scratch
When the wallet syncs from the first block, it is fine to start
at the genesis block.
2015-01-04 19:39:42 -08:00
moneromooo-monero 1d23db220a db_lmdb: do not keep a dangling pointer to stack objects 2015-01-04 19:39:41 -08:00
moneromooo-monero 29b5876ad1 db_lmdb: make cursor internal members private 2015-01-04 19:39:41 -08:00
moneromooo-monero a3157d7b69 blockchain_storage: refactor genesis block creation
The existing assert is kept as it is stricter than the function's
internal assert.
2015-01-04 19:39:41 -08:00
moneromooo-monero 8e41b1e735 blockchain_storage: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 98bdadcad7 blockchain_converter: delete blockchain on succesful exit
While the dtor implementation does not actually do anything, other
paths do delete it, and the dtor might do someting later.
2015-01-04 19:39:41 -08:00
moneromooo-monero 256162fcd5 checkpoints: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero b7270ab60e blockchain: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 23f3cb4c0e blockchain_db: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 10fd6cab6c blockchain_db: factor some exception code
Ideally, the log would go in the exception's ctor, but
two log levels are used, so I'd need to specify the level
in the ctor, which isn't great as it's not really related
to the exception.
2015-01-04 19:39:41 -08:00
moneromooo-monero 11129b9ee4 blockchain_converter: use the actual blockchain location 2015-01-04 19:39:40 -08:00
moneromooo-monero 0886183568 build: add liblmdb to the cmake autodetection system
update for rebase (warptangent 2015-01-04)
  src/cryptonote_core/CMakeLists.txt (edit)
  - replace LMDB_LIBRARIES with LMDB_LIBRARY set from autodetection
2015-01-04 19:39:40 -08:00
Thomas Winget 215e63b79f extraneous semicolon in Blockchain::complete_timestamps_vector
credit here:
https://bitcointalk.org/index.php?topic=583449.msg9562845#msg9562845
2015-01-04 19:39:40 -08:00
Thomas Winget 8e1b7e2ad4 raised maximum mapsize for lmdb to ~16GB 2015-01-04 19:39:40 -08:00
Thomas Winget 6c8b8acfe4 more blockchain height-related fixes, syncing other nodes code this time 2015-01-04 19:39:40 -08:00
Thomas Winget 9455e0cd58 ~ didn't work, need hard path. debug print. 2015-01-04 19:39:40 -08:00
Thomas Winget 4af0918501
very, VERY primitive blockchain converter
hard-coded config folder, hard-coded BlockchainDB subclass.

Needs finessing, but should be testable this way.

update for rebase (warptangent 2015-01-04)
  fix conflicts with upstream CMakeLists.txt files

  src/CMakeLists.txt (edit original commit)
  src/blockchain_converter/CMakeLists.txt (add)
2015-01-04 19:38:56 -08:00
Thomas Winget 26a7db38eb add new checkpointing behavior to Blockchain class 2015-01-04 19:31:20 -08:00
Thomas Winget 006e106ae9 Store output pubkeys separately, bug fixes 2015-01-04 19:31:20 -08:00
Thomas Winget ab7951d99a Minor bugfixes, redundancy removal
Minor bugfixes in block removal

Storing outputs outside their transactions is largely unnecessary, and
thus has been removed.
2015-01-04 19:31:20 -08:00
Thomas Winget 71b18d7166 moar bug fixes, removed debug prints 2015-01-04 19:31:19 -08:00
Thomas Winget 0915913111 BlockchainLMDB seems to be working*!
* - Well, mostly.  Haven't let it sync too far just yet.  Currently
trying to figure out the best way to deal with LMDB/mmap virtual memory
pages.
2015-01-04 19:31:19 -08:00
Thomas Winget 1a546e3222 some bug fixes, but still needs work
There are quite a few debug prints in this commit that will need removed
later, but for posterity (in case someone wants to debug this while I'm
away), I left them in.

Currently errors when syncing on the first block that has a "real"
transaction.  Seems to not be able to validate the ring signature, but I
can't for the life of me figure out what's going wrong.
2015-01-04 19:31:19 -08:00
Thomas Winget 006afe2172 Minor bug fixes and debug prints
Blockchain and BlockchainLMDB classes now have a debug print at the
beginning of each function at log level 2.  These can be removed at any
time, but for now are quite useful.

Blockchain runs, and adds the genesis block just fine, but for some
reason isn't getting new blocks.
2015-01-04 19:31:19 -08:00
Thomas Winget 90f402e258 minor fixes to Blockchain.cpp 2015-01-04 19:31:19 -08:00
Thomas Winget 74a1a89e27
Integrate BlockchainDB into cryptonote_core
Probably needs more looking at -- lot of things were done...in a rushed
sort of way.  That said, it all builds and *should* be at least
testable.

update for rebase (warptangent 2015-01-04)
  fix conflicts with upstream CMakeLists.txt files

  src/CMakeLists.txt (remove edits from original commit)
  tests/CMakeLists.txt (remove edits from original commit)
  src/cryptonote_core/CMakeLists.txt (edit)
  - use blockchain db .cpp and .h files
  - add LMDB_LIBRARIES
2015-01-04 19:29:51 -08:00
Thomas Winget d8c570b588 All LMDB BlockchainDB implemented, not tested
All of the functionality for the LMDB implementation of BlockchainDB is
implemented, but only what is in tests/unit_tests/BlockchainDB.cpp has
been tested.  This is basically add a block, see if you can get the
block and a tx from the block.  More tests should be added at some
point.
2015-01-04 19:01:11 -08:00
Thomas Winget e47e343a1c LMDB blockchain: remove outputs and spent keys 2015-01-04 19:01:10 -08:00
Thomas Winget a0af217d9a Adding block data to LMDB BlockchainDB coded
Still needs testing (and need to write a few more unit tests), but
everything should be there.  Lots of unfortunate duplication,
but...well, I can't see a way around it using LMDB.

A couple of other minor changes in this commit, only slightly relevant.
2015-01-04 19:01:10 -08:00
Thomas Winget db00ce0173 Parts of LMDB impl of BlockchainDB done and working
The rest should just be tedious copypasta and modification.
2015-01-04 19:01:10 -08:00
Thomas Winget b98b96489f Initial commit of lmdb BlockchainDB impl 2015-01-04 18:41:44 -08:00
Thomas Winget bc44bc19f4 Initial commit of BlockchainDB tests, other misc
miscellaneous changes to BlockchainDB/blockchain as well, namely
replacing instances of std::list with std::vector
2015-01-04 18:41:44 -08:00
Thomas Winget 07733f98c0 update new blockchain to build with new changes
Still need to add in the new checkpointing functionality, as well as
touch up a few things, but is okay for now.
2015-01-04 18:41:44 -08:00
Thomas Winget 1ffbeb2d2e stupid past me, fixing typos and shit... 2015-01-04 18:41:44 -08:00
Thomas Winget 67515b8b19 missing typedef 2015-01-04 18:41:43 -08:00
Thomas Winget aba548cbf7 import of BlockchainDB files
tried rebasing, tree-filter, and many other things.  at this point,
the history of these files previous to this can live on
in my bc2 branch, as I'm importing them as-is to here.
2015-01-04 18:41:43 -08:00
Riccardo Spagni f4b69d553a
year updated in license 2015-01-02 18:52:46 +02:00
Thomas Winget 1b462261b8
std::atomic_flag has no copy/move constructor, can't have a vector 2014-12-15 17:43:12 -05:00
Thomas Winget df53c0a595
small typo in previous commit 2014-12-15 17:28:11 -05:00
Thomas Winget 4a53898764
DNS seed timeout and fallback 2014-12-15 17:23:42 -05:00
Riccardo Spagni f4675dc05d
Merge pull request #203
583cf0a Document existing function (warptangent)
95eb944 Repeat prompt for wallet path if invalid (warptangent)
2014-12-13 13:52:30 +02:00
Riccardo Spagni c3ec723882
Merge pull request #202
d7aafd5 wallet2::rewrite update to not require bin file (warptangent)
2014-12-13 13:52:03 +02:00
Riccardo Spagni c1bf8fb94b
Merge pull request #201
9b7e0a0 wallet2::load correctly initialize m_blockchain for wallet loaded without bin file (warptangent)
2014-12-13 13:51:42 +02:00
Riccardo Spagni f5c2a5ec9c
Merge pull request #200
cfc8c55 Add simple_wallet::seed_set_language method (warptangent)
26b87df Add wallet2::verify_password method (warptangent)
2014-12-13 13:51:14 +02:00
Riccardo Spagni d5620851f9 onwards to 0.8.8.7
Signed-off-by: Riccardo Spagni <ric@spagni.net>
2014-12-13 13:45:57 +02:00
warptangent 583cf0ad8a Document existing function 2014-12-11 02:55:44 -08:00
warptangent 95eb944ead
Repeat prompt for wallet path if invalid
simplewallet run without a wallet path argument should prompt again if
an invalid path was entered.

Validity here currently means the string isn't empty.
2014-12-11 02:52:48 -08:00
warptangent d7aafd555a
wallet2::rewrite update to not require bin file
Allow pre-JSON wallet format to load without depending on existing bin
file.

Don't write bin file while inside keys rewrite, so bin file write
behavior here matches that of regular wallet load.
2014-12-10 02:56:54 -08:00
warptangent 9b7e0a06b5
wallet2::load correctly initialize m_blockchain for wallet loaded without bin file
Fix for simplewallet loading a wallet with a keys file but no bin file.

  - this situation previously required a user to restart simplewallet
    before it would refresh its blockchain from the server.
2014-12-10 02:42:15 -08:00
warptangent cfc8c55036
Add simple_wallet::seed_set_language method
Add simple_wallet::set_variable method to provide top-level "set"
command and support "set seed language" command.
2014-12-08 21:57:54 -08:00
warptangent 26b87dfdc2
Add wallet2::verify_password method
Allows wallet password to be verified without changing wallet state.
2014-12-08 21:57:03 -08:00
Riccardo Spagni efad735145
version bump to 0.8.8.6 2014-12-08 22:55:28 +02:00
Riccardo Spagni ebb117c7b6
Merge pull request #196
f9822c4 wallet JSON update for non-deterministic wallet data (warptangent)
4c6230d Checking and handling for deterministic vs non-deterministic wallet (warptangent)
1beedb9 Extract check for deterministic keys to wallet2::is_deterministic() (warptangent)
359ede3 indentation (warptangent)
2290eff replace lines with call to recently added print_seed() (warptangent)
2014-12-08 21:29:28 +02:00
Riccardo Spagni 1925eeffa8
Merge pull request #183
250254c Exception handling while refreshing in rpc wallet (credits to QCN) (Sammy Libre)
2014-12-08 20:03:39 +02:00
warptangent f9822c483e wallet JSON update for non-deterministic wallet data
wallet2::store_keys() and wallet2::load_keys() should only use the JSON
attribute "seed_language" when applicable. That is only for
deterministic wallets.

 - store_keys()  don't add JSON attribute "seed_language" if
   seed_language is empty

 - load_keys()  don't call set_seed_language if JSON attribute
   "seed_language" not present
2014-12-06 03:15:18 -08:00
warptangent 4c6230d6cf Checking and handling for deterministic vs non-deterministic wallet
simple_wallet::seed()

 - Check that wallet is deterministic.

simple_wallet::new_wallet()

 - Prompt for seed language only if it's a non-deterministic wallet,
   along with previous conditions.

simple_wallet::open_wallet()

 - Fixed check for deterministic wallet (flag based on command line
   non-deterministic argument was used before, but it's inapplicable to
   opening an existing wallet).

 - As with deterministic wallet, non-deterministic also included to be
   rewritten to new JSON format file. That's what's done for newly
   generated non-deterministic wallets, so old versions should be
   updated to same format.
2014-12-06 02:24:11 -08:00
warptangent 1beedb9dd4 Extract check for deterministic keys to wallet2::is_deterministic()
It's cleaner for wallet2.cpp and it also allows deterministic check by
simplewallet.cpp.
2014-12-06 02:05:50 -08:00
warptangent 359ede3958 indentation 2014-12-06 01:47:59 -08:00
warptangent 2290eff6d6 replace lines with call to recently added print_seed() 2014-12-06 01:47:05 -08:00
Riccardo Spagni 9f74cc8e19
increased version number for tagged release 2014-12-02 11:42:40 +02:00
Riccardo Spagni a144997c48
fixed CMake version matching 2014-12-02 08:36:01 +02:00
Riccardo Spagni ef2a2b42c9
Merge pull request #186
3300ae5 remove unused display variable (warptangent)
0e0e557 return true on success (warptangent)
2e11eb1 deterministic wallet use of twelve words fixed (warptangent)
21a3c46 ensure that keccak is called on view spend key, not a possibly pre-sc_reduce32 version of it - for deriving view secret key (warptangent)
2014-12-02 07:34:56 +02:00
warptangent 3dd19c4cd4 prompt for seed language and error handling
- "seed" simplewallet command was only displaying seed if wallet was newly generated
2014-12-01 14:36:24 -08:00
warptangent 3300ae5f4e remove unused display variable 2014-12-01 14:08:26 -08:00
warptangent 0e0e55714d return true on success 2014-12-01 13:35:09 -08:00
warptangent 2e11eb1504 deterministic wallet use of twelve words fixed 2014-12-01 13:35:09 -08:00
warptangent 21a3c46a1b ensure that keccak is called on view spend key, not a possibly pre-sc_reduce32 version of it
- for deriving view secret key
2014-12-01 13:35:09 -08:00
Riccardo Spagni affde29754
moved rapidjson to external folder, fixed CMake 2014-12-01 21:15:50 +02:00
Riccardo Spagni 4cd15cdde5
Merge pull request #1
f1eaf88 Prints seed after wallet upgrade. Removed iostream include. (Oran Juice)
70971be Doxygen comments (Oran Juice)
031ca23 Rewrites to old wallet file correctly (Oran Juice)
1f833dc Doxygen comments in (Oran Juice)
0bd88ff Writes seed language while generating wallet. Wallet open fix. (Oran Juice)
09a659e Stores seed language in wallet file. added rapidjson. Yet to test backward compatibility (Oran Juice)
2014-12-01 20:15:06 +02:00
Riccardo Spagni 40971b4ee6
Merge pull request #188
dde7897 Disable legacy fees for now (iamsmooth)
cc74b43 Remove DEFAULT_FEE, add temporary acceptance of too-small per-kb fee >= 0.1, denominations based on DEFAULT_DUST_THRESHOLD, document fee arg to create_transactions as unused, se DEFAULT_DUST_THRESHOLD for wallet dust collection instead of calcualted tx fee (iamsmooth)
2014-11-26 22:45:44 +02:00
Riccardo Spagni ab7c6c07e7
Merge pull request #180
ce71c01 cmake: work around a bug with implicit link directories (Ben Boeckel)
de4fc40 mingw: copy required libraries to the build tree (Ben Boeckel)
ec54e2f cmake: place binaries together in the build tree (Ben Boeckel)
18c56ab msys: don't use LTO (Ben Boeckel)
5680c9c msys: factor out -Werror on msys (Ben Boeckel)
4751542 msys: look in msys' directory for files (Ben Boeckel)
d855fe4 miniupnpc: bump the _POSIX_C_SOURCE feature macro (Ben Boeckel)
c696492 unbound: fix getaddrinfo detection for 32-bit windows (Ben Boeckel)
e377687 cmake: Windows and static builds need this (Ben Boeckel)
01895dd cmake: fix up link lines (Ben Boeckel)
4b6515c unbound: fix type checking (Ben Boeckel)
d43a20f unbound: plumb the libdir up (Ben Boeckel)
7d708e4 cmake: support 2.8.7 (Ben Boeckel)
464c280 cmake: fix up miniupnpc's define (Ben Boeckel)
9689df9 cmake: clean up EXTRA_LIBRARIES (Ben Boeckel)
3b7bdcb cmake: set the project name (Ben Boeckel)
0f0efc4 cmake: prepend to CMAKE_MODULE_PATH (Ben Boeckel)
031e3da cmake: remove scream-make (all-caps functions) (Ben Boeckel)
abbd5c0 unbound: import cmake build system (Ben Boeckel)
e59b5b7 miniupnpc: clean up build system (Ben Boeckel)
475fe20 cmake: minor cleanups (indentation and typos) (Ben Boeckel)
799e8b2 cmake: use option() for STATIC (Ben Boeckel)
c24d22b cmake: clean up if auto-dereferencing (Ben Boeckel)
9ed415a build: inform the build of what generates version.h (Ben Boeckel)
eba180a cmake: support git info in released tarballs (Ben Boeckel)
eeffac6 cmake: fix up BOOST_IGNORE_SYSTEM_PATHS (Ben Boeckel)
a43f1a8 cmake: remove configuration variables (Ben Boeckel)
a87ce09 cmake: factor out error messages (Ben Boeckel)
9aa48b6 miniupnpc: clear out else/endfoo command arguments (Ben Boeckel)
8a86ac8 daemon_tests: update cmake code (Ben Boeckel)
fa3ff75 gtest: support an external gtest (Ben Boeckel)
7bfcffa cmake: put each test executable in its own directory (Ben Boeckel)
f53f047 cmake: handle private vs. public headers (Ben Boeckel)
55ca7d3 cmake: refactor common code with libraries (Ben Boeckel)
c773f46 cmake: refactor common code with executables (Ben Boeckel)
89cff7b cmake: put each library into its own directory (Ben Boeckel)
2014-11-25 21:49:00 +02:00
Ben Boeckel ec54e2f82b cmake: place binaries together in the build tree
This allows Windows to copy binaries to one place rather than to each
executable directory.
2014-11-18 17:02:28 -05:00
iamsmooth dde7897fd4 Disable legacy fees for now 2014-11-11 02:03:00 +00:00
iamsmooth cc74b43651 Remove DEFAULT_FEE, add temporary acceptance of too-small per-kb fee >= 0.1, denominations based on DEFAULT_DUST_THRESHOLD, document fee arg to create_transactions as unused, se DEFAULT_DUST_THRESHOLD for wallet dust collection instead of calcualted tx fee 2014-11-09 10:53:29 +00:00
Thomas Winget d2287d3108 per kb fees not passing correct fee to transfer() 2014-11-06 22:09:23 -07:00
Thomas Winget dc67b12ea9 Should now properly do per-kb fee
I'm an idiot.
2014-11-06 22:09:14 -07:00
Thomas Winget 557e27fd21 per kb fees 2014-11-06 22:09:07 -07:00
Sammy Libre 250254c338 Exception handling while refreshing in rpc wallet (credits to QCN) 2014-11-01 11:30:53 +05:00
Ben Boeckel e3776876af cmake: Windows and static builds need this 2014-10-24 15:52:01 -04:00