/** * Send the microtransaction to the network. * * @param MicroTX $microTX * @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 send(MicroTX $microTX, $apiContext = null, $restCall = null) { $payLoad = $microTX->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/txs/micro", "POST", $payLoad, null, $apiContext, $restCall); $microTX->fromJson($json); return $microTX; }
/** * @dataProvider mockProvider * @param MicroTX $obj */ public function testSend($obj, $mockApiContext) { $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock(); $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson())); $result = $obj->send($mockApiContext, $mockBlockCypherRestCall); $this->assertNotNull($result); }
/** * @return MicroTX */ public function build() { $microTX = new MicroTX(); if ($this->fromPubkey !== null) { $microTX->setFromPubkey($this->fromPubkey); } if ($this->fromPrivate !== null) { $microTX->setFromPrivate($this->fromPrivate); } if ($this->fromWif !== null) { $microTX->setFromWif($this->fromWif); } $microTX->setToAddress($this->toAddress); $microTX->setValueSatoshis($this->valueSatoshis); return $microTX; }