How to sign raw transaction with private key. this is my raw transaction :


which is made by bitcoin-cli createrawtransaction .

That raw transaction made in server.

And I want to sign this raw transaction in my local PC. How do I sign that with private key?

Please let me know with the sample code. My language is java.

Very Thank you.

1 Answer 1


With java? Sign it with the program that created the raw transaction, bitcoin-cli.

With signrawtransactionwithwallet.

Or with signrawtransactionwithkey (0.17.0 RPC)

signrawtransactionwithkey "hexstring" ["privatekey1",...] ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex","amount":value},...]

take txid,vout,scriptPubKey from an online explorer, live.blockcypher.com

redeemScript should be blank.

"raw transaction" "["priv key"]" "[{"txid":"the taxid","vout":the vout integer,"scriptPubKey":"from the explorer","redeemScript":"","amount":the amount}]"

after sign, if want to call sendrawtransaction, if the tx id is not synced will be "Missing Inputs"(in dogecoin-1.10.0 executed) ; or if wallet is offline or if started with -noconnect, then broadcast the transaction online like here https://live.blockcypher.com/btc/pushtx/

More info to deal with a -noconnect and no synced data situation: How to send bitcoin from an offline Bitcoin Core that doesn't have a synced balance?

  • Very Thanks for your answer. This is Good. I had to do this at offline, So I thought I should do it using some programming which I'd have to made. But your way is very good and works.
    – paul You
    Feb 28, 2019 at 15:03

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.