Last active
August 29, 2015 14:06
-
-
Save rubensayshi/e727adef25697dde9f76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| use BitWasp\BitcoinLib\BitcoinLib; | |
| require_once(__DIR__. '/vendor/autoload.php'); | |
| $bitcoin_livenet_normal = '1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp'; | |
| $bitcoin_testnet_p2sh = '2N954bXdCyZM7bGG81tiEfZbXK1tcRgGWhX'; | |
| // set magic bytes for bitcoin livenet for all static calls | |
| BitcoinLib::setMagicByte('00|05'); | |
| // should use bitcoin livenet right now | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_livenet_normal), | |
| BitcoinLib::validate_address($bitcoin_livenet_normal)); | |
| // should use bitcoin livenet right now | |
| // and fail | |
| var_dump(BitcoinLib::validate_address($bitcoin_testnet_p2sh), | |
| BitcoinLib::validate_address($bitcoin_testnet_p2sh)); | |
| // manually specify bitcoin testnet | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_testnet_p2sh, '6F|C4'), | |
| BitcoinLib::validate_address($bitcoin_testnet_p2sh)); | |
| // set magic bytes for bitcoin testnet for all static calls | |
| BitcoinLib::setMagicByte('6F|C4'); | |
| // should use bitcoin testnet right now | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_testnet_p2sh), | |
| BitcoinLib::validate_address($bitcoin_testnet_p2sh)); | |
| // set magic bytes for bitcoin livenet for all static calls | |
| BitcoinLib::setMagicByte('00|05'); | |
| // should use bitcoin livenet right now | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_livenet_normal), | |
| BitcoinLib::validate_address($bitcoin_livenet_normal)); | |
| // set magic bytes for bitcoin testnet for all static calls, by an alias | |
| BitcoinLib::setMagicByte('bitcoin-testnet'); | |
| // should use bitcoin testnet right now | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_testnet_p2sh), | |
| BitcoinLib::validate_address($bitcoin_testnet_p2sh)); | |
| // set magic bytes for bitcoin testnet for all static calls, by an alias | |
| BitcoinLib::setMagicByte('bitcoin'); | |
| // should use bitcoin testnet right now | |
| // and succeed | |
| var_dump(BitcoinLib::validate_address($bitcoin_testnet_p2sh), | |
| BitcoinLib::validate_address($bitcoin_testnet_p2sh)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment