what is forking attack? and different between forking attack and selfish mining? I am a student who studies block-chain for these days.

I have a question about forking attack and selfish mining in mining strategies

as you see picture below

I don't understand why miner should send some money to a victim to do forking attack...

what does this means to do forking attack?

is it possible to do forking attack except sending some money to a victim?

and as below picture about selfish mining

what is difference between forking attack and selfish mining if miners exclude

to do send some money to a victim in forking attack?

can anyone help me to understand what M->B and M->M'(double spending) means??

and why do need it to do forking attack??

With 51% of the network hashrate the forking attack is theoretically possible. Classically, what you have described is a double spending attack.

First, the attacker pays M->B and B releases the goods. Then, the attacker presents a longer valid chain paying M->M instead and the blocks containing M->B are orphaned.

It is not simply a matter of presenting an alternate block, it must be a valid alternate block(s) with more valid proof of work (a longer chain) which must also be based on the genesis block and any (each) checkpoint.

With 51% of the network hashpower, selfish mining is also possible, where the attacker ignores any network generated blocks and continues to extend their own chain with blocks that they have created. Because the attacker's hashpower is greater, theirs will be the longest chain with the greatest PoW.


What is a block index in blockchain.info? On blockchain's blockchain api documentation, located here

https://blockchain.info/api/blockchain_api

There is an api call that uses a parameter called block_index. What is this value, and how does it differ from block_height? From playing around with changing the block_index value in the following api call:

https://blockchain.info/block-index/$block_index?format=json

It seems like (imo quite arbitrarily, which adds to my confusion) that block_index 14849 corresponds to the genesis block. Finally, on the api page listed at the top the first example output they show gives a block whose index is 818044, yet when I enter the following api call into my browser's address bar:

https://blockchain.info/block-index/818044?format=json

I get "Block Not Found". Is this just a bug in blockchain.info that the example output they provide doesn't actually work, or am I using block_index incorrectly?

I think that this value is an internal unique index in bc.i database.

It is not possible to use txid as an index because of 2x2 duplicate transactions in blockchain

https://blockchain.info/tx/d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599
https://blockchain.info/tx/e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468

occurred in the early stage of bitcoin

see BIP-30 https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki

UPD: ok, you are asking about block index, but my answer is for tx index. May be using straight autoincrement int64 value for database is better than int256


Is there incentive for those who run lightning nodes? This is likely very much a noob question, but I would like to know if there are fees or incentives for those who are running a lightning node? Of course, other than having access to lightning network?

Yes, but just running a lightning node is not enough.

In order for your node to be able to earn fees, it has to have payments passing through it. For this you need to have a routing node, which has at least 2 open channels (where is payment coming from, where is payment going). The more open channels your node has, the more it will be chosen by the routing algorithms of the nodes that want to make a payment, to be routed through.

The amount of BTC/LTC/... you would earn as fees is not fixed, instead the market decides (supply & demand). It is very little though, like 1 Satoshi per payment. However, consider that Lightning is designed to have many more payments per second than Blockchains, so this could sum up.

The fees you may gain are probably lower for the Lightning Network than they are for on-chain payments (per transaction), but also your cost will be lower; there is no need for delivering any PoW, as this is provided by the underlying Blockchain. In fact earning fees through the Lightning Networks behaves rather like staking -> The costs mainly compound of the HW & electricity you need to run your node (aiming for 24 / 7) as well as the risk you expose your "staked" Bitcoin to, as they basically need to stay non-stop in a hot wallet.

Most of the time it will not make sense to have a routing node, but rather just a simple node on your phone so you can pay for your daily coffee. With this node you will probably not route any payments and consequently not earn any money with it.


What prevents similar time-warp attacks in Bitcoin as happened to Verge? Right now (may 2018), Verge (an altcoin with proof of work)  was attacked by time-warp attack. More can be read here

https://blog.theabacus.io/the-verge-hack-explained-7942f63a3017

What exactly prevents from similar attack to happen to Bitcoin?

Verge has different hash logic (more frequent retarget, more concurrent hash algorithms), but the logic of the attack should, in my reading, apply also to bitcoin.

Since it did never happen in Bitcoin, I probably missed something. How is Verge different from Bitcoin that this happened in Verge, but not in bitcoin?

Nothing directly prevents it in Bitcoin, and indeed the attack has been demonstrated on testnet3 many times---it's the primary reason that testnet3 currently has almost three times as many blocks as Bitcoin, despite being launched several years after Bitcoin mainnet and with a something similar to[1] Bitcoin's 10-minute average block interval.

Indirectly, there are several reasons the time warp attack is less practical on Bitcoin mainnet than testnet3 or altcoins like Verge:

Obvious: once blocks used in a time-warp attack are broadcast, anyone can see that median-time-past (the monotonic clock in Bitcoin) is lagging far behind real time.
Slow: the time warp attack exploits the formula used for retargeting, but retargeting only runs once every 2,016 blocks (two weeks at normal rate) and can only reduce difficulty by a maximum of 75% per period.  Now, 75% is a lot, but so is spending two weeks executing a publicly-visible attack.  Further difficulty decreases can be executed faster due to the modified difficulty, but they're still pretty slow: 3.5 days for the second retarget; about 1 day for the third; about 6 hours for the fourth; etc...
Easily fixable by miners: if honest miners control the majority of the hashrate, they can simply refuse to build on top of blocks whose timestamps are too far in the past.  If median-time-past is restored to its normal trailing average before the end of the initial 2,016-block retarget period, difficulty won't be changed any more than normal.

If all these reasons do indeed provide indirect mitigation, then why do we see the attack on testnet3 every few months?  Mainly because testnet3 uses the same SHA256d proof of work function as Bitcoin and so anyone who wants to mine blocks really quick can hook up some modern ASIC miners to create a bunch of testnet blocks quickly.  This would normally rapidly increase difficulty, but the increase is prevented using the time warp attack.  That said, in at least one case in the past where a time warp attacker made testnet3 unusable for an extended amount of time, some generous person pointed their own huge mining rig at testnet3 to overwhelm the attacker and bring difficulty back up.

On Bitcoin mainnet, if the attack was ever executed, I think the story would be different.  Within days, a large percentage of the userbase would know the attack was ramping up and would start to pressure honest miners to reject the attacker's blocks.  I personally expect miners would comply (as the next step would be for people to start throwing around phrases like "PoW function change"), which would defeat the attacker and cost him expected revenue for every rejected block.

If attackers expect the scenario would play out basically the same way I think it would, then there's no point in them starting the attack in the first place---which I think is what ultimately prevents time warp attacks on Bitcoin.

[1] Testnet3, unlike Bitcoin, has a rule that if no block has been mined within 20 minutes (according to block header time), that a miner can create a difficulty-1 block (the lowest difficulty).  That means that even completely honest mining on testnet3 is faster than on mainnet, as on mainnet something like 20% of blocks take longer than 20 minutes to find.

Some extra notes:

A fork could change the retarget calculation to use median-time-past instead of raw block header time.  This could fix the time warp attack on Bitcoin, but it would probably have to be a hard fork.
Since the BIP113 soft fork, median-time-past has been used to restrict which nLockTime transactions miners can include in their blocks.  Not many transactions use nLockTime with a time at present, but if there was a time warp attack, users could start doing so to create a large fee incentive for miners to bring median-time-past closer to real time.


multiple wallets on same mobile device Can I install and use different wallet apps on one mobile device?

The intention is to have:

a hodl wallet and a daily use wallet
And to compare GUI for preferred UE

Will the apps interfere with each other in any way?

Yes, there is no nothing preventing you to doing that as long as you use different private key, but usually your mobile wallet will generate an HD wallet for you so you wont have to deal with that problem.

Just be sure to use recognized mobile wallet like those here https://bitcoin.org/en/choose-your-wallet?step=1

Also notice that some mobile wallet will offer you to have separate wallet inside their own software, like electrum


Are Bitcoin fees optional? I was making a multisig account in coinb.in. Then I tried to make a transaction (spend funds). At the bottom there was a box for writing the fee.

What fee? I thought bitcoin sending was free! Beside the box, it said, "Make sure you include an adequate fee, otherwise your transaction may be rejected. 0.0005 BTC or more is recommended."

The fee is optional; however, including your transaction in the next found Bitcoin block is also optional.

The miner who finds a block gets to decide which, if any, transactions are recorded with the block they found.

Factors that influence whether your transaction is included in that found block include:

The block size limit.  Sometimes the transactions are too large to all fit into the block, so most will prioritize higher fee transactions to be included first.
Local settings for the person finding the block can be set to ignore transactions with fees lower than an amount of their choosing.
Some people will include all the transactions they have seen, as long as they will all fit, but this is not the normal default mode of operating for miners.  If you do not include any fee, then this would be your only chance.


How can I build litecoin from source in Visual Studio (2010 or 2012)? I am curious if anyone has successfully built and linked all dependencies for litecoin and, finally, built litecoin in Visual Studio.

If so, could someone please provide some instructions on how to do this?  I'd like to run some tests and I'm quite familiar with the Visual Studio debugger.

its a fork of bitcoin so this should be the same https://bitcointalk.org/index.php?topic=24670.0


Warning: Unknown block versions being mined! It's possible unknown rules are in effect Recently, my full node (Bitcoin Core 0.14.2) displays this for both HD and non-HD wallets:

  Warning: Unknown block versions being mined! It's possible unknown rules are in effect

What does this mean?

Miners have started signalling for BIP 91, which sets bit 4 in version numbers. When BIP 91 activates, it will force miners to set bit 1 (which then indirectly will cause activation of BIP 141 SegWit).

No software release has implemented BIP 91, as a result, it warns because it sees an unknown feature rollout with significant support from miners.


Bitcoin backend integration - Do I really need the notion of "a wallet"? I am developing an application that will accept Bitcoins targetting some specific "items" in my application, and later transfert some of those Bitcoins to externals addresses.

In many similar projects I read about, they use the notion of "wallets". For example if you use Bitcoinj: it seems the first thing to do is to create wallets!

I understand what GUI wallet softwares are and why those are important for end users. But in a backend application, if I understand correctly, a wallet is simply a seed that can generate some private/public keys pairs in a deterministic way. Is that correct?

So, in the end, the only thing that really matters in order to be able to manage the coins sent to "a wallet" (sent to a specific user or for a specific "item") is to know the private keys that were involved.

In my application, I plan on generating a new private/public keys pair for every new "receive coins" transaction. Not from a seed, simply a random pair! And since I already have a database, I was thinking about storing the generated keys in a table (the private keys begin encrypted), with information about what the transaction was for.

And when I would need to send coins to external addresses, I would decrypt some private keys, create inputs using them, create a transaction that I would sign, and then broadcast that transaction.

In other words, currently I would not really have the notion of "wallets".

So my question:

Am I missing something about what "a wallet" actually does (in a backend application)?

Do I need something else in order to implement the "receive/send" process I'm talking about or is my database table with all the private/public keys pairs enough?

I understand what GUI wallet softwares are and why those are important for end users. But in a backend application, if I understand correctly, a wallet is simply a seed that can generate some private/public keys pairs in a deterministic way. Is that correct?

Correct, but you miss the most important feature of a wallet...crafting transaction / bitcoin script! And that part is not trivial as it involves such things as coin selection algorithm, bitcoin standard script +~segwit(also for generating segwit address), signatures etc.

What matter in the end are the key indeed... but you should not underestimated what feature does a wallet provide and instead of persisting tons of encrypted priv key you should definitively take a look of HD wallet (BIP32, BIP44, BIP49, BIP84)which are "basically" a determinist way given a seed / mnemonic, to handle an infinite amount of key. This way you could just persist paths.

See a wallet more like a tool, or a library a module a package whatever, you would require that I'm pretty sure, because when you mention "create inputs using them, create a transaction that I would sign, and then broadcast that transaction", that's what a wallet does.

About you received/send, I guess you have to handle or take into account a given transaction state, mined, validated (~6 confirmations, depends your requirements) or not. This way your app will behave differently. Basically you need a node or an API and a wallet "package" tool which will bridge the gap between your app and the node.


Can someone explain what is a mining RPC? I just read about this update.

What does a mining RPC mean and stand for?

RPC stands for Remote Procedure Call and it is a technology that allows you to perform actions on a machine being on another machine (or on the same machine but in a different process).

The new RPC calls from the update are calls related to Bitcoin mining. Most mining software will use these calls to get information from the bitcoind client running on the same machine.

So, nothing to do with crypto, just an extension of the API you don't have to worry about.


How often does Bitcoin connect to the fallback nodes? Does the standard client have a preference for connecting to fallback nodes (for example, by trying to have at least 1 connection to such node at all times), or are they treated like any other nodes?

Bitcoin only connects to them specially when you don't have enough nodes, and then it will disconnect as soon as the seednodes give you a nodelist. Bitcoin might choose to connect to seednodes as regular peers as well, but they're not given any preference.


How to read blockchain.info transactions in the blockchain? so i'm learning about bitcoin, and i've purchased overpriced bitcoin for 1USD.
the flow was as follow:

i've created an account in https://localbitcoins.com and contacted a seller.
the seller sent me 0.0007 BTC to that account, the site switches addresses as i understand to keep it secured - this is the address that i have there 1DZPyyLMcu1jKaEJ5fskeEpsMbjY49L9JL
i've created a paper wallet and transferred the funds there: https://blockchain.info/address/12Egs85EKjDpDLLRigbszSR9TnyGRKqhnD

my questions are:

i do see the 0.0007 transaction, but why is the previous transaction it's linked to is ~69BTC? shouldnt it be linked to a signle 0.0007 transaction from the old wallet?
why can't i see any transaction at https://blockchain.info/address/1DZPyyLMcu1jKaEJ5fskeEpsMbjY49L9JL ? as i think i've transferred the localbitcoins from there.

so, i'm quite confused, how do i read the history, starting from the last transaction (12Eg...)?

The transaction in which someone sends you 0.0007 BTC includes more payments to other people and one payment back to himself, what is called the change.

When you get Bitcoin in a wallet, everything you get in each transaction is a separate input. Any or several of those can be used to make a transaction, but you can't break them. In order to send a smaller amount than an input, what you do is to make two payments, one to the address to which you want to send that smaller amount and another one to yourself, usually to a new address for privacy reasons. In you example, the sender had a 69 BTC input, made some payments and sent himself back around 67 BTC.

Than second address you mention (1DZPyyLMcu1jKaEJ5fskeEpsMbjY49L9JL) has not been seen in the network, what means that it is not associated with any transaction yet. In the big transaction your 0.0007 have an "unspent" next to them. This means that you have not used them and they are in that address.


Where can I find historical exchange rate data for BTC/USD? I'm looking for historical exchange rate data for Bitcoins/USD beginning in 2010, but I haven't been successful. This is for academic research. I tried bitchart.org. I don't know how to access the MtGox API either.

Can you help me with a step-by-step procedure to download the data in CSV format (or any other format)? It would be awesome if you could just provide me with the actual data file.

http://www.coindesk.com/price
http://www.investing.com/currencies/btc-usd-historical-data
http://www.quandl.com/c/markets/bitcoin-data
https://bitcoinchain.com/markets

Also, there was a Bitcoin Time Series spreadsheet.  Scroll to the bottom to see the data sources.


How to resolve "no block source available"? I've got some trouble using bitcoin-qt.

It stays on: "No block source available...  242 weeks behind."
And "Catching up ... Processed 0" etc...
Map port using UPnP is activated, and proxy disabled and I have 7 active connections to the Bitcoin network. I tried without firewall or antivirus, but nothing happened. I went into log file and I saw this:

send version message: version 70001, blocks=0, us=1**.***.**.***:8333, them=*.**.****.**:8333, peer=*.****.***.****:8333
socket recv error 10054
disconnecting node 124.1

Don't take attention to the "*".
For each send in the logfile there is a socket recv error...

Edit :

I'm running

bitcoin-qt v0.8.3-beta
OS - windows XP pro sp3
I tried to put it off / on -> nothing else

What can I do? Thank you for your help.

I was having this problem. I updated my client to the newest version (https://bitcoin.org/en/download) and it solved itself. I think the clients might stop communicating with other clients who don't update. Haven't read that anywhere or anything, just a guess.

The problem has returned, but updating the client is still a good thing to do.


Why did Dan Kaminsky say that Bitcoin is dependent on the Federal Reserve? Dan Kaminsky embed a custom message in a block, which reads "BitCoin's new dependency upon [...] BERNANKE". Why did he say that Bitcoin is dependent on the Federal Reserve?

Once upon a time someone used Bitcoin's ability to embed arbitrary text inside a transaction to put an ASCII Art Ben Bernanke into the blockchain. Referring to the fact that current blocks must still reference the Bernanke block as a "dependency" rounds out the joke.


How can somebody steal the Genesis block? So I read on bitcointalk the other day that there was a new coin about to be released (woo hoo right?!) and then they posted that somebody had stolen the genesis block.

What exactly does that mean?

How does somebody steal a block and what does that mean to the other blocks/block chain or miners?

I assume this is referring to the duckduckcoin launch fiasco.

For pre-mined coins based on the Bitcoin software, the pre-mined coins typically just go to whoever mines the first few blocks. The idea is that you don't open the software up until those blocks are mined. But if you do, and someone else mines those blocks, they get the pre-mine. To protect against this, you must release the software with a checkpoint after the pre-mine. Apparently, somebody forgot to add that checkpoint.


Bitcoin fund disappeared from my Mycellium account I've recently made a purchase of some BTC through KuCoin. Transaction was approved and I then proceeded to transfer that money to my Mycelium account. 1Cht7fCGg7Kw2m5qAtRyrx7s9AjstGkX13 (transaction made through blockchain).
The funds were reflected on my app on IOS, but the app kept crashing whenever I tried to look at the transactions. So I deleted it and installed it again. After entering the seed words again my balance now appears to be zero. I don't understand what happened. I tried downloading electrum and entering the seed words there but my BTC are not reflected. I would very much appreciated if I can get some help. Thanks

The block explorers show that this address received 0.04526392 BTC today and spent it all two hours and a half later. Either this is an intermediate address or someone with your seedphrase / private key sent the money somewhere else.
The address with the current actual balance of 0.051 BTC is 1CqxsGigGw1ufiGJUYnjLNuSqsRkLfJ2R6.


What is the reputation of bitfloor? It seems that bitfloor is a well designed trading platform, and a competitor to MtGox. However, the trading volume is low.

How long has bitfloor been in business?

Have there been any negative accusations such as fraud?

How safe is my money/bitcoins at bitfloor?

I am still unable to withdraw my bitcoins that were deposited before their September 2012 security breach.  Therefore BitFloor is technically insolvent.

They are registered with FinCEN as a money-service business in the U.S.  Thus I assume they are not immune to U.S. courts and U.S. bankruptcy laws.

They are one judgement away from having their bank funds frozen by a creditor, likely forcing BitFloor to declare bankruptcy.  If that happens, your funds might be used for paying out to legal costs, paying for the receiver, and then whatever is left for payment to all remaining unsecured creditors such as yourself, proportionate to the amount owed (i.e., "pennies on the dollar").

http://bitcointalk.org/index.php?topic=112069.msg1218947#msg1218947

I like BitFloor and I'ld like to see them succeed, but continuing to operate an exchange while insolvent is a move that is irresponsible and shows disrespect to its customers, current and prior.


Between which locations are transfers using Bitcoins cheaper than PayPal for 100$? I believe that once it becomes significantly cheaper to transfer money between countries using Bitcoins, its usage will increase significantly. My question is, therefore, between which countries will a transfer (from bank account to bank account) be cheaper using Bitcoins than PayPal. For simplicity, let's say that the PayPal fees are 2,9% + 30 cents per transaction and that the amount to transfer is 100$.

From Denmark to the US, I believe that the fees will be like the following:

My bank account to MtGox bank account in Denmark: 0%
MtGox exchange fee: 0,6%
Loss due to market spread (difference between buying and selling price/2): 1,12%
Transfer of Bitcoins: 0%
MtGox to USD: 0,6%
Loss due to market spread (difference between buying and selling price/2): ~0%
MtGox to US bank account: 0%?

This means that there will be a 2,32% fee between these currencies if there is no fee from MtGox to US bank account, while the PayPal fees will be 3,2% for 100$. This means that Bitcoins will be a cheaper method of transfer between Denmark and the US. Now I would like to know which other countries it would also be cheaper to use Bitcoins to transfer between?

The reason why I calculate market spread as difference between buying and selling price/2 is because the market price should normally be in the middle between the buying and selling price on an exchange. The spread will depend on the daily trading volume of the exchange, and since the trading volume between Danish krones is so low, the exchange cost due to market spread is a significant expense.

In the euro zone MtGox is not cheaper for small payments like $100. Depositing and withdrawing euros both include a fee of ~1.20 euro (10 PLN) + 0.60% for the transfer.

I don't know what deposit/withdrawal fees are for US dollars, neither if there are exchanges that do not require this fee. I know Intersango does as well.


Which Exchanges Allow Short Selling/Margin Trades with USD/BTC or USDT/BTC I think Bitfinex did. But for example Poloniex has USDT & BTC but does not allow short selling with USDT.

There's apparently a website that reviews various exchanges that allow trading on margin:

http://margintradingbitcoin.com/

OKCoin and Bitstamp are the two that I've heard of on there.


How to calculate the the amount of all Peercoins(PPC) in circulation? According to Wikipedia:

http://en.wikipedia.org/wiki/Peercoin

the reward is halved every time the mining power increases by x16. So does that mean that you need historic data on the mining power in order to calculate how many coins there are?

Also, does anyone know what's the initial reward and difficulty? I can't seem to find those either

According to Wikipedia:

  http://en.wikipedia.org/wiki/Peercoin

  the reward is halved every time the mining power increases by x16. So
  does that mean that you need historic data on the mining power in
  order to calculate how many coins there are?

No you do not need historical data on mining power, but you can calculate out the historical data with a simple calculation used by the entire ppc chain to get an idea of how much hashing power there has been historically. (but that's not the question you are asking).

  Also, does anyone know what's the initial reward and difficulty? I
  can't seem to find those either

Block explorers are your best bet. ABE based explorers like cryptocoinexplorer have some nice API functions. using http://ppc.cryptocoinexplorer.com/chain/PPCoin/q/totalbc I am told there have been  21019084.894021 PPC mined currently

the first block with a reward (block 1) hash is 00000000000be4e024af5071ba515c7510767f42ec9e40c5fba56775ff296658

http://ppc.cryptocoinexplorer.com/block/00000000000be4e024af5071ba515c7510767f42ec9e40c5fba56775ff296658
"
2499.75 Coins generated
Hash: 00000000000be4e024af5071ba515c7510767f42ec9e40c5fba56775ff296658
Previous Block: 0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3
Next Block: 0000000000fdfc564b25df5858ad9f5e3378d9102a22d5c785f9ab92ec3a304a
Transaction Merkle Root: 1bdae84eff34e15399335fc2a48c70fa6b0b9caf972e38b0e3bda106d223f668
Time: 1345400356 (2012-08-19 18:19:16)
Difficulty: 256.003 (Bits: 1c00ffff)
Nonce: 1915373966
Transactions: 1
Value out: 2499.75
"

So there were 2499.75 coins on the first block.
The first mined block had a difficulty of 256.003

as always, google is your friend. Check it out


How to create a transaction with a custom script? Is there a step-by-step tutorial or any documentation covering how to create a transaction that is not a standard OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG?

It seems very odd that there is absolutely no documentation or information covering how to create a transaction like this, when it is one of Bitcoin's greatest advantages.

Maybe a link to some open-source software which creates custom script transactions would be helpful. I don't know of any that exist off hand though.

I would suggest using Python to accomplish this. pybitcointools have what you need to be able to deserialize a hex transaction to JSON, and manipulate that and then serialize again to be able to sign and broadcast via support for blockchain.info.

This example will rebuild the standard script from the ground up:

>>> opdup = 0x76
>>> ophash160 = 0xA9
>>> push20 = 0x14
>>> opeqver = 0x88
>>> opchecksig = 0xAC
>>> pubkeyhash = 0x2dbde30815faee5bf221d6688ebad7e12f7b2b1a

We are going to append hex values by moving them bitwise.

OP_DUP OP_HASH160 2dbde30815faee5bf221d6688ebad7e12f7b2b1a OP_EQUALVERIFY OP_CHECKSIG
This is the hex we want 76a9142dbde30815faee5bf221d6688ebad7e12f7b2b1a88ac

This is one way of doing it

>>> quickfix = 0xff
>>> asm = quickfix
>>> asm = asm << 8 | opdup
>>> asm = asm << 8 | ophash160
>>> asm = asm << 8 | push20
>>> asm = asm << 8*20 | pubkeyhash
>>> asm = asm << 8 | opeqver
>>> asm = asm << 8 | opchecksig

Ant then to check if its the same:

>>> almost = hex(asm)
>>> ready = almost.partition("0xff")[2]
>>> print(ready)

Hope this is what you are after :-)


Shorter Chains in blockdata Assuming two blocks are published at exactly the same time, a race for the next block to be added to one of them begins, which eventually one chain will eventually win.

My question: will the shorter chain still be published? Does the network still syncronize the shorter chain, i.e. does every client contain a copy of not only the longest chain, but all (for lack of a better word)  "sidechains"?
If so, are there any conditions as to what will be syncronized beyond block validity?

Thanks in advance!

will the shorter chain still be published?

Published -- no. However, if the stale tip was previously the best tip, it will be stored in a Bitcoin Core node implementation according to the source and other nodes can retrieve it up to a certain point in time. The time limit is imposed to avoid fingerprinting.

  Does the network still synchronize the shorter chain.

No, the node only ever extends the active chain.


Once SegWit is implemented, could updated miners still choose to ignore SegWit transactions? Regular transactions can be ignored. What about SegWit transactions?

Transaction selection is up to the miners. The only mandatory transaction is the coinbase transaction (the transaction that collects the transaction fees and pays them out with the block subsidy as the block reward).

Besides that they may select anything between no transactions at all, over only regular transactions or only SegWit transactions, to the mix of all transactions that gives them the most transaction fees.


With the Bittrex BTC-BCH pair how do I order enough BCH to exactly spend one BTC? Bittrex orders have their lot size/quantity in BCH and price in BTC. If I only have one BTC in my wallet how can I convert it all to BCH?

To ask another way: How do I know the exact quantity of BCH to order so that I fully convert my one BTC to BCH.

Note this question applies to other pairs and other exchanges. I am also looking for how fees would come into the equation as if I request too much BCH there might not be enough BCH in my wallet to cover fees.

Thanks for adding another question with additional clarification.

Assuming the interface has stayed the same since May-July 2017 for Bittrex, there won't be a reliable way to accomplish this. This also occurs in other exchanges.

If i submit a trade and want to pay .002 BTC per 1 BCH, that's the upper LIMIT. You can't "force" it to buy BCH that high. It just won't buy anything at a cost greater than .002. In any normal scenario nor would anyone want to pay more than necessary to obtain the desired amount. Most systems work on a "this is what i want to buy, this is how much i'll pay for it". With an order book, if the system can buy it for you cheaper, it will. You are simply setting your upper limit. Thus it's called a "limit order". Limit trading is the most popular because the system will not pay more than what you've specified in reaching the amount of BCH you've specified. Going back to the example, if the system found some BCH for you at a price of .0019, it'll sell it to you for that price.

In every system i've used that has limit orders, there is always left over. It's almost impossible to get a 1:1 ratio. I have benefited greatly from sudden fall's in market price on big purchases because my orders were completing for far less. The same for the sell side. In a sudden shift up in price, i found myself getting more for my sales because people were paying more.

This does have an unintended consequence. You'll have change. Sometimes the change is so small it won't even display. I have about .. 15 currencies all showing zero in Kraken, but actually have a tiny fraction remaining because of this very reason. Can't create a sell order for such a small quantity. Not willing to pay the withdraw fee as the fee is exponentially higher than the tiny value.

I get that it can be annoying, there just isn't a desire to implement something that does a "give me only what i ask for even if it's not a benefit to me". Might even be illegal in the US to "inflate" the purchase price to a buyer just to make sure there is nothing left over.

In sum: There is no way to get the system to provide a 1:1 trade of exactly what you want to sell for the specified price. There is also no way to "calculate" the price unless the system sat still for an extended period with no volume. Anything you attempt to calculate on screen could already be made irrelevant in the back end via API or other traders.

The only other option for getting rid of an "exact value" would be to withdraw it and sell it elsewhere. Shapeshift would be a good example. There you can mess with the values to spend exactly 1 BTC, or enter 1 BTC and it will simply tell you how much BCH you'll get. It's not an order book with a system trying to match up trades.

Note: Basing this "Bittrex" specific information based on some Youtube video's of the exchange and this article: https://medium.com/@scozky/getting-started-with-trading-on-bittrex-55237f482ef5. The bulk of the knowledge was used to confirm that Bittrex uses a system that is almost exactly the same as every other "advanced" trading system (IE: Coinbase = simplistic. No limit prices. You get what they decide to give you) that implements usage of "limit orders".

EDIT: I missed the "fee" aspect here. You'll never "not have enough" The fee's are percentage based. Trade occur in small slices since the system is matching you as a buyer, up to someone else who is a seller, for equal to, or less than your limit. If you wanted to buy 1 BTC at .002 per BCH.. and it found someone that will sell 1 BCH for .002, they take their fee off THAT trade. The trade was worth 1 BCH. When they take 0.25% (assuming their zendesk post is accurate) you get 0.9975 BCH. They keep .0025 BCH as "the fee".

https://bittrex.zendesk.com/hc/en-us/articles/115003684371-BITTREX-SERVICE-FEES-AND-WITHDRAWAL-LIMITATIONS

Final Note: I'm over simplifying the limit system for Bittrex as this isn't part of the question.


Pending transaction shows as confirmed on blockchain explorer I'm using a MultiBit wallet (version 0.5.1) and a transfer from Coinbase to the wallet has been showing up as unconfirmed since March 18th (16 days).

Checking the transaction on the ledger, however, shows that it's been confirmed and completed. I've restarted the wallet, my computer, clicked "repair" and still nothing.

How can I go about attempting to get my transaction finalized?

How can I go about attempting to get my transaction finalized?

It seems the transaction is finalised. Its just that your wallet doesn't know about it.

  Checking the transaction on the ledger, however, shows that it's been confirmed and completed.

I assume this means you have checked the Transaction-ID against several different  Blockchain explorers and they all show the Transaction as having more than six confirmations.

In this case you need to do as Pieter Wuille suggested. Create a new wallet, using different software. Either import the private-key or sweep the private-key into the new wallet. There are important implications of these two approaches. People mostly recommend sweeping as safer for most folk.

Before it can show the correct balance, the new wallet may need to synchronise with the network (depending on whether you choose a full-node or lightweight wallet), if so this may take from a few days to a week or more.


Generate Bech32 addresses to receive customer funds I would like to use Segwit addresses however I seem to be finding mixed information on compatibility. As I currently understand it, older clients will not be able to send to a Bech32 address.
Is this the case?

Per this development guide: https://bitcoincore.org/en/segwit_wallet_dev/
It sounds as if I should be creating P2SH-P2WPKH addresses for accepting deposits.

As I currently understand it, older clients will not be able to send to a Bech32 address. Is this the case?

Yes. Bech32 addresses are a completely new address type and format. Because it is new, many clients currently do not have Bech32 support implemented or have not yet released a version supporting it.

  It sounds as if I should be creating P2SH-P2WPKH addresses for accepting deposits.

Yes. For maximum compatibility, you should use P2SH-P2WPKH. Later you can transition to using Bech32 once more wallets implement support for Bech32 and it becomes widespread.


Suggestion for Airgap Bitcoin Core - Comments? Lesson learned the hard way: I lost a small value of bitcoins due to foolishly  backing up private keys to a file which was uploaded to a cloud server. My wallet used to be bitcoin core.

Right now my keys are in electrum with an air gapped laptop wallet and a watching wallet.

I'd prefer to use bitcoin core because having my own blockchain is preferable.

I know you can use bitkey, but as a Windows user, but it seems too complex.

I'm considering the following solution, and would welcome comments.

Currently, I still run bitcoin core with an empty wallet, on my desktop PC connected to the internet. The blockchain is on a separate SSD disk and I run the empty wallet to keep the blockchain up to date.

I would then keep a core wallet holding the keys to my coins, on the air gapped laptop. When I want to send or receive bitcoins I would move the SSD to the laptop. The SSD would use a SATA to USB connector, so it would be an easy plug in. As soon as I'd done the send or receive I would move the SSD back to the internet PC.

I assume that the blockchain on the SSD would resynch the send and receive transactions.

I could use Electrum Personal Server, but this means running other stuff which I don't understand. Armory is another option, but I'd prefer to stick with core.

Is my approach feasible? Secure? Overkill?

If I understand you correctly, Im not sure your system will work, because your air-gapped laptop is never connected to the internet, the transaction wont get broadcast.  You can try it, I may be wrong.

I have done a similar process using rawtransactions, where you prepare the rawtransaction on an online computer, using an explorer API (https://chainz.cryptoid.info/api.dws is one that I found works) you get the tx input and vin, create the rawtransaction and save the hex output to a small USB (smaller the better).  Then on your airgapped machine use signrawtransaction to sign it, then transfer that hex output back to the online machine and sendrawtransaction.

I automated that process in Python, you can see how it works in more detail on my github https://github.com/Scalextrix/coinofflinewallet

It worked with QR codes as well for a fully airgapped solution, but I had a lot of trouble with the Python webcam/QRcode libraries and ended up not bothering.  My code is not extensively tested, its really an example, you should validate it fully before use.


How do I transfer my wallet to a new one? wallet, g Bitcoin Wallet (official) for Android and I want to transfer my wallet from there, to Electrum on my desktop. How do I do that?

Instead of transferring the wallet, just transfer the bitcoins - i.e. on Android: Send the entire amount to your electrum-address.


Where in the source code of the Core Client is the GetBlockValue() function? I was reading Antonopoulos' book and there is a piece of code in chapter 8 in the part about Coinbase Reward and Fees and the code is a GetBlockValue() function. I was looking for it on github but didn't find it. I found something about a function called GetBlockSubsidy() that works in a similar way and is apparently a newer version but I can't find this one either. Also all the links I found linking to main.cpp in the repository don't work. Where is this part of the code now or what am I missing?

GetBlockValue was renamed to GetBlockSubsidy, and main.cpp was renamed to validation.cpp.  So you should now look at GetBlockSubsidy in src/validation.cpp.

You can search on Github for GetBlockValue; you won't find any hits in code but you will find some in commits.  That's how I found this.


BOP: Not authorized to receive from the temporary destination I'm trying to run my own BOP (BitsOfProof) server and connect to it. I appear to be able to connect, but I am unable to execute any commands. I am connecting with the following:

    StompJmsConnectionFactory connectionFactory = new StompJmsConnectionFactory();
    connectionFactory.setBrokerURI("tcp://localhost:61613");
    connectionFactory.setUsername("admin");
    connectionFactory.setPassword("password");
    JMSServerConnector api = new JMSServerConnector();
    api.setConnectionFactory(connectionFactory);
    api.setClientId(UUID.randomUUID().toString());
    api.init();

    Transaction t = api.getTransaction("07eec690b003f13ffe73608be35f22e3da6deb55bfd479dbc67c5f44c8d48963");
    System.out.println("t:" + t.getHeight());
    System.out.println("t:" + t.isDoubleSpend());

    Block b = api.getBlock("0000000000fb2149b0a8c0418041513b122e129e17992e22276c558ee7e8269b");
    System.out.println("b: " + b.getHeight());

and the error I am getting is:

Caused by: org.fusesource.stomp.client.ProtocolException: Received an error: Not authorized to receive from the temporary destination. Principals=[org.apache.activemq.jaas.GroupPrincipal(admins), org.apache.activemq.jaas.UserPrincipal(admin), org.apache.activemq.apollo.broker.security.SourceAddressPrincipal(127.0.0.1)]
at org.fusesource.stomp.client.CallbackConnection.processStompFrame(CallbackConnection.java:110)
at org.fusesource.stomp.client.CallbackConnection.access$0(CallbackConnection.java:92)
at org.fusesource.stomp.client.CallbackConnection$1.onTransportCommand(CallbackConnection.java:61)
at org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:659)
at org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:538)
at org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209)
at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100)
at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77)

As far as I can tell, the admin user should have access to everything.  I tried creating a new user to connect with, and the same error was encountered.  Anyone have any idea what I'm doing wrong?

Tamas has already found a workaround for this issue over on the Apollo JIRA

You need to change your apollo.xml to use the "default" virtual host id, instead of the one that is configured by the Apollo deployment.  Its possible that the client side (BOP) needs to be configured to specify the virtual host to use somewhere, but I have no idea where, so this works for now.

<virtual_host id="default">


How can one verify the address you are sending BTC to I've had an incident with an exchange that provides addresses to deposit BTC funds. For some unknown reason, the exchange is telling me they have never received the funds. I read the address with a QR code reader so, unless there are problem using QR codes everything should be correct. I can see the transaction on the block chain and it has been sitting there for many days now.

Is there some method of verifying the addresses provided by an exchange (or anyone) that the address is theirs and they can confirm it is theirs via some sort of response mechanism to an address verification query on the blockchain prior to sending actual funds? Is this doable using the Sign Message feature?
I've been researching this but don't understand what the Signing address is? Is it my public key or the key derived from my public key? Please point me to the docs that explain this process.

Thanks

No, this isn't something that can be accomplished within Bitcoin itself.

Normally you get this kind of verification from having the address presented to you by a secure website (HTTPS) which you know belongs to the intended recipient, via an SSL certificate signed by a trusted authority (signified by a padlock icon in your browser or something similar). But if either the recipient's server or your computer have been hacked, this address could be modified by an attacker to be his address instead.  (SSL only guarantees that he can't do it simply by modifying the data traveling over the Internet between the two of you.)  So in principle, you could verify the address by contacting the recipient some other way, e.g. a support phone number or something.  But this depends on the recipient giving you a way to do this, and it doesn't happen via the blockchain or anything unique to Bitcoin.

Bitcoin does provide a mechanism for message signing, but it doesn't really help here.  With this system, the owner of an address can sign a message, and others can verify the signature.  So you could get a signed message saying "Yes we are the XYZ exchange", and verify that the address owner signed it.  But in case of the attack mentioned above, you have been given an address that really belongs to the attacker, and the attacker can therefore sign a message saying "Yes we are the XYZ exchange", which will properly verify.  A digital signature doesn't prove that the content of the message is truthful.


MultibitHD is No Longer Supported (transfer funds without fee) I just realized that multibithd is no longer supported. I have some funds there and I try to make 2 transactions, which were not confirmed in blockchain, because I also place them without commission.

If multibithd is supposed to doesn't work. What will happen with that transaction? will it expire? will it be completed? The status in multibit is sending since December 18, 2017.

I already moved my funds to electrum and that transaction does not appear.

Also, I do not understand if the transaction is unconfirmed because it places the commission = 0  or because multibit does not work anymore.

And, what would happen if I make another transaction in electrum?

Thank you and waiting for your answers.

Check the average transaction fee on the blockchain right now, and then look for your transaction on blockchain.info. If your mining fee is significantly lower that average, it will be stuck there for a long time. Eventually your transaction priority will be pushed higher, but there's a backlog of unconfirmed transaction overloading the blockchain right now. If your fee was too low, it will eventually reject the transaction and it will come back to your wallet. You can't do much at the moment right now when your transaction is in a hanging state.


how much cost a bitcoin transaction? My client asked me to use the bitcoin blockchain to store some photos hash as proof of existance.

I read that pulling this data on into the blockchain is not free

1) How much does it cost ?

2) Who gets that money ?

I suggest you look at opentimestamps. From the website:

A timestamp proves that some data existed prior to some point in time. OpenTimestamps defines a set of operations for creating provable timestamps and later independently verifying them. At the time of writing timestamping on the Bitcoin blockchain is supported, the format is flexible enough to support a variety of methods.
Anyone could realize a timestamp with the permissionless blockchain by paying the transaction fees, for your convenience we offer calendar servers that perform this operation for you. These servers are free to use and they don't require any registration or api key.


What is the reason for halving the rewards? What is the reasons for halving the rewards?

Why not, for example, let the reward be always the same and the amount of currency always growing? Are the reasons technical or just purely ideological?

Because the block halving incentives getting into Bitcoin NOW, rather than later. Early birds take more risks and get more rewards. Otherwise the network would have problems getting enough miners involved in the first place.

Asides that, there is a concept of inflation and deflation - we have already experienced the first one, so we might as well try the latter one.


Is there a mechanism to handle stale bitcoins? Possible Duplicate:
  Why doesn't Bitcoin return lost coins back into the block reward?
  What could be the consequences of many bitcoins being lost out of circulation if people lose their wallets?

Okay, the first question has to do with stale bitcoins.  Say people lose their private keys.
Over time it just keeps building, and a large portion of the 21mm bitcoins are immobilized.
What happens?

The same scenario can occur for a different reason, say people start putting bitcoins in their
IRAs and there millions of bitcoins held immobile.  Also, how do I know that in 20 years they still will be good.  Maybe the network truncates the transaction log and my part falls off.

If coins are lost, they are gone forever. This only hurts the person who lost the coins... and in fact it makes the rest of the coins more scarce and thus more valuable long term.

Because Bitcoins are divisible down to eight (or more) decimal places, it really means there are 21,000,000 x 1,000,000 = 210,000,000,000,000 units (and this can be divided even further with changes to the code. In practice, this means that one can always have a "small enough" unit of Bitcoin to buy tiny items.

So if X number of Bitcoins are lost, the rest simply become more valuable, and unless a coffee costs less than .000000000000001 BTC or something, there will not even be a need to alter any code. If we were using those tiny units, a convenient name would be given to them and life would be fine and dandy.


What happens to the bitcoin mining if the device changes? First I've opened this site via mobile and registered with a Google account. Some time later, I continued to mine bitcoin through my laptop with the same account. Will this device change make it impossible for me to exchange the earned bitcoins to dollar or other currencies?

Will this device change make it impossible for me to exchange the earned bitcoins to dollar

No, it will make no difference whatsoever to your ability to exchange earned bitcoins to dollars.
However this is because all websites offering Bitcoin mining with mobile phones or laptops are scams which have no intention of ever giving you the Bitcoins they have tricked you into thinking you have earned.
Criminals don't care what changes of computer their victims make.
They might use it as a convenient excuse to blame you for not being able to give you your "earnings" but they'd have easily invented some other excuse if you hadn't made any change.

As others have noted

The difficulty of mining Bitcoin has increased hugely year on year.
It became infeasible to mine Bitcoin on laptops many many years ago. You now need nearly-free electricity and the equivalent power of tens or hundreds of thousands of laptops to have any chance of profit.
It has never been possible to mine Bitcoins on smartphones.


Do all Crypto Coins use the same Wallet Format? There are many crypto currencies now, BTC, LTC, MTC, Potcoin and so on. Each of these have their own wallet.dat files used by the client software.

My question is: Do all these crypto currencies make use of the same format of wallet.dat file?

pywallet.py can be used to dump the keys from a BTC wallet.dat file.

Can pywallet.py also be used to dump the information from a wallet of an alternate crypto currency like LTC/MTC and so on?

The wallet.dat is a Berkeley DB file.
You can parse it using following command (You need to install Berkeley DB on your unix environement first)

db_dump wallet.dat

I checked for Bitcoin and Litecoin and in both case the wallet.dat was using the same version of Berkeley DB.

VERSION=3
format=bytevalue
database=main
type=btree
db_pagesize=4096
HEADER=END

I haven't try pywallet.py but I guess it should work for all these Bitcoin derived altcoins.


How to use remote bitcoind with docker I want to use multiple nodes with the same remote bitcoind. E.g. my node on my desktop, my node on digital ocean, my node on Google cloud ...

I don't want to run everywhere a full bitcoind and pay for the disk space.
I currently check the option to use btcpayserver (docker) on Google cloud as well. Again, it would need bitcoind.

Any hints welcome.

c-lightning internally calls bitcoin-cli and will pass a couple of commandline arguments to it. These arguments are all prefixed with --bitcoin-* and will match the ones that bitcoin-cli accepts.

So for your use-case you first need to make sure that bitcoin-cli is available on the machine that you will be running the c-lightning instances on. If it isn't you can simply use the Bitcoin PPA to install (but not run) bitcoind which will also install bitcoin-cli (assuming you're using a debian based OS):

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update

For a remote bitcoind you need to specify the following arguments:

--bitcoin-rpcconnect=<bitcoind-ip:port> this tells bitcoin-cli to connect to a remote bitcoind instance instead of trying localhost:8332 (make sure bitcoind is configured with -rpcallowip=<ip>, where <ip> is the machine you'll be running c-lightning on)
--bitcoin-rpcuser=<username> the username configured with bitcoind
--bitcoin-rpcpassword=<password> the password configured with bitcoind

In any case I'd suggest running bitcoin-cli --bitcoin-rpcconnect=<bitcoind-ip:port> --bitcoin-rpcuser=<username> --bitcoin-rpcpassword=<password> from the command line on the c-lightning machine to verify that bitcoind and bitcoin-cli are configured correctly.


Is there an API for price estimation? I need to display at my website what a certain amount of Bitcoins will likely cost. I can fetch the latest price using the MtGox API and multiply it by the amount, but for large amounts this is inaccurate because the buy itself will move the price. The only other option seems to fetch the whole orderbook, and calculate it myself each time, but isn't there an API for this?

while amount > 0:
        amount_i = int(mtgox_depth['bids'][index]['amount_int'])
        price_i = int(mtgox_depth['bids'][index]['price_int'])
        if amount_i < amount:
            total_value += amount_i * price_i
            amount -= amount_i
        elif amount_i >= amount:
            total_value += amount * price_i
            amount = 0
        index -= 1
    spot = int(total_value / float(total_amount))
    return spot

Something like this, where mtgox_depth is a json object of https://mtgox.com/api/1/BTCUSD/depth?raw, should work for you.


Bitcoins recently sent from localbitcoins.com wallet not showing in recipient wallet I recently sent bitcoin from local bitcoin .com and it's not registering in my wallet that I sent it. It's 1000$ what do I do?

I do not use localbitcoins.com but it is possible if you can see the transaction that you made, you might be able to find the transaction ID. Then, you can search for your transaction ID on blockchain.info to find out the status. Even if you cannot, the answer is just to wait.

Every time you request a receiving address a new one is generated.


terminology and conceptual question about progress of PoW what is wrong about thinking

  prbobability of attacker increases with time t that goes into PoW since they have more time to secretly mine their alternate blockchain ?

This refer to double spending. Can one think in these terms or is progress of finding a solution to pow to related to it.

Please enlighten.

Time only helps the attacker if they have more hashpower than all other miners together. That scenario is called a majority-attack and discussed on numerous questions on this site. Such an attacker can essentially rewrite arbitrary lengths of history.

However, if the attacker only has minority hashrate, time works against them. The more time passes, the more likely is it that other miners advance the blockchain further than the attacker in the same time. Once the attacker falls behind, nobody will consider their chaintip when it is broadcast and the attack is failed.


What this param in chainparams.cpp do? consensus.nRuleChangeActivationThreshold = 6; // 75% of 6
consensus.nMinerConfirmationWindow = 8; // nPowTargetTimespan / nPowTargetSpacing * 4

For what this rule exit ? How to calculate this rule for find valid
value for altcoin.
What can be happen if it's value to low or to high ?

Is this value attached to the nPowTargetTimespan / nPowTargetSpacing * 4

Or is it completely unrelated to them?

Those parameters are for BIP 9 soft fork deployments. For a BIP 9 soft fork with these deployment parameters, the fork will transition from the STARTED state to LOCKED_IN when 6 blocks (nRuleChangeActivationThreshold) out of an 8 block non-overlapping window (nMinerCOnfirmationWindow) signal for that soft fork.

These values are not necessary for normal operation. They are only used for soft forks, so unless you are deploying soft forks, these values don't matter at all.

  Is this value attached to the nPowTargetTimespan / nPowTargetSpacing * 4

No, it is not. There is no relation between these parameters at all.


How do I know that my Ledger HW Wallet is using receive addresses for my wallet and not another remote wallet? I'm a paranoid newb, I bought a hardware wallet (Ledger nanos) and have transferred funds to it. I noticed that it generates P2SH addresses, so how could I know if the script hashed is spendable by my own wallet only?

The wallet could very well generate P2SH multisig addresses that could be spendable remotely by the wallet manufacturer.

I understand I could transfer these funds to myself and check the ScriptSig, but that would be too late.

Keep in mind that the ledger itself, if compromised could leak the pk in other ways. These methods I outlined will only confirm to you that a given address belongs to the set of private keys you hold, not that you're the only person holding these pks

like you said: one way you can cheaply verify that is to simply take the address and send a little bit of money to it. That does not answer if your key is compromised but it does tell you if the address belongs to your seed or not.

Another way would be to manually derivate the address from the private key using the BIP39 tool here until you reach the address that ledger gave you.

This second one doesn't require you to send any money but it is more risky as you need to trust the code in the page I sent you and you're literally inserting your pk in a form in the web, which is never a good idea.

The third thing you could do is generate Private Keys with a method you trust (i.e. using Samourai wallet or something) and then use that mnemonic in the ledger as a seed. This way you know that only you have that private key.


Checking the Merkle Root for Block #100000 The below text is copied from the Bitcoin Developer Reference at bitcoin.org:

  If a block has three or more transactions, intermediate merkle tree rows are formed. The TXIDs are placed in order and paired, starting
  with the coinbase transaction’s TXID. Each pair is concatenated
  together as 64 raw bytes and SHA256(SHA256()) hashed to form a second
  row of hashes. If there are an odd (non-even) number of TXIDs, the
  last TXID is concatenated with a copy of itself and hashed. If there
  are more than two hashes in the second row, the process is repeated to
  create a third row (and, if necessary, repeated further to create
  additional rows). Once a row is obtained with only two hashes, those
  hashes are concatenated and hashed to produce the merkle root.

I'm trying to use this logic to recreate the merkle root for block #100000.  There are 4 transactions in this block.  I start by copying the transaction hash for the coinbase transaction and the one following back-to-back into a Sha256 calculator to get the hash.  Then I hash that hash one more time: Sha256(sha256()).  I repeat that procedure one more time with the second two transactions in the block.  Finally, I repeat the procedure again using the resulting hashes to obtain the Merkle Root.  Unfortunately, this doesn't tie to the Merkle Root shown in the block header at blockchain.info.

Can someone explain where I went wrong?

Thanks.

You have to byte-swap the transaction ID's before hashing them, hash each child node, and byte-swap the final hashed hex value.

Transaction 1 (Coibase Transaction)
8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87

To Byteswap it you can use:

a = "8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87"
"".join(reversed([a[i:i+2] for i in range(0, len(a), 2)])) @Greg Hewgill

Byteswapped = 876dd0a3ef4a2816ffd1c12ab649825a958b0ff3bb3d6f3e1250f13ddbf0148c

Transaction 2
fff2525b8931402dd09222c50775608f75787bd2b87e56995a7bdd30f79702c4
Byteswapped = c40297f730dd7b5a99567eb8d27b78758f607507c52292d02d4031895b52f2ff

You want to concatenate the byte-swapped transaction values of 1 and 2. Transaction 1 goes first.

876dd0a3ef4a2816ffd1c12ab649825a958b0ff3bb3d6f3e1250f13ddbf0148cc40297f730dd7b5a99567eb8d27b78758f607507c52292d02d4031895b52f2ff

To hash this hex string you can use the following code running Python in your command terminal:

      import hashlib

      transaction12_hex = "876dd0a3ef4a2816ffd1c12ab649825a958b0ff3bb3d6f3e1250f13ddbf0148cc40297f730dd7b5a99567eb8d27b78758f607507c52292d02d4031895b52f2ff"

      transaction12_bin = transaction12_hex.decode('hex')

      hash = hashlib.sha256(hashlib.sha256(transaction12_bin).digest()).digest()

      hash.encode('hex_codec')

      15b88c5107195bf09eb9da89b83d95b3d070079a3c5c5d3d17d0dcd873fbdacc

Transaction 3
6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4
Byteswapped = c46e239ab7d28e2c019b6d66ad8fae98a56ef1f21aeecb94d1b1718186f05963

Transaction 4
e9a66845e05d5abc0ad04ec80f774a7e585c6e8db975962d069a522137b80c1d
Byteswapped = 1d0cb83721529a062d9675b98d6e5c587e4a770fc84ed00abc5a5de04568a6e9

If you do the same thing for transaction 3 and 4 the final hash is: 49aef42d78e3e9999c9e6ec9e1dddd6cb880bf3b076a03be1318ca789089308e

Our last step is to combine the final hashed value of 1 & 2 and 3 & 4 and double hash it and byte-swap it.

Our answer is f3e94742aca4b5ef85488dc37c06c3282295ffec960994b2c0d5ac2a25a95766 the Merkle Root.


Whether I have to scan all types of addresses to discover BIP44 wallet from mnemonic? Let's assume that I am going to create a new address in bitcoin HD wallet knowing only mnemonic words and that previously addresses were generated according to BIP44.
BIP44 gives an algorithm how to perform discovery but one thing is not clear for me: whether I should check all possible address types described in the wiki (P2PKH, P2SH, Bech32) in outputs of transactions or there is some simpler way to check that particular index of child node was used to receive payments?
Any help will be apprecated, thank you!

That depends on what kind of wallet you have.

The derivation path is designed to tell you which types of addresses you need to.

m/44 means just regular addresses
m/49 means segwit nested in P2SH.
m/84 means native segwit.

Wallets such as electrum allow you to select which address type to check, and then perform the account recovery process you linked in your post. Ledger and Trezor similarly expect you to select address type when opening the companion apps on the computer.

If you are building a wallet or tool, you should either prompt the user to select the address type, or iterate all three combinations (and give an option to enter a manual derivation path for non-compliant wallets).


Uncaught exception 'Coinbase_ApiException' with message 'Status code 401' I am using magento extension of coinbase bitcoin for my sandbox account.

But whenever I am trying to place an order on my store I am getting following error :

Fatal error:  Uncaught exception 'Coinbase_ApiException' with message 'Status code 401' .

Help me to resolve this.

HTTP status 401 is "Unauthorized", you likely have your credentials or keys configured incorrectly.


Found Bitcoin Core Wallet with unconfirmed Transactions, anything to salvage? I am currently looking through old .dat files and found a wallet with two "Received with" transactions that are unconfirmed.
When I enter the address from the Label on blockchain.info the address shows a balance of 0 and 0 transactions.
Does that mean, that the transactions are invalid, and that I have to find the origin address to figure out a remaining balance, or is there anything other that I can do?
Bitcoin Core is only synced to 2017 yet.

Wait till it syncs to today. If remains the same, congratulations, you're $100k richer. Otherwise pretty useless.


How are the unlocking script + locking script executed? I just wanted to verify the input of transaction 7de75. The related output is index 10 of transaction 00f64.
The locking script defined in 76a91 (index 10) is:
OP_DUP
OP_HASH160
7ddb236e7877d5040e2a59e4be544c65934e573a
OP_EQUALVERIFY
OP_CHECKSIG

The unlocking script in 7de75 is:
3045022100b7393ff959120e3ccb5284e3cf2eaa200235643a1549a4e6faaa911619089e2b02207b677827c7beeb53503e016a8dd29164d07cb79f0f1e058df9b8dfa3568d029001
04c4b7a7f7bb2c899f4aeab75b41567c040ae79506d43ee72f650c95b6319e47402f0ba88d1c5a294d075885442679dc24882ea37c31e0dbc82cfd51ed185d7e94

I've concatenated both:
3045022100b7393ff959120e3ccb5284e3cf2eaa200235643a1549a4e6faaa911619089e2b02207b677827c7beeb53503e016a8dd29164d07cb79f0f1e058df9b8dfa3568d029001
04c4b7a7f7bb2c899f4aeab75b41567c040ae79506d43ee72f650c95b6319e47402f0ba88d1c5a294d075885442679dc24882ea37c31e0dbc82cfd51ed185d7e94
OP_DUP
OP_HASH160
7ddb236e7877d5040e2a59e4be544c65934e573a
OP_EQUALVERIFY
OP_CHECKSIG

and executed it via bitcoinIDE. However, OP_EQUALVERIFY failed. Could somebody explain to me where I made a mistake?
edit: I think Rene Pickhard explains the issue here but I cannot follow the explanation

This appears to be a bug in BitcoinIDE. The issue is that it is computing the hash differently from what it actually is. Because it finds a different hash, the comparison that checks that the hashes match (the OP_EQUALVERIFY) fails.
However the hash does match. If you compute the hash manually, you get a different hash than what BitcoinIDE is showing.
Using the btcdeb project, I am able to execute this script and step through all of the opcodes correctly.


Backtesting mtgox for historical trade analysis? I want to test out a few trading ideas for bitcoin. It seems to work on a small time horizon, and I'd like to backtest the past year or so of MtGox data. Is there a service that provides this? If not, is there a place I can buy the historical data dump?

Update

It looks like there are several projects around getting mtgox historical data out.

Nitrous' MtGox Trades Tool: This one seems to be the most useful to my needs. You get a dump, and can manipulate the data to create candles for backtesting. https://bitbucket.org/nitrous/bq

If you are more into Quantopian, there is a way to use weighted daily pricing data already imported: https://www.quantopian.com/posts/anyway-to-import-bitcoin-data

bitcoincharts.com will let you download their entire trade history of any exchange (for free) here: http://api.bitcoincharts.com/v1/csv/. Given the raw trade data (amount, price, timestamp), with some code, you can construct candles. I'm not sure this is of any use, though, because I don't know what kind of backtesting you're doing and whether you are dependent on some existing software that may or may not work with raw trade data (or whether you can make candles from it).


What hash rate can a Raspberry Pi achieve? Can the GPU be used? A Raspberry Pi is a credit card sized $25 (or $45, for the deluxe option) computer, designed for educational use. Has anyone tried running mining software on it? If so, what's the hashrate like? (apparently the CPU is approximately equivalent to a P2 300MHz - I know the hashrate will be very low!)
Also, can the GPU be used to mine? What's the hashrate for that, if it's been done.
From the FAQ on the above linked site: "The GPU provides Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode.
The GPU is capable of 1Gpixel/s, 1.5Gtexel/s or 24 GFLOPs of general purpose compute and features a bunch of texture filtering and DMA infrastructure.
That is, graphics capabilities are roughly equivalent to Xbox 1 level of performance. Overall real world performance is something like a 300MHz Pentium 2, only with much, much swankier graphics."
Note: The price of $25 or $45 excludes a way of powering it (via MicroUSB), a keyboard, a mouse and likely a USB hub. I think you need to provide an SD card too.

There is a nice wiki page here: https://en.bitcoin.it/wiki/Mining_hardware_comparison

The raspberry pi is listed by its processor in the arm section: ARM1176JZ(F)-S. It gets 0.2 Mhash/s when clocked at 800 MHz.


Consistency when multiple blocks are added Let's say that 2 miners were able to add a block around the same time. However, when they broadcast their respective blocks to the network, other nodes receive these blocks in arbitrary order. The block that arrives later will be considered invalid because the hash of the previous block will not match up.

How does blockchain ensure that the newly block added is the same one for all the nodes?

EDIT:

Even if everyone is connected to the network this can happen:

Blocks A and B are added at the same time. Then next round C happens on top of A, and D happens on top of B. All nodes will delete the shortest block-tip before they even hear about the other broadcast.

node 1:
chain +A  +C
chain +B  +D

node 2:
chain +B  +D
chain +A  +C

And if this keeps happening, all the nodes will maintain different versions of the blockchain which, in their view is the correct version

node 1:
chain+A+C+...

node 2:
chain+B+D+...

All nodes will delete the shortest block-tip before they even hear about the other broadcast.

This assumption is incorrect.

For Bitcoin Core (and since all full nodes are either Bitcoin Core, modeled off of Bitcoin Core, or forked from it, this applies to basically all nodes), all blocks which have a valid Proof of Work and a few other things are written to disk and added to the block index and chainstate. At the very least the headers are recorded as headers are received before the blocks are. So if I am using Chain+A and I receive block B, I will store block B and mark it as not in my main chain but still fully valid. When block C, I will update my main chain with block C (advance the current tip to block C). When I receive block D, I store block D to disk and mark it as not in my main chain but still fully valid.

If I had received block D (or its header) without having received block B (or its block header), then I will discard it as invalid. However this is unlikely to happen because I will almost always know the best headers chain of all of my peers because I asked for it when they connected and I will receive headers from each of them for every valid block they receive.

Such a fork will resolve when one chain has more work than the other chain. This will typically happen when one becomes longer than the other. When that happens, because all nodes know of the other chain having either its block headers or the blocks themselves, all nodes following the shorter chain will automatically switch over to using the longer chain.

If the split should persist indefinitely, then this will not happen, but that is extremely unlikely given that it becomes more and more improbable for every single block on each chain to be found, broadcast, and received by all nodes simultaneously.


What stops miners from no longer submitting failed hashes to the network, to reduce the difficulty and block time? As I understand it, the difficulty adjusts based on the hashrate to keep the block times at 10 minute intervals. But if Alice and Bob are the only ones mining on the network, what's to stop Alice from only broadcasting the correct hash that she finds, effectively reducing the seen hashrate by 2 and making blocks 5 minutes instead?

Miners don't broadcast failed hashes to the network.  They don't do anything at all with them, they simply ignore them and try again.  Nobody else ever sees them.

The way we know the network hash rate is not from observing all the hashes that were performed.  Rather, when we see a successful hash, the network difficulty allows us to infer the number of unsuccessful hashes that, on average, must have been performed to get it.

For example, the network difficulty is currently about 6.07e12.  This means, roughly, that a successful hash is required to start with about 74 zero bits, so the probability of any given hash being successful is about 2.6e22.  Thus, each time a single successful hash is broadcast to the network, we infer that about 2.6e22 hashes must have been performed throughout the entire network.  Since success is random, the actual number of hashes performed since the previous successful hash may have been significantly more or less.  But when we average over many blocks, we can come up with a reasonable estimate of the overall rate at which the network is performing hashes, even though we only ever see the successful ones.

Likewise, adjustments to the network difficulty aren't directly based on the overall hash rate.  Rather, they're simply based on the rate at which successful hashes have been observed; specifically, how long it has taken for the  last 2016 successful hashes to show up.  From the discussion above, this is correlated to the overall hash rate, but the overall hash rate isn't actually used in the difficulty adjustment calculation.

In your example, Alice's decision to broadcast failed hashes or not plays no role in the Bitcoin protocol.  If she broadcasts a failed hash (i.e. a block with an incorrect proof-of-work), it will simply be ignored.  In fact, other nodes on the Bitcoin peer-to-peer network will likely disconnect from her (a so-called "ban"), because she's cluttering up the net with useless junk.


Why don't people buy at one exchange and sell at another? Bitcoinity.org shows that for the past 30 days, bitstamp's price is high at 101.00, low at 77.00, and current price is 98.04. On contrast, mtgox's price for the past 30 days is high at 115.00, low at 86.20, and current price is 110.50.

In other words, someone or anyone can just buy from bitstamp and sell to mtgox to make profit.

What's stopping people from doing so? What's the catch?

It can't be that people aren't aware that they could do it right?

Many people already do this with bitcoin. In finance, this is called arbitrage trading, or simply arbitrage, sometimes even abbreviated arb.

The reason for the price differences are fees for transferring between the bitcoin exchanges (you have to transfer both, bitcoins and fiat currency for a complete cycle) and fees for trading bitcoins against fiat currencies.

Because of the arbitrage traders, who make profits as long as the price difference is big enough, the prices on different exchanges quickly adjust to be right at the border between where the fees eat up the earning and where you make profits.

There is an excellent page, http://bitcoin-analytics.com , which can tell you where there currently are arbitrage oppurtunities. Simply go to the website and click on "Arbitrage".


Difference between originator of transaction and owner of the source fund Here is an excerpt from Andreas Antonopoulos, Mastering Bitcoin, Chapter 5 (Transaction), sub chapter(Creating Transactions):

My question is what's the difference between the originator of transaction and owner of the source fund?
Who actually signed the transaction? For example, if Alice pay to Bob 0.1BTC, is that transaction signed by Alice?

if Alice pay to Bob 0.1BTC, is that transaction signed by Alice?

Yes.

If I understand your quotation correctly, Andreas Antonopoulos is saying that Alice's personal assistant Charlie, could have prepared the transaction without any signature and passed it to Alice for approval and signing.

I don't know which wallets support this kind of arrangement. For most of us the preparation and signing are all handled together at the same time.


Is it possible to get already-sent bitcoins from a corrupted wallet? I bought some bitcoins on LocalBitcoins then downloaded Bitcoin-qt then instantly sent it to my wallet and now the wallet is corrupted... Is there a way to get them back?

Create a backup of your current wallet.dat file. Check this is you don't know where the file is stored.
Check debug.log in your bitcoin datadir, see if there are any errors, ask somebody, post here, post on IRC
Start bitcoind or Bitcoin-Qt with command line argument -salvagewallet (if you don't know how to run a Application with command line arguments, try to ask someone or get help over IRC freenode/#bitcoin.
If step 3 didn't help, check if you have a backup from your wallet.dat, replace files (only overwrite your wallet.dat if you followed step 1).
If nothing worked out, get help from a bitcoin expert over IRC (but never give away your wallet.dat!)


When does a crypto exchange write to a blockchain? From my understanding, when dealing with an exchange you first transfer your currency to the exchange's address. The exchange then pools the currency of its participants.

When transactions then take place across the exchange, the exchange doesn't write to the underlying blockchain, but records all these transaction by changing their records of ownership in their own internal database.

When you withdraw your funds, you then retrieve your currency back to your own wallet.

Does this mean an exchange will only write to the blockchain when you transfer currency to or withdraw money from the exchange?

Yes and No, depending on the exchange. You can confirm this by watching the deposit transaction on the blockchain. For example using blockchain.info.

Some exchanges write to the blockchain once you deposit by immediately transfering your deposit to their cold wallet.

Others, like bitkonan will keep your funds on your deposit address for quite a while until you either trade or attempt a withdrawal.

So depends on the Exchange architecture, but for sure they all write to the blockchain when you make a withdrawal.

The unfeasible alternative of making a real transaction whenever anyone trades would lead to too many transactions on the real blockchain and trades would have to wait to be mined so as to be completed.


Why the message is need in verify function here is the how bitcoin works under the hood article
http://www.imponderablethings.com/2013/07/how-bitcoin-works-under-hood.html
i did not got this why message is needed when using this verify function ?
1 =? v(message, public key, signature)

Say you see a check for "$50,000 to Bob" that needs to be signed by Ed. What you want to know is whether the signature on the check came from Ed and signs the message "$50,000 to Bob". So the question a signature checker answers is, does the given signature attach the given credential to the given message. How would it check that without the message?

Checking a signature detached from a message would serve no purpose. Say you see that check for $50,000 to Bob. If Ed actually signed "$50 to Alice", the the signature check must fail -- since Ed didn't sign that message. So you can't check the signature without knowing the message.


Why I obtain this error trying to compile this wallet? I am not yet a Linux guy and I am going crazy trying to install the MJ Coin wallet compiling it on Ubuntu 14.04.

This are the only provided instruction to install it:

  Debian

  First, make sure that the required packages for Qt5 development of
  your distribution are installed, for Debian and Ubuntu these are:

apt-get install qt5-default qt5-qmake qtbase5-dev-tools qttools5-dev-tools \
    build-essential libboost-dev libboost-system-dev \
    libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev \
    libssl-dev libdb++-dev

then execute the following:

qmake
make

So I have installed the dependencies using apt-get and it seems to me that I have no problem.

Then I perform qmake and I obtain the following output:

andrea@andrea-virtual-machine:~/Documenti/wallet/MJcoin$ sudo qmake
Project MESSAGE: Building with UPNP support Removed plural forms as
the target language has less forms. If this sounds wrong, possibly the
target language is not set or recognized. Removed plural forms as the
target language has less forms. If this sounds wrong, possibly the
target language is not set or recognized. Removed plural forms as the
target language has less forms. If this sounds wrong, possibly the
target language is not set or recognized.
andrea@andrea-virtual-machine:~/Documenti/wallet/MJcoin$

Finally I execute the make compile command but I obtain the following error message:

.........................................................................
.........................................................................
.........................................................................
cd /home/andrea/Documenti/wallet/MJcoin; /bin/sh share/genbuild.sh
/home/andrea/Documenti/wallet/MJcoin/build/build.h g++ -c -m64 -pipe
-fstack-protector-all --param ssp-buffer-size=1 -O2 -D_REENTRANT -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector -fPIE -DQT_GUI -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DQT_DISABLE_DEPRECATED_BEFORE=0 -DUSE_UPNP=1 -DSTATICLIB -DHAVE_BUILD_INFO -DLINUX -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -Isrc -Isrc/json -Isrc/qt -Isrc/leveldb/include -Isrc/leveldb/helpers -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -Ibuild -Ibuild -o build/net.o src/net.cpp src/net.cpp:19:32: fatal error:
miniupnpc/miniwget.h: File o directory non esistente  #include
<miniupnpc/miniwget.h>
                                ^ compilation terminated. make: *** [build/net.o] Errore 1

The enghlish translation of the error output is: File or directory don't exit #include miniupnpc/miniwget.h

What could be the problem? How can I try to fix it?

Like it says, you are missing the header file miniupnpc/miniwget.h.  Usually this means there is a required library that is not installed.

Ubuntu has the convenient tool apt-file for finding which package provides a particular file.  Install the apt-file package (apt-get install apt-file) and run apt-file update to install the file list.  Then you can do

$ apt-file search miniwget.h
libminiupnpc-dev: /usr/include/miniupnpc/miniwget.h

So you need to install the libminiupnpc-dev package.

Since the documentation doesn't seem to mention this dependency, you may want to report this as a documentation bug to the MJcoin developers.


What needs to be written down for a paper wallet? I'm installing bitcoin-core with snap on Ubuntu for a dry-run at generating a paper wallet.
Perhaps naively, I thought to "write down" something like:
nicholas@mordor:~/bitcoin$
nicholas@mordor:~/bitcoin$ ls
nicholas@mordor:~/bitcoin$
nicholas@mordor:~/bitcoin$ ssh-keygen -t ed25519 -C saunders.nicholas@gmail.com
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/nicholas/.ssh/id_ed25519): ./bitcoin_wallet
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./bitcoin_wallet
Your public key has been saved in ./bitcoin_wallet.pub
The key fingerprint is:
SHA256:MtZQUFLqDWU0fJbkFhner+ZRF1WZ1MacM0WOBbGPvCc saunders.nicholas@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
|      o*O.++  +B&|
|       *.+=o   @*|
|      +  o+ . oo+|
|     . = .   o o.|
|      = S     = o|
|     . o     o o |
|            + E .|
|           o . o |
|            .    |
+----[SHA256]-----+
nicholas@mordor:~/bitcoin$
nicholas@mordor:~/bitcoin$ ls
bitcoin_wallet  bitcoin_wallet.pub
nicholas@mordor:~/bitcoin$
nicholas@mordor:~/bitcoin$ cat bitcoin_wallet
-----BEGIN OPENSSH PRIVATE KEY-----
b3...AAtzc2gtZW
QyNTUxOQAAACD...AAAKBLLY/ISy2P
yAAAAAt...jpB6ZXAZLiLoXx+D9kw
AA..JYB62mUlxCESA
KyOkHp...LmNvbQEC
-----END OPENSSH PRIVATE KEY-----
nicholas@mordor:~/bitcoin$
nicholas@mordor:~/bitcoin$ cat bitcoin_wallet.pub
ssh-ed25519 AAA..IuhfH4P2T saunders.nicholas@gmail.com
nicholas@mordor:~/bitcoin$

where I need the public and private key.  Obviously, very easy to make a mistake, but isn't that what's required??
I'm not understanding all this mention of writing down seed words or passphrases.  Isn't the key pair required?

leaving aside QR codes or other automated tools for storing keys.

The design/structure of a paper wallet is not something is set in stone, but the main idea is writing public and private key pairs on a piece of paper.
The universal flow for generating an address is:

A public key is derived from private key
A bitcoin address is derived from public key

The common flow (Mnemonic) for generating an address is:

Master private key is derived from mnemonic phrases
A private key is derived from master private key
A public key is derived from private key
A bitcoin address is derived from public key

As you can see 3rd and 4th steps of Mnemonic key-generation flow are the same as universal key-generation flow. You can unlock your Bitcoin with plain private key without mnemonic phrases. Mnemonic phrases are just used to derive private key, so you can simply write down public key(65-byte or 33-byte) and private key(32-byte) onto a piece of paper regardless how you generated your key-pairs.


Is the blockchain ever-increasing? (forever) Possible Duplicate:
  Are there any studies into the size of the blockchain scaling over time?

Hi folks, I have a theoretical question. Since the blockchain stores all bitcoin transactions, does this mean that it is ever-increasing and will never, ever stop gobbling up disk space?

Cheers!

Yes, the blockchain itself will keep increasing forever. On the other hand, one does not need to store the entire blockchain to use Bitcoin. It is possible that later version of Bitcoin will start pruning old, spent transactions to keep local disc storage smaller.


Why Ethereum is growing in USD but decreasing in BTC? Please explain to me why the ETH/BTC price is decreasing but ETH/USD price is increasing. How does that work? Why it costs less in bitcoins but more in USD?

It means that the value of btc is increasing at a higher rate than the value of eth.  Therefore it takes less btc to buy eth, and the cost of eth in btc is dropping.


How to speed up initial block chain sync using SSD without wasting space? I have a 60GB SSD as my Windows system drive, which isn't enough to save the entire blockchain to. I installed BitCoin Core (bitcoin-qt) and set the data directory to be on my 2TB HDD. However, the initial blockchain sync is running since 2 days already, currently being '40 Weeks behind'. The HDD is showing 100% load in Windows task manager. CPU is at <50% load, network usage is <1MB/s while syncing.

Can I speed up the initial sync by using the SSD for DB storage, while binary blockchain data is saved to conventional HDD?

Does that actually speed up the sync?

Yes, it is possible to load the blockchain binary data off to a bulk storage (HDD), while keeping the Index DB on performant storage (SSD).
The Bitcoin Blocks are stored in the blocks subdirectory in your datadir. The location of your datadir is either %AppData%\BitCoin, or set manually by you during the installation of bitcoin-qt.

I ASSUME you're using BitCoin Core (aka bitcoin-qt) on Windows 7 or higher, C:\ being your SSD, F:\ being your HDD, bot formated as NTFS. The location of datadir is %AppData%\BitCoin\.

Move %AppData%\BitCoin\blocks to the HDD, e.g. to F:\BTC\blocks
OPTIONAL Move F:\BTC\blocks\index back to the SSD: %AppData%\BitCoin\index

NOTE: The blocks folder must not exist in %AppData%\BitCoin now!

Open a cmd window by pressing WIN+R, then type cmd and click ok
Type/Paste mklink /J %AppData%\BitCoin\blocks F:\BTC\blocks and hit ENTER. (This creates a NTFS Junction, creating a link in %AppData%\Bitcoin called blocks, pointing to the existing F:\BTC\blocks folder on the HDD)
OPTIONAL Type/Paste  mklink /J F:\BTC\blocks\index %AppData%\BitCoin\index and hit ENTER (Create new link at F:\BTC\blocks\index pointing to existing %AppData%\BitCoin\index)

Now, the blocks directory is on the HDD for cheap bulk storage, while its index subdirectory and parent datadir is on the speedy SSD. Only binary blockchain data is stored on HDD.

About the index directory (Steps 2, 4): As Pieter Wuille comments below, you don't really need to move the index directory within blocks back to SSD. But since it contains one of the databases, I figured it might help performance when starting up bitcoin-qt. [citation needed]

In my case, this Windows task manager shows read/write speeds 10 times higher than befode (20-30MB/s). Download speed did go up to 2-4MB/s (50MBit Internet), CPU load is up at 85%.

I didn't monitor blocks/second improvement, but the taskmanager values show better throughput of data, which should directly relate to more blocks per second. I synced 15 weeks of blockchain while writing this (30m), versus only 1 week before the modification!

The datadir without binary blockchain data is a little over 2GB, with 25 weeks worth of blockchain still missing. I'd recommend at least 5GB free space on the SSD for the currently 80GB big blockchain.


How to confirm a payment was made? I am planning to write a site that receive payments in Bitcoin.

The client add products to the cart, then during check out I will create a Bitcoin address to let him pay for it (each cart gets a unique address). I found the code to create multiple address here. I plan to use the NBitcoin library.

How do I verify the Bitcoin address has been paid? I'm planning to use a service like blockchain.info, but I only have the following information

destination Bitcoin address (my generated address)
the amount it should receive

Is there an easy way to use blockchain.info to query that my address was really paid using C#? I read the API but it is confusing.

I'm not sure about Nbitcoin node's API, but I could help you on a blockchain explorer API.

I would recommend Blockr.io, they are fast and trustable. Use the following code to check for confirmed transactions: (output is in json)

http://btc.blockr.io/api/v1/address/balance/198aMn6ZYAczwrE5NvNTUMyJ5qkfy4g3Hi,1L8meqhMTRpxasdGt8DHSJfscxgHHzvPgk?confirmations=1

Change the confirmations tag to whatever amount you want. I highly advise against 0.


How to differentiate between sending and receiving address in blockcypher api result? I am using BlockCypher's API to get a list of transactions for a bitcoin address. I need to maintain a record of IN and OUT transactions from this address with time and transaction hash. However, I am not able to differentiate between the receiving and sending address. It is so much clear with Etherscan.

API Endpoint :

https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/full?confirmations=3&limit=2000

Can someone please help me differentiate it?

You should look at

   "inputs": [
        {
          "prev_hash": "017ce1c080eda9c5364b6efbcbd2d9b790983bb36fb81316d53269bb83703f08",
          "output_index": 0,
          ...
          "output_value": 269570000,
          ...
          "addresses": [
            "1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp"
          ],
          "script_type": "pay-to-pubkey-hash",
          ...
        },
        {
          "prev_hash": "02be075b8e6cf357fd34f81eaa273e9e4f5f970af3dc01b9fa07ae0d1795cb75",
          "output_index": 1,
          ...
          "output_value": 3876180000,
          ...
          "addresses": [
            "1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp"
          ],
          "script_type": "pay-to-pubkey-hash",
          ...
        },
        ...],
        "outputs": [
        {
        "value": 47981690876,
        ...
        "spent_by": "fe6a1669bc5c00171b921d7883ff674a7ac3fb8cd6a986ef6c69175d336ffc89",
        "addresses": [
            "15Z9atbppxt97unmzBdGkHuSx9UdptwqDb"
        ],
        "script_type": "pay-to-pubkey-hash"
        }
        ]

These are the relevant lines.


Bitcoin-qt v0.8.0b client on Mac OS X 10.8 crashes, why? I was running the stable 0.7.2 bitcoin-qt client (under OS X 10.8.2) for a couple of weeks, with the block-chain completely sync'ed on an ongoing basis. No transactions in my wallet.

I upgraded to the 0.8.0b release, and it spent a few hours reindexing the entire blockchain and catching up. So far so good.

0.8.0 client continued to run normally (launch, download / sync new blocks, etc.) for several days.

Then, today, it crashes right after loading the wallet, but before it attempts any network connections. Crash is reproducible and persistent across reboots. Here's where the debug.log output ends. (No further errors.)

Bitcoin version v0.8.0-beta (2013-02-18 18:38:34 -0500)
...
init message: Verifying block database integrity...
Verifying last 288 blocks at level 3
No coin database inconsistencies in last 222481 blocks (8492 transactions)
block index            4479ms
init message: Loading wallet...
nFileVersion = 80000
wallet                 1500ms
init message: Importing blocks from block database...

I fixed the problem myself.  During a system sleep or perhaps a hang and hard reset (graceless shutdown) the block index got corrupted.  Best-practices for Bitcoin-qt, at least on a Mac, are probably to quit out of the app before putting the system to sleep.

To fix the problem, I trashed the entire directory

~/Library/Application Support/Bitcoing/chainstate/

and then relaunched the client. It re-indexed all the existing blocks (took about 2 hours,) but did not have to re-download the entire blockchain.

After allowing it to fully re-sync and catch up all blocks, I was able to do transactions normally. 48 hours later the client is still running stably and normally. (Including quitting & re-starting the client.)


Bitcoin Core 0.17 sethdseed then dumpwallet how to recompute extended private masterkey? Using bitcoin-cli -datadir=X sethdseed true "WIF_KEY" the current wallet within datadir is updated
Then, using bitcoin-cli -datadir=X dumpwallet my_dump.txt shows a fresh new  # extended private masterkey: tpriv..., which is determiniscally generated from the WIF_KEY

Now, using the # extended private masterkey I could indeed generate the same address than bitcoin core with the m/0'/0'/i' derivated path.

How could I compute the # extended private masterkey without dumping the wallet, using tools like libbitcoin bx ?

Also, the dumping file show a WIF_KEY 2019-03-22T14:43:55Z hdseed=1 # addr=mnMEP6P92XKxKfEM5v2SxzLBMVB2tf7Lsj hdkeypath=s which is exactly the m/44'/1'/0'/0/0 from the WIF_KEY passed in sethdseed cmd, why ?

Bitcoin Core uses the method described in BIP 32 to generate the master private key from a seed. The seed here is WIF private key. To get the master private key from the seed, you will need to decode the WIF private key to get the byte sequence that it represents. Then you can hash it as described in BIP 32 and encode it to get the master private key.

You can use bx to do this:

bx wif-to-ec <WIF key> | bx hd-new