bitcoin-address
Advanced tools
Comparing version 0.0.1 to 0.0.2
18
index.js
@@ -13,2 +13,7 @@ | ||
var p2sh_types = { | ||
prod: '05', | ||
testnet: 'c4' | ||
}; | ||
/// check if a wallet address is valid | ||
@@ -20,6 +25,2 @@ /// if address_type is supplied | ||
if (address.length !== 34 && address.length !== 33) { | ||
return false; | ||
} | ||
var decoded_hex = base58.decode(address); | ||
@@ -46,5 +47,8 @@ | ||
// check that the address type is correct if requested | ||
if(address_type && | ||
decoded_hex.slice(0, 2) !== address_types[address_type]) { | ||
return false; | ||
if (address_type) { | ||
var type = decoded_hex.slice(0, 2); | ||
if (type !== address_types[address_type] && | ||
type !== p2sh_types[address_type]) { | ||
return false; | ||
} | ||
} | ||
@@ -51,0 +55,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "bitcoin address verification and other related functions", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/shtylman/bitcoin-address", | ||
@@ -19,3 +19,3 @@ "repository": { | ||
"devDependencies": { | ||
"mocha": "1.1.x" | ||
"mocha": "1.2.x" | ||
}, | ||
@@ -22,0 +22,0 @@ "main": "index", |
@@ -1,4 +0,4 @@ | ||
# address [![Build Status](https://secure.travis-ci.org/shtylman/bitcoin-address.png)](http://travis-ci.org/shtylman/bitcoin-address) # | ||
# bitcoin-address [![Build Status](https://secure.travis-ci.org/shtylman/bitcoin-address.png)](http://travis-ci.org/shtylman/bitcoin-address) # | ||
Provides utility functions for working with bitcoin addresses | ||
Functions for working with bitcoin addresses | ||
@@ -5,0 +5,0 @@ ## install ## |
@@ -19,3 +19,9 @@ var address = require('..'); | ||
validate('116CGDLddrZhMrTwhCVJXtXQpxygTT1kHd'); | ||
// p2sh addresses | ||
validate('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt'); | ||
validate('3NJZLcZEEYBpxYEUGewU4knsQRn1WM5Fkt', 'prod'); | ||
validate('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7'); | ||
validate('2MxKEf2su6FGAUfCEAHreGFQvEYrfYNHvL7', 'testnet'); | ||
}); | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4934
119