diff options
Diffstat (limited to 'src/wallet/api/wallet.cpp')
-rw-r--r-- | src/wallet/api/wallet.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index d1c849537..9a9638b40 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -158,8 +158,33 @@ std::string Wallet::genPaymentId() bool Wallet::paymentIdValid(const string &paiment_id) { - crypto::hash8 pid; - return tools::wallet2::parse_short_payment_id(paiment_id, pid); + crypto::hash8 pid8; + if (tools::wallet2::parse_short_payment_id(paiment_id, pid8)) + return true; + crypto::hash pid; + if (tools::wallet2::parse_long_payment_id(paiment_id, pid)) + return true; + return false; +} + +bool Wallet::addressValid(const std::string &str, bool testnet) +{ + bool has_payment_id; + cryptonote::account_public_address address; + crypto::hash8 pid; + return get_account_integrated_address_from_str(address, has_payment_id, pid, testnet, str); +} + +std::string Wallet::paymentIdFromAddress(const std::string &str, bool testnet) +{ + bool has_payment_id; + cryptonote::account_public_address address; + crypto::hash8 pid; + if (!get_account_integrated_address_from_str(address, has_payment_id, pid, testnet, str)) + return ""; + if (!has_payment_id) + return ""; + return epee::string_tools::pod_to_hex(pid); } uint64_t Wallet::maximumAllowedAmount() @@ -360,7 +385,7 @@ std::string WalletImpl::integratedAddress(const std::string &payment_id) const { crypto::hash8 pid; if (!tools::wallet2::parse_short_payment_id(payment_id, pid)) { - pid = crypto::rand<crypto::hash8>(); + return ""; } return m_wallet->get_account().get_public_integrated_address_str(pid, m_wallet->testnet()); } @@ -595,6 +620,15 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const m_status = Status_Error; std::ostringstream writer; + writer << boost::format(tr("not enough money to transfer, available only %s, sent amount %s")) % + print_money(e.available()) % + print_money(e.tx_amount()); + m_errorString = writer.str(); + + } catch (const tools::error::tx_not_possible& e) { + m_status = Status_Error; + std::ostringstream writer; + writer << boost::format(tr("not enough money to transfer, available only %s, transaction amount %s = %s + %s (fee)")) % print_money(e.available()) % print_money(e.tx_amount() + e.fee()) % |