Commit 02630cd9 authored by Daniel Connolly's avatar Daniel Connolly

correct some functions to send BCH transactions by default

parent 57656681
......@@ -126,7 +126,7 @@ public abstract class NetworkParameters {
private static Block createGenesis(NetworkParameters n) {
Block genesisBlock = new Block(n, Block.BLOCK_VERSION_GENESIS);
Transaction t = new Transaction(n);
Transaction t = new Transaction(n, 1);
try {
// A script containing the difficulty bits and the following message:
//
......
......@@ -200,8 +200,12 @@ public class Transaction extends ChildMessage {
private String memo;
public Transaction(NetworkParameters params) {
this(params, CURRENT_VERSION);
}
public Transaction(NetworkParameters params, int version) {
super(params);
version = 1;
this.version = version;
inputs = new ArrayList<TransactionInput>();
outputs = new ArrayList<TransactionOutput>();
// We don't initialize appearsIn deliberately as it's only useful for transactions stored in the wallet.
......
......@@ -3926,6 +3926,7 @@ public class Wallet extends BaseTaggableObject
* @throws MultipleOpReturnRequested if there is more than one OP_RETURN output for the resultant transaction.
*/
public void completeTx(SendRequest req) throws InsufficientMoneyException {
req.setUseForkId(true); // this library will always send BCH transactions
lock.lock();
try {
checkArgument(!req.completed, "Given SendRequest has already been completed.");
......@@ -4042,6 +4043,7 @@ public class Wallet extends BaseTaggableObject
* transaction will be complete in the end.</p>
*/
public void signTransaction(SendRequest req) {
req.setUseForkId(true);
lock.lock();
try {
Transaction tx = req.tx;
......
......@@ -2817,7 +2817,7 @@ public class WalletTest extends TestWithWallet {
assertEquals(1, request2.tx.getOutputs().size());
assertEquals(CENT, request2.tx.getOutput(0).getValue());
// Make sure it was properly signed
request2.tx.getInput(0).getScriptSig().correctlySpends(request2.tx, 0, tx3.getOutput(0).getScriptPubKey());
request2.tx.getInput(0).getScriptSig().correctlySpends(request2.tx, 0, tx3.getOutput(0).getScriptPubKey(),tx3.getOutput(0).getValue(),Script.ALL_VERIFY_FLAGS);
// However, if there is no connected output, we will grab a COIN output anyway and add the CENT to fee
SendRequest request3 = SendRequest.to(OTHER_ADDRESS, CENT);
......@@ -3243,7 +3243,7 @@ public class WalletTest extends TestWithWallet {
} else if (input.getConnectedOutput().getParentTransaction().equals(t2)) {
assertArrayEquals(expectedSig, input.getScriptSig().getChunks().get(0).data);
} else if (input.getConnectedOutput().getParentTransaction().equals(t3)) {
input.getScriptSig().correctlySpends(req.tx, i, t3.getOutput(0).getScriptPubKey());
input.getScriptSig().correctlySpends(req.tx, i, t3.getOutput(0).getScriptPubKey(),t3.getOutput(0).getValue(),Script.ALL_VERIFY_FLAGS);
}
}
assertTrue(TransactionSignature.isEncodingCanonical(dummySig));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment