1

I'm programming the back-end for an ecommerce solution, Bitcoind API gives me one way of sending money to a bitcoin address: sendfrom <fromaccount> <tobitcoinaddress> <amount>

If I understood well, this will transfer money from one account to an address, but I don't see any way of sending from address to address. I didn't implemented accounts on my backend system, and don't want to do it as it's an aditional layer of complexity that I don't want to deal with right now.

So, I supose this will grab money from whatever address/addresses asociated to the account and send them to the bitcoin address provided. Any way of doing what I want to do?

1

To find the transaction outputs you can spend

listunspent 0 99999999999 "[\"addressYouWantToSpend\"]"

Then create the tx

createrawtransaction "[{\"txid\":\"txIdToSpend\",\"vout\":n}]" "{\"destinationAddress\":amountToSend, \"changeAddress\":changeAmount}"

Then sign the tx

signrawtransaction <hexStringProvidedBycreaterawtransaction>

Then publish the tx

sendrawtransaction <hexStringProvidedBysignrawtransaction>
  • Wouldn't I know the fees after making the transaction? This won't allow me to check if the account has enough funds for paying the fees of how much he wants to send. – Cornezuelo del Centeno Feb 25 '15 at 15:41
  • fee = utxo value - amountToSend - changeAmount. So you are implicitly deciding the fee when you specify changeAmount. Not after making the transaction but before. – Oscar Guindzberg Feb 25 '15 at 16:06
  • Just to be clear, some other options to create transactions automatically set a reasonable fee. Here you have to choose the fee yourself. – Oscar Guindzberg Feb 25 '15 at 16:12
0

You have a few options here. You can create a raw transaction as discussed in another answer, but this is probably the most difficult and easiest to do wrong (make sure your inputs and outputs match!)

Another option would be to create a one-to-one mapping from addresses to accounts.

You can also play games with the move command moving coins from one account to another and then sending, from that account, but this is complex also.

  • I would love to avoid raw transactions as well. I was thinking about using an account named CASHOUT and with move move the bitcoins from the order address to any of the CASHOUT addresses as soon as I ship the product. Then, I would add paytxfee=<amt> on bitcoin.conf so I'll know in advance how many BTCs I'm going to pay, and counting with those fees when cashing out to an address outside the server, but I'm not sure if that would work... – Cornezuelo del Centeno Feb 25 '15 at 15:38

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.