Skip to content

Commit

Permalink
support usdt-okc20
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangjinyuan committed May 11, 2023
1 parent e22f138 commit 5f5d26d
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ logs/
por_test.csv
por_test_*.csv
userPathJson-*
okx_por_*.csv
*_por_*.csv
*_address_balance.csv
venv/
origin/
6 changes: 3 additions & 3 deletions cmd/checkbalance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func CoinAddressBalanceValidator(cmd *cobra.Command, args []string) {
return
}
// coin black list
if _, exist := common.CheckBalanceCoinBlackList[coin]; exist {
if common.IsCheckBalanceBannedCoin(coin) {
log.Errorf("check balance not support the coin %s, please set the correct one!", coin)
return
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func VerifySingleCoinAllAddressBalance(validator *common.AddressBalanceValidator
func VerifyAllCoinAddressBalance(validator *common.AddressBalanceValidator) {
for _, v := range common.PorCoinDataMap {
// check coin black list
if _, exist := common.CheckBalanceCoinBlackList[v.Coin]; exist {
if common.IsCheckBalanceBannedCoin(coin) {
continue
}
balance, err := validator.GetCoinAddressBalanceInfo(strings.ToLower(v.Coin), v.Address, v.SnapshotHeight)
Expand Down Expand Up @@ -355,7 +355,7 @@ func getDestCoinList(coin string) []string {
for k, v := range common.PorCoinUnitMap {
if v == destCoin {
// check coin black list
if _, exist := common.CheckBalanceCoinBlackList[k]; exist {
if common.IsCheckBalanceBannedCoin(k) {
log.Errorf("check balance not support the coin %s, ignore por total balance: %s", k, porCoinTotalBalance[k].String())
continue
}
Expand Down
15 changes: 12 additions & 3 deletions cmd/verifyaddress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func handle(i int, line string) (string, bool) {
coinTotalBalance[totalCoin] = val
}

if coin == "EOS" || coin == "RIPPLE" {
if common.IsVerifyAddressBannedCoin(coin) {
return coin, true
}

Expand Down Expand Up @@ -146,10 +146,19 @@ func AddressVerify(cmd *cobra.Command, args []string) {
continue
}
coin, ok := handle(count, strings.TrimSpace(temp))
// not stats EOS and RIPPLE
if coin == "EOS" || coin == "RIPPLE" {

if common.IsVerifyAddressBannedCoin(coin) {
continue
}

if _, exist := fail[coin]; !exist {
fail[coin] = 0
}

if _, exist := success[coin]; !exist {
success[coin] = 0
}

if !ok {
fail[coin]++
} else {
Expand Down
37 changes: 37 additions & 0 deletions common/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (

TrxCoinType = "TRX"
BethCoinType = "BETH"
AlgoCoinType = "ALGO"

BtcMessageSignatureHeader = "Bitcoin Signed Message:\n"
LtcMessageSignatureHeader = "Litecoin Signed Message:\n"
Expand Down Expand Up @@ -53,6 +54,7 @@ var (
"USDT-AVAXC": "ETH",
"USDT-ARBITRUM": "ETH",
"USDT-OPTIMISM": "ETH",
"USDT-OKC20": "ETH",
"USDC": "ETH",
"POLY-USDC": "ETH",
"USDC-AVAXC": "ETH",
Expand Down Expand Up @@ -103,6 +105,9 @@ var (
"APTOS": "APTOS",
"TONCOIN-NEW": "TON",
"DOT": "DOT",

// ALGO
"USDT-ALGO": "ALGO",
}

PorCoinTypeMap = map[string]string{
Expand Down Expand Up @@ -175,12 +180,16 @@ var (
"LINKK-OKC20": EcdsaCoinType,
"TRXK-KIP20": EcdsaCoinType,
"OKT": EcdsaCoinType,
"USDT-OKC20": EcdsaCoinType,

// ED25519
"SOL": Ed25519CoinType,
"APTOS": Ed25519CoinType,
"TONCOIN-NEW": Ed25519CoinType,
"DOT": Ed25519CoinType,

// ALGO
"USDT-ALGO": AlgoCoinType,
}

PorCoinMessageSignatureHeaderMap = map[string]string{
Expand Down Expand Up @@ -253,12 +262,16 @@ var (
"LINKK-OKC20": OKXMessageSignatureHeader,
"TRXK-KIP20": OKXMessageSignatureHeader,
"OKT": OKXMessageSignatureHeader,
"USDT-OKC20": OKXMessageSignatureHeader,

// ED25519
"SOL": OKXMessageSignatureHeader,
"APTOS": OKXMessageSignatureHeader,
"TONCOIN-NEW": OKXMessageSignatureHeader,
"DOT": OKXMessageSignatureHeader,

// ALGO
"USDT-ALGO": OKXMessageSignatureHeader,
}

PorCoinUnitMap = map[string]string{
Expand Down Expand Up @@ -288,6 +301,7 @@ var (
"USDT-AVAXC": "USDT",
"USDT-ARBITRUM": "USDT",
"USDT-OPTIMISM": "USDT",
"USDT-OKC20": "USDT",
"USDC": "USDC",
"POLY-USDC": "USDC",
"USDC-AVAXC": "USDC",
Expand Down Expand Up @@ -342,6 +356,9 @@ var (
// EOS
"EOS": "EOS",
"RIPPLE": "RIPPLE",

// ALGO
"USDT-ALGO": "USDT",
}

PorCoinBaseUnitPrecisionMap = map[string]int{
Expand Down Expand Up @@ -371,6 +388,7 @@ var (
"USDT-AVAXC": 6,
"USDT-ARBITRUM": 6,
"USDT-OPTIMISM": 6,
"USDT-OKC20": 18,
"USDC": 6,
"POLY-USDC": 6,
"USDC-AVAXC": 6,
Expand Down Expand Up @@ -425,6 +443,9 @@ var (
// EOS
"EOS": 4,
"RIPPLE": 6,

// ALGO
"USDT-ALGO": 6,
}

CheckBalanceCoinBlackList = map[string]bool{
Expand All @@ -448,5 +469,21 @@ var (

"EOS": true,
"RIPPLE": true,

"USDT-ALGO": true,
}

VerifyAddressCoinBlackList = map[string]bool{
"EOS": true,
"RIPPLE": true,
"USDT-ALGO": true,
}
)

func IsCheckBalanceBannedCoin(coin string) bool {
return CheckBalanceCoinBlackList[coin]
}

func IsVerifyAddressBannedCoin(coin string) bool {
return VerifyAddressCoinBlackList[coin]
}
16 changes: 15 additions & 1 deletion common/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ func TestVerifyUtxoCoinSignature(t *testing.T) {
sign2: "IFMFCCk781/sT/oHoUxL5oZpqQZlImQrhJ3odvkVWARcaK4EAl3XPEA/IVgxh6VaSLmMP/Wno1dxWdmxe2gcs3U=",
script: "522102f5c9ab0dd178eb44cd6baae7c1698ae23caec399d58da93a32509665113152742103729f817997a0442e6a39ee0c15f0cd3a17e55ef768ae6f055b2c323a1cba9eb121021e6568b58ef452791f56d0ba2f2ea1200c730f114ab88701833a0a2cf77ef09e53ae",
},
{
coin: "BTC",
addr: "3Dqq8D5NNfH28RM2kEGzLnhPYRuXDL6bu6",
msg: "I am an Okcoin address",
sign1: "ILLlcEugYiWkge8aS7cQqhHIhk7iVZU5VpJWG830lch7I02Psg3SM/2s1/YY0aWHhNvtcA3QAK0Wnj8NWOTugKA=",
sign2: "IAhfztm0YG0yddgGanfbtA0XfB1kgp+UnHzKnfDyLn4BRnD5v6Q6vb/PgshH8i/gcfcgizdBbPUCIaFsXnP5Sag=",
script: "52210357df00444cf67ada94e25d6a6c6178b14beb6aa33147c74b43a629968d38b07521021922578fd9f4736d52effb0a2404b279557d8e442febd81b46d52eb17948b5462103f587f7297e4d5f8f58007a26cd5e7d83db4687421e08b97d3cbda9387959d6f453ae",
},
}

for _, tt := range args {
Expand Down Expand Up @@ -122,7 +130,13 @@ func TestVerifyEvmCoinSignature(t *testing.T) {
coin: "ETH",
addr: "0x8c3cb9665833fd9f79eb14cba16d82bbab6f22d8",
msg: "I am an OKX address",
sign: "0xa2412073bf6b489c58e4937a4c5cdb3f35aff31bd76e643f56b303b3a0109f1461fe7497c64a66b1baecd6605d866b4d51ddd9e62fa1472c3ddb89a0dc27c7ae1c",
sign: "0xc75173a3ca53bcfeb7b2bfc16aed036191436085fe1a5c846f7021ae2baf5f81646b5089822399b6ee076bb59974ec6bd425954ca97bff084a74efeca0c8c8c61c",
},
{
coin: "ETH",
addr: "0xa28062bd708ce49e9311d6293def7df63f2b0816",
msg: "I am an Okcoin address",
sign: "0x462950c4dbbc0f2fb36002ba7e5c2a98dfae7d89203f4dbf152e03304edb444d670c8bbacb78072c4dc1184db245401c73ee1395715afbb8dd600ba6a63e3abc1b",
},
}
for _, tt := range args {
Expand Down
2 changes: 2 additions & 0 deletions docs/support_coins.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
| USDT | Avalanche |
| USDT | Arbitrum |
| USDT | Optimism |
| USDT | OKC |
| USDC | Ethereum |
| USDC | OKC |
| USDC | Polygon |
Expand Down Expand Up @@ -50,6 +51,7 @@
| USDT | Avalanche |
| USDT | Arbitrum |
| USDT | Optimism |
| USDT | OKC |
| USDC | Ethereum |
| USDC | OKC |
| USDC | Tron |
Expand Down
26 changes: 26 additions & 0 deletions example/rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,32 @@
"tokenAddress": "",
"enabled": false
}
},
{
"name": "usdt-okc20",
"coin": "okc",
"api": {
"endpoint": "https://www.oklink.com/api/v5/explorer/block/address-balance-history",
"jsonPattern": "$.data[0].balance",
"defaultUnit": "OKT",
"tokenAddress": "0x382bB369d343125BfB2117af9c149795C6C65C50",
"customHeaders": {
"Ok-Access-Key": "e1fae3b0-07c3-4a5a-a29f-8cd55181fff3",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "*/*"
},
"enabled": true
},
"rpc": {
"endpoint": "",
"jsonPattern": "$.result",
"defaultUnit": "",
"customHeaders": {},
"authUser": "",
"authPassword": "",
"tokenAddress": "0x382bB369d343125BfB2117af9c149795C6C65C50",
"enabled": false
}
}
]
}

0 comments on commit 5f5d26d

Please sign in to comment.