0

I am very new to bitcoinj library. I am using 0.14.7 version of bitcoinj and developing my own application in java. I have created a watch-only wallet by using the tPub of the Offline wallet. Upto Receiving payments on watch-only wallet, it is working fine. Now, i have to spend those coins. For that, I have created a transaction and found its transaction Hash.

To sign that transaction Hash with private key, I have followed How to sign raw transaction given a private key and SHA hash (in java) code. and now I am getting the signed hash. Please guide me that how can I use this signed hash to send and broadcast the transaction.?

Your help will be appreciable. Thanks in advance.

The sample code is given below:

// Through this way, I am finding the Transaction Hash.

SendRequest request = SendRequest.to(Address.fromBase58(params,externalAddress), Coin.parseCoin(amount));
request.signInputs = false;
request.tx.getInputs();
request.missingSigsMode = Wallet.MissingSigsMode.USE_DUMMY_SIG;
String hash = request.tx.getHashAsString();

//now using createSignHash method, which is taking transaction hash and signing that with private key and returning the Signed Hex.
System.out.println("Signed Hash : " + createSignHash(hash)); 

1 Answer 1

1
 sendrawtransaction signedHex

is the rpc you need to call which will submit your raw transaction to local node and network.

1
  • First of all thanks for replying. According to [link] (en.bitcoin.it/wiki/Raw_Transactions), "raw transaction API was introduced with Bitcoin-Qt/bitcoind version 0.7". I am using bitcoinj. How to use sendRawTransaction here? Can you help me to know the process for bitcoinj? or is there any alternative for sendRatTransaction there?
    – FairyRosie
    Commented May 25, 2018 at 6:52

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.