mirror of
https://github.com/monero-project/monero.git
synced 2025-05-05 01:54:58 -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
|
@ -1852,3 +1852,60 @@ TEST(parsing, unicode)
|
|||
epee::misc_utils::parse::match_string2(si, s.end(), bs);
|
||||
EXPECT_EQ(bs, "あまやかす");
|
||||
}
|
||||
|
||||
TEST(parsing, strtoul)
|
||||
{
|
||||
long ul;
|
||||
const char* p;
|
||||
const char* endp;
|
||||
|
||||
errno = 0; // Some libc's only set errno on failure, some set it to 0 on success
|
||||
|
||||
p = "0";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(0, ul);
|
||||
EXPECT_EQ(p + 1, endp);
|
||||
|
||||
p = "000000";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(0, ul);
|
||||
EXPECT_EQ(p + 6, endp);
|
||||
|
||||
p = "1";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(1, ul);
|
||||
EXPECT_EQ(p + 1, endp);
|
||||
|
||||
p = "0q";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(0, ul);
|
||||
EXPECT_EQ(p + 1, endp);
|
||||
|
||||
p = " \t 0";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(0, ul);
|
||||
EXPECT_EQ(p + 9, endp);
|
||||
|
||||
p = "q";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(0, errno);
|
||||
EXPECT_EQ(0, ul);
|
||||
EXPECT_EQ(p, endp);
|
||||
|
||||
p = "999999999999999999999999999999999999999";
|
||||
endp = nullptr;
|
||||
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
|
||||
EXPECT_EQ(ERANGE, errno);
|
||||
EXPECT_EQ(ULLONG_MAX, ul);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue