payment processing, how long?

I try to implement the payment processing API from
I created a request by the example of their website, and receive a generated bitcoin adress:

See an example here:
I send 0.001 BTC to that adress. It has already 8 confirmations atm. But when are they send to my adress? How much confirmations does needs?

Thank you

What if block N were based not on N-1 but on both N-2 and N-3?

If the bitcoin protocol were changed so that the merkle root from block N-1 were replaced in block N by the two roots of blocks N-2 and N-3, then it would become possible to mine 2 blocks at a time in parallel and increase the block frequency compared to the time each block took to propagate. Each block would still get confirmed by 6 of the following 7 blocks. The block size variance could be controlled by requiring that transactions with odd hashes go into odd-numbered blocks and vice-versa. What would be the limitations of this variant protocol compared to the existing Bitcoin protocol, assuming nobody considered one confirmation to be much better than zero?

How does Bitcoin Core sort memory pool transactions by fee?

I’m trying to understand the algorithm Bitcoin Core uses to sort memory pool transactions by fee.

Gavin’s fee rework proposal states:

Next, sort all remaining memory pool transactions by fee-paid-per-kilobyte, and include as many as will fit until the block is maximum block size bytes big, not including “free” transactions (transactions with fee-per-kb of less than the default spam threshold of 0.0001 BTC/kilobyte).

This makes sense, because a miner should want to load a block with transactions carrying the most “fee density”, or fee per byte.

However, reviewing the CreateNewBlock function in miner.cpp, it’s not clear how Bitcoin Core accounts for transaction length when prioritizing memory pool items:

// Prioritise by fee once past the priority size or we run out of high-priority
// transactions:
if (!fSortedByFee &&
    ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority)))
    fSortedByFee = true;
    comparer = TxPriorityCompare(fSortedByFee);
    std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);

TXPriorityCompare seems to just look at absolute fee:

    TxPriorityCompare(bool _byFee) : byFee(_byFee) { }

    bool operator()(const TxPriority& a, const TxPriority& b)
        if (byFee)
            if (a.get<1>() == b.get<1>())
                return a.get<0>() < b.get<0>();
            return a.get<1>() < b.get<1>();
            if (a.get<0>() == b.get<0>())
                return a.get<1>() < b.get<1>();
            return a.get<0>() < b.get<0>();

In other words, this looks like a sort on absolute transaction fee, not fee density. What am I missing?

php private key to wallet import format (wip)

I have been writing a php file intended to create a bitcoin private key and change it to wallet import format. The issue is when I try a command in a gnome-terminal such as:
bitcoin-cli importprivkey ygm8fAjomMyKVcb8vK8MPBByYpMDySY1vAxcpw6DUfPBHb8kv “” false
I get an error:
error: {“code”:-5,”message”:”Invalid private key encoding”}

From this I’ve infered that my code is flawed in creating a private key and changing it into wallet import format. But from what I see in the source code it should do what it says to at under “Private key to WIF”

Here are the php files:



$a = new btcMakePrivKey();
#echo $GLOBALS['base58oper'];
function decodeHex($hex) {
    $hexchars = "0123456789ABCDEF";

    $hex = strtoupper($hex);
    $return = "0";
    for ($i = 0; $i < strlen($hex); $i++) {
        $current = (string) strpos($hexchars, $hex[$i]);
        $return = (string) bcmul($return, "16", 0);
        $return = (string) bcadd($return, $current, 0);
    return $return;
function encodeBase58($hex) 
    $base58chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
    if (strlen($hex) % 2 != 0) {
        die("encodeBase58: uneven number of hex characters");
    $orighex = $hex;

    $hex = decodeHex($hex);
    $return = "";
    while (bccomp($hex, 0) == 1) {
        $dv = (string) bcdiv($hex, "58", 0);
        $rem = (integer) bcmod($hex, "58");
        $hex = $dv;
        $return = $return . $base58chars[$rem];
    $return = strrev($return);

    //leading zeros
    for ($i = 0; $i < strlen($orighex) && substr($orighex, $i, 2) == "00"; $i += 2) {
        $return = "1" . $return;
    return $return;
class btcMakePrivKey
    //$base58oper = new base58();
    public function __construct()
        #$this->base58oper = new base58();
        $count = 0;  $privKey = "";
        while($count < 62)
            $appendable = devurandom_rand(0,15);
                case 10:
                $appendable = 'A';
                case 11:
                $appendable = 'B';
                case 12:
                $appendable = 'C';
                case 13:
                $appendable = 'D';
                case 14:
                $appendable = 'E';
                case 15:
                $appendable = 'F';
            $count = $count + 1;
            $privKey = $privKey . $appendable;
        $privKey = $this->addLeadingByte($privKey);
        #echo $privKey . "\n\n";
        $pkHashed = $this->sha256Hash($this->sha256Hash($privKey) );
        $checksum = substr($pkHashed, 0, 8);
        $privKey = $privKey . $checksum;
        #$privKey = $this->base58oper->encode($privKey);
        $privKey = encodeBase58($privKey);
        echo $privKey;// . "\n\n" . $pkHashed . "\n\n" . $checksum;
    private function addLeadingByte($privKey)
        return '80' . $privKey;
    private function sha256Hash($privKey)
        return hash('sha256', $privKey, false);

and devRand.php:

//equiv to rand, mt_rand
//returns int in *closed* interval [$min,$max]
function devurandom_rand($min = 0, $max = 0x7FFFFFFF) {
    $diff = $max - $min;
    if ($diff < 0 || $diff > 0x7FFFFFFF) {
    throw new RuntimeException("Bad range");
    $bytes = mcrypt_create_iv(4, MCRYPT_DEV_URANDOM);
    if ($bytes === false || strlen($bytes) != 4) {
        throw new RuntimeException("Unable to get 4 bytes");
    $ary = unpack("Nint", $bytes);
    $val = $ary['int'] & 0x7FFFFFFF;   // 32-bit safe
    $fp = (float) $val / 2147483647.0; // convert to [0,1]
    return round($fp * $diff) + $min;

I intend my code to create a bitcoin private key and convert it to a useable key in wallet import format, which can be used in bitcoin-cli importprivkey insertKeyHere “” false