Sendtoaddress using custom private key

0

Let's say the user sends me his private key. What is the appropriate RPC command to spend the Bitcoins of this user using his private key?

Should I import his private key in the wallet before?

heyo

Posted 2014-08-14T17:42:40.673

Reputation: 71

1Note that under any normal circumstances, you should never send/receive a private key. It kinda defeats the purpose of having public key cryptography.Tim S. 2014-08-14T17:45:44.437

Alternate solution: use https://brainwallet.github.io/#tx so you don't have to rescan the blockchain for transactions, or do raw signing stuff.

Tim S. 2014-08-14T17:57:48.123

Answers

1

If you're using Bitcoin Core, you must first import the private key using the importprivkey console command. The coins held by that private key will then be added to your existing balance (if any).

If you want to spend those specific coins rather than some others in your wallet, you can use the "coin control" feature. This can be enabled in Settings:Options:Display; when you send coins, you will be offered a list to select which addresses/transactions you want to spend from.

Nate Eldredge

Posted 2014-08-14T17:42:40.673

Reputation: 21 420

Thanks a lot for your answer. Let's say I want to spend those specific coins. Do you know the way to do it with RPC commands?heyo 2014-08-14T18:35:27.530

0

For RPC you can do a raw transaction where you can specify which inputs to use. First listunspent then createrawtransaction, then sign and transmit to the network.

https://en.bitcoin.it/wiki/Raw_Transactions

siliconsys

Posted 2014-08-14T17:42:40.673

Reputation: 96