Compare commits

..

4 Commits

Author SHA1 Message Date
moneroexamples d2d6504dd0 fix mysql_tests
5 years ago
moneroexamples 66047b9dc6 dont require inputs and outputs_id to be unique
5 years ago
moneroexamples 9087478ea3 upgrade xmregcore
5 years ago
moneroexamples 174b934501 Output table and known_outputs_t modified
5 years ago

3
.gitmodules vendored

@ -1,3 +1,4 @@
[submodule "src/xmregcore"]
path = src/xmregcore
url = https://git.wownero.com/asymptotically/xmregcore
url = https://github.com/moneroexamples/xmregcore
branch = release_v13

@ -1,4 +1,4 @@
# Generated by YCM Generator at 2019-11-20 22:37:52.132783
# Generated by YCM Generator at 2019-02-04 16:43:28.957650
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
@ -36,27 +36,28 @@ import ycm_core
flags = [
'-x',
'c++',
'-DBOOST_ALL_NO_LIB',
'-DBOOST_CHRONO_DYN_LINK',
'-DBOOST_DATE_TIME_DYN_LINK',
'-DBOOST_FILESYSTEM_DYN_LINK',
'-DBOOST_PROGRAM_OPTIONS_DYN_LINK',
'-DBOOST_REGEX_DYN_LINK',
'-DBOOST_SERIALIZATION_DYN_LINK',
'-DBOOST_SYSTEM_DYN_LINK',
'-DBOOST_THREAD_DYN_LINK',
'-DASIO_STANDALONE=YES',
'-DBUILD_SSL=TRUE',
'-I/home/mwo2/monero/build',
'-I/home/mwo2/monero/contrib/epee/include',
'-I/home/mwo2/monero/external',
'-I/home/mwo2/monero/external/db_drivers/liblmdb',
'-I/home/mwo2/monero/external/easylogging++',
'-I/home/mwo2/monero/src',
'-I/home/mwo2/openmonero/ext/restbed/source',
'-I/home/mwo2/openmonero/src/xmregcore',
'-I/tmp/tmpaV0i5C/distribution/include',
'-I/tmp/tmpaV0i5C/gen',
'-I/usr/include/mysql',
'-I/usr/include/mysql++',
'-I/usr/local/include',
'-I/usr/local/include/mysql',
'-I/usr/local/opt/openssl/include',
'-Wall',
'-Weffc++',
'-Wextra',
'-Wno-unknown-pragmas',
'-std=c++14',
'-std=gnu++14',
'-isystem', '/home/mwo2/monero/build',
'-isystem', '/home/mwo2/monero/contrib/epee/include',
'-isystem', '/home/mwo2/monero/external',
'-isystem', '/home/mwo2/monero/external/db_drivers/liblmdb',
'-isystem', '/home/mwo2/monero/external/easylogging++',
'-isystem', '/home/mwo2/monero/src',
'-isystem', '/home/mwo2/openmonero/ext/restbed/dependency/asio/asio/include',
'-isystem', '/home/mwo2/openmonero/ext/restbed/dependency/kashmir',
]
@ -156,11 +157,3 @@ def FlagsForFile( filename, **kwargs ):
'do_cache': True
}
def Settings( **kwargs ):
language = kwargs[ 'language' ]
if language == 'cfamily':
return {
'flags': flags
}
return {}

@ -29,8 +29,8 @@ to MyMonero. They include:
## Live stagenet version
- [http://139.162.60.17:81](http://139.162.60.17:81) - down for now.
- [http://139.162.60.17:8100](http://139.162.60.17:8100) - MyMonero frontend - down for now.
- [http://139.162.60.17:81](http://139.162.60.17:81)
- [http://139.162.60.17:8100](http://139.162.60.17:8100) - MyMonero frontend
This is OpenMonero running on stagnet network. You can use it to play around with it.
Please note that the live version is running on cheap VPS, which may result in

@ -2,7 +2,7 @@
"daemon-url" :
{
"_comment" : "RPC urls to monero deamon",
"mainnet" : "http://127.0.0.1:34568",
"mainnet" : "http://127.0.0.1:18081",
"testnet" : "http://127.0.0.1:28081",
"stagenet" : "http://127.0.0.1:38081"
},
@ -43,8 +43,8 @@
"mainnet" :
{
"_comment": "these are official monero project donation address and viewkey. change it to yours",
"address" : "Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP",
"viewkey" : "e62e40bfd5ca7e3a7f199602a3c97df511780489e1c1861884b00c28abaea406"
"address" : "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A",
"viewkey" : "f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501"
},
"stagenet" :
{

@ -1,19 +1,19 @@
var config = {
apiUrl: "https://hodl.wowbux.org/api/",
mainnetExplorerUrl: "https://explore.wownero.com/",
apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://139.162.60.17:8082/",
nettype: 0, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 11,
txMinConfirms: 4, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
nettype: 2, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero
coinSymbol: 'WOW',
openAliasPrefix: "wow",
coinName: 'wownero',
coinUriPrefix: 'wownero:',
addressPrefix: 4146,
integratedAddressPrefix: 6810,
subAddressPrefix: 12208,
coinSymbol: 'XMR',
openAliasPrefix: "xmr",
coinName: 'Monero',
coinUriPrefix: 'monero:',
addressPrefix: 18,
integratedAddressPrefix: 19,
subAddressPrefix: 42,
addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63,
@ -23,11 +23,11 @@ var config = {
feePerKB: new JSBigInt('2000000000'),//20^10 - not used anymore, as fee is dynamic.
dustThreshold: new JSBigInt('1000000000'),//10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold
txChargeRatio: 0.5,
defaultMixin: 20, // minimum mixin for hardfork v8 is 10 (ring size 11)
defaultMixin: 10, // minimum mixin for hardfork v8 is 10 (ring size 11)
txChargeAddress: '',
idleTimeout: 30,
idleWarningDuration: 20,
maxBlockNumber: 500000000,
avgBlockTime: 300,
avgBlockTime: 120,
debugMode: false
};

File diff suppressed because one or more lines are too long

@ -16,6 +16,7 @@ import monero
# openmonero backend url
om_url = "http://127.0.0.1:1984/"
#om_url = "http://139.162.60.17:1984/"
async def make_request(url, payload=""):

@ -35,7 +35,7 @@ USE `openmonero`;
DROP TABLE IF EXISTS `Accounts`;
CREATE TABLE IF NOT EXISTS `Accounts` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`address` varchar(100) NOT NULL,
`address` varchar(95) NOT NULL,
`viewkey_hash` char(64) NOT NULL,
`scanned_block_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
`scanned_block_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -63,7 +63,6 @@ CREATE TABLE IF NOT EXISTS `Inputs` (
`amount` bigint(20) UNSIGNED ZEROFILL NOT NULL DEFAULT '00000000000000000000',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `output_id` (`output_id`,`key_image`),
KEY `account_id2` (`account_id`),
KEY `tx_id2` (`tx_id`),
KEY `output_id2` (`output_id`)
@ -91,7 +90,7 @@ CREATE TABLE IF NOT EXISTS `Outputs` (
`mixin` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `out_pub_key` (`out_pub_key`),
UNIQUE KEY `out_pub_key` (`out_pub_key`, `tx_id`),
KEY `tx_id` (`tx_id`),
KEY `account_id` (`account_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -35,7 +35,7 @@ USE `openmonero_test`;
DROP TABLE IF EXISTS `Accounts`;
CREATE TABLE IF NOT EXISTS `Accounts` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`address` varchar(100) NOT NULL,
`address` varchar(95) NOT NULL,
`viewkey_hash` char(64) NOT NULL,
`scanned_block_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
`scanned_block_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -80,7 +80,6 @@ CREATE TABLE IF NOT EXISTS `Inputs` (
`amount` bigint(20) UNSIGNED ZEROFILL NOT NULL DEFAULT '00000000000000000000',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `output_id` (`output_id`,`key_image`),
KEY `account_id2` (`account_id`),
KEY `tx_id2` (`tx_id`),
KEY `output_id2` (`output_id`)
@ -190,7 +189,7 @@ CREATE TABLE IF NOT EXISTS `Outputs` (
`mixin` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `out_pub_key` (`out_pub_key`),
UNIQUE KEY `out_pub_key` (`out_pub_key`, `tx_id`),
KEY `tx_id` (`tx_id`),
KEY `account_id` (`account_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=140460833003782 DEFAULT CHARSET=utf8;

@ -46,8 +46,7 @@ CurrentBlockchainStatus::monitor_blockchain()
break;
}
//OMVLOG1 << "PoolQueue size: "
OMINFO << "PoolQueue size: "
OMVLOG1 << "PoolQueue size: "
<< TP::DefaultThreadPool::queueSize();
update_current_blockchain_height();
@ -590,51 +589,62 @@ bool
CurrentBlockchainStatus::read_mempool()
{
// get txs in the mempool
mempool_txs_t local_mempool_txs;
std::vector<tx_info> mempool_tx_info;
vector<spent_key_image_info> key_image_infos;
auto future_result = thread_pool->submit(
[this](auto& local_mempool_txs)
[this](auto& mempool_tx_info, auto& key_image_infos)
-> bool
{
std::vector<transaction> txs;
if (!this->mcore->get_mempool_txs(txs))
if (!this->mcore->get_mempool_txs(
mempool_tx_info, key_image_infos))
{
OMERROR << "Getting mempool failed ";
return false;
}
return true;
for (size_t i = 0; i < txs.size(); ++i)
{
// get transaction info of the tx in the mempool
auto const& tx = txs.at(i);
}, std::ref(mempool_tx_info),
std::ref(key_image_infos));
tx_memory_pool::tx_details txd;
if (!future_result.get())
return false;
txpool_tx_meta_t meta;
// not using this info at present
(void) key_image_infos;
if (!this->mcore->get_core().get_txpool_tx_meta(tx.hash, meta))
{
OMERROR << "Failed to find tx in txpool";
return false;
}
std::lock_guard<std::mutex> lck (getting_mempool_txs);
local_mempool_txs.emplace_back(meta.receive_time, tx);
// clear current mempool txs vector
// repopulate it with each execution of read_mempool()
// not very efficient but good enough for now.
mempool_txs.clear();
} // for (size_t i = 0; i < mempool_tx_info.size(); ++i)
// if dont have tx_blob member, construct tx
// from json obtained from the rpc call
return true;
for (size_t i = 0; i < mempool_tx_info.size(); ++i)
{
// get transaction info of the tx in the mempool
tx_info const& _tx_info = mempool_tx_info.at(i);
}, std::ref(local_mempool_txs));
transaction tx;
crypto::hash tx_hash;
crypto::hash tx_prefix_hash;
if (!future_result.get())
return false;
if (!parse_and_validate_tx_from_blob(
_tx_info.tx_blob, tx, tx_hash, tx_prefix_hash))
{
OMERROR << "Cant make tx from _tx_info.tx_blob";
return false;
}
std::lock_guard<std::mutex> lck (getting_mempool_txs);
(void) tx_hash;
(void) tx_prefix_hash;
mempool_txs.emplace_back(_tx_info.receive_time, tx);
mempool_txs = std::move(local_mempool_txs);
} // for (size_t i = 0; i < mempool_tx_info.size(); ++i)
return true;
}
@ -862,7 +872,7 @@ CurrentBlockchainStatus::get_searched_blk_no(const string& address,
bool
CurrentBlockchainStatus::get_known_outputs_keys(
string const& address,
unordered_map<public_key, uint64_t>& known_outputs_keys)
known_outputs_t& known_outputs_keys)
{
std::lock_guard<std::mutex> lck (searching_threads_map_mtx);

@ -50,6 +50,8 @@ public:
// recieved_time, tx
using mempool_txs_t = vector<pair<uint64_t, transaction>>;
//output_pubk, amount
using known_outputs_t = unordered_multimap<public_key, uint64_t>;
// height , timestamp, is_coinbase
using txs_tuple_t
@ -259,8 +261,7 @@ public:
virtual bool
get_known_outputs_keys(string const& address,
unordered_map<public_key,
uint64_t>& known_outputs_keys);
known_outputs_t& known_outputs_keys);
virtual void
clean_search_thread_map();

@ -1452,6 +1452,9 @@ OpenMoneroRequests::import_recent_wallet_request(
XmrAccount updated_acc = acc;
//cout << updated_acc.scanned_block_height
//<< ',' << no_blocks_to_import << '\n';
// make sure scanned_block_height is larger than
// no_blocks_to_import so we dont
// end up with overflowing uint64_t.
@ -1710,19 +1713,9 @@ OpenMoneroRequests::get_tx(
if (current_bc_status->get_xmr_address_viewkey(
xmr_address, address_info, viewkey))
{
auto coreacc = make_account(xmr_address, view_key);
if (!coreacc)
{
// if creation failed, just close the session
session_close(session, j_response, UNPROCESSABLE_ENTITY,
"Cant create coreacc for " + xmr_address);
return;
}
auto identifier = make_identifier(
tx,
make_unique<Output>(coreacc.get()));
auto identifier = make_identifier(tx,
make_unique<Output>(&address_info, &viewkey));
identifier.identify();
@ -1749,7 +1742,6 @@ OpenMoneroRequests::get_tx(
// a placeholder for exciting or new account data
XmrAccount acc;
// select this account if its existing one
if (xmr_accounts->select(xmr_address, acc))
{
@ -1816,7 +1808,7 @@ OpenMoneroRequests::get_tx(
// we have to redo this info from basically from scrach.
unordered_map<public_key, uint64_t> known_outputs_keys;
CurrentBlockchainStatus::known_outputs_t known_outputs_keys;
if (current_bc_status->get_known_outputs_keys(
xmr_address, known_outputs_keys))
@ -1830,7 +1822,7 @@ OpenMoneroRequests::get_tx(
// and inputs in a given tx.
auto identifier = make_identifier(tx,
make_unique<Input>(coreacc.get(),
make_unique<Input>(&address_info, &viewkey,
&known_outputs_keys,
&mcore_addapter));
identifier.identify();
@ -2170,8 +2162,7 @@ OpenMoneroRequests::create_account(
// in a moment we will try to get last block timestamp
// to replace this value. But if it fails, we just use current
// timestamp
uint64_t current_blockchain_timestamp
= std::time(nullptr);
uint64_t current_blockchain_timestamp = std::time(nullptr);
// get last block so we have its timestamp when
// createing the account
@ -2179,14 +2170,14 @@ OpenMoneroRequests::create_account(
if (current_bc_status->get_block(current_blockchain_height, last_blk))
{
if (last_blk.timestamp != 0)
current_blockchain_timestamp = last_blk.timestamp;
current_blockchain_timestamp = last_blk.timestamp;
}
DateTime blk_timestamp_mysql_format
= XmrTransaction::timestamp_to_DateTime(
current_blockchain_timestamp);
//@todo setting up start_height and scanned_block_height
//needs to be revisited as they are needed for importing
//wallets. The simples way is when import is free and this

@ -396,9 +396,8 @@ for (auto const& tx_tuple: txs_data)
<< " in tx " << tx_hash_str << " in blk " << blk_height
<< ' ' << outputs_found;
continue;
//throw TxSearchException("insert output_found: "
// "no_rows_inserted is zero!");
throw TxSearchException("insert output_found: "
"no_rows_inserted is zero!");
}
} // if (!found_mine_outputs.empty())
@ -587,9 +586,8 @@ for (auto const& tx_tuple: txs_data)
<< " in tx " << tx_hash_str << " in blk " << blk_height
<< ' ' << inputs_found;
continue;
//throw TxSearchException(
//"insert inputs_found: no_rows_inserted is zero!");
throw TxSearchException(
"insert inputs_found: no_rows_inserted is zero!");
}
} // if (!inputs_found.empty())
@ -723,7 +721,7 @@ TxSearch::populate_known_outputs()
hex_to_pod(out.out_pub_key, out_pub_key);
known_outputs_keys[out_pub_key] = out.amount;
known_outputs_keys.insert({out_pub_key, out.amount});
}
}
}

@ -30,7 +30,7 @@ class TxSearch
public:
// out_pk , amount
using known_outputs_t = std::unordered_map<public_key, uint64_t>;
using known_outputs_t = std::unordered_multimap<public_key, uint64_t>;
using addr_view_t = std::pair<address_parse_info, secret_key>;
using pool_txs_t = std::vector<pair<uint64_t, transaction>>;

@ -27,6 +27,8 @@ public:
virtual string table_name() const = 0;
virtual json to_json() const = 0;
virtual ~Table() = default;
friend std::ostream& operator<< (std::ostream& stream, const Table& data);
};

@ -7,15 +7,10 @@
#define OMWARN CLOG(WARNING, OPENMONERO_LOG_CATEGORY)
#define OMERROR CLOG(ERROR, OPENMONERO_LOG_CATEGORY)
//#define OMVLOG1 CVLOG(1, OPENMONERO_LOG_CATEGORY)
//#define OMVLOG2 CVLOG(2, OPENMONERO_LOG_CATEGORY)
//#define OMVLOG3 CVLOG(3, OPENMONERO_LOG_CATEGORY)
//#define OMVLOG4 CVLOG(4, OPENMONERO_LOG_CATEGORY)
#define OMVLOG1 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG2 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG3 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG4 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG1 CVLOG(1, OPENMONERO_LOG_CATEGORY)
#define OMVLOG2 CVLOG(2, OPENMONERO_LOG_CATEGORY)
#define OMVLOG3 CVLOG(3, OPENMONERO_LOG_CATEGORY)
#define OMVLOG4 CVLOG(4, OPENMONERO_LOG_CATEGORY)
#define OMINFO_IF(cond) CLOG_IF(cond, INFO, OPENMONERO_LOG_CATEGORY)
#define OMWARN_IF(cond) CLOG_IF(cond, WARNING, OPENMONERO_LOG_CATEGORY)

@ -1240,7 +1240,7 @@ blocks_and_txs_from_complete_blocks(
{
transaction tx;
if (!parse_and_validate_tx_from_blob(tx_blob.blob, tx))
if (!parse_and_validate_tx_from_blob(tx_blob, tx))
return false;
txs.push_back(tx);

@ -1 +1 @@
Subproject commit 6e0c9e4b9fa1d2ce1182e61290ff5190608c8b6a
Subproject commit 20c9de37cfa5b199bd36e0a2e12fcb01337ef779

@ -925,10 +925,32 @@ TEST_F(MYSQL_TEST, SelectInputsForOutput)
ASSERT_TRUE(xmr_accounts->select_inputs_for_out(output_id, inputs));
for (auto&& in: inputs)
{
cout << in << 'n';
}
EXPECT_EQ(inputs.size(), 3);
EXPECT_EQ(inputs.front().key_image, "00dd88b3a16b3616d342faec2bc47b24add433407ef79b9a00b55b75d96239a4");
EXPECT_EQ(inputs.back().key_image, "abc529357f90641d501d5108f822617049c19461569eafa45cb5400ee45bef33");
auto it= std::find_if(
inputs.begin(), inputs.end(),
[](auto const& input)
{
return input.key_image
== "00dd88b3a16b3616d342faec2bc47b24add433407ef79b9a00b55b75d96239a4";
});
EXPECT_TRUE(it != inputs.end());
it= std::find_if(
inputs.begin(), inputs.end(),
[](auto const& input)
{
return input.key_image
== "abc529357f90641d501d5108f822617049c19461569eafa45cb5400ee45bef33";
});
EXPECT_TRUE(it != inputs.end());
inputs.clear();
@ -1035,7 +1057,9 @@ TEST_F(MYSQL_TEST, InsertSeverlInputsAtOnce)
TEST_F(MYSQL_TEST, TryToInsertSameInputTwice)
{
// the input table requires a row to be unique for pair
// of key_image + output_id
// of key_image + output_id. UPDATE. This is no longer
// the case as output public keys are not garanteed to
// be unique
ACC_FROM_HEX(owner_addr_5Ajfk);
@ -1048,10 +1072,10 @@ TEST_F(MYSQL_TEST, TryToInsertSameInputTwice)
EXPECT_GT(inserted_id, 0);
// second insert should fail and result in 0
// second insert should also be fine
inserted_id = xmr_accounts->insert(mock_data);
EXPECT_EQ(inserted_id, 0);
EXPECT_GT(inserted_id, 0);
}

@ -1,15 +0,0 @@
[Unit]
Description=Wownero Full Node
After=wownero.service
Wants=wownero.service
[Service]
User=openmonero
Group=openmonero
LogsDirectory=openmonero
Type=simple
ExecStart=/usr/local/bin/openmonero --config-file /etc/openmonero.json \
--log-file /var/log/openmonero/openmonero.log
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save