This repository was archived by the owner on Oct 30, 2018. It is now read-only.
File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,19 @@ const bytes = require('bytes');
20
20
*/
21
21
exports . _isValidPayoutAddress = function ( address ) {
22
22
return bitcore . Address . isValid ( address ) ||
23
- bitcore . Address . isValid ( address , bitcore . Networks . testnet ) ;
23
+ bitcore . Address . isValid ( address , bitcore . Networks . testnet ) ||
24
+ this . isValidEthereumAddress ( address ) ;
25
+ } ;
26
+
27
+ /**
28
+ * Validate the given payout address is an Ethereum address
29
+ * @param {String } address
30
+ */
31
+ exports . isValidEthereumAddress = function ( address ) {
32
+ if ( typeof address !== 'string' ) {
33
+ return false ;
34
+ }
35
+ return / ^ 0 x ( [ 0 - 9 A - F a - f ] { 2 } ) { 20 } $ / . test ( address ) ;
24
36
} ;
25
37
26
38
/**
Original file line number Diff line number Diff line change @@ -30,6 +30,22 @@ describe('module:utils', function() {
30
30
31
31
} ) ;
32
32
33
+ describe ( '#isValidEthereumAddress' , function ( ) {
34
+
35
+ it ( 'should return true for valid mainnet' , function ( ) {
36
+ expect ( utils . isValidEthereumAddress (
37
+ '0xC2D7CF95645D33006175B78989035C7c9061d3F9'
38
+ ) ) . to . equal ( true ) ;
39
+ } ) ;
40
+
41
+ it ( 'should return false for invalid address' , function ( ) {
42
+ expect ( utils . isValidEthereumAddress (
43
+ '1234 Fake Street'
44
+ ) ) . to . equal ( false ) ;
45
+ } ) ;
46
+
47
+ } ) ;
48
+
33
49
describe ( '#_isValidDirectory' , function ( ) {
34
50
35
51
it ( 'should return the the result of existsSync' , function ( ) {
You can’t perform that action at this time.
0 commit comments