Skip to content

Commit

Permalink
Add Dash
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanlemeshev committed Aug 17, 2018
1 parent e83e430 commit 9938af5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'`
Expand Down
11 changes: 11 additions & 0 deletions currencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions dash_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
}

0 comments on commit 9938af5

Please sign in to comment.