forked from lthn/blockchain
wallet: self-directed tx with payment id are not allowed anymore (soft rule) to avoid issues with 3rd p services
This commit is contained in:
parent
ea4f75a74f
commit
e66a404d08
2 changed files with 28 additions and 1 deletions
|
|
@ -4348,11 +4348,38 @@ bool wallet2::store_unsigned_tx_to_file_and_reserve_transfers(const finalize_tx_
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::check_and_throw_if_self_directed_tx_with_payment_id_requested(const construct_tx_param& ctp)
|
||||
{
|
||||
// If someone sends coins to his own address, all tx outputs will be detected as own outputs.
|
||||
// It's totally okay unless payment id is used, because it would be impossible to distinguish
|
||||
// between change outs and transfer outs. Thus, such tx with a payment id can't be correctly
|
||||
// obtained via RPC by the given payment id. It could be a problem for an exchange or other
|
||||
// service when a user, identifyied by payment id sends coins to another user on the same
|
||||
// exchange/service. Coins will be received but RPCs like get_payments won't give the transfer.
|
||||
// To avoid such issues we prohibit such txs with a soft rule on sender side.
|
||||
|
||||
for (auto& d : ctp.dsts)
|
||||
{
|
||||
for (auto& addr : d.addr)
|
||||
{
|
||||
if (addr != m_account.get_public_address())
|
||||
return; // at least one destination address is not our address -- it's not self-directed tx
|
||||
}
|
||||
}
|
||||
|
||||
// it's self-directed tx
|
||||
payment_id_t pid;
|
||||
bool has_payment_id = get_payment_id_from_tx(ctp.attachments, pid) && !pid.empty();
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(!has_payment_id, "sending funds to yourself with payment id is not allowed");
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::transfer(const construct_tx_param& ctp,
|
||||
currency::transaction &tx,
|
||||
bool send_to_network,
|
||||
std::string* p_signed_tx_blob_str)
|
||||
{
|
||||
check_and_throw_if_self_directed_tx_with_payment_id_requested(ctp);
|
||||
|
||||
TIME_MEASURE_START(prepare_transaction_time);
|
||||
finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
prepare_transaction(ctp, ftp);
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ private:
|
|||
void check_for_free_space_and_throw_if_it_lacks(const std::wstring& path, uint64_t exact_size_needed_if_known = UINT64_MAX);
|
||||
bool generate_packing_transaction_if_needed(currency::transaction& tx, uint64_t fake_outputs_number);
|
||||
bool store_unsigned_tx_to_file_and_reserve_transfers(const finalize_tx_param& ftp, const std::string& filename, std::string* p_unsigned_tx_blob_str = nullptr);
|
||||
|
||||
void check_and_throw_if_self_directed_tx_with_payment_id_requested(const construct_tx_param& ctp);
|
||||
|
||||
currency::account_base m_account;
|
||||
bool m_watch_only;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue