Bitcoin Forum
November 17, 2024, 07:49:59 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Spend exactly the coins of a given private address  (Read 1433 times)
doublemining (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
August 21, 2014, 10:43:16 PM
 #1

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?
grue
Legendary
*
Offline Offline

Activity: 2058
Merit: 1452



View Profile
August 21, 2014, 11:11:46 PM
 #2

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

It is pitch black. You are likely to be eaten by a grue.

Adblock for annoying signature ads | Enhanced Merit UI
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
August 22, 2014, 02:09:49 PM
 #3

"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.
Abdussamad
Legendary
*
Offline Offline

Activity: 3696
Merit: 1580



View Profile
August 22, 2014, 09:44:34 PM
 #4

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.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
August 23, 2014, 11:00:30 PM
 #5

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.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
August 25, 2014, 07:56:33 PM
 #6

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 <hex string> [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [<privatekey1>,...] [sighash="ALL"]

I used signrawtransaction <hex string> 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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!