Help: I want to configure wallet.dir to be saved on aws s3 instead of locally I'm building bitcoin from source to add some functionality. The main reason is that I want to use AWS S3 to store my wallet.dat file (for security reasons) instead of being stored locally.
Basically, I want all the references to the wallet directory and file to be through aws-cli, instead of directly on the machine. I'd be thankful for any suggestions.

Running on ubuntu 16.04 (EC2), headless.

Thanks!

You'd have to rewrite the relevant pieces of the Bitcoin Core source code to do this directly.  It'll be particularly challenging because access to wallet.dat is not done directly, but through the bdb library, so you'd have to hack that as well.

Probably a better approach would be to have a script that periodically backs up the wallet.dat file to your s3 bucket.  However, you'll have to temporarily shut down Bitcoin Core to do that, because if you copy wallet.dat while it's being written to, you might get an inconsistent copy that doesn't work.

I'm not sure of the best tools these days for interacting with the s3 API.  s3cmd is one option, though I've had issues recently with it not working, which I haven't unraveled yet.


Trying to run bitcoind gives Segmentation Fault Trying to run bitcoind on Ubuntu 16.04 and have all the required libraries after following the guide in the Mastering Bitcoin Book. After building from source without any parameters triggered i get the following error:

bitcoind
Segmentation fault (core dumped)

Apparently this is due to trying to access a memory index out of bounds however does anyone know how i might be able to resolve it?

Any help would be great :)

This sounds like an issue for the GitHub issue tracker, not stack exchange :)

https://github.com/bitcoin/bitcoin/issues

Please include the core dump, and which version of bitcoin you built.


What Ripple API libraries are available? I am wondering, what libraries are out there for communicating with Ripple through its API (either websocket or JSON RPC)?

Ripple labs have created a number of GitHub repositories relating to Ripple, including ripple-lib for JavaScript and a work in progress ripple-lib-java for Java.
Rubble Labs have released their ripple library for Golang
CodeShark has released a C++ library for communicating with Ripple through a websocket


Besides mining Bitcoin what is another good use for an Antminer S1? Are there any other SHA-256 coins out there that are worth mining? Also, would I be able to mine scrypt-based coins?

There are many other SHA256 coins. Whether they are "worth mining" will depend on their difficulty, market value, the cost of your electricity, and the value of the time it takes you to  set them up. As all these things are constantly changing, your first question cannot really be answered in a way that will have any lasting usefulness; such questions are discouraged on Stack Exchange.

For your second question: this is an ASIC device that is capable of running SHA256 and nothing else. You cannot use it to mine scrypt coins.


Can I upgrade the software on Cointerra TerraMiner IV? I got in to bitcoin mining about a year ago by purchasing a used Cointerra TerraMiner IV. The price of bitcoin was higher than the electricity cost to run the machine. I don't know a lot about the internals of the machine, but I know it's 4 GoldStrike I 28nm ASIC boards (2 per board) controlled by an embedded linux beaglebone board. With the current news about the Bitcoin/XT split, I'm wondering if it's possible to upgrade the mining software to support XT.

I'm not too familiar with ASIC boards—does "application-specific" exclude Bitcoin XT in this case?

My background: Computer Science/Software Engineering/Internet Security Research

The miner does not need a software upgrade to mine with Bitcoin XT.  The pool or whichever mining solution you choose would need to connect to a Bitcoin XT node rather than a Bitcoin core node.


How to test 12 words passphrase for a Bitcoin address? I read same passphrase can be used on more wallet. How can I check passphrase goes with address without sending money, without the risk someone observe the passphrase?

By passphrase I assume you mean the mnemonic.

If your wallet software supports creating multiple wallets, you can just make another wallet and just use the same mnemonic. Instead of creating a new wallet, you restore a wallet from the seed. To your software, it will be another wallet because it is stored in a different file.

Or you can download another wallet software and restore your mnemonic to a wallet with that other software. Note that that wallet must support using a mnemonic and uses the same format. Most wallets use BIP 39 mnemonics, however Electrum does not so you cannot restore an Electrum mnemonic to another wallet.

You should see the same addresses either way.


What does this comment in Chainparams.cpp mean? There is a comment in the Bitcoin source code under src/chainparams.cpp

/**
 * Build the genesis block. Note that the output of its generation
 * transaction cannot be spent since it did not originally exist in the
 * database.
 *
 * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
 *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
 *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
 *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
 *   vMerkleTree: 4a5e1e
 */

What exactly does this value refer to?

coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

The original 50 BTC coinbase is not spendable since it was not included in the UTXO set. Any transaction trying to spend it would be invalid, since the previous output from the coinbase tx does not exist in the utxo set.

The hex string is an encoding of The Times 03/Jan/2009 Chancellor on brink of second bailout for banks, along with the regular coinbase params. It is essentially a marker that proves that the chain was not premined before 03/01/2009 by including the headline from a paper on that day.


Do testnet networks require the same main network fee? As in the title, I'm wondering if testnet networks always require the same fee.

I know the coins aren't worth any thing, so it doesn't matter if I have to pay the fee or not, but I'm just curious.

I would say so. I can't find any code that make fees lower or optional for testnet users.

However, it's substantially easier to send a free transaction.

inline bool AllowFree(double dPriority)
{
    // Large (in bytes) low-priority (new, small-coin) transactions
    // need a fee.
    return dPriority > COIN * 144 / 250;
}

dPriority is higher for larger amounts. Testnet coins are worth much less, so you're more likely to send lots of them around. For example, if you sent 50 testnet coins half an hour after you got them, that would be eligible for a free transaction.


What exactly does the "For each input, if the referenced output exists in any other tx in the pool, reject this transaction." tx validation rule mean? I am currently following the "tx" messages section of en.bitcoin.it/wiki website, and I need some clarity about the following rule regarding the validity of a transaction:

For each input, if the referenced output exists in any other tx in the pool, reject this transaction.

I don't really understand which of these two interpretations is meant here:

The output referenced by the input must not be referenced by another input of a transaction already in the pool.
The output referenced by the input must not be present in a transaction already in the pool.

Or perhaps it means something else entirely?

First of all a meta note: lots of information on https://bitcoin.it is seriously outdated, including this.

I don't really understand which of these two interpretations is meant here:

The output referenced by the input must not be referenced by another input of a transaction already in the pool.
The output referenced by the input must not be present in a transaction already in

What is meant is (1). For a transaction to be acceptable, all outputs referred to by its inputs must exist (created by an output of a transaction that's either in the blockchain or in the mempool), and those outputs cannot be spent already (by an input of a transaction either in the blockchain or already in the mempool). A simpler way to state this would perhaps be: if all transactions currently in the mempool would confirm, the inputs of the transaction that is being verified must refer to outputs that still exist.
This isn't exactly true anymore. BIP125 (Replace-by-fee) will in some cases permit a transaction to be accepted when the mempool already has a transaction spending one of its inputs. In that case, the older transaction is removed and replaced with the newer one.


ATI OpenCL V.S. NVidia Cuda Cores First of all, i would like to say, i really don't want this thread to be some debate about your favorite video card manufacturer. So please just take that elsewhere.

I have heard from a lot of people that ATI & Open CL is much better for mining than NVidia with Cuda.

When i first heard this i was kind of shocked, because pretty much everything i have ever heard in the past was that Nvidia's Cuda was quite powerful at solving mathematical problems, and I even had a couple university professors that swore by Nvida cards over ATI for this very reason.

So what is it, about the Bitcoin and Litecoin algorithms that make it so much easier for ATI cards, or should i say harder for NVidia cards?  I want to understand the technical reason behind the common knowledge.

Thanks.

In many ways, it is just coincidental that GPUs are going at hashing. It doesn't surprise me that some GPU engines are a better fit than others. A particular GPU might be very good at some types of mathematical operations (or rendering, for that matter) but might not be particularly good for hashing.
This is discussed in some detail on the bitcoin.it wiki:

Firstly, AMD designs GPUs with many simple ALUs/shaders (VLIW design) that run at a relatively low frequency clock (typically 1120-3200 ALUs at 625-900 MHz), whereas Nvidia's microarchitecture consists of fewer more complex ALUs and tries to compensate with a higher shader clock (typically 448-1024 ALUs at 1150-1544 MHz). Because of this VLIW vs. non-VLIW difference, Nvidia uses up more square millimeters of die space per ALU, hence can pack fewer of them per chip, and they hit the frequency wall sooner than AMD which prevents them from increasing the clock high enough to match or surpass AMD's performance. This translates to a raw ALU performance advantage for AMD:

AMD Radeon HD 6990: 3072 ALUs x 830 MHz = 2550 billion 32-bit instruction per second
( Nvidia GTX 590: 1024 ALUs x 1214 MHz = 1243 billion 32-bit instruction per second

This approximate 2x-3x performance difference exists across the entire range of AMD and Nvidia GPUs. It is very visible in all ALU-bound GPGPU workloads such as Bitcoin, password bruteforcers, etc.
Secondly, another difference favoring Bitcoin mining on AMD GPUs instead of Nvidia's is that the mining algorithm is based on SHA-256, which makes heavy use of the 32-bit integer right rotate operation. This operation can be implemented as a single hardware instruction on AMD GPUs (BIT_ALIGN_INT), but requires three separate hardware instructions to be emulated on Nvidia GPUs (2 shifts + 1 add). ?This alone gives AMD another 1.7x performance advantage (~1900 instructions instead of ~3250 to execute the SHA-256 compression function).
Combined together, these 2 factors make AMD GPUs overall 3x-5x faster when mining Bitcoins.

This is also discussed in a bitcoin talk thread.


How does Stellar multi-signing happen practically? In Blog we read, that Government & NGO came together to sign the transaction, and in docs we read that transaction is invalid if it includes signatures that aren't needed to authorize the transaction and that a transaction envelope wraps a transaction with a set of signatures. But how does the multi-signing process is intended to happen practically?

Let's say I make a transaction that required my and friend's signature, I sign it and publish it. Does it fail because of missing signature? Is my friend notified through stellar that there's a transaction that requires his signature, thus "inviting" him to take a look at it? Can my enemy find it and sign it to deny me contracts? And in case of 20 signers? And in case someone doesn't sign, when does transaction fails? Can he not-sign it in a way to fail the transaction before set expiration time?

The coordination of the tx envelope before it has the right number of signers happens by some other channel. If you and your friend both need to sign for any tx from an account, you would sign it and then email or IM the tx_blob to your friend. Your friend would then add their signature to the tx_blob and submit.

If your enemy signs a tx you can simply remove your enemy's signature before submitting it to the network.

If someone doesn't sign then the server you submit the tx to will reject it immediately.

Source: Multisig and Simple Contracts


How is a bitcoin transaction validated? w.r.t. a bitcoin transaction, I am really struggling to understand how does bitcoin network validate that I 1) have the bitcoin that I want to send, and 2) haven’t already sent it to someone else.

If my account balance was being kept track of then it would have been easy. The nodes would do a simple if check to test if I have sufficient balance in my account before I spend any money. But as I have learnt a bitcoin transaction destroys bitcoins and generates new ones (UTXO). So a transaction looks like:

FromAddress, ToAddress, Id_of_Bitcoin_being_destroyed, Id_of_bitcoin_being_created

The above assumes that I have the exact change I want to pay - since that is sufficient for purposes of my question.

So now before committing this transaction, the nodes need to verify:

isDestroyed(Id_of_Bitcoin_being_destroyed) == false; i.e. coin has not been spent already

Owner(Id_of_Bitcoin_being_destroyed) == me; i.e., coin belongs to me

could someone please explain in detail how is this happening?

Is a node doing a reverse table scan (i.e., scan the blockchain starting from most recent transaction to oldest one) until it locates Id_of_Bitcoin_being_destroyed? Then it can answer both questions above. However, this algorithm cannot scale at all and is the crux of what I am trying to understand.

To make it concrete lets say Id_of_Bitcoin_being_destroyed = 1234. A reverse table scan happens and following record is located:

From:Me, To:Brian, 1234, 5678

The node detects I have already spent the coin and transaction fails.

Another example. In this case a reverse table scan finds:

From:Brian, To:Me, 5678, 1234

The node can say with confidence that I own the coin and it has not been spent.

I have sincerely tried very hard to understand this and find the answer online including looking at [1, 2] but was unsuccessful. E.g., 1 just says this:

  This transaction can be validated – that is, it can be confirmed that
  I own the bitcoin that I am transferring to you, and that I haven’t
  already sent it to someone else – by plugging the signature and my
  public key (which everyone knows) into the bitcoin program.

But this leaves much unexplained to me.

Nodes maintain multiple databases, they do not just store the blockchain and scan it every time it wants to do something. These databases include a block index (so that it knows where to find a block) and the UTXO set. The database containing the UTXO set is what matters here. That database contains the identifiers for every single UTXO and the UTXO itself. A UTXO consists of a spending condition (known as the scriptPubKey) and an amount.

A node will begin building its UTXO database when it starts syncing the blockchain. As it validates blocks, it goes through every transaction in that block and adds to its UTXO database the outputs that every transaction creates. It also removes every UTXO that is spent by a transaction. So once a node is fully synced, the UTXO database contains every Unspent Transaction Output in a way that is easy to lookup.

So when validating a transaction, to determine whether the inputs have not yet been spent, the node will try to find the UTXO using the txid and output index (a UTXO's unique identifiers) in its UTXO database. If it is successful and gets exactly one result, then it knows that the UTXO has not been spent. If it gets no results, the UTXO has already been spent and thus the transaction can be marked invalid.

Once the node has the UTXO for an input, it can proceed to verify that the input satisfies the spending conditions. The spending conditions are contained within the UTXO in a field known as the scriptPubKey. The scriptPubKey is a script written in Bitcoin's transaction scripting language. It is half of a program. When combined with the scriptSig that is provided in the transaction input, the program should be complete and executable.

So the node will (essentially) take the scriptSig, append the scriptPubKey to the end of it, and execute the resulting program. If that program completes execution and returns true, then the script is valid and the spending conditions have been met. Thus that input is valid. If all inputs are valid, and the rest of the transaction checks pass (locktime checks, outputs have valid amounts, etc.) then the entire transaction is accepted as valid.

If you noticed, I mentioned that UTXOs have spending constraints, not owners. This is because UTXOs don't have owners. Some can be spent by anybody because the spending constraint says that anyone can spend the output. All that a node cares about is that the spending constraints are met.

But we as humans care about owners, so there are a subset of spending constraints that are commonly used to indicate that someone is an "owner" of a UTXO and is the only person allowed to spend it. These spending constraints basically say the following:

"in order to spend this output, the spender must provide both a public key which matches this particular hash  and a signature over the spending transaction produced with the private key of the public key with the aforementioned hash"

This spending condition can be abstracted into human terms as saying "the person with the private key that corresponds to the public key whose hash is in the script owns that output".


Issue running cgminer from crontab I trying to script the launch of cgminer based on a crontab.

Using a crontab entry that fires up a bash shell script that launches cgminer. Running the script directly launches cgminer flawlessly. Running the script from crontab always give the "no gpus usable" error.

I have triple checked that all vars are set (DISPLAY, GPU_MAX_ALLOC_PERCENT, GPU_USE_SYNC_OBJECTS=1), that the paths are correct, etc.

The entry is in the crontab accessible when being (sudo -s).

Any clues on what could be wrong ?

Again, drivers and SDK are installed correctly as everything works correctly when I launch the script manually.

The script launches cgminer with a basic cmd :

cd dir_where_cgminer_is_stored
./cgminer -c /folder/myconfig.conf

Thanks

Actually, I forgot to start cgminer with the user running X (being autologged in).

Doing

su user_running_the_x_session -c "/home/user/mine.sh"

worked perfectly.

BTW Art Shayderov, yes, cron is used for repeated jobs, like for example the one I am talking about here ;)


How do blocks signal whether it supports segwit for the 95% threshold? Ideally, I'd also like to see graphs that indicate how close we are to segwit adoption and the number of minimum blocks we are away from actual segwit adoption.

BIP141 – Deployment says:

This BIP will be deployed by "version bits" BIP9 with the name "segwit" and using bit 1.
For Bitcoin mainnet, the BIP9 starttime will be midnight 15 november 2016 UTC (Epoch timestamp 1479168000) and BIP9 timeout will be midnight 15 november 2017 UTC (Epoch timestamp 1510704000).

As we're currently on the second version of blocks, the version field will be showing 0x20000002 when signaling readiness for segwit and 0x20000000 when not. Readiness for segwit2x would show as 0x20000010 if only signaling bit 4 or 0x20000012 if signaling both bit 1 and bit 4.
BIP 9 requires 95% readiness signaled over one difficulty period (from reset to reset). Once that is achieved, SegWit will be activated on the network after the following difficulty period has passed.
It appears that Coin.Dance will show support in the linked graph, as indicated by the footnote "BIP 141 (voting starts on 2016-11-15)".
Note: In BIP9 signaling readiness only starts with the first difficulty retarget after the starttime. In the case of SegWit this is likely to be around the 19th of November.


Mtgox account verification pending, how to withdraw my bitcoins? I had submitted my personal document for verification over 30 days; however, my account still pending for verification, what I can do to withdraw my bitcoin?

all the new accounts created since a few months have to be verified for any withdrawals, including bitcoins, as stated in a big warning on every page of mtgox :

"Attention Users: All withdrawals and deposits require account verification."

so yes you ll have to wait for your verification to be processed before you can withdraw anything.

the delays seem to be around 5-6 weeks, so . ..  if you already waited one month you should soon get an answer, you will  receive an email when your verification is processed.


0 Payout at litecoin pool with a processing power of 1.6 Mh/s. Why? Recently I managed to get my hands on 10 servers with 32 cores each and 128GB ram each. I realised that in 10 hours of working at 100% I had mined exactly 0 litecoins using a p2pool. I think it's called mint.

I was delivering an average of 1,6 MH/s to the pool. I was in the TOP 3 active miners of the pool.

My mining layout is: One CPUminer (minerd) per server with one thread per core all pointing to the same pool with the same username (litecoin wallet address).

Does anyone have any clue why this is happening? Is it a technical problem or was I just purely and simply tricked?

According to the crypto-coins' profitability calculator coinwarz, with that much hash power you could have a gross daily earning of about US $14 should you mine Dogecoins and not Litecoins. Mining Litecoins instead, theoretically you could earn about US $11 per day.

Most of the times it's much more profitable to mine an alt-coin than the grand-daddies of them all (i.e. Bitecoin and Litecoin). The problem is, of course, you need to have wallets for those alt-coins and open an account at an exchange that accepts them to get bitcoins or dollars for them.

How many blocks per day is your pool finding? You won't be paid at all until/unless your pool finds a block.  That statistic will give you an idea of how often you'd be paid.

In "normal" pools the whole blocks' reward goes to the pool administrator who then pays miners their share -according to the hash power they've provided- minus his fee, so there's a bag of coins (coming from fees) whence to pay you should the pool find no blocks in some time.

Since p2pools lack (by design) a central administrator, you're forced to wait until it finds a block. The pro is you don't have to trust an admin. to be fair and honest, only source code you can audit/inspect should you know how to.


Bitcoin.conf doesn't exist in my Windows 10 I am in dire need to prune the blockchain because of the storage space on my computer being completely clogged up now. But I cannot locate the files. I have found the directory, but the bitcoin.conf file simply doesn't exist. Please help me!

In Bitcoin Core, go to Settings > Options and click the button labeled "Open Configuration File". This will make a bitcoin.conf file and open it in a text editor. Add the lines that you want (probably prune=550) and save the file. Then restart Bitcoin Core.


I've seen a transaction with 24 ancestors in the mempool, Is there a sensible use of this? I've seen a transaction with 24 ancestors in thee mempool, Is there a sensible use of this? Or is a kind of spam or something else?

It got mined on block 613101

$ getmempoolentry 132c52367b5e8c6abe87eee8bc60032c58f3d1296b8ca216373d924d94013d45

{
  "fees": {
    "base": 0.00000202,
    "modified": 0.00000202,
    "ancestor": 0.00019743,
    "descendant": 0.00000202
  },
  "size": 202,
  "fee": 0.00000202,
  "modifiedfee": 0.00000202,
  "time": 1579178958,
  "height": 613089,
  "descendantcount": 1,
  "descendantsize": 202,
  "descendantfees": 202,
>  "ancestorcount": 24,
  "ancestorsize": 4848,
  "ancestorfees": 19743,
  "wtxid": "34799217c58ef6da2417db2cc7ddf0715f9d0ab86926b3fd99e23e1ce92968c4",
  "depends": [
    "676a48b91e030f2d757b9ae877d452b0d88a3304d19f0960d988d69fc9c180f2"
  ],
  "spentby": [
  ],
  "bip125-replaceable": false
}

Looking at the ancestor transactions this looks like someone is writing chunks of data to the chain.

The couple of transactions I looked at all have an OP_RETURN output and then send to bc1qraz56wyj28km560u2pyyml9dr3uaxv9sts67ct, chaining them together.

Looking at the OP_RETURN data, this could also be some kind of timestamping or another sort of anchoring as the data doesn't look random:

000c486100023...
000c487000029...
000c48740002e...
000c487500024...
000c48780002f...
000c487b0002a...
000c487e0002a...
000c48810002c...

It's hard to say. Maybe someone else has more insight into this.


Is stack overflow reputation actually a Cryptocurrency? In a way, it is already a currency since I can offer a bounty for my question.

So is it correct to call reputation points from StackExchange a Cryptocurrency?

If not, then why?

No, it is not accurate to call the reputation system a cryptocurrency.

Cryptocurrencies use a distributed form of updating the ledger of ownership, not controlled by any one person. Stack Exchange reputation points are just an online point system maintained and controlled by the Stack Exchange company. The two are very different.

Cryptocurrencies also typically have a blockchain, and are transferrable at any time between any two persons. With SE Rep, you can only transfer if you do a bounty. And SE rep can be created out of thin air for someone answering a question well. Cryptocurrencies have a supply that is carefully controlled by code, and can only be created by solving a block.


Bitcoind Testnet time/timereceived constantly changing? I've got a small question: over a week ago I did some transactions on the Bitcoin testnet as I am developing a new GUI header for full nodes. When continuing development today, I noticed that when running the command 'listtransactions' the fields 'time' and 'timereceived' are different from what they were last week.

When checking the transaction ID on this website, it shows the date corresponding with what I receive when using listtransactions.

Can anyone explain to me why the time/timereceived fields changed and why they are so far off from when I actually did the transaction?

Some additional info:

I started my node on the testnet today for the first time since a
week
Actual transaction happened last week on (I think) tuesday
around 13:00 Amsterdam time

"time" is a Unix epoch time when the transaction was added to the wallet

"receivedtime" is A Unix epoch time when the transaction was detected by the local node or the time of the block on the local best blockchain that included the transaction. Not returned to move category payments


Is it possible to design a hardware wallet that can allow operation of a routing Lightning node with the security level of a hardware wallet? I'm wondering if its possible to design a hardware wallet such that it can be used for a Lightning node that routes payments for their channel partners such that their funds can never be stolen even if their main machine has been kernel hacked.

I'm thinking that this is how it might work:

The hardware wallet would receive a signed transaction originating from its source channel-partner AND an unsigned transaction (to sign) sending to its destination channel-partner.
The hardware wallet verifies that the sum of the amounts of both transactions sum to greater than 0 (ie verifying that the node isn't losing funds by signing this transaction), verifies that the inputs are valid (using SPV), verifies that both transactions requires the same hash-secret to unlock, and verifies that its only sending to a multi-sig address that requires its private key to unlock
The hardware wallet then signs the unsigned requested transaction and gives it back to the Lightning Client to send

It seems like if a hardware wallet did this kind of verification, it would be safe to have a routing Lightning node that interacted with an always-connected hardware wallet with the level of security that a normal hardware wallet has. Is something along these lines possible?

Yes, a hardware wallet could be designed for use on the Lighting Network, but no, there's no such thing as eliminating risk of theft.  There is always risk of theft, no matter what you do.

A hardware wallet could be made to sign the transactions needed to construct the smart contracts for lightning channels, and could even be made to communicate with them.  This would keep the private keys out of the memory of the computer running the lightning node, thus reducing the risk...but not eliminating it.

There is always the chance that the protocol used to communicate to with the wallet is vulnerable to exploitation, or even the hardware wallet itself.  Even if the vulnerability didn't compromise the wallet, but merely rendered it inoperable for a time, an attack could be crafted where you end up forfeiting your money in the channel because you are unable to sign transactions.

Our technology is built on layers on top of layers on top of layers on top of layers.  Hardware wallets and tier 2 smart contract networks are no exception.  Anyone who tells you it is risk-free is selling something.


Is this a usable systemd startup script for bitcoind? The script here in the official github repo

https://github.com/bitcoin/bitcoin/blob/0.13/contrib/init/bitcoind.service

looks like a systemd startupscript to me. However, it's from 2014.

Can I put this into my /etc/systemd/system directory as a bitcoind.service startscript and enable it? Or do I have to configure something extra?

This what the source code of the script looks like in Sept 2017:

[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target

[Service]
User=bitcoin
Group=bitcoin

Type=forking
PIDFile=/var/lib/bitcoind/bitcoind.pid
ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=2s
StartLimitInterval=120s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

The script mentions a config-file -conf=/etc/bitcoin/bitcoin.conf - but I'm on Ubuntu/Debian, and the bitcoind package does not create a /etc/bitcoin/bitcoin.conf file.

What should I put it in there? Or should I leave it empty?

(I've already read this related question: Newbie question, bitcoind installation doubte )

Ahh there is already a pull request from June 2017 discussing various topics:

https://github.com/bitcoin/bitcoin/pull/10529/files

They propose, for instance, to rename /etc/bitcoin to /etc/bitcoind, for consistency reasons.

I haven't tested this particular systemd service file, but from my experience in Ubuntu, you need to create the directory structure beforehand and the user running bitcoind would need write permissions to /var/lib/bitcoind/. Otherwise the service will end with errors and will not run.

If you start bitcoind as user bitcoin, the daemon by default will look for and use /home/bitcoin/.bitcoin, which will inherently have write access. For simplicity, I suggest you point to the .conf created in this directory. I also suggest placing the pid file in this location.

I am not aware of any security vulnerabilities of using the user's home directory for -datadir and -pid, as those locations need to be write accessible to user bitcoin wherever you put them anyway; I'd actually like to see a discussion on this topic. Using the settings suggested in that systemd service file would mean you'd have to give user bitcoin write access inside a directory that is normally modifiable by root only.

Consequently, I suggest a slightly modified systemd service file:

[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target

[Service]
User=bitcoin
Group=bitcoin

Type=forking
ExecStart=/usr/bin/bitcoind -daemon -pid=/home/bitcoin/.bitcoin/bitcoind.pid \
-conf=/home/bitcoin/.bitcoin/bitcoin.conf -datadir=/home/bitcoin/.bitcoin -disablewallet
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=2s
StartLimitInterval=120s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target

Note that if you place PIDFile= before ExecStart= you will get a warning in the log, but the service will run anyway.

There is this current template https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service,
maybe you can take some security improvements from there as well. This template uses RuntimeDirectory=bitcoind to create /run/bitcoind owned by bitcoin (and places the pid file in there). It places bitcoin.conf probably in a read only environment, and ommits -datadir, which will in this case default to /home/bitcoin/.bitcoin.


Trouble running bitcoin unit tests with test_bitcoin on Ubuntu From Bitcoin Core's test directory (bitcoin/src/test), the executable test_bitcoin is supposed to run the unit tests. When I run test_bitcoin, however, I get:

replication requires locking support
Test setup error: std::runtime_error: CDBEnv::MakeMock : Error 22 opening database environment.

How can I run test_bitcoin? I installed Bitcoin from source.

Also:

I ran configure using the --with-incompatible-bdb flag.

Try installing the correct version of BerkleyDB. (4.8) I have the correct .debs in this repository:

http://github.com/nickodell/build_bitcoin

You may need to uninstall the newer version of libdb first.


Is it possible to use the RPC's Label feature in it's current state over the deprecated Accounts feature? I'm doing my bachelor project in web development using Bitcoin RPC. At the moment it uses the deprecated accounts feature, but i'd really like to upgrade to using the newer label feature instead. However is it currently useable on the master branch, or should i wait until v0.17 is fully released? (this is unfortunately after my hand-in date), so if that's the case, i guess i have to stick to using accounts?

Sources:
https://github.com/bitcoin/bitcoin/pull/7729
https://github.com/bitcoin/bitcoin/pull/12953

Yes, you can use the current Labels function as it is now.


How to save the mempool information immediately before the node receives a block? I want to use Bitcoin RPC API 'getrawmempool' to save the snapshot of the mempool immediately before my full node receives a block. This requires modification of the Bitcoin source code. How should I modify it? Who can help me very kindly?

You can use zmqpubsequence to get updates of all transactions added/removed to/from mempool and blocks received.
Example:
Save zmqpubsequence=tcp://127.0.0.1:28332 in bitcoin.conf
Run below python code:
import binascii
import asyncio
import zmq
import zmq.asyncio
import signal
import struct
import sys

if (sys.version_info.major, sys.version_info.minor) < (3, 5):
    print("This example only works with Python 3.5 and greater")
    sys.exit(1)

port = 28332

class ZMQHandler():
    def __init__(self):
        self.loop = asyncio.get_event_loop()
        self.zmqContext = zmq.asyncio.Context()

        self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
        self.zmqSubSocket.setsockopt(zmq.RCVHWM, 0)
        self.zmqSubSocket.setsockopt_string(zmq.SUBSCRIBE, "sequence")
        self.zmqSubSocket.connect("tcp://127.0.0.1:%i" % port)

    async def handle(self) :
        topic, body, seq = await self.zmqSubSocket.recv_multipart()
        sequence = "Unknown"
        if topic == b"sequence":
            hash = binascii.hexlify(body[:32])
            label = chr(body[32])
            mempool_sequence = None if len(body) != 32+1+8 else struct.unpack("<Q", body[32+1:])[0]
            print('- SEQUENCE ('+sequence+') -')
            print(hash, label, mempool_sequence)
        # schedule ourselves to receive the next message
        asyncio.ensure_future(self.handle())

    def start(self):
        self.loop.add_signal_handler(signal.SIGINT, self.stop)
        self.loop.create_task(self.handle())
        self.loop.run_forever()

    def stop(self):
        self.loop.stop()
        self.zmqContext.destroy()

daemon = ZMQHandler()
daemon.start()

Source: https://github.com/bitcoin/bitcoin/blob/master/contrib/zmq/zmq_sub.py
python3 zmqtest.py
b'0000000000000020dd401c162d8514e7cc13a2aa123fbdaab05e117defe4fa45' C None
- SEQUENCE (Unknown) -
b'034c21d4ea43da1640baeed6a5b5da7d9581f946187840326a55a3fff652f896' A 1
- SEQUENCE (Unknown) -
b'507ec9296156c3925c6e2852284eeb07838480202d80eeb0718fc271e5c5a7e6' A 2
- SEQUENCE (Unknown) -
b'8da15cc34a0a16ef4160648a387afb98a212f4d93844c0b837ce156f3d40b70e' A 3
- SEQUENCE (Unknown) -
b'47134355caf0539bf1bb3c9496eb212318ed64f26bf8f7654026a7254fe8a3b1' A 4
- SEQUENCE (Unknown) -
b'044a56e511b1ff097c528cee053c8b4d0b97fe4237308f00d9714eca99ed7d58' A 5
- SEQUENCE (Unknown) -
b'a6edd6322b02e95a10890a811c6d0a8899d30874c8e2b02a017d785ee4ee5c80' A 6
- SEQUENCE (Unknown) -
b'4790472baba9c5860805fa3258d85d50bfa607f1ce8437ef2c4a3c6b503a8b86' A 7
- SEQUENCE (Unknown) -
b'ca82da8ee0e982995f7dd0a98580c102ae4adc4f8edf29ca64b98b1f3f1be751' A 8
- SEQUENCE (Unknown) -
b'1bcde3da8835980b8b884ba58bd36884fb5265fa6a06aabaabc8cf7517ce58ee' A 9
- SEQUENCE (Unknown) -
b'5a0d816ff22037c04d10597496c05bce9e72c6b379e33e24196902c64e2429dc' A 10
- SEQUENCE (Unknown) -
b'd0ddd43dafefb4230a3f71bd026bf7cf5e740d23163f95b809620fefeca9b0eb' A 11
- SEQUENCE (Unknown) -
b'a186fd5560d6def8eace6e9aa4a370c49cfcdbfb7883988697e9d008d1c81f73' A 12
- SEQUENCE (Unknown) -
b'40f790b2823b55ef21544f284e3381dcccd387c44512a2518edc0d64b7c78ff8' A 13
- SEQUENCE (Unknown) -
b'24fef1ea3a3058ec23015ae01788a9386fd937646dcc0ebc30d4078d4fd0ab83' A 14
- SEQUENCE (Unknown) -
b'245661a7e1a099b636541e80933720040b947efd8d63e96bae6a627ed5024d31' A 15
- SEQUENCE (Unknown) -
b'200e1379db62a299c4df69b2543ac9acc538cddd52bbc2000a40878a246ad5d2' A 16
- SEQUENCE (Unknown) -
b'37d8b02e67d30583ebfc41861c64a8bf0e10daec25366976ed002f8fa76e8300' A 17
- SEQUENCE (Unknown) -
b'677f74c4412d317921528809e983ccd57d1d387760614a99606d1d651bbdcb76' A 18
- SEQUENCE (Unknown) -
b'5c490f86c11c372d2cfd395020eb2a3726970f64829c7254f99520c8e9e9fa02' A 19
- SEQUENCE (Unknown) -
b'a176e21826a217cda3d3ef59393a9ba293ab7ca238f17b3a945a0928e172221d' A 20
- SEQUENCE (Unknown) -
b'7bc33a81ee5c5cd5083ef11e6a9d0d50fbe081fad0bf9d2f4c980f228a32f5a7' A 21
- SEQUENCE (Unknown) -
b'18f5d3c96a66a75d20f8f19c4a1d1eff28488610d8ac1241865e5d7b7a94bfbc' A 22
- SEQUENCE (Unknown) -
b'd14f474c19d0814c23f742f5bf7372dda29f872c072bbb7e25e97409020e4299' A 23
- SEQUENCE (Unknown) -
b'00000000000000046fbd9d36c40562094bf0049ead63e5311ac515123baf5789' C None

How to save the mempool information immediately before the node receives a block?

In the above results, Block 00000000000000046fbd9d36c40562094bf0049ead63e5311ac515123baf5789 was received and 23 transactions were added to mempool before it.
If a transaction is removed from mempool, python script will print:
b'TX_ID' R SEQ_NUMBER

Hope this helps although its not necessary that transactions between 2 blocks printed by the zmq python script will be same as getrawmempool results at that moment. The script will only print additiion and removal of transactions in sequence.


How is the blockchain used with the Brave browser? I am not sure if here is the correct place to ask this question. I just want to know if there is someone who is familiar with this topic and if they do, they can answer the question here.

There does not seem to be any detailed information regarding this point when it comes to Brave browsers on the Internet. Even this quora question does not have any answers despite the number of followers.

I would appreciate any answers regarding this issue.

Looking at the Payments tab under Brave's preferences helps to clarify the blockchain aspect quite a bit. Basically: Brave Payments is an attempt to replace the necessity of running advertisements for publications you visit to pay their bills and feed their staff. The BAT token, which is traded on markets and holds value, is used to make micropayments to publishers who's work you're viewing online. These numbers aren't accurate at all, but, for example: You load 50 BAT into your browser's wallet. If you spend 4 minutes reading an article from TheFutureOfNews.eth, you will transfer 0.1 BAT to that publisher. This way, incentive is created for work to be created and viewed, without the need for obtrusive advertising in between the viewer and creator.

As the BAT token and Brave browser are a web3 project, the proper place for the question would be over at https://ethereum.stackexchange.com/ .


Do I need to register my shiny new Crypto with some agency if I want to pay someone with it? While I am guessing that, as most anyone can create a crypto and sell it or accept it as a form of payment, that it would be legal to give crypto as a form of payment (as bitcoin originally did with the Pizzas). However with SEC (or possibly some other government body) wanting to regulate and/or tax cryptos I wonder, am I allowed to give crypto as a form of payment without some sort of registering it with a government agency? I have not found any laws prohibiting it and can only find info about registering ICOs with SEC (in the US). Any thoughts?

If you agree to buy your neighbour's old lawnmower using buttons and lint as payment, the SEC don't want or need to know about your novel form of payment.
The same generally applies to other forms of payment.
Generally where a taxable event occurs, you have to work out the equivalent amount in some government approved currency. For example, if the price of lint skyrockets and your US neighbour sells her lint stockpile for huge profits, she'll probably have to work out the dollar equivalent and pay some sort of capital gains tax. But this is different from registering lint as a currency - you don't have to do that.
Where government agencies mostly like to be involved is when  you are setting up some sort of financial institution or money handling business like a payment processor. The creation of BItcoin did not involve the creation of any financial institutions or money handling businesses. In fact it was designed to do away with that sort of third-party that needs to be trusted. Such institutions may have crept in and taken over a lot of Bitcoin usage but that does not mean the SEC are after Nakamoto to register Bitcoin. If Nakamoto had needed to register Bitcoin in 195 countries beforehand, it would never have got started. Ditto any cryptocurrency or lint-based system invented today.
Of course all this depends greatly on jurisdiction. The rules in Burkina Faso may differ from those in Ecuador.


How to set fee in bitcoinj Is any possible way to set fee to specific value in bitcoinj wallet? Right now I have something like this and I don't know when to set fee:

    Address address = Address.fromBase58(params, destAddress);
    SendRequest req = SendRequest.to(address, Coin.valueOf(value));

    b_wallet.completeTx(req);
    peers.broadcastTransaction(req.tx);

It can be something like this,

req.fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;

REFERENCE_DEFAULT_MIN_TX_FEE refers to the minimum fee required to relay a transaction in a block which is set to 1000 Satoshis as of now.

One must remember that the transaction fee is like an incentive brought forward by the Bitcoin user to make sure that a particular transaction will get included into a block which is generated in future(and soon enough). Hence, an appropriate value of fees must be included with a transaction. Check FeesPerKB for this too.


Buying bitcoins in Zimbabwe I'd like to use US dollars to buy bitcoins in Zimbabwe. Does anyone know how I could do this or how to find bitcoin sellers in Zimbabwe?

You could use https://localbitcoins.com/ it's a bitcoin escrow service, YMMV, read up up how it works here.
They list Harare as a place where you can trade with locals.
May be good for small amounts.

That or if you can open an bank account in Europe, USA, Australia etc (You can often do that from a large bank in your home country), wire the money to that account, then use one of the larger exchanges; like most other people do. However, that could be rather expensive with international wire & exchange fees etc. Better for larger amounts.


Why can’t lightning tx’s be signed with sighash single to allow for fee updates? Are out-of-band fee payments to confirm a lightning closing transaction the only way to manage a situation where the sat/kw of a previously signed commitment tx are simply below market?

If additional inputs/outputs could be added, fees could be easily adjusted to the fee rate during channel closing and not at the time when the tx was signed...

Let's distinguish a couple cases:

Cooperative close

In the case of a cooperative close, the two channel partner can agree on any transaction they want. Thus, they can pick the fee rate on the spot. As the two outputs would likely not have any timelocks, either party could use child-pays-for-parent (CPFP) to bump the initial closing transaction. They could even issue an RBF transaction initially and update it later if it doesn't confirm quickly enough.

Unilateral close

The party that initiates the closing transaction has their funds locked to allow the counterparty to apply their breach-remedy if an old state was published. This means that traditionally only the counterparty can make use of CPFP to accelerate the closing transaction. This is inconvenient, because there wouldn't be a need for a unilateral close unless the counterparty were currently uncooperative.

The recent lnd 0.7.0 release notes mention that improvements were made to their transaction closing procedures to support both RBF and CPFP.


If I only know my private key, can I still login to my wallet, even if this requires some calculations? I keep my 12 word mnemonics carefully off line. But suppose I just had my private key left after some disaster or other could I then, after some procedures, log in to my wallet ? I can see that I can get from Private Key to Public Address by a Python Routine but then I seem to be unable to progress further.

Yes. The main idea of mnemonic backups is that the mnemonic encodes a master private key. All other addresses that your wallet generates are derived from this initial secret.
To recover your transaction history and funds, you would need to go further than just to derive a single public key. You would need to rederive all of the wallet's addresses and then search the blockchain for any transactions that pertain to these addresses. The simplest way to achieve a recovery would be to import the mnemonic into the same wallet software that created it, or another wallet that implements the same derivation scheme (of which there are multiple, unfortunately).
I'd recommend that you additionally note what software was used to create the mnemonic, (and which wallet software you used to transact from the mnemonic, if the two differ). If you know it, you might also want to note the derivation path with your backup.


Bitcoin-cli balance minconf When I use the getbalance command in bitcoin-cli and I set minconf to 1. Will it display the bitcoins with 1 confirmations and more? If this is true, what is a good amount of confirmations that will make the transaction safe but also fast?

To answer your question, yes, setting minconf to 1 will display the balance of your wallet that is summed up by combining the transactions in your wallet that have a minimum of 1 network confirmation.

Your secondary question is really a question between balancing the security of your transactions and the speed at which you wish to spend your funds, because waiting, say, 2 network confirmations will be faster (~20 minutes), but will not be confirmed long enough on the block chain for the transaction to be "secure".

This is essentially a form of the "50 percent attack":

An attacker that controls more than 50% of the network's computing power can, for the time that he is in control, exclude and modify the ordering of transactions. This allows him to:

Reverse transactions that he sends while he's in control. This has the potential to double-spend transactions that previously had already been seen in the block chain.
Prevent some or all transactions from gaining any confirmations
Prevent some or all other miners from mining any valid blocks

The attacker can't:

Reverse other people's transactions
Prevent transactions from being sent at all (they'll show as 0/unconfirmed)
Change the number of coins generated per block
Create coins out of thin air
Send coins that never belonged to him

With less than 50%, the same kind of attacks are possible, but with less than 100% rate of success. For example, someone with only 40% of the network computing power can overcome a 6-deep confirmed transaction with a 50% success rate.

It's much more difficult to change historical blocks, and it becomes exponentially more difficult the further back you go. As above, changing historical blocks only allows you to exclude and change the ordering of transactions. It's impossible to change blocks created before the last checkpoint.

Since this attack doesn't permit all that much power over the network, it is expected that no one will attempt it. A profit-seeking person will always gain more by just following the rules, and even someone trying to destroy the system will probably find other attacks more attractive. However, if this attack is successfully executed, it will be difficult or impossible to "untangle" the mess created -- any changes the attacker makes might become permanent.

The above was taken from https://en.bitcoin.it/wiki/Weaknesses

Hope this helps


Is it possible for an unsolvable block to exist? Is there a proof that the hashing will always yield a result? Or proof that there exist unsolvable blocks?
It's my understanding that even if we hit an unsolvable block that eventually the transactions in the block would change, so what's being hashed would change. Of course, that subsequent data could also be unsolvable... etc.
I'm just curious to what we do or do not know about the solvability of blocks.

It depends on what you mean. (Review: https://en.bitcoin.it/wiki/Block_hashing_algorithm)
Is it possible that with today's difficulty target a miner can exhaust the 32-bit nonce space in the block header without "solving" the block? Yes. But then the miner can change bits in the coinbase transaction (including a field unofficially called extraNonce), change a few bits in the version, increment the timestamp and then also like you mentioned, rearrange/add/remove transactions from the body of the block candidate. So depending on how restrictive you want to be with your question, a miner will never really run out of inputs to try.
But what about the output? A block is "solved" when it's hash, interpreted as a 32-byte integer, is less than a target value (also a 32-byte integer). So what we're looking for then is:
SHA256(data) < Target
This means there are many potential solutions for a block at any given time (all the 20-or-so-byte integer values less than the current target value). If it were impossible to find one single solution in this set that would mean that SHA256 is broken and does not have the random, evenly distributed output we think it does.


Tracing bitcoin wallet with the address I once created a bitcoin account and obtained an address. When i needed to transfer some bitcoin, i didn't check the address hoping it was active. After the transfer, I tried opening it but it did not. I thereafter created another account. What happens to my transfer?
Secondly, how do I use the address to locate the bitcoin wallet so my money wont be lost?
Thanks.

I once created a bitcoin account

This implies you created an account with an online business through a website. Perhaps they managed your money for you in their wallet. This is arguably the most insecure way for you to hold Bitcoin.

  and obtained an address

You don't mention a private-key. If you don't have sole control of your private-key from its creation until now, then you don't really own any bitcoin yourself.

  What happens to my transfer?

If you have an account (or two) with some online business, you have to contact them to find out what happened to any money you gave them.

If so, this isn't really a question about Bitcoin itself - which was designed to work without the need for any online business to hold your Bitcoins for you.

Bitcoin transactions cannot be reversed or cancelled. The Bitcoins are owned by anyone who knows the private-key for the address you sent Bitcoins to.

  how do I use the address to locate the bitcoin wallet so my money wont be lost?

You can't use an address to find a wallet.

You can look inside wallets to see which addresses they contain. If a wallet contains an address that matches the address you originally obtained - then you have found one of possibly several wallets that can spend the Bitcoins associated with that address.

20-30% of all Bitcoins are lost forever and can never be spent by anyone at all.


How can we trust any crypto currency if the NSA could use 51% attacks? My understanding of cryptocurrencies is that with the "51% attack" you can fake transactions and stop anybody from making any transactions. If any crypto currency actually threatens Government backed currencies then what would stop a company like the NSA from using their resources from attacking the currency? They have to have enough money and enough computing power if they are collecting all this data and are backed by the United States Government.

As mentioned in comments, the 51% attack doesn't let you fake transactions. You just take control of what gets in the blockchain from the moment the attack is realized.

As to realizing the attack, the current Bitcoin hashing power is about 60,000TH/s.

Right now, the more efficient mining rigs cost at least $2,000/TH/s. So just getting all that mining power would cost the NSA, or any similarly powerful actor, about $120M. That's assuming that so many miners can actually be sourced which is highly doubtful at the current production volume.

Then you'd have to factor in all the procurement, the time it takes to setup operations of that scale and the mind-boggling electricity bill. So it's probably a 2-3 years project with a half-billion dollars price attached.

And then what would be the NSA's motive? The dollar is doing just fine right now and the US government can control Bitcoin just as well is they want to do so.


IPAD lost with Ripple wallet Lost my Ipad with Toast ripple wallet. I have wallet address, recovery keys and phrase. Can I create a new wallet and send the coins from old to new?

You don't need to send the coins anywhere. Just recreate the old wallet with the recovery phrase.

Digital assets aren't literally in wallets. Wallets just hold the keys necessary to access to assets.


Why does getheaders P2P API return more than getblocks? I've been reading through the Bitcoin P2P protocol documentation as well as experimenting with Bitcore library but confused about one thing.

So getblocks seems to return inventory objects, which are just pointers, so you have to make another getdata request using those inventories to get the actual block.

And getheaders seems to return headers from starts to stop.

They act similar, except that getheaders returns more than just the pointers. I'm confused here because I feel like getheaders should be the "light mode" which only downloads small amount of data compared to getblocks. This is also shown by the fact that getheaders download up to 2000 headers by default while getblocks downloads up to only 500 inventories.

So am i misunderstanding any of this? Why does getheaders return more information than getblocks AND also return more results that getblocks (2000 vs 500)?

Really getblocks should have been called getblockhashes , as the response contains just block hashes, not full blocks.

Every block can be observed in three different ways:

The full block, containing all transactions and header information.
The block without the transactions, but just the 80-byte header which includes a Merkle root committing to the transactions.
Just the 32-byte hash of the block header (which is used to identify the whole block, and is thus also called the block hash).

getblocks was designed to be used for synchronizing blocks. The usual sequence was that node A would send a getblocks, B would respond with an inv with block hashes, A would reply with a getdata for each block he's missing, and B would send over the full blocks using block messages. The limit was 500, as downloading more than 500 blocks at once was presumably deemed too much and pointless (as that could be up to 500 MB of data).

getheaders on the other hand was designed for headers synchronization, something at the time only used by lightweight clients. These would not download (all) full blocks, and the headers sent in response would generally be the only futher communication. As headers are only 80 bytes per block, even 2000 of them is just 160 kB of data.

Since the introduction of headers-first synchronization (which essentially uses getheaders to learn about block hashes and headers simultaneously, and then download missing blocks from multiple peers at once), the old getblocks based synchronization is superseded (it's still implemented for compatibility with software that doesn't have headers-based sync, but other than that inferior in every way except implementation complexity).


Possible to move specific transaction from one account to another? I'm running bitcoind (0.8.0) and I'm wondering if there's a way to "move" a specific transaction from account A to account B (without actually broadcasting a new transaction). I know about the "move" command, but I can't target specific transactions with this.

Reason for this is that I'd like to use different accounts as "tags" for transactions. I want to have one single address for incoming transactions and then (after having processed them) tag them with different labels (accounts).

Is there any way to do this?
Thanks for your hints.

The only way to do that would be to change the account associated to the address that received the transaction. Have a look at setaccount.


51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily? I was shocked to see binance CZ comment to literally "roll back" the bitcoin chain by just "calling" in some favors from "friendly" Asian miners .

This ONE person could effectively do it???  I mean are we all in a bubble, in some kind of utopia then, to think that the chain's decentralization makes it "bulletproof" and resistant to collusion by miners?

(1) This is fundamental question:  How are our highly regarded and brilliant Devs of bitcoin explaining such situation where only a handful of persons´ interests could essentially be enough to do a majority 51% attack?

(2) And secondly, are there active debates about how to mitigate such situation in the future, what technical aspects implemented in the btc chain (or to be implemented) could be helpful?

This huge mining farms are essentially very disturbing. it is like  in proof of stake , where the "richest" has most power. And in the PoW mining case , its similiar just that the "biggest hardware" has most power.

we have to try somehow to eliminate such easily corruptible scenarios, right?

in todays digital world, there are plenty of collusion examples of even more than 1000 different persons involved.

Handful of colluding majority miners would be a piece of cake, right?

Thank you for explaining to me this issue . I hope sincerely that this is taken up by our awesome dev community, or maybe I am just misunderstanding everything.

Disclaimer: I believe this question may be primarily opinion-based and not very appropriate for this site, but there are a number of technical misunderstandings that can be clarified along with it, so I'll give it a shot.

There are many nuances involved here, and I fear that a large part of them didn't reach as much of an audience as the exchange announcing "we decided not to do it". I believe this was a poor choice of words, as the decision they made wasn't whether or not to roll back the chain; only whether or not to offer a bounty for doing so. I personally believe it would be very unlikely that the alternative would have actually resulted in a deep rollback.

Let's analyze the situation from a number of perspectives.

If we only consider miner's actions, is it theoretically possible for them to roll back the chain? Yes. If you're wondering if there is a small number of mining company CEOs in the world, which, if all together convinced, with complete disregard for their own financial interests, the health of the network, or legal repercussions, could decide to roll back the chain to a point before the theft, the answer is yes. This is the reason why people care about mining decentralization, and permissionlessness of entering the mining market. However, unless it's not just a majority of the hash rate that is on board with this, but actually close to all the network's hashrate (a substantially harder problem, as there are many small miners in addition to the few big ones), this would likely have take days or even weeks (if it's close to 50%), a time during which many things can happen - including a public outcry and a UASF-style fork to prevent the rollback from being accepted by the ecosystem. If considered over an even bigger timescale, events like this may even incentivize people and businesses to become miners, in order to reduce the influence of large pools.

Assuming miners maximize short-short term profit, would it be financially interesting to rollback? No. Even if we assume that everyone in the network is acting selfishly to try to maximize their own (short-term) profit, and ignores the protocol rules and the possible repercussions from doing so, it is not. By the time the information about the theft became known, the transaction was already confirmed several hours before. During those hours, miners had created dozens of blocks, which together earned several hundred BTC in subsidy and fees. The exchange would need to offer at least that amount to the affected miners, to compensate them for the income they'd lose from rolling back those blocks, before it would even be worth discussing. Let's call this the rollback cost R. As the stolen amount was in the thousands (let's call this S), that seems like a reasonable option. However, nothing prevents the thief from using (part of) the stolen funds to do the same. Every BTC offered by the exchange above R can be countered by an equivalent amount offered by the thief. And then it becomes clear that the thief has the upper hand: the exchange can at most gain S-R by a rollback, but the thief stands to gain S by not having a rollback. A theoretical possibility is a bidding war between the exchange and the thief, where both increase the amount paid to make miners act in their favor. The end game of this is that the exchange offers S-R, the thief offers slightly more and keeps R, and miners are paid S-R by the thief, and no rollback happens.

What would happen in the real world? Theoretical models are interesting to study, but in reality many more practical considerations exist. I believe those too are generally in favor of no rollback:

Coordination between distrusting miners (especially close 100% hashrate) is hard, and would take time. The more time it takes, the less advantageous a rollback becomes (see the above point), and the more damage would be done to the ecosystem (see the next point).
An hours-long (in the very best case) or a weeks-long (in the worst case) rollback would monumentally hurt the ecosystem, and likely undermine the public's confidence in the system to the extent that it would severely reduce the profitability of many parties involved (including miners and the exchange itself!).
Even ignoring all the above, miners may not be willing to take a bribe to rollback because of legal reasons if they're publicly known (which they mostly currently are). They may equally not want to take stolen money as a bribe, so this cuts in both directions. This point becomes weaker if the mining ecosystem is more decentralized, but that would also make coordination harder.
As I pointed out above, in the extreme scenario where such a rollback is actually happening, the public has time to react. If a sufficiently large group of economically relevant parties in the network refuse to accept the rollback, miners have no choice but to go along with that. This is a last-resort option, and likely damaging to the ecosystem on its own, but it is an option.

So to summarize: in theory there are absolutely ways in which a rollback could happen, and it's good to be aware of those. In reality, the security of the system relies on economic incentives already which are nontrivial to analyze. It however seems very unlikely that in the case of a theft a deep rollback is a reasonable outcome.


How to spend bitcoins From Account and specify Fee I am writing an application that uses bitcoin wallet accounts to specify what addresses belong to what user. I have been reading the documentation trying to find a way to spend Bitcoins specifying the account from, address to, and miners fee.

After reading the documentation, I think that is impossible, because there are only two ways:

The first one is using sendFrom, but you can't set the fee with this command. You could use settxfee but that is a changing number depending on the Kb's of the tx.
The second one is using CreateRawTransaction and SendRawTransaction, but in order to specify the inputs, there is no way to get the inputs, other than calling listunspent, but that returns the inputs for all wallets, and there is no way to tell that command to only return the unspent inputs for a specific account.

Is there really no way to send bitcoins from account specifying the fee?

Please don't use bitcoin cores accounting system anymore (especially for new projects). It has been deprecated (and might be removed in near future).

A way of solving your issue would be by calling getaddressesbyaccount (get addresses of a specific account) and then use listunspent with these addresses.
Then you could create your own coin selection and use createrawtransaction singrawtransaction and sendrawtransaction.


Bitcoin Core initialization taking forever Today is the third day, when I'm waiting for Bitcoin Core win-x64 application will sync/initialize. How long should I wait more?

Are you running the latest version? (0.12 is much faster than earlier versions) On decent PC hardware with decent internet connection it should finish well within a day, I think.

On a PC you might want to give bitcoind a bit more memory:

-dbcache=<n>    Set database cache size in megabytes (4 to 16384, default: 100)


What happens if a miner publishes a block which contains an invalid transaction? What happens if a miner (accidentally or maliciously) publishes a block with correct proof of works, which contains an invalid transaction (e.g., a double spending one)? Is the block ignored by the network?

A block with an invalid transaction is an invalid block, regardless of the proof of work.

When it is broadcast, other full nodes will ignore it as spam, and typically disconnect from the node that sent it.  A bad block is unlikely to propagate very far on the network.

When other miners see it, they will also ignore it.  If they mine on top of it, they will be wasting their hashing power.  This also means that the miner who did the proof of work on the invalid block has wasted their own hashing power.  This is why it's important that miners validate the transactions they include in blocks.


Formula for calculating daily mining earnings I have seen other formulas, but they all vary and don't work. Can someone please show me a formula where I can plug in the difficulty and hash rate and that will give me how many bitcoin I generate in a day.

I know there are online calculators, but I want a formula for a spreadsheet.
Thank you to all replies.

Let X be hashes per second, and Y be the difficulty. Let Z be the Log base 1-1/(2^32*Y) of 1/2. Z is how many hashes it will take you to find a block, on average. Let A be the current block reward (it's currently 25). Let B be the number of seconds in a 24-hour day: 86,400. You will earn, on average, A*X*B/Z bitcoins per day.


How do i install bitcoind on my redhat linux server? I have recently created an api that runs the bitcoind commands. I had it running on another server, but it was setup by someone else. I have been searching for sensible instructions on how to install bitcoind on my new server, but can't find any.

git clone git://github.com/bitcoin/bitcoin.git
cd bitcoin/src/
make -f makefile.unix
sudo cp bitcoind /usr/local/bin


Can one manually type the mined block on bitcoin core and broadcast it? I get that all miners compete to find the block first, which is then broadcasted to other nodes who then verify it. But what spikes my interest is would it be possible to broadcast the block to the blockchain without a miner's software's help? Can bitcoin core work alone for mining purposes?

Yes. Bitcoin Core has a RPC submitblock, which, as the name implies, allows you to provide a block to be submitted to the Bitcoin network.
In fact, Bitcoin Core supports the getblocktemplate protocol which means you can solo mine with Bitcoin Core. Furthermore, pools are probably running Bitcoin Core in their backend and their pool software just uses the getblocktemplate protocol to get the transactions for a block and prepare the work that is sent out to the actual miners.


how exactly was the original coefficient for difficulty determined? I'm assuming difficulty has a "target" of 10 minutes because the coefficient satoshi chose becomes multiplied by a variable to help the network remain in proportion. IE, if the network hashrate is 2x the previous network hashrate, bnProofOfWorkLimit is multiplied by the previous difficulty and also by 2, which is the measurement of how much faster the network is producing hashes.

This is pretty simple to understand. However, I've been wondering about how the original difficulty was chosen so that the target is 10 minutes.

Is it based on some hard physical limit of computing?

I've come across this code in chainparams.h on line 113:

bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);

What does ~uint256(0) mean in C++? I know that ~uint256(0) >> 32 means 1 / 2^24 in human-readable terms.
Why is the ~uint256(0) function used instead of simply 256?
Why was this chosen to be expressed as 256 >> 32 rather than 1 >> 24? Is there a good reason for this?

Any direction to learn more about this would be appreciated as well.

Note: I am not asking why the amount of time chosen was equal to 10 minutes, I am asking how the number 1 / 2^24 was arrived at to estimate 10 minutes in terms of how long it takes to calculate a sha256 digest.

I'm not sure it was. When the network started operating (and Satoshi was pretty much the only one mining), blocks weren't found every 10 minutes. For example, the first 2016 blocks were found in 24 days rather than 2 weeks. Normally this would cause the target to go up but it can't go above the hardcoded max target, so only in block 32256 in December 30 2009 we started seeing the retarget mechanism kicking in and blocks arriving every 10 minutes.

However, seeing that it did come out close to 10 minutes, it's possible Satoshi figured out the hashrate of his own machine, and chose the parameter as a round number close to what it would take to find a block every 10 minutes on his hardware.

I think you did not understand this line of code correctly. Hash values are represented as 256-bit unsigned integers. uint256(0) gives the representation of 0 in this data type. ~ is logical not and ~uint256(0) inverts all bits, giving the highest possible integer, 2^256-1. Right shifting by 32 bits gives 2^224-1, so that each hash has a chance of 1/2^32 to be lower than the max target.

The value is then converted to the more compact "bits" form, which also causes it to be rounded to (2^16-1)*2^208.

Doing 256>>32 or 1>>24 would have resulted in 0 since integer types can't hold fractions.


Can i convert BAR ( Tidex ) to XRP ( Binance ) ? I need some advice, I do have some BARS with me on Tidex but I would like to send them to my Binance account but in other coin format e.g BARS to Ripple. Is it possible to do so, if any option please do let me know.

So you want to;

Sell your BAR into another currency?
Send the new currency from Tidex to Binance?
Enter a new currency that is not BAR?

It will be easiest to sell BAR for ETH or BTC, since these make the biggest markets on Binance. Then send to Binance as you have the choice to buy many different coins from there.

What currency do you want to enter into after you have sold BAR?


Why does it cost money to transfer bitcoin? Noob question here.

Why are there transaction fee when transferring bitcoins and who charges them? Being decentralized does not imply that anyone is able to join?

The transaction (tx) fee is the difference in value between you tx input(s) and your tx output(s). The fee is to incentivise miners to include your tx in a block. Until your tx is included in a block it's not part of the blockchain and the recipient will most likely not acknowledge the payment.

When you see your tx as pending it means it's been added to the mempool but has not yet been added to a block. When you see your tx displayed as 1,2,3 etc. confirmations that means it was included in the block mined 3,2,1 blocks ago (blocks are mined on average every 10 minutes).

You can create a tx with 0 fees and in the past they may have been picked up by a miner. These days with the high tx volume (currently there are 10k outstanding in the mempool) a 0 fee tx would almost never get added (unless a miner had another non-economic motive).

I was able to confirm a tx with a fee of 0.00000226 BTC on the 24 Sep 2017. To do that I was literally watching the mempool and picked a time when it was nearly empty. Currently my Bitcoin-Core wallet is recommending a fee of 0.002 BTC/kB which would work out to a fee of 0.0005 for a typical tx.


What were the dates of Bitcoin's previous price plummets prior to 2015? What articles were written about it? As of Jan 2015, the price of Bitcoin has plummeted from 300ish to 200 since the summer of 2014. This wasn't the first time happening to have the price plummet in such a state where mass media starts reporting "the death of bitcoin".

What were the previous dates and percentage drops in USD that caught mass media attention prior to 2015 Jan?
What were some of the articles that were reported on these dates believing that Bitcoin is about to die? And by whom?

The most notable cases were:

In 2011, the price reached a peak of $32 in June, and went down all the way to $2 in November. A decrease by a x16 factor, or 93.75%.
In 2013, the price reached a peak of $266 in April, and quickly afterwards went down to the $65 range. A 75% drop.

This can be seen graphically here and here.

As for media coverage, this list of "obituaries" is handy. Among the most infamous (at least, around people who were around that long) is wired.com's 2011 piece "The Rise and Fall of Bitcoin".


Access Bitcoin Blockchain to analyze transfer patterns I am interested in analysing patterns in transfers between bitcoin users. Is it possible to extract the following data from the bitcoin ledger:

time
sender
amount
receiver

I don't need the real identity of sender/receiver. I understand that the address can be used to approximate unique users? Is this correct?

Is it possible to extract the following data from the bitcoin ledger: (time, sender, amount, receiver)?

Something like that would be possible, you could run your own bitcoin node and query the data from that, or use an API from a site like blockchain.info, which provides transaction data. Here's an example of a transaction from blockchain.info:
https://blockchain.info/rawtx/a196032e52c0a9d7a9737ffa212f029bceb9618d0bff5c6dde99ecac4e28bf06

Note that transactions do not have times encoded into them, the time such a site gives would just be the time that site received the transaction first.

  the address can be used to approximate unique users? Is this correct?

This is not correct in general, while some users may reuse the same address for every transaction (one-to-one), other users generate new addresses for every transaction they receive, so there is a many-to-one relationship between addresses and users. In the more uncommon case, there are also multisignature addresses, which often involve more than one person approving any spends from that address, so that you sometimes have a one-to-many relationship between the address and the users. All addresses of that type start with a '3' or 'bc1' though. So its a lot more complicated to make assumptions about users than it is to just look at addresses.


How Master seed is generated using Bitcore API? Can someone please explain how to get Master Seed when a new HD keys is created using Bitcore APIs?

My purpose is to implement wallet service in my application using Bitcore APIs.

Refer this link here

In case you are talking about mnemonic seed use this -

Install bitcore-mnemonic

npm install bitcore-mnemonic
bower install bitcore-mnemonic

Then use it to generate mnemonic seed -

var Mnemonic = require('bitcore-mnemonic');
var code = new Mnemonic(Mnemonic.Words.ENGLISH);
code.toString();
// army van defense carry jealous true garbage claim echo media make crunch...

var xpriv = code.toHDPrivateKey();

If you just want to generate a private from bitcore api you can use this function -

var bitcore = require('bitcore');
var HDPrivateKey = bitcore.HDPrivateKey;

Please note there is no rule to generate a private key. A private key is just a random string. It could even be your name or a whole article. But you must create a private key that is 'random' in nature. Also never use programming language functions like md5 hash or something to generate a private key because they are not truly random.

Bitcore api, however, provides an easy way to generate a private key using the above method. From there you can proceed as usual.

var bitcore = require('bitcore');
var HDPrivateKey = bitcore.HDPrivateKey;

var hdPrivateKey = new HDPrivateKey();
var retrieved = new HDPrivateKey('xpriv...');
var derived = hdPrivateKey.derive("m/0'");
var derivedByNumber = hdPrivateKey.derive(1).derive(2, true);
var derivedByArgument = hdPrivateKey.derive("m/1/2'");
assert(derivedByNumber.xprivkey === derivedByArgument.xprivkey);

var address = derived.privateKey.toAddress();

// obtain HDPublicKey
var hdPublicKey = hdPrivateKey.hdPublicKey;


Is the denumerability of private keys a threat? Since the set of all private keys is denumerable, it is at least possible to create a searcheable record of all keypairs. Which, when finished, is a killer for the whole idea. Am I right or do I miss some essential part?

There's around 2^256 possible private keys. However, there's only 2^160 valid wallet addresses. To store each key-address pair we need 160+256 bits = 25 bytes, so the searchable record will take several million mass of solar system if stored on 4TiB harddrives.

But first we need to create this database. If we equip each PC on Earth (around 2 billion) with 4 GPUs (each generating around 20Mkey/s), we will need much more time than the age of the universe. By the way, we most likely will also hit the hard drive write performance limit if we write each pair to disk.


What is the exact input for the hash function? I've read that it's some variation of: version, previous block hash, merkle root, time, bits, and nonce, but I'm not certain on where to get this data and how it should be formatted. I'd like to know the exact string I can put into something like this and exactly where I can find it. I've followed this video and downloaded his spreadsheet but am uncertain on which part I can copy into the hash function to get the same output as the spreadsheet. Also wondering about how to convert time to the right format. Thanks in advance.

I've read that it's some variation of: version, previous block hash,
  merkle root, time, bits, and nonce

This is exactly right.

Manually verify block hash

(thanks to @exmachinalibertas) on this reddit comment

Grab a block (eg. block 3): Block 3 in json or Block 3 in hex
Concatenate (in this order, little endian, hex format) the version, previous block hash, merkle root, unix epoch time, difficulty target (bits), and nonce. You'll see you can copy the first 160 characters from the Block 3 in hex link. 01000000bddd99ccfda39da1b108ce1a5d70038d0a967bacb68b6b63065f626a0000000044f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e995dbe6649ffff001d05e0ed6d
Run the terminal command (unix):

$ echo 01000000bddd99ccfda39da1b108ce1a5d70038d0a967bacb68b6b63065f626a0000000044f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e995dbe6649ffff001d05e0ed6d | xxd -r -p | openssl sha -sha256 | xxd -r -p | openssl sha -sha256
Reverse the output from

4944469562ae1c2c74d9a535e00b6f3e40ffbad4f2fda3895501b58200000000
to
0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449

And there's the block hash!

  I'd like to know the exact string I can put into something like this
  and exactly where I can find it

This likely will not work because it looks like it's expecting a string and it will be strange to try and convert the bytes in the block header to ASCII characters.

Note: You will need to install openssl for terminal. Also, the xxd command will convert the hex string to bytes so the hash is not done on the ASCII bytes.


Why are there no very low bids/very high asks on GDAX? When I look at the GDAX exchange, I see that the highest ask is 8894, and the lowest bid is 8880. What I find strange about this is how close these numbers are. Suppose I were to, right now, post a bid for 5000 - something extremely low. It would probably sit on the exchange for days or weeks. So why don't I see any such bids on the exchange?

Surely somebody in the past several weeks might have gotten the idea to post a very low bid or a very high ask. Regardless of how smart or stupid an idea that is, the point is that all it takes is one person to do it in a multi-week period, and it'll show up on the exchange.

Is it just that nobody is doing this, or is it that GDAX isn't showing all of the orders posted? Or am I misunderstanding something more fundamental?

It appears that the GDAX main page only shows orders that are fairly close to the market price, probably to keep the user interface manageable.  You can see a wider range by increasing the aggregation.

You can't view the complete order book through the UI, as far as I can tell, but you can get it through the GDAX API.  If you fetch
https://api.gdax.com/products/BTC-USD/book?level=3
you get all outstanding orders in JSON format.  There are asks as high as $9999999999 and bids as low as $0.01.


Why is it so expensive to transfer Bitcoins? I am starting with bitcoins and I want to buy some neo and ripple. Like every newbie I typed "Buy neo" on google, and a lot of tutorials say I can not buy directly neo, I have first to buy some bitcoins (for example in coinbase.com) and then transfer them to a cryptocurrency market like binance.com and then in binance I will be able to change my bitcoins in neo and ripple. That's what I done and I it worked perfectly, but I was very surprised by the cost of the transfer from coinbase to binance, when transfering 120 dollars around 30 dollars where taken for transfer fees !?! What's the point in using alternative moneys if it is far more expensive than actual banks? And how can I do to avoid these transfer fees next time I want to buy neos??

What's the point in using alternative moneys if it is far more expensive than actual banks?

Well, there are more advantages. It's a decentralized system, you act pseudonymously...

  And how can I do to avoid these transfer fees next time I want to buy neos??

1) You wait until the fees are low again. 3 months ago, you could send 500$ as Bitcoins with a fee of only 0.07$. I think, they will decrease again.

2) I think, there are also exchanges that accept $ or € to buy NEO directly (https://anycoindirect.eu/en/buy/neo for example)


Question about bitcoin wallet How can someone including governments and hackers can find the owner of bitcoin wallet or the company that has offered that bitcoin wallet to the owner ?

If they have someone's bitcoin wallet address can they understand who is the owner ?

If they have someone's bitcoin wallet address can they understand that wallet belongs to which broker?

BitCoin provides anonymity but not unlinkability. This mean that BitCoin transactions are public and can be traced.

Link a BitCoin address to a real identity is not easy and there isn't a standard procedure to do that. But there are many approaches of how someone could try to know to what person one address belongs.

For example, when you send money to an exchange or make a payment, you're linking your address with your identity. So, the exchange or the person that you're paying, now they know that you're the owner of that address. The goverment may have a legal way to demand for that information to an exchange, for example. Note that the addresses used by exchanges are often of public knowledge and there are studies about that, but your identity is not compromised, except that the exchange is hacked.

There are also other ways to try to identify someone's addresss. And there are ways to try to mix BitCoin payments so they can't be traced. If you want full anonymity and unlinkability, you should use other coins as Monero.

If you want to know more about this complex topic, I recommend this lecture.


Is there any tool to extract the bitcoin transaction network from the blockchain? I'm looking for a way to extract some data from the latest downloaded bitcoin blockchain. In particular I'm interested in extracting the whole transaction network, so input and output public keys used in each transaction, the transaction date, hash, block hash and BTC amount.  I tried several solutions so far with no luck:

Bitcoin-Transaction-Network-Extraction

rusty-blockparser

bitcointools

BitcoinDatabaseGenerator

BCGraph

I've had some luck with bitcoindatabasegenerator and rusty-blockparser, but while these tools succesfully extract the output PKs, input PKs are nowhere to be found in the resulting files.

Summarizing, I'm looking for something like this to produce a network visualization of bitcoin transactions:

|Source PK(s) (BTC)| ------> Transaction ------> |Target PK(s) (BTC)|

Im not really an expert in coding so this makes everything more complicated for me. Can you suggest me a way to extract this data from downloaded Blk files?

Any help would be greatly appreciated!

BlockChain::BlockChain ( QObject* parent ) : QFile ( parent ), blkFile ( START_BLOCK )
{
  connect ( this, SIGNAL ( block ( const QByteArray& ) ), parent, SLOT ( block ( const QByteArray& ) ) );
  connect ( this, SIGNAL ( doneFile ( ) ), parent, SLOT ( doneFile ( ) ) );
  QTimer::singleShot ( 0, this, SLOT ( start ( ) ) );
}

void BlockChain::start ( )
{
  setFileName ( blkFileName ( blkFile++ ) );
  if ( !open ( QIODevice::ReadOnly ) )
  {
    _trace ( QString ( "cant open [%1]" ).arg ( fileName ( ) ) );
    emit block ( QByteArray ( ) );
    deleteLater ( );
  }
  else
  {
    _trace ( QString ( "processing [%1]" ).arg ( fileName ( ) ) );
    QTimer::singleShot ( 0, this, SLOT ( next ( ) ) );
  }
}

void BlockChain::next ( )
{
  if ( pos ( ) < size ( ) )
  {
    quint32 magic;
    quint32 sz ( read ( (char*)&magic, 4 ) );
    while ( !magic && pos ( ) < size ( ) - 4 )
      read ( (char*)&magic, 4 );
    xassert ( ( ( magic == MAGIC_ID ) || !magic ) && ( sz == 4 ) );
    if ( magic )
    {
      read ( (char*)&sz, 4 );
      emit block ( read ( sz ) );
      QTimer::singleShot ( 0, this, SLOT ( next ( ) ) );
      return;
    }
  }
  close ( );
  emit doneFile ( );
  QTimer::singleShot ( 0, this, SLOT ( start ( ) ) );
}

const QString BlockChain::blkFileName ( const int i ) const
{
  return
    ( i < 10 ) ? QString ( DATA_ROOT "\\blk0000%1.dat" ).arg ( i ) :
    ( i < 100 ) ? QString ( DATA_ROOT "\\blk000%1.dat" ).arg ( i ) :
    QString ( DATA_ROOT "\\blk00%1.dat" ).arg ( i );
}


Buying and Selling on MtGox I have a quick rather "noob" question about MtGox. I've noticed many reports about MtGox being very slow at "paying out" usd, and have seen many people suggesting that you should transfer your bitcoins to Coinbase before selling them, so you can get your USD faster.

However I have a simpler question, if I want to sell a bitcoin on mtgox, am I "stuck"? Meaning if I sell 1 bitcoin for, example ($1000 usd), would the 1000 usd immediately be tried to be put into my bank account and then be "on hold"? Or could I take that 1000 usd and immediately buy another 1 bitcoin about 5 minutes later when it is $900.

I am basically trying to evaluate the possibility of a "quick turnaround" on MtGox buying and selling bitcoins, the equivalent of a "Day Trader" in the stock market

Thanks!

If you're looking for the 'quick around' investment, you probably should have money/coins sitting in both accounts. Bitcoins and other cryptocurrencies tranfer nice and quick, but fiat cash is alway SLOW... too slow. Expect the worse case scenario when moving fiat cash. There is no incentive to move your fiat cash quickly. (and thats why we love cryptos :D )


Is there a way of rewarding users who confirm others' transactions? Users who confirm or validate others' transactions are performing a public service on the Bitcoin network.

Is there any way to reward such users, perhaps by giving them priority for confirmation of their own transactions?

This is the purpose of transaction fees. By mining a block, all transactions hashed in the block are confirmed, and the corresponding transaction fees go to the block discoverer (along with the block reward).
Right now the block reward dwarfs the transaction fee reward... but there is no downside to including other transactions while mining, so all of the nodes will do it.


Why do keys need both X and Y coordinates, if X can be solved for Y using the curve equation? Reference:
https://en.bitcoin.it/wiki/File:PubKeyToAddr.png
 and
https://en.bitcoin.it/wiki/Secp256k1

Why do we need both X and Y to make a private key?

A private key is just a number modulo the order of the curve.

A public key is the (X,Y) coordinate pair corresponding to that number (the private key) multiplied by the base point (which is a property of the curve used).

If you're talking about public keys: you're almost right. The Y coordinate can indeed be computed from the X coordinate, if you know the sign (given the formula y^2 = x^3 + 7, there are two solutions for Y for every X).

In fact, if you're using a recent version of several wallet clients (bitcoind/bitcoin-qt since 0.6.0 for example), this trick is used. It's called compressed public keys, and it means that when spending a transaction output, the public key stored in the spending script (and thus the block chain) only contains the X coordinate and a marker byte to denote which of both Y coordinates is used. This is slightly slower to validate, but saves space.

In practice, public keys are encoded in the following legal ways:

0x02 + [32-byte X coordinate] (if the Y coordinate is even)
0x03 + [32-byte X coordinate] (if the Y coordinate is odd)
0x04 + [32-byte X coordinate] + [32-byte Y coordinate]

(the two solutions for Y always have different oddness, but as we're talking about a coordinate in a finite field rather than a real number, it does not actually have a 'sign')


Transaction unconfirmed after a day! Help! I made a bitcoin transaction yesterday and it's still unconfirmed. Maybe the default fee of my wallet was too low. Could anyone please help me get this confirmed? It really is urgent. I'd greatly appreciate it!

Here it is:
https://blockchain.info/tx/1e6ba30a70a6ed95a0095bd672f75e101724751e4a0c22769c0a89813473bebf?show_adv=true

You will need to create a new transaction to the address with a higher fee. There is very little you can do to an existing transaction in the pool.


How to interact with bitcoind using C++? I know that bitcoind is written in C++, but I cannot figure out how to use its API within my program. I have been using a Python wrapper effectively, but I need another process running that is as quick as possible. Is there a library somewhere for bitcoind? Thanks.

Or could you just point me to a good Json-rpc library?


bitcoin-cli importprivkey to the same user or different users If i call the bitcoin-cli importprivkey multiple times, does it import the private key to the same user or to different users? In the bitcoin-cli importprivkey, it does not specify to which user account is the key importing to.

You can set account like that

bitcoin-cli importprivkey "myPrivKey" "Account" true

if you want to import multi private keys do it like that

bitcoin-cli importprivkey "myPrivKey" "Account" false
bitcoin-cli importprivkey "myPrivKey" "Account" false
bitcoin-cli importprivkey "myPrivKey" "Account" false
bitcoin-cli importprivkey "myPrivKey" "Account" true

So you don't rescan the entire local block database each time, but the last time.

to import it to default account leave it empty

bitcoin-cli importprivkey "myPrivKey" "" true

Also please consider stopping using accounts since it will be removed in 0.16 version.


What countries are already represented in the Bitcoin network? What countries are already represented in the Bitcoin network?  I am asking this to see a list of countries, so we will know how well it is spreading, and if there is some area that is not reached.  So please, show us where we can find this list:

If you are interested in Bitcoin nodes, This website seems to keep a count of how many of them are connected by country:

http://bitcoinstatus.rowit.co.uk

Or, if you want more graphical (and cooler looking) data, just look at this globe:

http://www.weusecoins.com/globe-bitcoin/

It shows you what amount of Bitcoin nodes are connected in each geographical area not only at a country level, but going down to what I believe is a city level.


How can I brute force decrypt my blockchain wallet? I have a Blockchain wallet but am unable to decrypt my wallet and login.  I created the wallet on OSX and am trying to login on a PC but it's not working.

What are my options to brute force this account, when I know most of the characters involved?

I'm a programmer, and can write the code, so knowing what URLs and data files I need to work with would be a help.

You can wrap a brute-force wrapper around any of the answers here. Just write some loops that iterate on all possible passwords, and call one of the functions in the linked question to try and decrypt you wallet.

This is what I used in a similar scenario (Javascript/node.js).


If I transfer bitcoin into Trezor that has been on a paper wallet since 7-31-17. Can I still get BCH and BTG? If I transfer bitcoin into Trezor that has been on a paper wallet since 7-31-17. Can I still get BCH and BTG? Trezor has a coin-splitting tool, but it says that I had to have held Bitcoin in my Trezor on before August 1st.

The reason you cannot use the coin-splitting tool is that the private key of your offline wallet is where the new BCH and BTG coins were created at the time of the fork. By sending your BTC to Trezor, you are only spending the BTC part, the BCH and BTG are still associated with your paper wallet's key.

After your send the BTC to Trezor, you need to import your paper wallet's private key into a Bitcoin Cash and Bitcoin Gold wallet, and then send the coins to a new fork-specific addresses from there. Make sure to send the BTC away first before you start exposing your paper wallet's key, to ensure you do not lose the BTC in the process. See How to claim Bitcoin Cash & Bitcoin Gold from paper wallet for more information.


How do I fix Bitcoin-qt Error: "Cannot allocate memory bitcoin in ProcessMessage()" I'm on a Macbook Pro, launching Bitcoin-qt, version 0.8.2, and I see this error when it tries to sync:

EXCEPTION: 11DbException
Db::put: Cannot allocate memory
bitcoin in ProcessMessage()

Any idea what I should do? I've backed up the wallet.dat file. Not sure why it cannot allocate memory to continue to sync.

This error has been showing up recently and it seems to me ( just my 2 cents here ) that it works down to 2 possible issues, the most common is physical memory in your system.  The more memory available to Bitcoin, the better as the block chain is getting to the point I almost need a new hard drive just for the block chain.  It helps if you have more than 2 Gig of ram, not how much space is left on the hard drive, although that can also cause cannot allocate memory errors on some systems.

Either way, start with this link, if your model is listed, look in to more memory and all that involves. If it isn't, look at what ones listed there are comparable to yours and consider upgrading to one that can have the memory upgraded later.

http://support.apple.com/kb/HT1270

The other option is to move your block chain information to a different folder and reopen Bitcoin and see how far it goes to download the block chain information.  If the second option ' magically ' clears it, it could be due to one of the alternate currencies based on Bitcoin and one of the peers sending erroneous block chain information.  If it does run in to an issue with 10 or more weeks left to update, then it is a memory issue.  Also, back up your wallet.dat file ( copy to some thing like btcwallet.dat ) on to a removable drive as it contains your ' basic wallet including password lock ' information and a new system could rebuild your current wallet with that one file.