Skip to content

Commit

Permalink
upgrade gleec 2
Browse files Browse the repository at this point in the history
  • Loading branch information
**** committed Dec 29, 2021
1 parent ce9100a commit 88d00fe
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/org/bitcorej/chain/ChainStateProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ public class ChainStateProxy implements ChainState, UTXOState, USDTState, XMRSta
GLEECStateProvider gleec = new GLEECStateProvider(Network.MAIN);
services.put("GLEEC", gleec);
services.put("GLEEC_MAIN", gleec);
GLEECStateProvider gleec2 = new GLEECStateProvider(Network.MAIN);
services.put("GLEEC2", gleec2);
services.put("GLEEC2_MAIN", gleec2);
SPRKStateProvider sprk = new SPRKStateProvider(Network.MAIN);
services.put("SPRK", sprk);
services.put("SPRK_MAIN", sprk);
Expand Down
27 changes: 27 additions & 0 deletions core/src/main/java/org/bitcorej/chain/gleec2/GLEEC2NetParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.bitcorej.chain.gleec2;

import org.bitcoinj.params.AbstractBitcoinNetParams;
import org.bitcorej.chain.zcash.ZcashNetParams;

public class GLEEC2NetParams extends AbstractBitcoinNetParams {

public GLEEC2NetParams() {
super();
addressHeader = 0x3c;
p2shHeader = 0x55;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
}

private static GLEEC2NetParams instance;
public static synchronized GLEEC2NetParams get() {
if (instance == null) {
instance = new GLEEC2NetParams();
}
return instance;
}

@Override
public String getPaymentProtocolId() {
return "main";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.bitcorej.chain.gleec2;

import org.bitcoinj.core.Base58;
import org.bitcoinj.script.Script;
import org.bitcoinj.script.ScriptBuilder;
import org.bitcorej.chain.zcash.ZcashStateProvider;
import org.bitcorej.core.Network;
import org.bitcorej.utils.NumericUtil;

import static org.bitcoinj.script.ScriptOpCodes.*;
import static org.bitcoinj.script.ScriptOpCodes.OP_CHECKSIG;

public class GLEEC2StateProvider extends ZcashStateProvider {

public GLEEC2StateProvider(Network network) {
super(network);
super.params = GLEEC2NetParams.get();
super.consensusBranchId = 0x76b809bb;
}

@Override
public String generateP2PKHScript(String address) {
byte[] versionAndDataBytes = Base58.decodeChecked(address);
byte[] bytes = new byte[versionAndDataBytes.length - 1];
System.arraycopy(versionAndDataBytes, 1, bytes, 0, versionAndDataBytes.length - 1);

System.out.println(NumericUtil.bytesToHex(bytes));
Script script = new ScriptBuilder()
.op(OP_DUP)
.op(OP_HASH160)
.data(bytes)
.op(OP_EQUALVERIFY)
.op(OP_CHECKSIG)
.build();
return NumericUtil.bytesToHex(script.getProgram());
}
}

0 comments on commit 88d00fe

Please sign in to comment.