0

I've been working on my Litecoin wallet for a while now. But I can't seem to control the transaction fee when I make raw transactions.

I know how to send transactions with Litecoin-Qt GUI: https://live.blockcypher.com/ltc/tx/2b2f0aab9d2661840a60b172dcda24f359e85b7dbd0810e7afb2d3a6c0b8e59c/

No problem with that, the fee was 0.00017 LTC and was included in the next block. The vsize of this TX = 170, which explains the 0.00017 LTC fee.

But I'm also working on my own wallet on my VPS with the Litecoin-CLI. I made a raw TX, signed it and sent it. This happened: https://live.blockcypher.com/ltc/tx/32ceefc7f377ad53c91922dffe62e6fd19e48a46d6afb4d610c2c090646404dc/

A transaction fee of 0.1 LTC!!! And the vsize is just 192.

I went back to the litecoin.conf file and it has the paytxfee=0.001 parameter. Which means it would cost me 0.001 LTC/kB. maxtxfee wasn't turned on yet, but now it is with a value of 0.001. When I try to send now, it just prompts me with: "error":{"code":-26,"message":"256: absurdly-high-fee"}.

What am I doing wrong?

(Yes I'm testing my wallet on the mainnet, I'm stupid)

4

The fee of a transaction is just the difference between the input and the output value. In the second transaction you posted, the input value was 0.25 LTC and the output value was 0.15 LTC, so you paid a 0.1 LTC fee (0.25-0.15) as you say. If you choose an input which is larger than the output you want to send as well as the fee, you have to create a change output to send the rest back to your wallet as well, otherwise it will all go to the miners as fees. For example, if your input was 0.25 LTC, and you wanted to send 0.15 LTC and only pay 0.01 LTC fee, your transaction would need to have two outputs, one for 0.15 LTC, and one for 0.09 LTC back to an address you own, so that the total fee is just (0.25-(0.15+0.9) = 0.01)

  • I came across fundrawtransaction which made it really easy. – Lexus123 Jan 10 '18 at 12:05
2

It sounds like you are creating a transaction by hand using the createrawtransaction RPC command. createrawtransaction is not influenced by any of the transaction fee commands or parameters at all. You will need to set the fee manually when you do this by creating change outputs as necessary.

As MeshCollider said, the transaction fee is the difference between the sum of the inputs and sum of the outputs of a transaction. So when you use createrawtransaction, you must ensure that the sum of the outputs you create are not too low or too high.

If you don't want to do this manually, you can use the fundrawtransaction command which will select inputs from your wallet and create change outputs as necessary. fundrawtransaction does handle transaction fees.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.