-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
****
committed
Dec 29, 2021
1 parent
ce9100a
commit 88d00fe
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
core/src/main/java/org/bitcorej/chain/gleec2/GLEEC2NetParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/org/bitcorej/chain/gleec2/GLEEC2StateProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |