mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
wallet2: commit_tx() lightwallet support
This commit is contained in:
parent
43b57804f8
commit
1197cb71e9
@ -3484,8 +3484,24 @@ crypto::hash8 wallet2::get_short_payment_id(const pending_tx &ptx) const
|
||||
void wallet2::commit_tx(pending_tx& ptx)
|
||||
{
|
||||
using namespace cryptonote;
|
||||
crypto::hash txid;
|
||||
|
||||
if(m_light_wallet)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_SUBMIT_RAW_TX::request oreq;
|
||||
cryptonote::COMMAND_RPC_SUBMIT_RAW_TX::response ores;
|
||||
oreq.address = get_account().get_public_address_str(m_testnet);
|
||||
oreq.view_key = string_tools::pod_to_hex(get_account().get_keys().m_view_secret_key);
|
||||
oreq.tx = epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(ptx.tx));
|
||||
m_daemon_rpc_mutex.lock();
|
||||
bool r = epee::net_utils::invoke_http_json("/submit_raw_tx", oreq, ores, m_http_client, rpc_timeout, "POST");
|
||||
m_daemon_rpc_mutex.unlock();
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "submit_raw_tx");
|
||||
// MyMonero and OpenMonero use different status strings
|
||||
THROW_WALLET_EXCEPTION_IF(ores.status != "OK" && ores.status != "success" , error::tx_rejected, ptx.tx, ores.status, ores.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal submit
|
||||
COMMAND_RPC_SEND_RAW_TX::request req;
|
||||
req.tx_as_hex = epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(ptx.tx));
|
||||
req.do_not_relay = false;
|
||||
@ -3496,13 +3512,14 @@ void wallet2::commit_tx(pending_tx& ptx)
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "sendrawtransaction");
|
||||
THROW_WALLET_EXCEPTION_IF(daemon_send_resp.status == CORE_RPC_STATUS_BUSY, error::daemon_busy, "sendrawtransaction");
|
||||
THROW_WALLET_EXCEPTION_IF(daemon_send_resp.status != CORE_RPC_STATUS_OK, error::tx_rejected, ptx.tx, daemon_send_resp.status, daemon_send_resp.reason);
|
||||
|
||||
// sanity checks
|
||||
for (size_t idx: ptx.selected_transfers)
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(idx >= m_transfers.size(), error::wallet_internal_error,
|
||||
"Bad output index in selected transfers: " + boost::lexical_cast<std::string>(idx));
|
||||
}
|
||||
}
|
||||
crypto::hash txid;
|
||||
|
||||
txid = get_transaction_hash(ptx.tx);
|
||||
crypto::hash payment_id = crypto::null_hash;
|
||||
|
Loading…
Reference in New Issue
Block a user