forked from ryanralph/altcoin-address
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Developer
committed
Aug 1, 2019
1 parent
bcd0c8f
commit 2daed26
Showing
7 changed files
with
193 additions
and
54 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
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.
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 |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
"validator", | ||
"vertcoin", | ||
"nano", | ||
"nimiq", | ||
"raiblocks", | ||
"javascript", | ||
"browser", | ||
|
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function ibanCheck(address) { | ||
var num = address.split('').map(function(c) { | ||
var code = c.toUpperCase().charCodeAt(0); | ||
return code >= 48 && code <= 57 ? c : (code - 55).toString(); | ||
}).join(''); | ||
var tmp = ''; | ||
|
||
for (var i = 0; i < Math.ceil(num.length / 6); i++) { | ||
tmp = (parseInt(tmp + num.substr(i * 6, 6)) % 97).toString(); | ||
} | ||
|
||
return parseInt(tmp); | ||
} | ||
|
||
module.exports = { | ||
isValidAddress: function (address, currency) { | ||
currency = currency || {}; | ||
address = address.replace(/ /g, ''); | ||
|
||
if (address.substr(0, 2).toUpperCase() !== currency.countryCode) { | ||
return false; | ||
} | ||
if (address.length !== currency.length) { | ||
return false; | ||
} | ||
if (ibanCheck(address.substr(4) + address.substr(0, 4)) !== 1) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
}; |
Oops, something went wrong.