Trying to understand how bitcore-node stores the data in the DB

I’m looking into the data and source of bitcore-node ( ), I’m a bit confused how all the information is stored in the database, probably it’s in a similar way to others block explorers, so maybe someone could help me.

In this case for example

In the database I found two txo- txo-acb2e895a9b3664cfcfb13dd0321ef0c1205cf2aa082681dc6ba424af6456a42-0

{"prevTxId":"8697331c3124c8a4cf2f43afb5732374ea13769e42f10aa3a98148a08989af5e","outputIndex":1,"sequenceNumber":4294967295,"script":"4730440220106c316c22d4bf8c970f8e4b1af1edd95121397cfe29ab987cb000b478ec8e4302202b77986b89d77ab716da3cf53424efacf35e9097b1c89194df220e99503b8cae01","scriptString":"71 0x30440220106c316c22d4bf8c970f8e4b1af1edd95121397cfe29ab987cb000b478ec8e4302202b77986b89d77ab716da3cf53424efacf35e9097b1c89194df220e99503b8cae01","heightConfirmed":37514}



Clearly different data, not sure why in one case we store the previous txid and in the other just the satoshis sent. It has to be obvious, but not sure what I’m missing here.

Another example

txo-00eff263871e6d44abed66d90abb10d5a211441668511dba3146e380360efe4b-0 (from 0 to 5 all have similar data)

{"prevTxId":"6aebb4a764a027436f703ca9d42d0735423798f56973f9f236832a91fc2e9026","outputIndex":0,"sequenceNumber":4294967295,"script":"473044022057801e812f964bcb9e8ff17b37acef55afbb7119a66f24a148ba65e86a7aa1e3022064af657d280068b979ea17a29969976aedee8a664b3f1b575ebb88ef9275302601","scriptString":"71 0x3044022057801e812f964bcb9e8ff17b37acef55afbb7119a66f24a148ba65e86a7aa1e3022064af657d280068b979ea17a29969976aedee8a664b3f1b575ebb88ef9275302601","heightConfirmed":10712}

Also,… they are inputs, not outputs of the transaction.

I’m trying to read the code, but I can’t get to understand all the pieces.

As someone points me in reddit, it looks like it’s using txo– to store both, outputs and inputs. So I’m not sure how bitcore manages to get the inputs/outputs separately later (the API allows you to request only the inputs for example). 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

Bitcoin Testnet Trouble with bitcoin-ruby

I am having trouble with the bitcoin-ruby gem. I get the following error when trying to send money to another address I have on the test network:

pk_script=': undefined methodbytesize’ for nil:NilClass

I am generating a private key with:

def new_address

And getting details for the private key with:

def key_details(prikey, pubkey)
  #returns prikey, prikey_hash58, pubkey_hash58, pubkey_uncompressed, address as a hash
  my_key =, pubkey)
  { prikey:prikey, 
    pubkey: my_key.pub_uncompressed, 

The code I have to send money to myself is as follows:

require 'bitcoin'
require_relative 'utilities.rb'
require 'open-uri' = :testnet3

def build_transaction(prev_tx, prev_out_index, key, value, addr, message)
  include Bitcoin::Builder

  new_tx = build_tx do |t|
    t.input do |i|
      i.prev_out prev_tx
      i.prev_out_index prev_out_index
      i.signature_key key
    t.output do |o|
      o.value value 
      o.script {|s| s.type :address; s.recipient addr }

def prev_tx(prev_hash, network)
  if network == "testnet3"
    prev_tx = Bitcoin::P::Tx.from_json(open("{prev_hash}.json"))
    prev_tx = Bitcoin::P::Tx.from_json(open("{prev_hash}.json"))

def key(publ_key, priv_key)
  key =, publ_key)

def bin_to_hex(s)

#transaction inputs
priv_key = "private_key"
publ_key = "public_key_long_format"
address = "address"
previous_tx = "previous_tx_hash"

# generate tx info off inputs
key =, publ_key)
prev_tx = prev_tx(previous_tx, "testnet3")
prev_out_index = 1
tx_value = prev_tx.outputs[prev_out_index].value

# build new tx
tx = build_transaction(prev_tx, prev_out_index, key, tx_value, address, "hello")

# puts tx.to_json
puts bin_to_hex(tx.to_payload)

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?

Metrics Correlated to “Health” of Bitcoin Node and Network

What metrics can I use as indicators of the health of (a) a full bitcoin node I am running and (b) the bitcoin network as a whole.

Some examples I’ve considered: recency of last block I received on my node is a good indicator of (a) or (b) — if a long time passes, I have an indication that either my node or the network is not in a good state. The number of full nodes (N) participating in the network is a good measure of (b). N is difficult to measure but the folks here are taking a good run at it:

What other metrics should I look at on my nodes or on broader level across the network, to gauge the health of my nodes and the network?

Is 12-word seed phrase safe enough?

Is 12-word seed phrase (as used by Electrum for example) safe enough for generating an offline wallet?

My understanding is this: 2048 words pool make 11 bits of entrophy per word. 12 words in seed make total 132 bits of entrophy.

Is this considered safe enough?

I’m not talking about being quantum-computing-resistent, just being infeasible to crack using brute force given the expected computing power in the foreseeable future.

How to setup bitcoind 10.2 for solo mining on LAN with Bitmain S3

Hy there,
i do not exactly know if i am right with my setup, so please be patient with my questions as a noob.
I have a Bitmain S3 with latest Firmware on the ASIC, and i do not exactly know how to configure the ASIC for solo mining in my LAN.

1.) I have a linux bitcoind server in my lan with the IP

2.) I have an ASIC bitmain S3 with the IP

3.) I have a bitcoin.conf as follows


4.) What statements do i need in the S3 configuration field? Do i need the rpcsuser+rpcpwd+btcaaddress or do i just need the btcaddress?

Thanks in advance for your awnsers!!!

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