public function testBuild()
 {
     $expectedMicroTX = MicroTXTest::getObject();
     $microTX = MicroTXBuilder::newMicroTX()->fromPubkey($expectedMicroTX->getFromPubkey())->fromPrivate($expectedMicroTX->getFromPrivate())->fromWif($expectedMicroTX->getFromWif())->toAddress($expectedMicroTX->getToAddress())->withValueInSatoshis($expectedMicroTX->getValueSatoshis())->build();
     $this->assertEquals($expectedMicroTX->getFromPubkey(), $microTX->getFromPubkey());
     $this->assertEquals($expectedMicroTX->getFromPrivate(), $microTX->getFromPrivate());
     $this->assertEquals($expectedMicroTX->getFromWif(), $microTX->getFromWif());
     $this->assertEquals($expectedMicroTX->getToAddress(), $microTX->getToAddress());
     $this->assertEquals($expectedMicroTX->getValueSatoshis(), $microTX->getValueSatoshis());
 }
<?php

// # Create MicroTX Sample (using a builder)
//
// This sample code demonstrate how you can create a new microtransaction, as documented here at:
// <a href="http://dev.blockcypher.com/#microtransaction-endpoint">http://dev.blockcypher.com/#microtransaction-endpoint</a>
// API used: POST /v1/btc/main/txs/micro
require __DIR__ . '/../bootstrap.php';
// Create a new instance of MicroTX object
$microTX = \BlockCypher\Builder\MicroTXBuilder::aMicroTX()->fromPubkey("02d4e3404e175923adf89c932fab96758716f6a0a896890f2494c5d9141eb3f543")->toAddress("C4MYFr4EAdqEeUKxTnPUF3d3whWcPMz1Fi")->withValueInSatoshis(10000)->build();
// For Sample Purposes Only.
$request = clone $microTX;
$microTXClient = new \BlockCypher\Client\MicroTXClient($apiContexts['BCY.test']);
try {
    $output = $microTXClient->create($microTX);
} catch (Exception $ex) {
    ResultPrinter::printError("Created MicroTX", "MicroTX", null, $request, $ex);
    exit(1);
}
ResultPrinter::printResult("Created MicroTX", "MicroTX", $output->getHash(), $request, $output);
return $output;
Beispiel #3
0
 /**
  * Send a microtransaction signing it on server side (sending the private key to the server).
  * Same functionality as fromPrivate method but using WIF format for private key.
  *
  * @param string $wif
  * @param string $toAddress
  * @param int $valueSatoshis
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return MicroTX
  */
 public function sendWithWif($wif, $toAddress, $valueSatoshis, $apiContext = null, $restCall = null)
 {
     $microTX = MicroTXBuilder::newMicroTX()->fromWif($wif)->toAddress($toAddress)->withValueInSatoshis($valueSatoshis)->build();
     $microTX = $this->create($microTX, $apiContext, $restCall);
     return $microTX;
 }