mirror of
https://github.com/monero-project/monero.git
synced 2025-08-08 11:02:29 -04:00
wallet: feature: transfer amount with fee included
To transfer ~5 XMR to an address such that your balance drops by exactly 5 XMR, provide a `subtractfeefrom` flag to the `transfer` command. For example: transfer 76bDHojqFYiFCCYYtzTveJ8oFtmpNp3X1TgV2oKP7rHmZyFK1RvyE4r8vsJzf7SyNohMnbKT9wbcD3XUTgsZLX8LU5JBCfm 5 subtractfeefrom=all If my walet balance was exactly 30 XMR before this transaction, it will be exactly 25 XMR afterwards and the destination address will receive slightly less than 5 XMR. You can manually select which destinations fund the transaction fee and which ones do not by providing the destination index. For example: transfer 75sr8AAr... 3 74M7W4eg... 4 7AbWqDZ6... 5 subtractfeefrom=0,2 This will drop your balance by exactly 12 XMR including fees and will spread the fee cost proportionally (3:5 ratio) over destinations with addresses `75sr8AAr...` and `7AbWqDZ6...`, respectively. Disclaimer: This feature was paid for by @LocalMonero.
This commit is contained in:
parent
059028a30a
commit
b13c5f6669
10 changed files with 405 additions and 43 deletions
|
@ -47,7 +47,7 @@
|
|||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define WALLET_RPC_VERSION_MAJOR 1
|
||||
#define WALLET_RPC_VERSION_MINOR 26
|
||||
#define WALLET_RPC_VERSION_MINOR 27
|
||||
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
|
||||
namespace tools
|
||||
|
@ -530,11 +530,23 @@ namespace wallet_rpc
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct amounts_list
|
||||
{
|
||||
std::list<uint64_t> amounts;
|
||||
|
||||
bool operator==(const amounts_list& other) const { return amounts == other.amounts; }
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(amounts)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct single_transfer_response
|
||||
{
|
||||
std::string tx_hash;
|
||||
std::string tx_key;
|
||||
uint64_t amount;
|
||||
amounts_list amounts_by_dest;
|
||||
uint64_t fee;
|
||||
uint64_t weight;
|
||||
std::string tx_blob;
|
||||
|
@ -547,6 +559,7 @@ namespace wallet_rpc
|
|||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_key)
|
||||
KV_SERIALIZE(amount)
|
||||
KV_SERIALIZE_OPT(amounts_by_dest, decltype(amounts_by_dest)())
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(weight)
|
||||
KV_SERIALIZE(tx_blob)
|
||||
|
@ -564,6 +577,7 @@ namespace wallet_rpc
|
|||
std::list<transfer_destination> destinations;
|
||||
uint32_t account_index;
|
||||
std::set<uint32_t> subaddr_indices;
|
||||
std::set<uint32_t> subtract_fee_from_outputs;
|
||||
uint32_t priority;
|
||||
uint64_t ring_size;
|
||||
uint64_t unlock_time;
|
||||
|
@ -577,6 +591,7 @@ namespace wallet_rpc
|
|||
KV_SERIALIZE(destinations)
|
||||
KV_SERIALIZE(account_index)
|
||||
KV_SERIALIZE(subaddr_indices)
|
||||
KV_SERIALIZE_OPT(subtract_fee_from_outputs, decltype(subtract_fee_from_outputs)())
|
||||
KV_SERIALIZE(priority)
|
||||
KV_SERIALIZE_OPT(ring_size, (uint64_t)0)
|
||||
KV_SERIALIZE(unlock_time)
|
||||
|
@ -598,6 +613,7 @@ namespace wallet_rpc
|
|||
std::list<std::string> tx_hash_list;
|
||||
std::list<std::string> tx_key_list;
|
||||
std::list<uint64_t> amount_list;
|
||||
std::list<amounts_list> amounts_by_dest_list;
|
||||
std::list<uint64_t> fee_list;
|
||||
std::list<uint64_t> weight_list;
|
||||
std::list<std::string> tx_blob_list;
|
||||
|
@ -610,6 +626,7 @@ namespace wallet_rpc
|
|||
KV_SERIALIZE(tx_hash_list)
|
||||
KV_SERIALIZE(tx_key_list)
|
||||
KV_SERIALIZE(amount_list)
|
||||
KV_SERIALIZE_OPT(amounts_by_dest_list, decltype(amounts_by_dest_list)())
|
||||
KV_SERIALIZE(fee_list)
|
||||
KV_SERIALIZE(weight_list)
|
||||
KV_SERIALIZE(tx_blob_list)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue