bitcoinj-cash / bitcoinj

A library for working with Bitcoin
http://bitcoinj.cash
Apache License 2.0
64 stars 35 forks source link

p2sh address sign #85

Open DevMinJong opened 4 years ago

DevMinJong commented 4 years ago

image Is it possible to make scriptPubkey by using the bitcoincashj if address p(address 3 in bitcoin) is in input, like the picture above? I coded like a code below, progressed a signdRawtransaction and found the error saying "script evaluated without error but finished with a false/empty top stack element". Is there any solution?


in.setScriptSig(script);
Sha256Hash sigHash = tx.hashForSignatureWitness(i, in.getScriptSig(), Coin.valueOf(preValue), Transaction.SigHash.ALL, false);

ECKey.ECDSASignature ecdsaSignature = key.sign(sigHash);
TransactionSignature txSignature = new TransactionSignature(ecdsaSignature, Transaction.SigHash.ALL, false, true);
tx.getInput(i).setScriptSig(ScriptBuilder.createInputScript(txSignature, key));
HashEngineering commented 4 years ago

You should use this library instead for bitcoincashj. Mine hasn't been updated in over 1 year and will likely result in many errors.

https://github.com/pokkst/bitcoincashj