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?

2
  • 1
    Note 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.
    Commented Aug 14, 2014 at 17:45
  • Alternate solution: use brainwallet.github.io/#tx so you don't have to rescan the blockchain for transactions, or do raw signing stuff.
    – Tim S.
    Commented Aug 14, 2014 at 17:57

2 Answers 2

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.

1
  • 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
    Commented Aug 14, 2014 at 18:35
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.