forked from ryanralph/altcoin-address
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from ognus/dash
Dash
- Loading branch information
Showing
11 changed files
with
2,995 additions
and
2,954 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// Karma configuration | ||
module.exports = function(config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['mocha', 'chai'], | ||
files: [ | ||
'dist/wallet-address-validator.min.js', | ||
'test/**/*.js' | ||
], | ||
reporters: ['progress'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
browsers: ['ChromeHeadless'], | ||
singleRun: true, | ||
concurrency: Infinity | ||
}) | ||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
|
||
frameworks: ['mocha', 'chai'], | ||
|
||
files: [ | ||
'dist/wallet-address-validator.min.js', | ||
'test/**/*.js' | ||
], | ||
|
||
reporters: ['progress'], | ||
|
||
port: 9876, | ||
|
||
colors: true, | ||
|
||
logLevel: config.LOG_INFO, | ||
|
||
browsers: ['ChromeHeadless'], | ||
|
||
singleRun: true, | ||
|
||
concurrency: Infinity | ||
}) | ||
}; |
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
"decred", | ||
"dogecoin", | ||
"ethereum", | ||
"ripple", | ||
"dash", | ||
"altcoin", | ||
"crypto", | ||
"address", | ||
|
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
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
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 |
---|---|---|
@@ -1,22 +1,28 @@ | ||
var cryptoUtils = require('./crypto/utils'); | ||
var baseX = require('base-x'); | ||
var codec = baseX("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"); // for ripple | ||
|
||
var ALLOWED_CHARS = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'; | ||
|
||
var codec = baseX(ALLOWED_CHARS); | ||
var regexp = new RegExp('^r[' + ALLOWED_CHARS + ']{27,35}$'); | ||
|
||
module.exports = { | ||
/** | ||
* ripple address validation | ||
*/ | ||
isValidAddress: function (address) { | ||
if (/^r[rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz]{27,35}$/.test(address) === false) | ||
return false; | ||
return this.verifyChecksum(address); | ||
}, | ||
/** | ||
* ripple address validation | ||
*/ | ||
isValidAddress: function (address) { | ||
if (regexp.test(address)) { | ||
return this.verifyChecksum(address); | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
verifyChecksum: function (address) { | ||
var bytes = codec.decode(address); | ||
var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); | ||
var checksum = cryptoUtils.toHex(bytes.slice(-4)); | ||
verifyChecksum: function (address) { | ||
var bytes = codec.decode(address); | ||
var computedChecksum = cryptoUtils.sha256Checksum(cryptoUtils.toHex(bytes.slice(0, -4))); | ||
var checksum = cryptoUtils.toHex(bytes.slice(-4)); | ||
|
||
return computedChecksum === checksum | ||
} | ||
return computedChecksum === checksum | ||
} | ||
}; |
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
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