mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 03:59:33 +00:00
Merge pull request #2201
dc0b312f
wallet_rpc_server: optionally return tx blobs on transfer calls (moneromooo-monero)5eb79983
epee: add a KV_SERIALIZE variant for optional parameters (moneromooo-monero)
This commit is contained in:
commit
5a04301b32
3 changed files with 69 additions and 7 deletions
|
@ -70,6 +70,12 @@ public: \
|
|||
#define KV_SERIALIZE_N(varialble, val_name) \
|
||||
epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name);
|
||||
|
||||
#define KV_SERIALIZE_OPT_N(variable, val_name, default_value) \
|
||||
do { \
|
||||
if (!epee::serialization::selector<is_store>::serialize(this_ref.variable, stg, hparent_section, val_name)) \
|
||||
this_ref.variable = default_value; \
|
||||
} while (0);
|
||||
|
||||
#define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(varialble, val_name) \
|
||||
epee::serialization::selector<is_store>::serialize_t_val_as_blob(this_ref.varialble, stg, hparent_section, val_name);
|
||||
|
||||
|
@ -86,6 +92,7 @@ public: \
|
|||
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_N(varialble, #varialble)
|
||||
#define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(varialble, #varialble) //skip is_pod compile time check
|
||||
#define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble) KV_SERIALIZE_CONTAINER_POD_AS_BLOB_N(varialble, #varialble)
|
||||
#define KV_SERIALIZE_OPT(variable,default_value) KV_SERIALIZE_OPT_N(variable, #variable, default_value)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -454,7 +454,8 @@ namespace tools
|
|||
return false;
|
||||
}
|
||||
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hash
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx_vector.back().tx));
|
||||
|
@ -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");
|
||||
|
||||
LOG_PRINT_L2("on_transfer_split calling commit_tx");
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
LOG_PRINT_L2("on_transfer_split called commit_tx");
|
||||
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,7 +595,8 @@ namespace tools
|
|||
{
|
||||
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_unmixable_sweep_transactions(m_trusted_daemon);
|
||||
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hashes
|
||||
for (auto & ptx : ptx_vector)
|
||||
|
@ -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,7 +665,8 @@ 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);
|
||||
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
if (!req.do_not_relay)
|
||||
m_wallet->commit_tx(ptx_vector);
|
||||
|
||||
// populate response with tx hashes
|
||||
for (auto & ptx : ptx_vector)
|
||||
|
@ -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 a new issue