Merge pull request #715

8bc1bd6 wallet: use minimum mixin when RPC asks for too low mixin (moneromooo-monero)
31d2e0f wallet_rpc_server: make use_fork_rules public (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2016-03-12 16:14:07 +02:00
commit bb7b31d5ed
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
2 changed files with 15 additions and 4 deletions

View File

@ -348,6 +348,8 @@ namespace tools
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const; bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const;
bool use_fork_rules(uint8_t version);
private: private:
/*! /*!
* \brief Stores wallet information to wallet file. * \brief Stores wallet information to wallet file.
@ -384,7 +386,6 @@ namespace tools
crypto::hash get_payment_id(const pending_tx &ptx) const; crypto::hash get_payment_id(const pending_tx &ptx) const;
void check_acc_out(const cryptonote::account_keys &acc, const cryptonote::tx_out &o, const crypto::public_key &tx_pub_key, size_t i, uint64_t &money_transfered, bool &error) const; void check_acc_out(const cryptonote::account_keys &acc, const cryptonote::tx_out &o, const crypto::public_key &tx_pub_key, size_t i, uint64_t &money_transfered, bool &error) const;
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const; void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
bool use_fork_rules(uint8_t version);
uint64_t get_upper_tranaction_size_limit(); uint64_t get_upper_tranaction_size_limit();
void check_pending_txes(); void check_pending_txes();

View File

@ -227,7 +227,12 @@ namespace tools
try try
{ {
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions(dsts, req.mixin, req.unlock_time, req.fee, extra); uint64_t mixin = req.mixin;
if (mixin < 2 && m_wallet.use_fork_rules(2)) {
LOG_PRINT_L1("Requested mixin " << req.mixin << " too low for hard fork 2, using 2");
mixin = 2;
}
std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions(dsts, mixin, req.unlock_time, req.fee, extra);
// reject proposed transactions if there are more than one. see on_transfer_split below. // reject proposed transactions if there are more than one. see on_transfer_split below.
if (ptx_vector.size() != 1) if (ptx_vector.size() != 1)
@ -287,11 +292,16 @@ namespace tools
try try
{ {
uint64_t mixin = req.mixin;
if (mixin < 2 && m_wallet.use_fork_rules(2)) {
LOG_PRINT_L1("Requested mixin " << req.mixin << " too low for hard fork 2, using 2");
mixin = 2;
}
std::vector<wallet2::pending_tx> ptx_vector; std::vector<wallet2::pending_tx> ptx_vector;
if (req.new_algorithm) if (req.new_algorithm)
ptx_vector = m_wallet.create_transactions_2(dsts, req.mixin, req.unlock_time, req.fee, extra); ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.fee, extra);
else else
ptx_vector = m_wallet.create_transactions(dsts, req.mixin, req.unlock_time, req.fee, extra); ptx_vector = m_wallet.create_transactions(dsts, mixin, req.unlock_time, req.fee, extra);
m_wallet.commit_tx(ptx_vector); m_wallet.commit_tx(ptx_vector);