Skip to content

Commit

Permalink
CZZ: sign with reverse txid
Browse files Browse the repository at this point in the history
  • Loading branch information
pengpengliu committed Dec 24, 2019
1 parent c9631f4 commit 3f41580
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public String getTxId() {
return txId;
}

public void setTxId(String txId) {
this.txId = txId;
}

public int getVout() {
return vout;
}
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/org/bitcorej/chain/czz/CZZStateProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import org.bitcoinj.script.ScriptBuilder;
import org.bitcorej.chain.KeyPair;
import org.bitcorej.chain.bch.BCHStateProvider;
import org.bitcorej.chain.bitcoin.Recipient;
import org.bitcorej.chain.bitcoin.UnspentOutput;
import org.bitcorej.core.Network;
import org.bitcorej.utils.BitUtils;
import org.bitcorej.utils.NumericUtil;

import java.math.BigDecimal;
import java.util.List;

public class CZZStateProvider extends BCHStateProvider {
Expand All @@ -23,6 +27,14 @@ public String generateP2PKHScript(String address) {
return NumericUtil.bytesToHex(ScriptBuilder.createOutputScript(Address.fromBase58(this.params, address)).getProgram());
}

@Override
public String encodeTransaction(List<UnspentOutput> utxos, List<Recipient> recipients, String changeAddress, BigDecimal fee, BigDecimal decimals) {
for (UnspentOutput output : utxos) {
output.setTxId(NumericUtil.bytesToHex(BitUtils.reverseBytes(NumericUtil.hexToBytes(output.getTxId()))));
}
return super.encodeTransaction(utxos, recipients, changeAddress, fee, decimals);
}

@Override
public String selectPrivateKeys(Script script, List<String> keys) {
for (int i = 0; i < keys.size(); i++) {
Expand Down

0 comments on commit 3f41580

Please sign in to comment.