@morcos mentioned in #6898 (comment) that there’s no rpc test for prioritisetransaction
. This adds a simple test to exercise this logic.
In writing this test I discovered something unusual – if you try to set a fee delta using prioritisetransaction
that is negative and greater in magnitude than the transaction’s fee, you get incorrect results. The CFeeRate
constructor that takes a fee and size doesn’t work if you pass in a negative fee. I don’t really understand the details of how conversion and type promotion work in this kind of situation, but as far as I can tell, on my machine, I think the compiler promotes the int64_t nFeePaid
to a uint64_t
(nSize
is a size_t
):
0nSatoshisPerK = nFeePaid*1000/nSize;
Link to the code: https://github.com/bitcoin/bitcoin/blob/c983d6fcb47bafb4b82529f512310ccaef076ca2/src/amount.cpp#L15
I think this arithmetic may work on a 32-bit platform, because it looked to me like doing arithmetic with an unsigned int
rather than a size_t
appeared to work.
Anyway I expect that #6898 will fix prioritisetransaction
to work properly with fee deltas that bring the modified fee below 0, so I just avoided that issue for now in this test; I can update it in the future to include that case after #6898.