本文整理汇总了PHP中BitWasp\Bitcoin\Bitcoin::getDefaultNetwork方法的典型用法代码示例。如果您正苦于以下问题:PHP Bitcoin::getDefaultNetwork方法的具体用法?PHP Bitcoin::getDefaultNetwork怎么用?PHP Bitcoin::getDefaultNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitWasp\Bitcoin\Bitcoin
的用法示例。
在下文中一共展示了Bitcoin::getDefaultNetwork方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNetworkSerializer
public function testNetworkSerializer()
{
$mem = new MemPool();
$serializer = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$parsed = $serializer->parse($mem->getNetworkMessage()->getBuffer())->getPayload();
$this->assertEquals($mem, $parsed);
}
示例2: testPeer
public function testPeer()
{
$localhost = '127.0.0.1';
$localport = '8333';
$remotehost = '127.0.0.1';
$remoteport = '9999';
$loop = new StreamSelectLoop();
$dnsResolverFactory = new \React\Dns\Resolver\Factory();
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
$reactServer = new Server($loop);
$network = Bitcoin::getDefaultNetwork();
$client = new NetworkAddress(Buffer::hex('0000000000000001'), $localhost, $localport);
$server = new NetworkAddress(Buffer::hex('0000000000000001'), $remotehost, $remoteport);
$msgs = new Factory($network, new Random());
$serverReceivedConnection = false;
$serverListener = new Listener($server, $msgs, $reactServer, $loop);
$serverListener->on('connection', function (Peer $peer) use(&$serverReceivedConnection, &$serverListener) {
$peer->close();
$serverReceivedConnection = true;
});
$serverListener->listen($server->getPort());
$connector = new Connector($loop, $dns);
$clientConnection = new Peer($client, $msgs, $loop);
$clientConnection->connect($connector, $server)->then(function (Peer $peer) use($serverListener, &$loop) {
$peer->close();
$serverListener->close();
});
$loop->run();
$this->assertTrue($serverReceivedConnection);
}
示例3: testNetworkSerializer
public function testNetworkSerializer()
{
$network = Bitcoin::getDefaultNetwork();
$parser = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$factory = new Factory($network, new Random());
$version = '1';
$relayUntil = '9999999';
$expiration = '9898989';
$id = '123';
$cancel = '0';
$minVer = '0';
$maxVer = '0';
$priority = '50';
$comment = new Buffer('comment');
$statusBar = new Buffer('statusBar');
$setCancel = [1, 2];
$setSubVer = [50, 99];
$detail = new AlertDetail($version, $relayUntil, $expiration, $id, $cancel, $minVer, $maxVer, $priority, $comment, $statusBar, $setCancel, $setSubVer);
$adapter = EcAdapterFactory::getPhpEcc(new Math(), EccFactory::getSecgCurves()->generator256k1());
$sig = new Signature($adapter, '1', '1');
$alert = $factory->alert($detail, $sig);
$serialized = $alert->getNetworkMessage()->getBuffer();
$parsed = $parser->parse($serialized)->getPayload();
/** @var \BitWasp\Bitcoin\Networking\Messages\Alert $parsed */
$this->assertEquals($alert->getDetail(), $parsed->getDetail());
$this->assertEquals($alert->getSignature()->getR(), $parsed->getSignature()->getR());
$this->assertEquals($alert->getSignature()->getS(), $parsed->getSignature()->getS());
}
示例4: testMethods
public function testMethods()
{
$loop = new \React\EventLoop\StreamSelectLoop();
$dns = (new \BitWasp\Bitcoin\Networking\Dns\Factory())->create('8.8.8.8', $loop);
$network = Bitcoin::getDefaultNetwork();
$random = new Random();
$messages = new \BitWasp\Bitcoin\Networking\Messages\Factory($network, $random);
$factory = new Factory($dns, $messages, $loop);
$this->assertInstanceOf($this->peerType, $factory->getPeer());
$services = Buffer::hex('00', 8);
$address = $factory->getAddress('127.0.0.1', 8332, $services);
$this->assertInstanceOf($this->addrType, $address);
$connector = $factory->getConnector();
$this->assertInstanceOf($this->connType, $connector);
$server = $factory->getServer();
$this->assertInstanceOf($this->serverType, $server);
$locator = $factory->getLocator();
$this->assertInstanceOf($this->locatorType, $locator);
$listener = $factory->getListener($server);
$this->assertInstanceOf($this->listenerType, $listener);
$handler = $factory->getPacketHandler();
$this->assertInstanceOf($this->handlerType, $handler);
$manager = $factory->getManager();
$this->assertInstanceOf($this->managerType, $manager);
}
示例5: testNetworkSerializable
public function testNetworkSerializable()
{
$factory = new Factory(Bitcoin::getDefaultNetwork(), new Random());
$filterclear = $factory->filterclear();
$serialized = $filterclear->getNetworkMessage()->getBuffer();
$parsed = $factory->parse(new Parser($serialized))->getPayload();
$this->assertEquals($parsed, $filterclear);
}
示例6: testNetworkSerializer
public function testNetworkSerializer()
{
$parser = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$getaddr = new GetAddr();
$serialized = $getaddr->getNetworkMessage()->getBuffer();
$parsed = $parser->parse($serialized)->getPayload();
$this->assertEquals($getaddr, $parsed);
}
示例7: testNetworkSerializer
public function testNetworkSerializer()
{
$array = [new Inventory(Inventory::MSG_TX, Buffer::hex('4141414141414141414141414141414141414141414141414141414141414141')), new Inventory(Inventory::MSG_TX, Buffer::hex('4141414141414141414141414141414141414141414141414141414141414142')), new Inventory(Inventory::MSG_TX, Buffer::hex('4141414141414141414141414141414141414141414141414141414141414143'))];
$not = new NotFound($array);
$serializer = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$serialized = $not->getNetworkMessage()->getBuffer();
$parsed = $serializer->parse($serialized)->getPayload();
$this->assertEquals($not, $parsed);
}
示例8: testNetworkSerializer
public function testNetworkSerializer()
{
$net = Bitcoin::getDefaultNetwork();
$factory = new Factory($net, new Random());
$inv = $factory->inv([new Inventory(Inventory::MSG_BLOCK, Buffer::hex('4141414141414141414141414141414141414141414141414141414141414141'))]);
$serialized = $inv->getNetworkMessage()->getBuffer();
$parsed = $factory->parse(new Parser($serialized))->getPayload();
$this->assertEquals($inv, $parsed);
}
示例9: testNetworkSerializer
public function testNetworkSerializer()
{
$net = Bitcoin::getDefaultNetwork();
$factory = new Factory($net, new Random());
$locator = new BlockLocator([Buffer::hex('4141414141414141414141414141414141414141414141414141414141414141')], Buffer::hex('0000000000000000000000000000000000000000000000000000000000000000'));
$getblocks = $factory->getblocks('1', $locator);
$serialized = $getblocks->getNetworkMessage()->getBuffer();
$parsed = $factory->parse(new Parser($serialized))->getPayload();
$this->assertEquals($getblocks, $parsed);
}
示例10: testNetworkSerializer
public function testNetworkSerializer()
{
$net = Bitcoin::getDefaultNetwork();
$serializer = new NetworkMessageSerializer($net);
$factory = new Factory($net, new Random());
$ping = $factory->ping();
$serialized = $ping->getNetworkMessage()->getBuffer();
$parsed = $serializer->parse($serialized)->getPayload();
$this->assertEquals($ping, $parsed);
}
示例11: testNetworkMessage
public function testNetworkMessage()
{
$net = Bitcoin::getDefaultNetwork();
$parser = new NetworkMessageSerializer($net);
$factory = new Factory($net, new Random());
$headers = $factory->headers([BlockHeaderFactory::fromHex('0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c')]);
$serialized = $headers->getNetworkMessage()->getBuffer();
$parsed = $parser->parse($serialized)->getPayload();
$this->assertEquals($headers, $parsed);
}
示例12: testNetworkSerialize
public function testNetworkSerialize()
{
$math = new Math();
$factory = new Factory(Bitcoin::getDefaultNetwork(), new Random());
$filter = BloomFilter::create($math, 10, 1.0E-6, 0, new Flags(BloomFilter::UPDATE_ALL));
$filter->insertData(Buffer::hex('04943fdd508053c75000106d3bc6e2754dbcff19'));
$filterload = $factory->filterload($filter);
$serialized = $filterload->getNetworkMessage()->getBuffer();
$parsed = $factory->parse(new Parser($serialized))->getPayload();
$this->assertEquals($parsed, $filterload);
}
示例13: testBlockSerializer
public function testBlockSerializer()
{
$parser = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$txHex = '01000000' . '01' . '0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF' . '4D' . '04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73' . 'FFFFFFFF' . '01' . '00F2052A01000000' . '43' . '4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC' . '00000000';
$blockHex = '01000000' . '0000000000000000000000000000000000000000000000000000000000000000' . '3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A' . '29AB5F49' . 'FFFF001D' . '1DAC2B7C' . '01' . $txHex;
$newBlock = BlockFactory::fromHex($blockHex);
$block = new Block($newBlock);
$serialized = $block->getNetworkMessage()->getBuffer();
$parsed = $parser->parse($serialized)->getPayload();
$this->assertEquals($block, $parsed);
}
示例14: testNetworkSerializer
public function testNetworkSerializer()
{
list($hex, $tx) = $this->getTestTx();
$net = Bitcoin::getDefaultNetwork();
$serializer = new NetworkMessageSerializer($net);
$factory = new Factory($net, new Random());
$txMsg = $factory->tx($tx);
$serialized = $txMsg->getNetworkMessage()->getBuffer();
$parsed = $serializer->parse($serialized)->getPayload();
$this->assertEquals($txMsg, $parsed);
}
示例15: testNetworkSerializer
public function testNetworkSerializer()
{
$network = Bitcoin::getDefaultNetwork();
$time = '9999999';
$ip = '192.168.0.1';
$port = '8333';
$services = Buffer::hex('0000000000000000', 8);
$add = new NetworkAddressTimestamp($time, $services, $ip, $port);
$parser = new NetworkMessageSerializer(Bitcoin::getDefaultNetwork());
$factory = new Factory($network, new Random());
$addr = $factory->addr([$add]);
$serialized = $addr->getNetworkMessage()->getBuffer();
$parsed = $parser->parse($serialized)->getPayload();
$this->assertEquals($addr, $parsed);
}