コード例 #1
-1
 public function newMasterKey($seed_hex_string)
 {
     return HierarchicalKeyFactory::fromEntropy(new Buffer(hex2bin($seed_hex_string)));
 }
コード例 #2
-1
        } else {
            if ($item->isTx()) {
                $txs[] = '';
            } else {
                if ($item->isFilteredBlock()) {
                    $filtered[] = '';
                }
            }
        }
    }
    if (count($blks) > 0 || count($filtered) > 0) {
        echo " [blocks: " . count($blks) . ", txs: " . count($txs) . ", filtered: " . count($filtered) . "]\n";
    }
}
$math = BitWasp\Bitcoin\Bitcoin::getMath();
$key = \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory::fromEntropy(new Buffer('this random sentence can be used to form a private key trololol123'));
$hd = $key->deriveChild(1);
$publicKey = $hd->getPublicKey();
echo $publicKey->getAddress()->getAddress() . "\n";
$flags = new Flags(BloomFilter::UPDATE_P2PUBKEY_ONLY);
$filter = BloomFilter::create($math, 1, 1, 1, $flags);
$filter->insertData($publicKey->getBuffer());
$loop = React\EventLoop\Factory::create();
$factory = new \BitWasp\Bitcoin\Networking\Factory($loop);
$dns = $factory->getDns();
$peerFactory = $factory->getPeerFactory($dns);
$host = $peerFactory->getAddress('192.168.192.101');
$local = $peerFactory->getAddress('192.168.192.39', 32301);
$peers = $peerFactory->getLocator();
$manager = $peerFactory->getManager($peers);
$manager->on('outbound', function (Peer $peer) use(&$node, $filter) {
コード例 #3
-1
ファイル: hd.multisig.php プロジェクト: nmarley/bitcoin-php
<?php

require "../vendor/autoload.php";
use BitWasp\Bitcoin\Mnemonic\MnemonicFactory;
use BitWasp\Bitcoin\Mnemonic\Bip39\Bip39SeedGenerator;
function status(\BitWasp\Bitcoin\Key\Deterministic\MultisigHD $hd)
{
    echo "Path: " . $hd->getPath() . "\n";
    echo "Keys: \n";
    foreach ($hd->getKeys() as $key) {
        echo " - " . $key->toExtendedKey() . "\n";
    }
    echo "Script: " . $hd->getRedeemScript()->getScriptParser()->getHumanReadable() . "\n";
    echo "Address: " . $hd->getAddress()->getAddress() . "\n";
    echo "\n";
}
$ec = \BitWasp\Bitcoin\Bitcoin::getEcAdapter();
$bip39 = (new MnemonicFactory())->bip39();
$seed = new Bip39SeedGenerator($bip39);
$s = [];
$k = [];
for ($i = 0; $i < 3; $i++) {
    $s[$i] = $seed->getSeed($bip39->create());
    $k[$i] = \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory::fromEntropy($s[$i]);
}
$sequences = new \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeySequence($ec->getMath());
$hd = new \BitWasp\Bitcoin\Key\Deterministic\MultisigHD(2, 'm', $k, $sequences, true);
status($hd);
$new = $hd->derivePath("0/1h/2");
status($new);
コード例 #4
-2
ファイル: bip39.php プロジェクト: nmarley/bitcoin-php
<?php

require_once "../vendor/autoload.php";
use BitWasp\Bitcoin\Crypto\Random\Random;
use BitWasp\Bitcoin\Mnemonic\MnemonicFactory;
use BitWasp\Bitcoin\Mnemonic\Bip39\Bip39SeedGenerator;
// Generate a mnemonic
$random = new Random();
$entropy = $random->bytes(64);
$bip39 = MnemonicFactory::bip39();
$seedGenerator = new Bip39SeedGenerator($bip39);
$mnemonic = $bip39->entropyToMnemonic($entropy);
// Derive a seed from mnemonic/password
$seed = $seedGenerator->getSeed($mnemonic, 'password');
echo $seed->getHex() . "\n";
$bip32 = \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory::fromEntropy($seed);