How to sign rawtransaction with private key

0

0

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

0200000001fcd54594bba82795afa84ebf500b3944546117c9371e951fc4539e7455ebafb20000000000ffffffff01b8f902000000000017a914b4e6b1471691d9e9e54cd19d39c8565bcadeb3338700000000

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.

paul You

Posted 2019-02-27T15:25:36.053

Reputation: 3

Answers

1

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

If the wallet is synced using signrawtransactionwithwallet

If want to input the private key or the wallet is not synced and knowing the private key: Using 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"; broadcast the transaction online like here https://live.blockcypher.com/btc/pushtx/

Sam

Posted 2019-02-27T15:25:36.053

Reputation: 26

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 2019-02-28T15:03:47.250