/** * Send a microtransaction signing it locally (without sending the private key to the server) * * @param string $hexPrivateKey * @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 sendSigned($hexPrivateKey, $toAddress, $valueSatoshis, $apiContext = null, $restCall = null) { $compressed = true; $pubkey = PrivateKeyManipulator::generateHexPubKeyFromHexPrivKey($hexPrivateKey, $compressed); $microTX = MicroTXBuilder::newMicroTX()->fromPubkey($pubkey)->toAddress($toAddress)->withValueInSatoshis($valueSatoshis)->build(); $microTX = $this->create($microTX, $apiContext, $restCall); $microTX->sign($hexPrivateKey); $microTX = $this->send($microTX, $apiContext, $restCall); return $microTX; }
/** * @test */ public function should_allow_generate_hex_public_key_from_hex_private_key() { $hexPublicKey = PrivateKeyManipulator::generateHexPubKeyFromHexPrivKey(self::ADDRESS_PRIVATE_KEY); $this->assertEquals(self::ADDRESS_PUBLIC_KEY, $hexPublicKey); }