Skip to content

Commit

Permalink
Bytecoin v.1.0.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Juarez committed Dec 9, 2015
1 parent 00915e6 commit 6d4e1d1
Show file tree
Hide file tree
Showing 82 changed files with 7,344 additions and 1,828 deletions.
5 changes: 5 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Release notes 1.0.9

- New API for Bytecoin RPC Wallet
- Various improvements

Release notes 1.0.8

- Fusion transactions for Bytecoin Wallet
Expand Down
3 changes: 2 additions & 1 deletion include/ITransfersContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class ITransfersContainer : public IStreamSerializable {
virtual size_t transactionsCount() const = 0;
virtual uint64_t balance(uint32_t flags = IncludeDefault) const = 0;
virtual void getOutputs(std::vector<TransactionOutputInformation>& transfers, uint32_t flags = IncludeDefault) const = 0;
virtual bool getTransactionInformation(const Crypto::Hash& transactionHash, TransactionInformation& info, int64_t& txBalance) const = 0;
virtual bool getTransactionInformation(const Crypto::Hash& transactionHash, TransactionInformation& info,
uint64_t* amountIn = nullptr, uint64_t* amountOut = nullptr) const = 0;
virtual std::vector<TransactionOutputInformation> getTransactionOutputs(const Crypto::Hash& transactionHash, uint32_t flags = IncludeDefault) const = 0;
//only type flags are feasible for this function
virtual std::vector<TransactionOutputInformation> getTransactionInputs(const Crypto::Hash& transactionHash, uint32_t flags) const = 0;
Expand Down
11 changes: 11 additions & 0 deletions include/ITransfersSynchronizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class ITransfersSubscription : public IObservable < ITransfersObserver > {
virtual ITransfersContainer& getContainer() = 0;
};

class ITransfersSynchronizerObserver {
public:
virtual void onBlocksAdded(const Crypto::PublicKey& viewPublicKey, const std::vector<Crypto::Hash>& blockHashes) {}
virtual void onBlockchainDetach(const Crypto::PublicKey& viewPublicKey, uint32_t blockIndex) {}
virtual void onTransactionDeleteBegin(const Crypto::PublicKey& viewPublicKey, Crypto::Hash transactionHash) {}
virtual void onTransactionDeleteEnd(const Crypto::PublicKey& viewPublicKey, Crypto::Hash transactionHash) {}
virtual void onTransactionUpdated(const Crypto::PublicKey& viewPublicKey, const Crypto::Hash& transactionHash,
const std::vector<ITransfersContainer*>& containers) {}
};

class ITransfersSynchronizer : public IStreamSerializable {
public:
virtual ~ITransfersSynchronizer() {}
Expand All @@ -71,6 +81,7 @@ class ITransfersSynchronizer : public IStreamSerializable {
virtual void getSubscriptions(std::vector<AccountPublicAddress>& subscriptions) = 0;
// returns nullptr if address is not found
virtual ITransfersSubscription* getSubscription(const AccountPublicAddress& acc) = 0;
virtual std::vector<Crypto::Hash> getViewKeyKnownBlocks(const Crypto::PublicKey& publicViewKey) = 0;
};

}
38 changes: 30 additions & 8 deletions include/IWallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ enum class WalletTransactionState : uint8_t {
SUCCEEDED = 0,
FAILED,
CANCELLED,
CREATED
CREATED,
DELETED
};

enum WalletEventType {
TRANSACTION_CREATED,
TRANSACTION_UPDATED,
BALANCE_UNLOCKED,
SYNC_PROGRESS_UPDATED,
SYNC_COMPLETED
SYNC_COMPLETED,
};

struct WalletTransactionCreatedData {
Expand Down Expand Up @@ -80,7 +81,8 @@ struct WalletTransaction {

enum class WalletTransferType : uint8_t {
USUAL = 0,
DONATION
DONATION,
CHANGE
};

struct WalletOrder {
Expand All @@ -100,13 +102,24 @@ struct DonationSettings {
};

struct TransactionParameters {
std::string sourceAddress;
std::vector<std::string> sourceAddresses;
std::vector<WalletOrder> destinations;
uint64_t fee = 0;
uint64_t mixIn = 0;
std::string extra;
uint64_t unlockTimestamp = 0;
DonationSettings donation;
std::string changeDestination;
};

struct WalletTransactionWithTransfers {
WalletTransaction transaction;
std::vector<WalletTransfer> transfers;
};

struct TransactionsInBlockInfo {
Crypto::Hash blockHash;
std::vector<WalletTransactionWithTransfers> transactions;
};

class IWallet {
Expand All @@ -124,6 +137,7 @@ class IWallet {
virtual size_t getAddressCount() const = 0;
virtual std::string getAddress(size_t index) const = 0;
virtual KeyPair getAddressSpendKey(size_t index) const = 0;
virtual KeyPair getAddressSpendKey(const std::string& address) const = 0;
virtual KeyPair getViewKey() const = 0;
virtual std::string createAddress() = 0;
virtual std::string createAddress(const Crypto::SecretKey& spendSecretKey) = 0;
Expand All @@ -140,12 +154,20 @@ class IWallet {
virtual size_t getTransactionTransferCount(size_t transactionIndex) const = 0;
virtual WalletTransfer getTransactionTransfer(size_t transactionIndex, size_t transferIndex) const = 0;

virtual size_t transfer(const WalletOrder& destination, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::vector<WalletOrder>& destinations, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::string& sourceAddress, const WalletOrder& destination, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual size_t transfer(const std::string& sourceAddress, const std::vector<WalletOrder>& destinations, uint64_t fee, uint64_t mixIn = 0, const std::string& extra = "", uint64_t unlockTimestamp = 0) = 0;
virtual WalletTransactionWithTransfers getTransaction(const Crypto::Hash& transactionHash) const = 0;
virtual std::vector<TransactionsInBlockInfo> getTransactions(const Crypto::Hash& blockHash, size_t count) const = 0;
virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const = 0;
virtual std::vector<Crypto::Hash> getBlockHashes(uint32_t blockIndex, size_t count) const = 0;
virtual uint32_t getBlockCount() const = 0;
virtual std::vector<WalletTransactionWithTransfers> getUnconfirmedTransactions() const = 0;
virtual std::vector<size_t> getDelayedTransactionIds() const = 0;

virtual size_t transfer(const TransactionParameters& sendingTransaction) = 0;

virtual size_t makeTransaction(const TransactionParameters& sendingTransaction) = 0;
virtual void commitTransaction(size_t transactionId) = 0;
virtual void rollbackUncommitedTransaction(size_t transactionId) = 0;

virtual void start() = 0;
virtual void stop() = 0;

Expand Down
6 changes: 5 additions & 1 deletion src/BlockchainExplorer/BlockchainExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,16 @@ bool BlockchainExplorer::PoolUpdateGuard::beginUpdate() {
for (;;) {
switch (state) {
case State::NONE:
return true;
if (m_state.compare_exchange_weak(state, State::UPDATING)) {
return true;
}
break;

case State::UPDATING:
if (m_state.compare_exchange_weak(state, State::UPDATE_REQUIRED)) {
return false;
}
break;

case State::UPDATE_REQUIRED:
return false;
Expand Down
12 changes: 7 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ file(GLOB_RECURSE JsonRpcServer JsonRpcServer/*)

file(GLOB_RECURSE PaymentGate PaymentGate/*)
file(GLOB_RECURSE PaymentGateService PaymentGateService/*)
file(GLOB_RECURSE Miner Miner/*)

source_group("" FILES $${Common} ${ConnectivityTool} ${Crypto} ${CryptoNoteCore} ${CryptoNoteProtocol} ${Daemon} ${JsonRpcServer} ${Http} ${Logging} ${NodeRpcProxy} ${P2p} ${Rpc} ${Serialization} ${SimpleWallet} ${System} ${Transfers} ${Wallet} ${WalletLegacy})

Expand All @@ -54,17 +55,17 @@ add_executable(ConnectivityTool ${ConnectivityTool})
add_executable(Daemon ${Daemon})
add_executable(SimpleWallet ${SimpleWallet})
add_executable(PaymentGateService ${PaymentGateService})
add_executable(Miner ${Miner})

if (MSVC)
target_link_libraries(System ws2_32)
endif ()

target_link_libraries(ConnectivityTool CryptoNoteCore Common Logging Crypto P2P Rpc Http Serialization System ${Boost_LIBRARIES})
target_link_libraries(Daemon CryptoNoteCore P2P Rpc Serialization System Http Logging Common Crypto upnpc-static BlockchainExplorer ${Boost_LIBRARIES})
target_link_libraries(SimpleWallet Wallet NodeRpcProxy Transfers Rpc Http Serialization CryptoNoteCore System Logging Common Crypto ${Boost_LIBRARIES})
target_link_libraries(PaymentGateService PaymentGate JsonRpcServer Wallet NodeRpcProxy Transfers CryptoNoteCore Crypto P2P Rpc Http Serialization System Logging Common InProcessNode upnpc-static BlockchainExplorer ${Boost_LIBRARIES})

if (MSVC)
target_link_libraries(ConnectivityTool ws2_32)
target_link_libraries(SimpleWallet ws2_32)
endif ()
target_link_libraries(Miner CryptoNoteCore Rpc Serialization System Http Logging Common Crypto ${Boost_LIBRARIES})

add_dependencies(Rpc version)

Expand All @@ -78,3 +79,4 @@ set_property(TARGET ConnectivityTool PROPERTY OUTPUT_NAME "connectivity_tool")
set_property(TARGET Daemon PROPERTY OUTPUT_NAME "bytecoind")
set_property(TARGET SimpleWallet PROPERTY OUTPUT_NAME "simplewallet")
set_property(TARGET PaymentGateService PROPERTY OUTPUT_NAME "walletd")
set_property(TARGET Miner PROPERTY OUTPUT_NAME "miner")
26 changes: 26 additions & 0 deletions src/Common/ObserverManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ class ObserverManager {
}
}

template<typename F, typename Arg0, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
void notify(F notification, const Arg0& arg0, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4) {
std::vector<T*> observersCopy;
{
std::unique_lock<std::mutex> lock(m_observersMutex);
observersCopy = m_observers;
}

for (T* observer : observersCopy) {
(observer->*notification)(arg0, arg1, arg2, arg3, arg4);
}
}

template<typename F, typename Arg0, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
void notify(F notification, const Arg0& arg0, const Arg1& arg1, const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) {
std::vector<T*> observersCopy;
{
std::unique_lock<std::mutex> lock(m_observersMutex);
observersCopy = m_observers;
}

for (T* observer : observersCopy) {
(observer->*notification)(arg0, arg1, arg2, arg3, arg4, arg5);
}
}

#else

template<typename F, typename... Args>
Expand Down
37 changes: 37 additions & 0 deletions src/Common/ScopeExit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.

#include "ScopeExit.h"

namespace Tools {

ScopeExit::ScopeExit(std::function<void()>&& handler) :
m_handler(std::move(handler)),
m_cancelled(false) {
}

ScopeExit::~ScopeExit() {
if (!m_cancelled) {
m_handler();
}
}

void ScopeExit::cancel() {
m_cancelled = true;
}

}
41 changes: 41 additions & 0 deletions src/Common/ScopeExit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.

#pragma once

#include <functional>

namespace Tools {

class ScopeExit {
public:
ScopeExit(std::function<void()>&& handler);
~ScopeExit();

ScopeExit(const ScopeExit&) = delete;
ScopeExit(ScopeExit&&) = delete;
ScopeExit& operator=(const ScopeExit&) = delete;
ScopeExit& operator=(ScopeExit&&) = delete;

void cancel();

private:
std::function<void()> m_handler;
bool m_cancelled;
};

}
5 changes: 5 additions & 0 deletions src/Common/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,9 @@ std::string get_nix_version_display_string()
return std::error_code(code, std::system_category());
}

bool directoryExists(const std::string& path) {
boost::system::error_code ec;
return boost::filesystem::is_directory(path, ec);
}

}
1 change: 1 addition & 0 deletions src/Common/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ namespace Tools
std::string get_os_version_string();
bool create_directories_if_necessary(const std::string& path);
std::error_code replace_file(const std::string& replacement_name, const std::string& replaced_name);
bool directoryExists(const std::string& path);
}
3 changes: 2 additions & 1 deletion src/CryptoNoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ const CheckpointData CHECKPOINTS[] = {
{810500, "302b2349f221232820adc3dadafd8a61b035491e33af669c78a687949eb0a381"},
{816000, "32b7fdd4e4d715db81f8f09f4ba5e5c78e8113f2804d61a57378baee479ce745"},
{822000, "a3c9603c6813a0dc0efc40db288c356d1a7f02d1d2e47bee04346e73715f8984"},
{841000, "2cffb6504ee38f708a6256a63585f9382b3b426e64b4504236c70678bd160dce"}
{841000, "2cffb6504ee38f708a6256a63585f9382b3b426e64b4504236c70678bd160dce"},
{890000, "a7132932ea31236ce6b8775cd1380edf90b5e536ee4202c77b69a3d62445fcd2"}
};
} // CryptoNote

Expand Down
1 change: 0 additions & 1 deletion src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ m_currency(currency),
m_tx_pool(tx_pool),
m_current_block_cumul_sz_limit(0),
m_is_in_checkpoint_zone(false),
m_is_blockchain_storing(false),
m_upgradeDetector(currency, m_blocks, BLOCK_MAJOR_VERSION_2, logger),
m_checkpoints(logger) {

Expand Down
2 changes: 0 additions & 2 deletions src/CryptoNoteCore/Blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ namespace CryptoNote {
bool get_out_by_msig_gindex(uint64_t amount, uint64_t gindex, MultisignatureOutput& out);
bool checkTransactionInputs(const Transaction& tx, uint32_t& pmax_used_block_height, Crypto::Hash& max_used_block_id, BlockInfo* tail = 0);
uint64_t getCurrentCumulativeBlocksizeLimit();
bool isStoringBlockchain(){return m_is_blockchain_storing;}
uint64_t blockDifficulty(size_t i);
bool getBlockContainingTransaction(const Crypto::Hash& txId, Crypto::Hash& blockId, uint32_t& blockHeight);
bool getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generatedCoins);
Expand Down Expand Up @@ -248,7 +247,6 @@ namespace CryptoNote {
std::string m_config_folder;
Checkpoints m_checkpoints;
std::atomic<bool> m_is_in_checkpoint_zone;
std::atomic<bool> m_is_blockchain_storing;

typedef SwappedVector<BlockEntry> Blocks;
typedef std::unordered_map<Crypto::Hash, uint32_t> BlockMap;
Expand Down
5 changes: 0 additions & 5 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ bool core::handle_command_line(const boost::program_options::variables_map& vm)
return true;
}

bool core::is_ready() {
return !m_blockchain.isStoringBlockchain();
}


uint32_t core::get_current_blockchain_height() {
return m_blockchain.getCurrentBlockchainHeight();
}
Expand Down
1 change: 0 additions & 1 deletion src/CryptoNoteCore/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ namespace CryptoNote {
std::vector<Crypto::Hash> buildSparseChain() override;
std::vector<Crypto::Hash> buildSparseChain(const Crypto::Hash& startBlockId) override;
void on_synchronized() override;
bool is_ready() override;

virtual void get_blockchain_top(uint32_t& height, Crypto::Hash& top_id) override;
bool get_blocks(uint32_t start_offset, uint32_t count, std::list<Block>& blocks, std::list<Transaction>& txs);
Expand Down
1 change: 1 addition & 0 deletions src/CryptoNoteCore/CoreConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CoreConfig::CoreConfig() {
void CoreConfig::init(const boost::program_options::variables_map& options) {
if (options.count(command_line::arg_data_dir.name) != 0 && (!options[command_line::arg_data_dir.name].defaulted() || configFolder == Tools::getDefaultDataDirectory())) {
configFolder = command_line::get_arg(options, command_line::arg_data_dir);
configFolderDefaulted = options[command_line::arg_data_dir.name].defaulted();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/CryptoNoteCore/CoreConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CoreConfig {
void init(const boost::program_options::variables_map& options);

std::string configFolder;
bool configFolderDefaulted = true;
};

} //namespace CryptoNote
1 change: 0 additions & 1 deletion src/CryptoNoteCore/ICore.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class ICore {
virtual bool handle_incoming_block_blob(const CryptoNote::BinaryArray& block_blob, CryptoNote::block_verification_context& bvc, bool control_miner, bool relay_block) = 0;
virtual bool handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS_request& arg, NOTIFY_RESPONSE_GET_OBJECTS_request& rsp) = 0; //Deprecated. Should be removed with CryptoNoteProtocolHandler.
virtual void on_synchronized() = 0;
virtual bool is_ready() = 0;
virtual size_t addChain(const std::vector<const IBlock*>& chain) = 0;

virtual void get_blockchain_top(uint32_t& height, Crypto::Hash& top_id) = 0;
Expand Down
Loading

0 comments on commit 6d4e1d1

Please sign in to comment.