Author

Topic: Spend exactly the coins of a given private address (Read 1433 times)

legendary
Activity: 3472
Merit: 4801
Oh yes thanks.
So I successfully created a raw transaction following this schema:

  • Get a list of not-yet-spent outputs with listunspent
  • Create a transaction using createrawtransaction
  • Apply signatures using signrawtransaction
  • Submit it using sendrawtransaction

I just have a last question to be sure I'm doing things right: here's signrawtransaction doc:
signrawtransaction [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [,...] [sighash="ALL"]

I used signrawtransaction and it worked, I was wondering if I had to specify the private key I want to use since all the inputs in the tx are from the same address?

You should not be testing on the bitcoin network.  That's a good way to lose a lot of money if you don't know what you are doing.

You should test on testnet until you are certain that you fully understand all the implications and consequences of what you are doing.

The parameters inside the square brackets [] are optional parameters.  If the private keys, and the unspent outputs are already known to the wallet, they are unnecessary.

legendary
Activity: 3472
Merit: 4801
What about assigning the address to a brand new account and using the sendfrom function?

"sendfrom" does not send from an address. It sends from an account.  The wallet will choose bitcoins that were received that other addresses, and then update the internal account value.

The only way you are going to control which outputs you spend is to either use a wallet with coin control from the user interface, or to build raw transactions.
legendary
Activity: 3682
Merit: 1580
Bitcoin core has coin control since 0.9.0. See the screens here:

https://bitcoinspakistan.com/blog/whats-new-in-version-0-9-0-of-bitcoin-qt/

Select only the unspent outputs of your imported address and you'll keep things separated.
legendary
Activity: 3472
Merit: 4801
"sendfrom" does not send from an address. It sends from an account.  The wallet will choose bitcoins that were received that other addresses, and then update the internal account value.

The only way you are going to control which outputs you spend is to either use a wallet with coin control from the user interface, or to build raw transactions.
legendary
Activity: 2058
Merit: 1452
use listunspent to get the amount stored at a particular address then use raw transactions api to create a transaction to spend from that particular address
newbie
Activity: 5
Merit: 0
Hi,
Can you help me with understanding what the importprivkey and sendfrom functions does exactly?

I would like to be able to import a private key in the wallet, and then spend the coins (I mean, the same, with no link to my others private keys) using the imported private key. Does importprivkey mix everything or are private keys well separated in bitcoind?
Jump to: