diff --git a/README.md b/README.md index 3a43173..85ed83f 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ func main() { - [ ] BitcoinPrivate/BTCP, `'bitcoinprivate'` or `'BTCP'` - [ ] BitcoinZ/BTCZ, `'bitcoinz'` or `'BTCZ'` - [x] Callisto/CLO, `'callisto'` or `'CLO'` -- [ ] Dash, `'dash'` or `'DASH'` +- [x] Dash, `'dash'` or `'DASH'` - [ ] Decred/DCR, `'decred'` or `'DCR'` - [ ] Digibyte/DGB, `'digibyte'` or `'DGB'` - [x] Dogecoin/DOGE, `'dogecoin'` or `'DOGE'` diff --git a/currencies.go b/currencies.go index 3aef068..f996121 100644 --- a/currencies.go +++ b/currencies.go @@ -87,6 +87,17 @@ var currencies = []currency{ }, validator: isValidBitcoinAddress, }, + currency{ + params: currencyParams{ + name: "dash", + symbol: "dash", + addressTypes: addressTypes{ + prod: []string{"4c", "10"}, + testnet: []string{"8c", "13"}, + }, + }, + validator: isValidBitcoinAddress, + }, currency{ params: currencyParams{ name: "litecoin", diff --git a/dash_test.go b/dash_test.go new file mode 100644 index 0000000..c8667f3 --- /dev/null +++ b/dash_test.go @@ -0,0 +1,32 @@ +package crptwav + +import "testing" + +func TestIsValidDash(t *testing.T) { + tt := []struct { + currency string + address string + network string + }{ + {address: "Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b", currency: "dash", network: "prod"}, + {address: "XcY4WJ6Z2Q8w7vcYER1JypC8s2oa3SQ1b1", currency: "DASH", network: "prod"}, + {address: "XqMkVUZnqe3w4xvgdZRtZoe7gMitDudGs4", currency: "dash", network: "prod"}, + {address: "yPv7h2i8v3dJjfSH4L3x91JSJszjdbsJJA", currency: "dash", network: "testnet"}, + } + for _, tc := range tt { + switch tc.network { + case NetworkProd: + if !IsValidProdAddress(tc.address, tc.currency) { + t.Errorf("Address %s should be valid %s %s address", tc.address, tc.currency, tc.network) + } + case NetworkTest: + if !IsValidTestnetAddress(tc.address, tc.currency) { + t.Errorf("Address %s should be valid %s %s address", tc.address, tc.currency, tc.network) + } + default: + if !IsValidAddress(tc.address, tc.currency) { + t.Errorf("Address %s should be valid %s %s address", tc.address, tc.currency, tc.network) + } + } + } +}