Exemplo n.º 1
2
/* This example script sweeps coin from the 'from_address' to the 'to_address'.
   Must specify the 'private_key' in Wallet Import Format.
   
   IMPORTANT! Specify your own API Key. Your Private Key never goes to Block.io.

   Contact support@block.io for any help with this.
*/

<?php 
require_once '/home/anazir/blockio-libs/php/lib/block_io.php';
$apiKey = 'YOUR API KEY';
$pin = 'NONE';
// Not Needed
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
$from_address = 'FROM ADDRESS';
$to_address = 'TO ADDRESS';
$private_key = 'PRIVATE KEY OF FROM_ADDRESS IN WALLET IMPORT FORMAT';
// let's sweep the coins from the From Address to the To Address
try {
    $sweepInfo = $block_io->sweep_from_address(array('from_address' => $from_address, 'to_address' => $to_address, 'private_key' => $private_key));
    echo "Status: " . $sweepInfo->status . "\n";
    echo "Executed Transaction ID: " . $sweepInfo->data->txid . "\n";
    echo "Network Fee Charged: " . $sweepInfo->data->network_fee . " " . $sweepInfo->data->network . "\n";
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
Exemplo n.º 2
1
/* This example script does the following:

   This script converts a given string into a Private Key for a specific address.
   Useful for extracting Private Keys in Wallet Import Format when using Distributed Trust,
   and mop-py to sweep coins out of the Distributed Trust address without going through Block.io.

   IMPORTANT! Specify your own API Key here.
   The network to use for the Wallet Import Format is determined from the API Key used.

   Contact support@block.io for any help with this.
*/

<?php 
require_once 'path/to/block_io.php';
/* Replace the $apiKey with the API Key from your Block.io Wallet. */
$apiKey = 'YOUR API KEY';
$pin = 'PIN - NOT NEEDED';
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
$network = $block_io->get_balance()->data->network;
// get our current network off Block.io
$passphrase = strToHex('alpha1alpha2alpha3alpha4');
$key = $block_io->initKey()->fromPassphrase($passphrase);
echo "Current Network: " . $network . "\n";
echo "Private Key: " . $key->toWif($network) . "\n";
// print out the private key for the given network
Exemplo n.º 3
1
 /**
  * Create a new wallet for an email and return its public key
  *
  * @author salvipascual
  * @param String, email
  * @return String
  * */
 private function createNewWallet($email)
 {
     $block_io = new BlockIo($this->apiKey, $this->pin, 2);
     $address = $block_io->get_new_address(array('label' => $email));
     return $address->data->address;
 }
Exemplo n.º 4
0
   2. Deposit coins into the new MultiSig address
   3. Withdraw coins from MultiSig address back into the sending address in (2)   

   IMPORTANT! Specify your own API Key and Secret PIN in this code. Keep your Secret PIN safe at all times.

   Contact support@block.io for any help with this.
*/

<?php 
require_once '/path/to/block_io.php';
/* Replace the $apiKey with the API Key from your Block.io Wallet. A different API key exists for Dogecoin, Dogecoin Testnet, Litecoin, Litecoin Testnet, etc. */
$apiKey = 'DogecoinTestnetAPIKey';
$pin = 'SecretPin';
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
// create 4 keys for a 3 of 4 MultiSig address (1 key is Block.io's, added automatically by Block.io)
$passphrases = [strToHex('alpha1alpha2alpha3alpha4'), strToHex('alpha2alpha3alpha4alpha1'), strToHex('alpha3alpha4alpha1alpha2'), strToHex('alpha4alpha1alpha2alpha3')];
$keys = [$block_io->initKey()->fromPassphrase($passphrases[0]), $block_io->initKey()->fromPassphrase($passphrases[1]), $block_io->initKey()->fromPassphrase($passphrases[2]), $block_io->initKey()->fromPassphrase($passphrases[3])];
// create an address with label 'dTrust1' that requires 3 of 4 signatures from the above keys
$pubKeyStr = $keys[0]->getPublicKey() . "," . $keys[1]->getPublicKey() . "," . $keys[2]->getPublicKey() . "," . $keys[3]->getPublicKey();
$dTrustAddress = "";
echo "*** Creating Address with 4 Signers, and 3 Required Signatures: " . "\n";
try {
    $response = $block_io->get_new_dtrust_address(array('label' => 'dTrust1', 'public_keys' => $pubKeyStr, 'required_signatures' => 3));
    $dTrustAddress = $response->data->address;
} catch (Exception $e) {
    // print the exception below for debugging
    // echo "Exception: " . $e->getMessage() . "\n";
    // the label must exist, let's get its address then
    $dTrustAddress = $block_io->get_dtrust_address_by_label(array('label' => 'dTrust1'))->data->address;
Exemplo n.º 5
0
   2. Create an address labeled 'shibetime1' on the account if it does not already exist
   3. Withdraw 1% of total available balance in your account, and send it to the address labeled 'shibetime1'
   
   IMPORTANT! Specify your own API Key and Secret PIN in this code. Keep your Secret PIN safe at all times.

   Contact support@block.io for any help with this.
*/

<?php 
require_once '/path/to/block_io.php';
/* Replace the $apiKey with the API Key from your Block.io Wallet. A different API key exists for Dogecoin, Dogecoin Testnet, Litecoin, Litecoin Testnet, etc. */
$apiKey = 'YOUR DOGECOIN TESTNET API KEY';
$pin = 'SECRET PIN';
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
echo "*** Getting account balance\n";
$getBalanceInfo = "";
try {
    $getBalanceInfo = $block_io->get_balance();
    echo "!!! Using Network: " . $getBalanceInfo->data->network . "\n";
    echo "Available Amount: " . $getBalanceInfo->data->available_balance . " " . $getBalanceInfo->data->network . "\n";
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
echo "\n\n";
echo "*** Create new address\n";
$getNewAddressInfo = "";
try {
    $getNewAddressInfo = $block_io->get_new_address(array('label' => 'shibetime1'));
    echo "New Address: " . $getNewAddressInfo->data->address . "\n";
Exemplo n.º 6
0
   We recommend using the Bitcoin Testnet here. Please note that the Bitcoin Testnet (due to its small size)
   will reach ~0.8 confidence max. Live network for Bitcoin, Dogecoin, Litecoin will reach 0.99 confidence.

   Contact support@block.io for any help with this.
*/

<?php 
require_once '../lib/block_io.php';
/* Parse command line arguments */
parse_str(implode('&', array_slice($argv, 1)), $_GET);
/* Our account's credentials for Bitcoin Testnet */
$apiKey = 'YOUR API KEY';
$pin = 'notNeeded';
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
$toAddress = $_GET['to_address'];
$paymentExpected = strval($_GET['amount']);
$confidenceThreshold = floatval($_GET['min_confidence']);
print "Monitoring Address for Payments: " . $toAddress . "\n";
print "Amount Expected: " . $paymentExpected . "\n";
/* Look for a new incoming transaction, and let us know when done.
   Assumption: The $toAddress is new, and does not have previously received transactions */
while (true) {
    // Keep checking for a new transaction, end when there is at least one transaction and its confidence has reached 0.90.
    $txs = $block_io->get_transactions(array('addresses' => $toAddress, 'type' => 'received'));
    $paymentReceived = "0.0";
    // using strings for high precision monetary stuff
    //      print_r($txs);
    $txs = $txs->data->txs;
    // iterate over all transactions, check their confidence