12

According to the docs (http://godoc.org/github.com/btcsuite/btcrpcclient) the fee can be set by using

SetTxFee(fee btcutil.Amount) // hard coded0.0006 BTC

I set the fee to 0.0000016 bitcoin/kilobyte and do as follow:

  1. ListUnspent
  2. SetTxFee
  3. CreateRawTransaction
  4. SignRawTransaction
  5. SendRawTransaction

But when i try to send transaction i get

-26: 256: absurdly-high-fee

Is there any other way to set the fee using this library?

Debug.log

ThreadRPCServer method=listunspent
ThreadRPCServer method=settxfee
ThreadRPCServer method=createrawtransaction
ThreadRPCServer method=signrawtransaction    
ThreadRPCServer method=sendrawtransaction

Amounts:

amounts := map[btcutil.Address]btcutil.Amount{
     destAddress: destAmount,
}

UPDATE It seems like it tries to send whole sum of the transaction, not the amount i want it to send.

If transaction in to A is 1 BTC and i want to send 0.3 BTC to another address, how to achieve this when setting amounts?

cfstras
  • 967
  • 5
  • 20
Amidii
  • 329
  • 2
  • 16
  • How are you creating your amount? It could just be that you goofed a conversion somewhere. – Milo Christiansen Aug 13 '17 at 20:26
  • Updated first post with amounts. Fee works fine when using SendFrom() but when using CreateRawTransaction SetTxFee seems not to be working at all. – Amidii Aug 13 '17 at 21:28
  • Looks like that library has been refactored. You may or may not want to update. The new godoc is located here (https://godoc.org/github.com/btcsuite/btcd/rpcclient) and you'll need to `go get` the new lib. – RayfenWindspear Aug 29 '17 at 20:48

1 Answers1

0

settxfee is not for createrawtransaction command.

if you have one input with 1 BTC and you would send 0.9 BTC so remaining amount is the transaction fee.

if you don't want to set transaction fee for 0.1 BTC you could send 0.09 to change address and leave that 0.01 and it's your transaction fee.

Adam
  • 5,153
  • 1
  • 10
  • 22