wallet_rpc_server: optionally return tx blobs on transfer calls
also add do_not_relay flag to them, so it now becomes possible to create a tx without sending it yet
This commit is contained in:
parent
5eb79983be
commit
dc0b312f8a
@ -454,6 +454,7 @@ namespace tools
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hash
|
||||
@ -463,6 +464,13 @@ namespace tools
|
||||
res.tx_key = epee::string_tools::pod_to_hex(ptx_vector.back().tx_key);
|
||||
}
|
||||
res.fee = ptx_vector.back().fee;
|
||||
|
||||
if (req.get_tx_hex)
|
||||
{
|
||||
cryptonote::blobdata blob;
|
||||
tx_to_blob(ptx_vector.back().tx, blob);
|
||||
res.tx_blob = epee::string_tools::buff_to_hex_nodelimer(blob);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (const tools::error::daemon_busy& e)
|
||||
@ -519,9 +527,12 @@ namespace tools
|
||||
ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, m_trusted_daemon);
|
||||
LOG_PRINT_L2("on_transfer_split called create_transactions_2");
|
||||
|
||||
if (!req.do_not_relay)
|
||||
{
|
||||
LOG_PRINT_L2("on_transfer_split calling commit_tx");
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
LOG_PRINT_L2("on_transfer_split called commit_tx");
|
||||
}
|
||||
|
||||
// populate response with tx hashes
|
||||
for (auto & ptx : ptx_vector)
|
||||
@ -538,6 +549,13 @@ namespace tools
|
||||
res.amount_list.push_back(ptx_amount);
|
||||
|
||||
res.fee_list.push_back(ptx.fee);
|
||||
|
||||
if (req.get_tx_hex)
|
||||
{
|
||||
cryptonote::blobdata blob;
|
||||
tx_to_blob(ptx.tx, blob);
|
||||
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -577,6 +595,7 @@ namespace tools
|
||||
{
|
||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_unmixable_sweep_transactions(m_trusted_daemon);
|
||||
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hashes
|
||||
@ -588,6 +607,12 @@ namespace tools
|
||||
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
|
||||
}
|
||||
res.fee_list.push_back(ptx.fee);
|
||||
if (req.get_tx_hex)
|
||||
{
|
||||
cryptonote::blobdata blob;
|
||||
tx_to_blob(ptx.tx, blob);
|
||||
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -640,6 +665,7 @@ namespace tools
|
||||
{
|
||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, req.mixin, req.unlock_time, req.priority, extra, m_trusted_daemon);
|
||||
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hashes
|
||||
@ -650,7 +676,12 @@ namespace tools
|
||||
{
|
||||
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
|
||||
}
|
||||
res.fee_list.push_back(ptx.fee);
|
||||
if (req.get_tx_hex)
|
||||
{
|
||||
cryptonote::blobdata blob;
|
||||
tx_to_blob(ptx.tx, blob);
|
||||
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -119,6 +119,8 @@ namespace wallet_rpc
|
||||
uint64_t unlock_time;
|
||||
std::string payment_id;
|
||||
bool get_tx_key;
|
||||
bool do_not_relay;
|
||||
bool get_tx_hex;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(destinations)
|
||||
@ -127,6 +129,8 @@ namespace wallet_rpc
|
||||
KV_SERIALIZE(unlock_time)
|
||||
KV_SERIALIZE(payment_id)
|
||||
KV_SERIALIZE(get_tx_key)
|
||||
KV_SERIALIZE_OPT(do_not_relay, false)
|
||||
KV_SERIALIZE_OPT(get_tx_hex, false)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
@ -136,12 +140,14 @@ namespace wallet_rpc
|
||||
std::string tx_key;
|
||||
std::list<std::string> amount_keys;
|
||||
uint64_t fee;
|
||||
std::string tx_blob;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_key)
|
||||
KV_SERIALIZE(amount_keys)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(tx_blob)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
@ -156,6 +162,8 @@ namespace wallet_rpc
|
||||
uint64_t unlock_time;
|
||||
std::string payment_id;
|
||||
bool get_tx_keys;
|
||||
bool do_not_relay;
|
||||
bool get_tx_hex;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(destinations)
|
||||
@ -164,6 +172,8 @@ namespace wallet_rpc
|
||||
KV_SERIALIZE(unlock_time)
|
||||
KV_SERIALIZE(payment_id)
|
||||
KV_SERIALIZE(get_tx_keys)
|
||||
KV_SERIALIZE_OPT(do_not_relay, false)
|
||||
KV_SERIALIZE_OPT(get_tx_hex, false)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
@ -182,12 +192,14 @@ namespace wallet_rpc
|
||||
std::list<std::string> tx_key_list;
|
||||
std::list<uint64_t> amount_list;
|
||||
std::list<uint64_t> fee_list;
|
||||
std::list<std::string> tx_blob_list;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash_list)
|
||||
KV_SERIALIZE(tx_key_list)
|
||||
KV_SERIALIZE(amount_list)
|
||||
KV_SERIALIZE(fee_list)
|
||||
KV_SERIALIZE(tx_blob_list)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
@ -197,9 +209,13 @@ namespace wallet_rpc
|
||||
struct request
|
||||
{
|
||||
bool get_tx_keys;
|
||||
bool do_not_relay;
|
||||
bool get_tx_hex;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(get_tx_keys)
|
||||
KV_SERIALIZE_OPT(do_not_relay, false)
|
||||
KV_SERIALIZE_OPT(get_tx_hex, false)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
@ -217,11 +233,13 @@ namespace wallet_rpc
|
||||
std::list<std::string> tx_hash_list;
|
||||
std::list<std::string> tx_key_list;
|
||||
std::list<uint64_t> fee_list;
|
||||
std::list<std::string> tx_blob_list;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash_list)
|
||||
KV_SERIALIZE(tx_key_list)
|
||||
KV_SERIALIZE(fee_list)
|
||||
KV_SERIALIZE(tx_blob_list)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
@ -237,6 +255,8 @@ namespace wallet_rpc
|
||||
std::string payment_id;
|
||||
bool get_tx_keys;
|
||||
uint64_t below_amount;
|
||||
bool do_not_relay;
|
||||
bool get_tx_hex;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(address)
|
||||
@ -246,6 +266,8 @@ namespace wallet_rpc
|
||||
KV_SERIALIZE(payment_id)
|
||||
KV_SERIALIZE(get_tx_keys)
|
||||
KV_SERIALIZE(below_amount)
|
||||
KV_SERIALIZE_OPT(do_not_relay, false)
|
||||
KV_SERIALIZE_OPT(get_tx_hex, false)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
@ -263,11 +285,13 @@ namespace wallet_rpc
|
||||
std::list<std::string> tx_hash_list;
|
||||
std::list<std::string> tx_key_list;
|
||||
std::list<uint64_t> fee_list;
|
||||
std::list<std::string> tx_blob_list;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash_list)
|
||||
KV_SERIALIZE(tx_key_list)
|
||||
KV_SERIALIZE(fee_list)
|
||||
KV_SERIALIZE(tx_blob_list)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user