Ways to monitoring BTC trading profit and loss?

No need for fancy scripts and databases:

[what you put in] - [what you got out] = [your profit]

All you need to know:

the price of BTC at the beginning of the period
the price of BTC at the end of the period
have a list of all USD deposits/withdrawals
have a list of all BTC deposits/withdrawals (and the value of BTC in USD at that moment the deposit or withdrawal was made)

I will try to explain with an example:

Starting balance = $0 + 1 BTC
Deposit $1,000 (balance = $1,000 + 1 BTC)
Buy 1 BTC @ $900/BTC 1% fee = 0.01 BTC (balance = $100 + 1.99 BTC)
Sell 0.5 BTC @ $920/BTC 1% fee = $46 (balance = $555.40 + 1.49 BTC)
Withdraw $500 (balance = $55.40 + 1.49 BTC)

For a certain period in time the profit

= ([value of all assets at end of period] – [value of all assets at beginning of period]) + ([value of assets withdrawn] – [value of assets deposited])
= (($55.40 + 1.49BTC) - ($0 + 1BTC)) + (($500 + 0BTC) - ($1,000 + 0BTC))
= (($55.40 + 1.49BTC x $920) - ($0 + 1BTC x $900)) + (($500 + $0 x $920) - ($1,000 + $0 x $900)) // convert BTC to USD for the price at that time
= (($55.40 + $1,370.80) - ($0 + $900)) + (($500 + $0) - ($1,000 + $0))
= ($1,426.20 - $900) - $500 // My assets is worth $1426.20 at the end of the period, it was worth $900 at the beginning of the period but I added $500 from external sources (deposit - withdraw)
= $26.20 // Total value of my assets increased by $26.20

Even if I made zero trades for the month and the BTC price increased while I had BTC "stock", I would have made "profit" from a USD perspective as my total assets' value increased in USD terms.


How do you generate a bootstrap.dat file?

The bootstrap.dat file contains a serialized copy of the blockchain, usually up to the latest checkpoint released for the official client.  The official bitcoin client will read this file when starting to create the blockchain without downloading it from the peer nodes.  The file will then be renamed to bootstrap.dat.old so it won't be reprocessed when the client is restarted.

A Python script used to create the file can be found here.  You will need an up-to-date pynode chain database.

If you have the Armory code, you can compile this C++ program.  This uses the blockchain data blocks created by the official bitcoin client.


PHP How can I validate / verify a wallet public key?

BIP32 specifies the serialization format used by extended keys as:

  Serialization format Extended public and private keys are serialized
  as follows:

  4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private;
  testnet: 0x043587CF public, 0x04358394 private)
  1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys,
  4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
  4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
  32 bytes: the chain code
  33 bytes: the public key or private key data (serP(K) for public keys,
  0x00 || ser256(k) for private keys)

  This 78 byte structure can be
  encoded like other Bitcoin data in Base58, by first adding 32 checksum
  bits (derived from the double SHA-256 checksum), and then converting
  to the Base58 representation. This results in a Base58-encoded string
  of up to 112 characters. Because of the choice of the version bytes,
  the Base58 representation will start with "xprv" or "xpub" on mainnet,
  "tprv" or "tpub" on testnet.

  Note that the fingerprint of the parent
  only serves as a fast way to detect parent and child nodes in
  software, and software must be willing to deal with collisions.
  Internally, the full 160-bit identifier could be used.

  When importing a serialized extended public key, implementations must
  verify whether the X coordinate in the public key data corresponds to
  a point on the curve. If not, the extended public key is invalid.

Your PHP code must first run the b58check algorithm to verify the xpub is encoded correctly, and then decode it into the above values. Lastly, you must check that the pubkey found by decoding the xpub is a value point on the secp256k1 curve.


The getrawmempool RPC command, in verbose mode, produces an output that contains all known mempool transactions for your nodes. This output contains a bip125-replaceable boolean field which you can use to determine if a tx is explicitly or implicitly replaceable by fee.


Can I use the official wallet to recover bitcoins sent to an alternative wallet?

Most alternative wallets give you the possibility of exporting the private keys. Private keys can be imported in almost every other wallet.

In the case of Armory, the root key and chain code are used to generate a whole chain of private keys. You can ask for new addresses as you like inside your wallet, and by backing up only these two keys, you can recover all of them. This is a useful feature, but makes it harder to import in other wallets.

Luckily, Armory has an option to export the individual private keys of all the addresses you used. In the wallet menu there is a link "Backup Individual Keys" for this purpose. This exporting feature will always be available, also when Armory decides to stop, since it is independent of Bitcoin itself.

I don't know how other wallets support backing up individual keys, but I suppose most of them can.


How are Ledger Nano S private keys protected?

Ledger uses a secure element chip to store the private key.

In simplified terms this means that the private key is stored on a special chip that is almost like a small computer with a Operating System with a very strict and well defined interface. This interface is designed to NEVER allow an extraction of the private key except during the creation of the key when the seed is shown on the display. The only operation that uses the private key that is supported is to send input (read transactions in terms of bitcoin) that the chip signs with the private key, and then returns the signature. Therefore the only output you could get from the chip is the signed transaction, and never the private key, no matter where you put the chip.

Secure element chips are not a new invention by Ledger, but actually a technology used in many other use cases (other examples are passports and credit cards). Ledger uses a Javacard with version 3+, which supports creation of ECC keys that have size of bitcoin keys.
It should however be noted, that even though the chips are designed to never let anyone extract the key from the chip, even with physical access to it, a well motivated and funded actor (like NSA) could theoretically extract the private key.


im a beginner and i hve what probably a simple question

The cryptocurrency market isn't special, things work the same as they would in any other market.

It makes no difference how much you buy, nor what you buy (ie, bitcoin, an altcoin, Euros, a house, whatever).  Your profit is how much you sell for minus how much you invested.  So if you buy $40 worth of bitcoin, and sell for $50, you've made $10 profit (minus taxes and fees).


Why is a double hash of the previous transaction included in Txin?

I believe it is one of the principles of Bitcoin, to make transactions you first have to have a valid transaction it stems from. If the previous transaction is not valid than the first transaction isn't valid as well.


bitcoind validateaddress extended info.. somtimes there, somtimes not, why?

Note the difference: one has "ismine" true and in the other it's false.

I haven't specifically checked, but I presume that "ismine" indicates whether or not the address is one belonging to you (and whose key is in your wallet).  If it is your address, then bitcoind is able to report the associated public key, and various other details about how the key is stored and notes associated with it.

If the address is not yours, then since the address is only a hash of a public key, there is no way for bitcoind to know what the public key itself is, nor any other information about how the owner is storing the key, etc; that information is known only to the key's owner.  So you don't see these fields in the output.


Is BitCoin Mining Basically a Game? Do the Solved Math Equations do Anything?

Yes, its kinda like solving really hard math equations.

Mostly done by specificaly made machines like this one:
Antminer S9

But this video explains it all https://www.youtube.com/watch?v=GmOzih6I1zs


Bitcoin uses a thing called the Unspent Transaction Output Set (UTXO set), not accounts or balances. A transaction will consume UTXOs as inputs and create UTXOs as outputs. When a node receives a block (either during initial sync or normal relay), it will update its own internal database which contains the UTXO set. In this update, it removes the UTXOs that have been spent and adds the UTXOs that were created. Because it does this for every block, if a node is fully synced, it should know what all of the UTXOs are and have them stored in the database.

When a node receives your transaction, it will look up the UTXOs that your transaction spends in its database. If they don't exist, then it discards your transaction as invalid. It does not need to traverse the blockchain; the data it needs have been pulled out and put into another place where it can be easily looked up.


Bitcoin transaction confirmed and spend but not funds recieved

As per the transaction id you have given, you can see the status here:

https://blockchain.info/tx/2d581849f11fd34a7d82a6913f78eaf19802bcd0c20aca5905f0d9aeab5f0832

And you can see that the transaction is complete, infact you have used the funds already.


Is there a step by step tutorial on does Ardor's transaction vouchers work?

Vouchers are useful when Alice wants Bob to pay her in a secure tamper proof way.

First she asks Bob what is his account address, she then logs into the wallet using Bob's address and using the normal send money dialog performs a payment from Bob to her account.
But of course she cannot submit this payment since she doesn't have Bob passphrase.
Instead she enters her passphrase and checks the voucher checkbox. As a result the wallet generates a digitally signed voucher she can send to Bob as a json file or QR code. Nothing is submitted to the blockchain at this stage.

Bob now uses the "Load Voucher" function from the wallet gear menu to load Alice's voucher. He double checks all the details then signs and submits voucher to the blockchain.

The result is that Alice received her payment while Bob now has the voucher which represents an invoice for his financial records. Alice got her tokens and Bob is sure that he really paid Alice and that Alice indeed has a passphrase to her account.


Are there any studies into the size of the blockchain scaling over time?

Satoshi Nakamoto addressed this issue in the original crypto forum thread.

  Long before the network gets anywhere near as large as that, it would be safe
  for users to use Simplified Payment Verification (section 8) to check for
  double spending, which only requires having the chain of block headers, or
  about 12KB per day.  Only people trying to create new coins would need to run
  network nodes.  At first, most users would run network nodes, but as the
  network grows beyond a certain point, it would be left more and more to
  specialists with server farms of specialized hardware.  A server farm would
  only need to have one node on the network and the rest of the LAN connects with
  that one node.

  The bandwidth might not be as prohibitive as you think.  A typical transaction
  would be about 400 bytes (ECC is nicely compact).  Each transaction has to be
  broadcast twice, so lets say 1KB per transaction.  Visa processed 37 billion
  transactions in FY2008, or an average of 100 million transactions per day.
  That many transactions would take 100GB of bandwidth, or the size of 12 DVD or
  2 HD quality movies, or about $18 worth of bandwidth at current prices.

  If the network were to get that big, it would take several years, and by then,
  sending 2 HD movies over the Internet would probably not seem like a big deal.


Sent 95BTC to my client from Mt.Gox and it never showed

If you are not sure if your wallet balance is okay, search for your address in the Block Explorer. If you see your coins there, they are safe. I'm guessing it's this address, so everything should be fine.
Make sure your client is up-to-date. If it is too old it might not be able to communicate with the network. (remember to backup your wallet.dat beforehand)
If your updated client can't connect to the network (0 connections), check out this topic.
If your client is connected to peers, but after an hour you don't see any block progress, try closing down the client, deleting blk .dat files from your Bitcoin data directory, and then starting it again.
When you see your block count progressing, be patient. Leave your computer running the client over night. The procedure takes awhile, as Bitcoin needs to download and verify over 1GB of data.

If all else fails, you can try redeeming your wallet at MtGox (remember exactly if this is the only service providing this functionality) and using an online wallet service, like StrongCoin, to never have to deal with the problem again.


Transfering btc from blockchain to electrum wallet, still unconfirmed

There is currently a Phishing attack going on with electrum. Did you make sure you downloaded electrum from the official site? Also with wich electrum servers did your electrum wallet connect? Maybe one spreading false information to trick you into their fishing attack


How is the monetary part of bitcoin stored?

Within the Bitcoin protocol, each Bitcoin is represented as 100000000 satoshis. Therefore, you can divide bitcoin up with a precision of 0.00000001.

In a transaction, the number of satoshis being delivered to each output is recorded, along with a record of which previous output is being spent.

The fee is then derived from sum(Inputs) - sum(Outputs). The actual representation of the amount itself is encoded using the Variable Length Integer representation


Sorry newbie, I dont get the PoS block creation, to much contradiction

POS distributes valid block rewards proportionally to stakers. However, majority stakers cannot be unseated if they do not wish to trade their stake. A 51% staker can control/censor the system indefinitely.

POW always allows for new hashrate to come online. If fees increase, new mining will join, thereby diluting a potential 51% miner. Because external hashrate can always be added, the Power of any miner can always be balanced That is not the case with POS.


Do you need multiple wallets to manage your cryptocurrencies?

Almost every coin has its own infrastructure, so yes, you will need another wallet for almost every altcoin.

Luckily, there have been some people who invented hardware wallets which simplify the process.

Meaning you can hold multiple altcoins in this one program. They still have their own wallet, but is just much more user friendly.

See,

These wallets are both open source, and you are the only one who has acces to your private key, which means that these are pretty secure.

https://coinomi.com/

  Supported Coins (64!!): BTC, ABN, AC, AUR, BTA, BELA, XBC, BLK, BRIT, CDN, CCN, CLAM, CLUB, COMP, DASH, DGB, DOGE, DGC, EDR, EFL, EMC2, ETH, ETC, EXP, FTC, GAME, GCR, GRC, NLG, INSN, IOP, JUM, LDCN, LBRY, LTC, MONA, XMY, NMC, NAV, NEOS, NVC, USNBT, NSR, OK, PKB, PPC, PSB, PIVX, POSW, POT, RDD, RICHX, RBY, SDC, SMLY, SLR, STRAT, SYS, UNO, XVG, VRT, VASH, ZEC, XZC

https://jaxx.io/

  Supported coins (12): BTC, LTC, ETH, DASH (not on iOS), ETC, REP, ZEC (not on iOS), DOGE, ICN, GNT, GNO, DGD


Bitcoins never showed up in wallet. Yet sender says transfer complete

This should be easy to prove or disprove using any block chain explorer.  Ask the sender to send you the transaction hash for the transaction where the coins were supposedly sent to you.  Then, do a search for this transaction hash using any block chain explorer (such as blockchain.info).  If a transaction is found for the hash, with your bitcoin address and the amount that you expected as one of the outputs, then this confirms that the sender did indeed make the payment to you.  Otherwise, the sender can't support their claim.


Best way to safely host a high volume online transactional wallet?

It seems to be a good approach. The fundamental is keep a little bit "hot" to high liquidity and keep the rest into USB stickers + papers and if possible keep it safe in a vault or bank. Also, keep the anonymity and security of who has the access to the Bitcoins. Remember: Bitcoin is real money, and if you are working with a lot of money, it can be dangerous, someone can try to extort you to reveal all secret.

Don't forget too that USB stickers are volatile in long term by definition, and are not 100% safe. CD and DVD can scratch or can degrade over time. So, the paper is fundamental; keep it in a clean and dry place. Remember also to generate the wallet keys in a offline computer (installed from zero if possible). Read this article: How to set up a secure offline savings wallet.

There is a nice article about it here: Coinbase now storing 87% of customer funds offline


What / Who is the Bitcoin mining-power useful to?

It is useful to the currency itself.

Bitcoin tries to be a democratic currency rather than being controlled by a central authority. Democracy means that the majority of people rule by their vote. This is a concept that might work in real life (all irony intended), but it's hard to pull off on the Internet since we can't simply prevent one real person from creating thousands of virtual identities and using them to make his vote louder (so called Sybil attack).

Bitcoin solves this via a concept known as proof-of-work, which requires some non-trivial work to be done for every vote to be registered. While it is not a perfect solution (surely one can manage to do twice as much work as somebody less capable), it has an ambition to prevent all serious scams, making it infeasible for a single entity to overpower (outvote) the crowd.

Mining is the process of voting, and miners are the voters. Every voter has to find a reverse hash according to some very specific rules, which is considered a hard work. All the others can verify his solution easily.

I know this does not describe the problem entirely (and it was not my goal), but it should give you the idea. If interested in the technical details, please see the original paper or read some articles explaining Bitcoin in-depth. There's plenty of them out there, but be prepared to spend a few hours going through the stuff.


Addresses are intended to be used once, and there are problems with reuse, but it is usually safe to just use the same one repeatedly for donations if you don't have a way to update it easily. However, Bitcoin is still a new technology, so this may change in the future (making reuse stop working) - read the release notes of new versions before you upgrade to ensure you're not caught by surprise.

If you have a way to update the webpage automatically, there is a JSON-RPC method "getnewaddress" that you can use. However, it is very unsafe to run your Bitcoin wallet on a webserver, so be sure if you go this route that you push it from a separate, secured machine.

PayPal does not at this time support Bitcoin.


What are the consequences of donating bitcoins to WikiLeaks?

Having been in the Army and understanding the stance that the US government has taken, I'm sure t will be up to the commanders.  Many of whom will not look kindly on the gesture.  The official stance will be known when they take action.

As you know the transactions are public and there are a number of efforts to build visualization and data mining tool sets.  This article address the anonymity of transactions and describes nicely why there is no real anonymity if someone wants to dig.

http://anonymity-in-bitcoin.blogspot.com/2011/07/bitcoin-is-not-anonymous.html

You'll also notice two other important things about the article.  One is that it focuses on WikiLeaks and that they are using Visualization tool sets.  this tells me someone is already looking to make connections.


How to calculate segwit transaction fee in bytes?

That depends on what those inputs and outputs look like.

The formula, as specified in BIP141, is:

Call base_size the number of bytes needed to serialize the transaction in legacy format (which does not include the witnesses).
Call total_size the number of bytes needed to serialize the transaction including witnesses.
The weight of the transaction equals 3*base_size + total_size
The virtual size of the transaction (which is what feerates are usually expressed against) equals weight/4 or 0.75*base_size + 0.25*total_size.

Some reference numbers:

Outputs:

A P2PKH (1... address) output is 34 vbytes.
A P2SH (3... address) output is 32 vbytes.
A P2WPKH (bc1q... address of length 42) output is 31 vbytes.
A P2WSH (bc1q... address of length 62) output is 43 vbytes.

Inputs:

A P2PKH spend with a compressed public key is 149 vbytes.
A P2WPKH spend is 68 vbytes.
A P2SH-P2WPKH spend is 93 vbytes.


Is the time taken for the verification of a transcation not much relevant?

To do this the miners have to traverse through huge number of blocks to the block of then, won't it take much time?

When A wants to make a payment, he would reference the transaction txid and n in the input from where he earnt the bitcoins that he now wishes to spend. Full nodes generate an indexed database of all unspent transaction outputs (UTXOs), and refers to it when checking transactions for validity. This data is stored in $DATADIR/chainstate and aggressively cached in memory. Thus the nodes do not have to go through all the blocks prior to that, because they have all the unspent outputs handy. This functionality also allows full nodes to prune the blockchain to a desired size without losing the capability of verifying the transactions independently.


Why are only specific transaction types accepted into the mempool?

Any script can be used in P2SH/P2WSH technique. Using arbitrary scripts in transaction outputs cause grows of UTXO database and other problems.


Correlation of number of (non mining) full nodes to internet bandwidth

I don't think any such study exists, because it is very difficult to gain any concrete information about full nodes on the network.  Because nodes can (and often are) run over proxies or TOR, their true IP addresses are often obscured.  Furthermore, IP addresses aren't necessarily a good indicator of geographic location, and certainly not connection speed.

Even if you identify a node in a country with generally poor residential bandwidth, the operator of that node could be running it from a commercial data center that has much better connection speeds than the average for that country.  Attempting to sort full nodes into residential and commercial categories would be almost impossible.

It sounds like you're trying to do something similar to this:  Bitcoin node Decentralization


How to tell bitcoind to use more memory and CPU

It will by default use all CPU cores available.

However, if the database cache is too small, your node will spend its time fetching and writing database entries from/to disk, rather than verification

You can set the size of the database cache using a bitcoin.conf setting dbcache=N, where N is the number of megabytes of RAM.


What is the "Untrustworthy" tag on bitcointalk?

People still have scammer tags.

"Untrustworthy" is technically different than the scammer tag - the latter is a forum position, which appears in a certain place and has a specific icon. In Matthew's case it is just a custom title, usually reserved for VIP donators who can write there whatever they want.

I suppose Matthew's tag was commuted as part of his rehabilitation process.


Did Satoshi intend to allow midstate computation to speed up hashing?

I think Satoshi was not aware that the hashing routine could be optimized by the use of a midstate when he first created bitcoin.

If you look here, you can see that the first version of bitcoin that had the midstate optimization built into the miner was version 0.3.5 (it says 0.3.6 in the post, but you can see where someone quoted him that the post first read 0.3.5). He also says that it was implemented by someone called tcatm.

  Also in 0.3.6, faster hashing:

  - midstate cache optimisation thanks to tcatm

Satoshi mentions tcatm again here when trying to encourage people to upgrade to 0.3.8 by telling them they will get a better hash rate.

It's possible he knew it was possible and just didn't have time to implement it, I guess we'll probably never know for certain. But Gavin Andresen gave a talk on what Satoshi didn't know, and he speculated that Satoshi wasn't a very advanced cryptographer, based on some of the decisions made in bitcoin. As such, he may not have known about the inner workings of the hash function he selected, but just that SHA256d was regarded as a secure hash function.

EDIT: This may be the original post where tcatm proposed the midstate hashing optimization: https://bitcointalk.org/index.php?topic=648.0.


How do I export an xpub from Bitcoin Core for use in BTCPayServer?

This is not currently possible, as Bitcoin Core uses hardened BIP32 derivation to compute keys and addresses. This derivation scheme does not have a usable xpub that lets you derive the same keys publicly.

For more background, an xpub (or extended public key) is a string defined by BIP32. Every xpub has a corresponding xprv (extended private key). From the xpub one can derive a large number of child public keys, whose private keys can be derived from the corresponding xprv. This permits watching a large number of addresses without explicitly transferring all public keys.

The downside is that the xpub derivation scheme has a weakness: if an attacker knows the private key of any of the child keys and the xpub, he can compute the private key of all child keys. Because of this corcern, Bitcoin Core does not currently support xpub-compatible key derivation.

This will likely change in a future version with the introduction of descriptor wallets, which are far more flexible in specifying what keys and addresses belong to the wallet.


Questions about blockchains, network trust and why becoming a node?

Welcome to bitcoin.SE, Victor. There are too many questions, and mostly at a very generic level. We prefer specific questions, that can be answered in a 1-to-1 fashion. This is less of a forum here. Maybe bitcointalk.org is better suited. Also: there is the webpage "bitcoin.org", and Andreas' book "Mastering Bitcoin". It is an amazing book that'll definitely get you some answers. It's freely available online here.

I'll provide a short shot at some of the questions, if it is insufficient, just create a new one and insert a web link to here.

  1- How many blockchains should exist?

For every use case it's own blockchain, or for everyone wanting to quickly get rich, or, or, or .... This is mostly opinion based, and not easy to answer. Better for a discussion forum.

  Smart Contracts

Bitcoin has smart contracts, since inception, and many people do not understand what this means. There is a "mantra" that only Ethereum  has smart contracts (with it's solidity language), but that's not true. In the crypto space, there are several technologies now with smart contracts, and this deserves a whole discussion chapter. Again, have a look at bitcointalk.org, and search for smart contract. Amazing discussions there!

  2- What are the nodes that compose the bitcoin blockchain network? Am
  I one? The miners? Who are they?

Before explaining the details, I reference again the book from Andreas. Generally speaking, every full node is part of the bitcoin network, and does very important verifications steps of the transactions sent into the network. The miners would make sure, that the transactions are collected into a block, which then goes into the blockchain. These are mostly the same full node clients. So you can be a miner, or you cannot. Both options are required in the bitcoin eco system.

  3- I read that the size of the Bitcoin blockchain is very very big.
  Anyone know the current size? It is entirely stored in the nodes
  machines? If not, how does it work?

Roughly 200 Gigabytes. Think about a clock, that creates every 10minutes a block of ~ 1Megabytes in size (if blocks are full as currently), then you get 6 per hour, or 144 per day, or ~50.000 blocks per year. So 50gig per year is the growth factor in bitcoin. Data is only stored in full nodes, there are SPV nodes, that do not store the full chain (like on your mobile devices).

  4- I had a wallet in my computer, though I transferred my money to an
  exchange. What is stored in an offline wallet? Just a hash? A wallet
  is relevant for other kinds of implementations, like smart contracts?
  What would be stored in it?

That highly depends. You need to be much more specific for us to answer this. There are many crypto currencies out there, and many wallets... Basically the wallet contains only the private / public keypairs, and some software, that is required to create transactions. (Hint: Andreas book has a separate chapter on wallets).
A wallet has very little to do with smart contracts, I'd say for bitcoin world: nothing.

  5- ... and there is a third party when it comes to smart contracts,
  that is the organization behind the software, right?!

yes and no. At least in bitcoin world there is no organization. That is the whole deal about bitcoin. There is open source developers around the world,  and everyone can contribute. Even you :-)

  When it comes to smart contracts with money exchange, I have to send
  my money to someone. This entity is still the man in the middle. Am I
  wrong?

Yes, the exchange is your level of trust. It's all about trust: either you believe in mathematical proven code (and trust in the developpers behind, unless you are a genie), or you go to banks...

  If the organization behind Bitcoin just shut doors, turn their servers
  off (if there are any) what would be the impact in the environment ?

The whole point of bitcoin is, that there is no organization. Look into the links I provided. Such a statement would be the worst misconception... You will find answers in the links.

  Lastly what is the blockchain.info?

This is a company that runs a webpage with information from the blockchain (and much, much more). Their service is free of use, and very valuable if you are a developper in doing your first steps to see "inside" the blockchain.


You should consider the channel inactive, if after 2 weeks, the other channel does not broadcast a channel_update. At this point, you should try to close the channel cooperatively, and if this fails, broadcast the most recent commitment transaction.

If the channel is active, but just not routing payments, then you should try to figure out why that might be the case. Is it due to liquidity issues on the channel itself, or the other party's liquidity issues, or perhaps liquidity issues in your own channels?

For example, if the other party has no other channels, it will only ever route payments that it makes. If you have only one channel, or no liquidity, then you will never route payments other than your own through the channel.

If you feel that the party you're connected to is not maintaining their node and it is negatively affecting you, then you should attempt a cooperative close, and use the funds to open a new channel to a different peer.

As far as I'm aware, the current implementations do not determine the reputation of their peers, except obvious malicious actions which result in blacklisting. It is currently up to you to investigate and determine whether or not peers are useful.

This will likely change in future software updates, when we have more information about how people are routing payments and what is considered good or bad behavior. It would be premature to make too many assumptions at this stage.

When you close a channel, the fees depend on whether it is closed cooperatively or unilaterally. A cooperative close is a regular, small transaction, and the feerate is haggled, until both parties agree on the fee.

In the unilateral close, the fee depends on how many HTLCs are in flight, and the most recent feerate which has been agreed. The base transaction weight is 724 bytes if there are no HTLCs.


Warning about possible double spend at blockchain.info

As long as you wait for 6 or more confirmations, your coins are safe. Waiting for 6 confirmations would make it quite difficult for Slush to pull ahead of the rest of the network with their own chain, and make it quite apparent if they did.

Even if Slush is really attempting double-spends, it really wouldn't make much sense to do so on a miner payout. It would make sense for many sorts of transactions (instant-payout gambling sites, digital or physical goods, etc.) but not to compensate you on work you already did for them (if they wanted to play that game, it'd be far easier to simply never pay you). All that would give them is miners that want to leave because they're being cheated.

A more likely double-spend scenario would be as described at the GHash.IO & double spending post on Reddit. In short, it is believed that GHash.IO executed double spends against a Bitcoin-based betting site.

It's also important to note that blockchain.info's information on double spends being attempted could very well be misinterpreted (e.g. maybe an orphaned block, with a later payout, would result in the warning you see). That address has a very long history.


How much will Segwit *actually* increase bitcoin capacity for realistic transactions?

Note that the scriptSig field is not just the ECDSA signature itself (65 bytes) but also the public key in the case of a P2PKH input, or the redeem script for a P2SH input, and a couple more bytes for sizes. Also, there is a scriptSig for every input, not just one per transaction. You are looking at the average transaction size, most of which contain multiple inputs, but then assuming only one signature of 65 bytes.

Let's take an example transaction with a single input and output: https://blockchain.info/tx/82d62d5f4e69ae8338c39b7ae2e1d33db59bdf62c869ded7344adc936bab8653

This transaction is 226 bytes, 108 bytes of which is the scriptSig (including the length byte), which is nearly half the size of the transaction. Because the average transaction has more than just one input, the multiple scriptSigs make up a higher percentage of the total transaction size in those transactions - on average around 60% of the transaction. Taking that into account gives you the estimated increase on average, which was based on simulations run with the new rules according to current usage I believe.

  Really weight is a new concept, previously it was measured in bytes.

Indeed, it's misleading to say weight was the transaction size in bytes before this new weight was defined, you should compare the old size to the new virtual transaction size (which basically is what you did anyway by dividing by 4)


How do I spend Bitcoins from a specific address?

When you use importprivkey, the new private key is added to your wallet, giving you the ability to send coins received by a corresponding Bitcoin address. Your "balance" will also reflect this, including the coins accessible by this key in the total balance.

Bitcoind low level API gives you a pretty fine-grained control over your coins. Since there is no notion of a "source address" in the Bitcoin protocol, you have to specify the exact transaction and its output that you want to spend. Instead of using the common high-level RPC like sendtoaddress, you need to manually create a raw transaction, which comes in a few steps:

Prepare the transaction via createrawtransaction command, specifying outputs that you want to spend,
Sign the transaction using your imported private key via signrawtransaction,
Send it onto network using sendrawtransaction.

Be careful when using this API as Bitcoind does not protect you from making fatal mistakes, rendering your coins unspendable. Make sure you test your code on the testnet thoroughly before going live.


Transaction is not submitting using bitcore-explorers.js

So, I've searched for the error on the Internet, and here's what I found.

  EAI_AGAIN means the DNS server replied that it cannot currently fulfill the request

In addition, I used the BitPay BCH testnet explorer yesterday, the previous day, and the previous day. The last three days except today, the server was down and I saw "CloudFlare server down" message on the explorer's page. So, I guess they are moving the IP address behind CloudFlare's proxy, and the transition is not perfect.

Summary: It's not your mistake, but you could try flushing DNS cache.


What is NXT's Genesis Account's Passphrase / Password?

Genesis Account Number
The genesis account number is 1739068987193023818 (NXT-MRCC-2YLS-8M54-3CMAJ).
Genesis Account Passphrase
The passphrase “It was a bright cold day in April, and the clocks were striking thirteen.” gives any user access to the genesis account. It is the opening line of George Orwell’s ‘1984’, which begins on the 4th April 1984.
Even if you got in, it would be a negative balance which means you wont be able to send anything out. People use it to use it as a blackhole to send their nxt or assets to, since anything that goes in wont be coming back out.


Blockchain.info Receive Payments API problem

It is working now! Issue closed. Great service provided by BlockChain.


How does mnemonic recover a single private key?

Typically, they just pick the first one that the mnemonic generates.


RippleAPI how to issue IOUs using preparePayment

Okay I figured it out: first, I set up a trustline from USER_ADDR to GATEWAY_ADDR for 1000 EUR. I made sure that the qualityIn and qualityOut were set to 0, the default value:

var trustline = {
  "currency": "EUR",
  "counterparty": GATEWAY_ADDR,
  "limit": "1000",
  "ripplingDisabled": true,
  "frozen": false,
  "memos": [
    {
      "type": "test2",
      "format": "plain/text",
      "data": "texted data2"
    }
  ]
};

I signed and submitted this trustline.

I then used the following payment object to create an IOU for 50 EUR from the gateway to the user, indicating that the user had deposited 50 EUR with the gateway outside the Ripple system:

const payment = {
  source: {
    address: GATEWAY_ADDR,
    maxAmount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  },
  destination: {
    address: USER_ADDR,
    amount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  }
};

Earlier, this was not working due to qualityIn and qualityOut being to 0.91 and 0.87


Breadwallet creates a new address every time you use the one displayed.

There is no manual way of creating a new one manually.


How do I install Phoenix 2 on Mac OSX Mountain Lion?

I found the following to install PyOpenCL.  It installed on my MBP 8,1 running ML:

git clone http://git.tiker.net/trees/pyopencl.git
cd pyopencl
git submodule init
git submodule update
python configure.py
python setup.py build
make
sudo python setup.py install


Official Canadian source saying bitcoin is not legal tender?

The Currency Act defines what is meant by legal tender in Canada:

Legal tender

8. (1) Subject to this section, a tender of payment of money is a legal tender if it is made
(a) in coins that are current under section 7; and
(b) in notes issued by the Bank of Canada pursuant to the Bank of Canada Act intended for
circulation in Canada.

Since these are the only two forms of payment considered legal tender, and bitcoins are quite clearly neither of these, the conclusion must be that bitcoins are not legal tender in Canada. Note that the Act doesn't explicitly have to name Bitcoin for this conclusion to nevertheless be true.


my transaction is pending 3 days old ... what to do ? please help

The transaction says it has a fee of 120.32 sat/B.

Check out the following to get an idea of what fees you should pay: https://bitcoinfees.21.co/

As of this writing, it would cost around 300 satoshis/Byte to be probably processed within 30 minutes; and the fee you provided is estimated to take up to 1020 minutes (17 more hours) - with a 90% certainty.

What can happen:

You supplement the transaction with some more miner fee (not sure how to do this using Blockchain's wallet).
The transaction eventually makes it into a block, with its current fee
The transaction "expires", as in, gets "forgotten" if enough miners clear their memory pool before it gets included in a block - highly unlikely.

Edit: The question is a duplicate of Why is my transaction not getting confirmed and what can I do about it?


minerd disappears when i try to launch it with a batch file?

This is probably your antivirus either deleting or quarantining it.  Depending on your antivirus, you need to manually trust minerd.exe and/or restore it from quarantine.

I use Norton 360.  To unquarantine with Norton

Open Norton
Click tasks at the top
Click "Check Security History" on the left
Find minerd.exe, it might be easier to re-extract or re-download
Click more details
Click restore at the bottom

Comment and I will try for other antiviruses


There will be Robocoin ATM's in London and Bristol this Spring. https://twitter.com/satoshipoint


Bitcoin Transaction from MtGox hasn't shown up after several hours

I think MtGox usually gives you a transaction hash immediately. You can use it to track it, for example on the blockchain or blockexplorer websites.

Even without the transaction hash, you can still use these websites to try and find it by looking for the Bitcoin address you have withdrawn to. You may wish to check your MtGox account history to see which Bitcoin address they sent your Bitcoin.

If you do not see the transaction, don't panic. Especially if you have not included a transaction fee, miners may be slow to incorporate it into any block, in which case these websites will not find the transaction in any block, and might indeed not have seen the transaction at all.


Wallet is encrypted and currently locked, How can get unencrypted (unlocked) it?

I do not want to rain on your parade, but this may be hard to do. These wallets are made with the idea that outsiders will not get into them.

You could try to brute force the login, but it may take longer than a lifespan to break. However, here is something that you may consider. If you have a known rule-set for your password generation, you can substantially eliminate the possibilities in your brute force attack.

I am speculating that your passwords are complex, but there may be hope here based on the fact that password generation is not truly random. Because of this fact, there are rules that you (as the password generator) or a program like keepass (as the password generator) usually follow.

We really need more information to make an informed suggestion, but let me give you a couple scenarios.

If you create your own passwords:

Do you use spaces? Usually this is a yes or no for most people.
Is there a special character that you tend to focus on? Does it occur at a particular place (i.e. at the end)
Do you use words or phrases or is it always random?
What is the range of characters in your passwords? (i.e. Always type 6-10 characters).

If you use a generator for your passwords, there may be rulesets in place that help you eliminate possibilities:

Look at the number of characters allowed.
Are letters, upper case, lower case, numbers etc. required?
Are special characters allowed?

After you have answered this, and similar questions, you can begin to chip away at the total possible entries. So let us say you force at least one number and one capital letter and one special symbol and is 10 characters in length. Now, you can eliminate all possibilities that do not follow that pattern. You will not use brute force for any 9 character string, anything without a symbol, etc. Your possible result set can be reduced substantially because you inherently know the algorithm you use for password generation.

A goldmine for you is the eliminate the possibilities on a particular character in the string. Commonly, people will start or end a password with similar rules. For example, they put a $ at the beginning. Now you have reduced the search by a power factor. Keep this up with rules that you know would have been enforced and your set gets even smaller.

Now that your result set is reduced, work will be involved. Find a program to brute force a wallet, or utilize a script that you create to brute force. Most have APIs associated with them (i.e. https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list).

Technically, there are tools that will help with this process, (See: Forgot wallet encryption password, are any brute force tools available? ) so you may be able to find something useful there. Otherwise, if you cannot get a hold of those tools, pitch it to some computer science students at the local university to create such an app for a project :-) It would take a little bit to code and I am not sure of your programming abilities, but it would be very possible.

Good luck and I hope you get your wallet back!


Why didn't my change come back to my wallet? And where is it now?

The change should be in your wallet. Open up Electrum and check if your balance is what you expect it to be. You can also look in the addresses tab and click the arrow next to "Change" to see your change addresses and the Bitcoin that is held there.

If you are just looking at an address in a block explorer, you will not see the change return to that address. This is because nearly all wallet software follow the recommendation of generating new change addresses for each transaction. It is important to remember that an address is not your wallet; your wallet contains several addresses, but an address itself is not your wallet. You should not be looking at a block explorer to determine your wallet balance; it will be inaccurate as the block explorer does not know what addresses are actually in your wallet.


How vulnerable is bitcoin to quantum algorithms?

In short, yes, Bitcoin would be vulnerable to some variation of Shor's algorithm and quantum computing, as would basically every kind of crypto we use today. While ECDSA uses the elliptic curve discrete logarithm problem for its security, rather than the prime number factorization problem, you are correct in stating that a variant of Shor's can be used to solve the ECDLP in similar time. I believe there are similar threats with regard to SHA256, which is heavily used in Bitcoin's mining process.

You are also correct in stating that Bitcoin relies on a scripting system and is itself an open-source distributed computing project. Assuming you can arrive at a network consensus it is absolutely possible to change basically any aspect of Bitcoin - you just have to get the whole rest of the network to agree with you. I don't imagine that would be an issue if ECDSA or SHA256 were broken.

It's also entirely possible that the whole project itself could be forked to create an alternate version of Bitcoin similar to others which already exist. There is a variant called Litecoin, for example, which uses scrypt instead of SHA256 for mining - implementing an alternative to ECDSA could be easily done in a similar manner.

This, perhaps, is the true brilliance of Bitcoin: it's a Pandora's box that cannot be un-opened. Bitcoin as it exists today may or may not exist in a decade. Perhaps there is some unforeseen flaw that will soon be discovered, but that flaw will be fixed and the idea will live on. Assuming that there is any reasonable encryption/signing algorithm that is safe from quantum computing, it will be adopted and the cryptocurrency world will move on.


Like MCCCS said, the fact that it goes back to the start screen is a bug. Try installing an older version of MultiBit, and use that.
EDIT: Don't use Multibit. From the readme:

Dear Bitcoin Community,

It is time for us to let Multibit go.

KeepKey acquired Multibit a little over 1 year ago. At the time, the engineers who originally built and supported Multibit had announced that they would no longer be working on it or providing support. Multibit played an important role in the Bitcoin infrastructure. We felt that it was important for Multibit to continue and hoped that with our existing support and development teams, we would be able to keep Multibit alive.

The reality is that Multibit is in need of a lot of work. It has stubborn bugs that have caused us and Multibit users much grief. Additionally, Bitcoin has gone through a fundamental change in regards to the way fees work. The addition of SegWit in the coming weeks will mean the Multibit software has fallen still further behind.

Unfortunately, KeepKey simply does not have the resources to support the current issues, nor to rebuild Multibit to ensure ideal user experience. By focusing our attention on the KeepKey device, we will continue building and improving the best hardware wallet available.

Thus, KeepKey will discontinue support and maintenance of Multibit, effective immediately.

We recommend that all Multibit users discontinue using it and you move your keys to other wallet software of your choosing.

I would try using the electrum wallet, but DO NOT select to use SegWit addresses. Use the legacy addresses when restoring the wallet.


What are the odds of discovering a block as a solo miner?

Take the total network Th/s and divide by your total Th/s. That number gives you you a number that tells you how many blocks will occur before you get one (on average).

So if there is currently 3,666 Th/s on the network, and you have a 0.55 Th/s (like you would if you have a $5,000 KNCMiner Jupiter ASIC), then 3,666/0.55 = 6,665.

That means you have 1/6,665ths of total hashing capacity.   There will be 6,665 blocks before you get one.

So if there are 144 blocks in a day, then you need to wait 46.28 days to get a block when mining solowith that hardware.  But that is assuming difficulty doesn't rise.   So what will happen with a rising difficulty is you end up waiting much longer even, and possibly never end up getting a block when solo mining.

That's why solo mining is not as profitable as using a pool for anyone without tens of Th/s nowadays.


Is having a copy of my wallet.dat file enough to recover lost Bitcoin?

Yes, but having the wallet.dat file is only enough to recover the lost bitcoins if it hasn't been compromised in the meantime (that's why it's a good idea to encrypt your wallet). There have been at least 2 other questions in the last week or two where a user tried to recover an old wallet and found it had been emptied.

If you do encrypt your wallet (and you should, to protect against malware stealing it), then you'll also need your passphrase for the wallet when you want to restore it and reopen it.


First time bitcoin buyer; been reading, but still not sure how to purchase

The long alphanumeric address is one of your pseudonymous representations in the Bitcoin network. You may hand it out to your business partner in order to specify where you wish to receive the money.

After you've imparted your address, the sender may create a transaction which is a message to the Bitcoin network that signals his intent to sign over some of his bitcoins to you. This transaction will then be propagated through the network and hopefully incorporated into a block for confirmation. Once the transaction is written to a block, it has become part of the blockchain and the sent amount has been —bar exceptional occurrences— reliably signed over to your wallet.

Since there was really only one piece of information or step missing from your description, I hope that you're well informed at this point. ;)

To get a better overview on some related topics, may I suggest the following topics:

What's the difference between a wallet and an address?
Can someone explain how the Bitcoin Blockchain works?
I am new to Bitcoin, how can I get started?


They never claimed to have generated all private keys, only the ability to generate any possible private key.

The web site dynamically calculates a set of keys for a given page number. It does not store every possible key.

The web site cannot be used to discover a private key for a particular address because there is no way to search for an address.


bitcoin transfer without creating wallet

Sure, this would work.

That said, you are essentially building your own wallet - A wallet is simply a program that hold private keys, keeps track of spendable inputs, and signs transactions.

Your system achieves all of the above, so you are essentially building your own wallet.


Channels state validation in lightning network?

Let's say Alice wants to send a payment of 0.01 BTC to Dave and checks the following route through Bob and Carol, i.e.:

Alice ––– Bob –0.005–––0.02– Carol ––– Dave

Bob and Carol have a payment channel with a balance of 0.025 of which 0.005 are Bob's. If Bob now claims to be able to forward Alice's payment, this will only slow down Alice, but he would never be able to trick her. As the payment contract is crafted in cooperation of all four users along the route, Carol would also have to sign it. Since Carol shares the channel with Bob, she knows that Bob cannot sign over sufficient bitcoins to her to cover the payment, and would not agree to the payment.

Therefore, no one would have anything to gain by overstating their balance (except perhaps obstruction of payments), because their channel partner is also part of the contract and would deny a payment that exceeded the available balance.


Download the pre-compiled windows versions from the releases tab on the github page.

https://github.com/bitpay/copay/releases


Can I sign a text with a Bitcoin address using PHP only?

A bit late but I created a PHP library for cryptocurrency. You can use this library to achieve what you want.

You can use it like this:

require('CryptoPHP.php');
$wif_key = 'Kzy3fea4xCwLczAj3g8TYvDw6QRKCMqvVZX2J7vaXgy78VhieRdV'; //this is your wif key
$private_key = $this -> wif2key($wif_key); //get the wif key to a hex private key
$hash = 'Just a sample text'; //this is what you're trying to sign.

$signature = $this -> sign($hash,$private_key);


Is it safe to connect multiple alternative crypto currency clients to the same TOR socks port?

I don't think there any good reasons to use multiple SOCKS listener ports on the same tor in your situation.  After all, it all ends up in the same place.


It is not necessarily true that no amount of force or authority can cause or prevent any transfer of Bitcoin. The protocol does not allow arbitrary seizures or blocking, but there are still human factors involved.
Bitcoin is decentralized, so there is no central authority that governments can go to (or coerce) to force or disallow transactions. However Bitcoin is still owned by people, and people can be forced to perform certain actions that they do not necessarily want to do. While a government cannot command the Bitcoin network to make a transaction to happen, they can go to a particular individual who owns Bitcoin and coerce them to make a transaction
Furthermore, governments often have the power to arbitrarily seize assets owned by people. They can do this by force and physically taking things away. This is often how Bitcoin is seized - the hardware that contains the private keys is physically taken by the government. Once they have access to the private keys, the government can perform any transactions that they wish. There is nothing that Bitcoin can do to prevent this; it is up to the individual to ensure the security of their private keys.

For disallowing transactions, this is much harder. However, as before, there is still a human factor involved. In this case, it's miners who produce blocks. A government could mandate that miners operating in their jurisdiction are not allowed to create blocks containing certain transactions. If all miners were to follow such mandates, then a transaction could remain unconfirmed indefinitely and thus be effectively disallowed.
However this is much harder to do. The decentralized nature of mining means that miners who are in other jurisdictions that do not require censoring certain transactions can mine those transactions. Furthermore, miners who can protect their anonymity and are willing to break some laws can mine those censored transactions too.
Even if no current miner is willing to mine a censored transaction because their governments threaten them, more people could simply begin to mine who do not necessarily follow the same censorship requirements. Mining being decentralized allows anyone to be a miner, albeit at a high initial cost currently. Governments could also try to snuff out the non-censoring miners through force, possibly through seizure or destruction of mining hardware. But even so, people will still be able to mine, and there will inevitably be some miner out there who is willing to make a block that includes a transaction censored by every other miner. So in the end, it really is not possible to disallow a transaction.


Storing the hash of every transaction in the block header could make the block header much larger than it currently is. Right now the whole header is 80 bytes, and the tx merkle root is 32 bytes of that. You can hash any number of transactions into a 32 byte merkle root, so it works very well as a cryptographically secure compression technique.

I can think of a few effects of larger block headers:

SPV wallets would be more resource intensive to run, they would require much more storage and bandwidth. I think computing the merkle branch is probably rarely the hardware bottleneck to be considered when designing wallets.
Miners would be incentivized to mine small blocks. This is because a larger blockheader would mean a larger input value for the SHA-256 hash function, so it would take longer to compute the hash. This is important: the fastest block hash a miner could compute would be one with no transactions in it (other than the coinbase).
You would be able to fit less transactions in a block, since more of the blockspace would be used by the header. A good implementation would not change the number of transactions you could fit in a block, see Pieter's comments below.

There are probably more, feel free to expand on this list.


How to turn my bitcoins into legal money

Bitcoin acquired through mining are treated as income and subject to Income Tax at the appropriate rate (perhaps 40% if you also have a highly paid job). You'll need to declare this income in sterling equivalent. I believe you'll also be subject to NI contributions on those Bitcoin earnings.

If earned Bitcoins subsequently increase in value, I suspect the increase will be subject to Capital Gains Tax.

As others have said, employing a qualified accountant would be a sensible action.

HMRC Brief 9 - Bitcoin and other cryptocurrencies


How to validate the change address in a multisig transaction?

I went and RTFM and found a sufficient answer: Using the proper change-address descriptor for the wallet, I called deriveaddresses and I see the corresponding change address returned from bitcoin core.


How to tax trading in colored coins representing fiat?

You trade a bunch of stuff, you wind up with more dollars than you started with, you have a taxable profit.


Mixing techniques are designed in a way so that it cannot be identified. There is no sure shot way of telling whether a transaction is mixed unless the mixing is shoddy. It might as well appear that this is a transaction where one party is using multiple inputs to pay multiple parties. Example would be an establishment accepting bitcoins for its services from its customers and pays employees/suppliers/partners at the end of the day using bitcoins. It would have to use multiple inputs and multiple outputs.

Having said that, there are some techniques for determining which outputs are created by which inputs and if it is mixing, but these techniques are not foolproof and often make assumptions that are not guaranteed.


Colored coins are a method to track the origin of bitcoins, so that a certain set of coins can be set aside and conserved, allowing a party to acknowledge them in various ways. Such coins can be used to represent arbitrary digital tokens, such as stocks, bonds, smart property and so on.

The colored coins protocol is decentralized just like Bitcoin, but the current effort to develop an implementation is done under the BitcoinX project (tentative name), which also aims to provide some related services.

As this is still under development, you will not find any existing examples.

You can read more about it in Overview of colored coins (work in progress).


For mining, it is a 'no brainer' to me to get the most power efficient PSU as even those meager differences of efficiency will pay themselves off in a pretty short time... that is assuming that the price of these 'coins' stays at their unusually high price anyway.


What happens when a gateway on the Ripple network defaults or simply vanishes?

Any of those things can happen. Likely, there will be some "hot potato" going on as people rush to offload any IOUs they hold to people who haven't yet gotten the news. It's unlikely other gateways would honor the IOUs unless they were contractually obligated to. This would likely harm their customers as they'd have to make up the losses somehow -- likely with higher fees.

Gateways are in the business of being trusted. So they have a huge incentive to find ways to induce people to trust them. We don't yet know what will happen, but some possibilities include:

Gateways could cross-insure each other. (But this might make you less likely to trust a gateway for fear that it will collapse due to the collapse of another gateway.)
Gateways could be insured by governments or private insurance companies. (They hold other people's fiat currency, so the legal framework for doing this exists in many countries.)
Gateways could post bonds or liens on physical assets that could be seized or sold if the gateway defaults and used to cover their obligations.

Note that this is only a significant issue for people who wish to use the Ripple system to hold fiat currencies as a store of value. It's not a major issue for a merchant who just wants to get paid in dollars as they can use a gateway that electronically deposits the currency in their regular bank account on a daily basis. If that gateway goes out of business, they'd only lose a day or two's revenue and could switch gateways on the Ripple system with no disruption. (You might think losing two days revenue is a big deal, but remember, businesses already pay 2% to take credit cards. That's like losing seven days revenue every year.)


How can I transfer my Bitcoin Android wallet to another platform?

If your wallet was created with Bitcoin Wallet for Android 4.0 or later, you can extract the mnemonic (seed) with this, and then restore that seed into a wallet which supports a BIP-39 mnemonic with a BIP-32 path to gain access to the same funds, such as MultiBit HD or breadwallet.


My BTC was stolen using my Blockchain pairing code

Blockchain.info pairing code allows you to sync wallets. For example, it's for when you have coins on your phone and you want to be able to spend them from your computer. So, they synced their wallet with your account, including the private keys, and stole your coins.

From their website:

  As with your wallet ID, you should never share your pairing code with anyone. The pairing code grants full access to your wallet and its funds. It should be used only by you, when you want to access your wallet on your mobile device.


I think you are confusing some things here. A blockchain like Bitcoin, Ethereum, Ripple, or Hyperledger is a protocol in first place. And a protocol is agnostic to programming languages used.

What you are relating to are reference implementations of the protocol. The Bitcoin protocol has the famous Bitcoin implementation (later Bitcoin Core) initially written by Satoshi Nakamoto in C++. But there are so much more clients available in so much more programming languages.

Ethereum, for instance, has three reference implementations, the Eth client in C++, the Geth client in Go-Lang, and the PyEthApp in Python. And there are even more implementations in Rust, Ruby, etc. available.

I could go on with the other blockchains you mentioned, but you get the idea. A protocol can be implemented in any suitable language if desired. If you want an exotic example, have a look at Lisk which tries to build the full blockchain stack in pure JavaScript.


How are public & private keys in an address created?

As is normal when doing Elliptic Curve encryption, a private key is simply a random number. In the case of secp256k1, the elliptic curve used by Bitcoin, it has to be a number between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336 (or in hexadecimal, between 0x1 and 0xFFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364140).

This private key is converted to a public key by performing an EC point multiplication with the curve's base point. The result is an (x,y) coordinate pair, which constitutes the public key.

Finally, RIPEMD160(SHA256(pubkey)), where pubkey is a serialization of those coordinates, is computed, and encoded in base58, together with a checksum. This becomes the address.


Do checkpoints affect initial chain sync time?

A Checkpoint is the header hash permitted at a given height, thereby hardcoding the chain that the validating node must follow. If a node follows an alternative chain branch which reaches the same height, this branch can now be identified as such and rejected. This was initially designed to protect a node from following an alternative long branch, especially generated with low difficulty, which could be so long that it would challenge the available resources of the validating node.

Validation used to be skipped prior to checkpoints, but that is no longer the case. Validation is skipped up to "known blocks", but only if these are found in the strongest chain. Today, checkpoints don't reduce chain sync time.


Safely Accept Bitcoin Payments with 0 Confirmations

How is it possible to guarantee a transaction against double-spend, expiration or other fraud before it is confirmed by the Bitcoin network?

It isn't really possible in the absolute sense, but you can could perhaps create an insurance fund of sorts, to help provide guarantees against the rare occasion one of your customers is defrauded.
However you fundamentally cannot know for certain whether or not any specific transaction will be confirmed, until it has been. Even if a transaction has been seen by every node on the network, a miner could craft a conflicting transaction, and include it in their next block (with a success rate equal to their percentage of the hashpower). No amount of risk analysis can change this fact.

What kind of "risk analysis" might be performed to achieve this result?

It is hard to say for certain.
You could attempt to track where transactions originate from, like for example if you see transactions coming from large exchanges or service providers that are well-known and trusted in the community. Those entities are probably less likely to attempt a double spend.
You could watch for transactions marked as 'replace-by-fee' (RBF), which is a technique employed by many wallets, which allows the user to increase the fee-rate on a transaction for faster confirmation. Transactions marked as RBF could be treated as less trustworthy in regards to 'zero-confirmation' assurances.
There are likely other ways as well, those are the first couple that come to mind.


How to decode private key from Android Bitcoin Wallet?

from: https://github.com/schildbach/bitcoin-wallet/tree/master/wallet

The backup file is encrypted using your chosen password. You can use OpenSSL to decrypt:

openssl enc -d -aes-256-cbc -a -in <filename>


What transactions will be included in the next block?

You can see what a miner sees at this very moment, provided that your wallet is synched, by calling getrawmempool true in your bitcoin console. What you'll get is broadcasted transactions not yet included in a block.

In short, miners scan this list and then allow the valid transactions with a higher fee to be included first in the block they are about to mine.


How do I determine my transaction fee in an automated way?

How is this computed?

Bitcoin Core offers something called fee estimation, where you can gauge the amount of fee that is probably necessary to get a transaction into the next block. It returns the fee per kilobyte to get into one of the next n blocks, assuming the miners making them have similar transaction acceptance rules as prior ones.

1 confirmation 0.00026816 BTC
2 confirmation 0.00011483 BTC
3 confirmation 0.00002048 BTC
4 confirmation 0.00001255 BTC
5 confirmation 0.00001255 BTC
6 confirmation 0.00001255 BTC

Emulating this without running a fully validating node that can evaluate its memory pool over a long period of time is probably not particularly doable at present. Centralized wallets like Mycelium make HTTP calls to their own endpoint which returns this information on their behalf, there will probably be more endpoints for this in the future given the difficulty of estimating fees for non fully validating wallets.

  would the unusually large number of inputs for the new transaction justify a larger transaction fee? If so, how much larger?

The transaction fee is per kilobyte. Adding additional inputs requires both the public key for the address and a signature, and some miscellaneous overhead to be included. It will often be about one hundred bytes per vin, but this varies if the input is P2SH or not and if the keys used were compressed or not. Generally if the input is below 0.00005 BTC it is probably going to add more in cost in fee than the value of it to include.

This transaction on mainnet is similar in size to the one you describe, it has 16 vin, 2 vout, for a total size of 2291 bytes. The key for 1FkiXxeKektpHVjvfknVvC6eQmjM9DEu9D is compressed (begins with 02 and is only 33 bytes long) which contributed to the small size of the transaction.


Is it possible to use Bitcoin Core Qt as interface for DIFFERENT full node?

No, there is no support for this. It is not an interface which uses the RPC interface, it has much deeper access within the wallet than RPC provides.


What causes seemingly normal transactions to not be confirmed?

Priority is an outdated concept and most miners don't use it anymore. Similarly, the standard fee is out of use.

Today, miners appear to be selecting transactions based on transaction fee per data size measured in [satoshi/byte].

Your transaction gave a fee of 0.4 mBTC and was 3471 bytes. This computes to 11.5 satoshi/byte. Currently, the predicted fee to get into the next block is 40+ satoshi/byte. Transactions with 11-20 satoshi per byte are predicted to have a 90% chance to be confirmed with a delay of 1-18 blocks.

If your MultiBit wallet is not up to a current version, you might experience better fee estimates by updating. A lot of wallet providers have vastly improved their fee estimations lately.


Failed to start lightningd.service: Unit bitcoind.service not found

At the top of this tutorial they say: This guide assumes you’re on MacOS, comfortable with terminal, already have a Bitcoin Full Node running on Raspberry Pi 3 (optionally with Tor) and now you want to also add a c-lightning node to it.

bitcoind.service not found means that you don't have bitcoin-core installed.


Can hardware wallets actually display the amount of funds leaving your control?

That is correct, a hardware wallet does not have access to any information from the blockchain except that provided by the host computer. So it does not know anything about the amounts unless the host provides it to them.

Because of this, hardware wallets have some extra requirements for signing. Many devices, for non-segwit inputs, require the entire previous transaction to be sent to the device. This way they can compute its txid and compare that to the txid specified for that input. In this way they can be sure of the amounts being sent as they can look at the output amount(s) in the previous transaction.

However Segwit actually fixes this issue for them. In Segwit, the amount for the input being signed is part of the data that is signed. So it directly commits to the amount being sent and therefore the host cannot lie about that amount or it will receive an invalid signature.


Can I see the workings (console) of my bitcoin full node?

You are running the Qt version of Bitcoin, which includes the GUI. If you have bitcoind, you can quit the Bitcoin application and type bitcoind into your terminal.
Otherwise, type tail -f ~/.bitcoin/debug.log in your terminal to see then end of the debug file, which will show you when new blocks arrive.
Alternatively, you can install bitcoind from Bitcoin.org. This is a different package than Bitcoin-Qt. Bitcoind only runs "in terminal" so there is no GUI.


The hash refers to the signature hash, to which all tx data except for the input script is committed to (unless you are signing with a sighash flag other than ALL).

The signature hash is what is signed with ECDSA to produce the signature.


Can an old block be inserted into the blockchain?

Every block refers to a specific parent, resulting in all blocks together forming a tree structure. Typically it's just a single very long branch, with very occasional short side branches (1 to 2 blocks long).

You cannot "insert" a block into the block chain, as no block refers to it as parent.


Is it possible for more than 21 million bitcoins to exist if 51% agree?

Maybe. It would require a split in bitcoin users. Those who wanted the change could switch to a new version of the bitcoin software with the code changed to allow it. The problem comes from the fact that it would have to be a voluntary change. Some would want to change, others wouldn't, and this would split the bitcoin community. Any transactions that occur in the either chain wouldn't be reflected in the other. But any balance you had at the time of the split would be reflected in both chains.

It would be a matter of semantics on whether the new, modified bitcoin would even be considered the real 'bitcoin'. If the majority of the community thought it was an invalid change, then the new would take the role of just another altcoin and people probably wouldn't even call it bitcoin. If the majority liked the change, it's possible that the old bitcoin would lose value and be considered just another altcoin while the new version takes it's place (or even cease to be used at all). Or, it could be even and they could coexist, but that seems unlikely to me.

I don't think such a fork is something that the BTC developers would do to the community. Open source communities are generally afraid of forks anyway because they tend to kill projects by splitting the development team. Beyond that, doing so has the power to really lower the confidence in BTC as a currency. The people who already have coins would feel mistreated because the protocol change would mean the minimum value of their coins would be lower. It would essentially be equivalent to the gold conversion being lowered on the dollar during the gold standard.


Is there any way to prevent intra wallet transaction fees?

A traditional Bitcoin wallet contains a bunch of private keys and a bunch of accounts. Each private key has a corresponding Bitcoin address.

For each private key that the wallet has issued, some account is associated with that key. This serves only one purpose -- it determine which account gets its balance raised when funds are received at that address.

Intra-wallet transfers require no transaction and thus pay no fee. I can switch from 10 Bitcoins in account "Jeff" and 0 in account "Judy" to 0 in "Jeff" and 10 in "Judy" just by swapping a 0 and a 10 inside the wallet. The Bitcoins remain at the same address, they are just credited to a different account.


What are the perceived advantages of bitcoin as a store of value?

Bitcoin has several advantages over other means as a store of value.

They take no space. This means that you can store them in a USB as well as a backups online for example in an email.
You do not need to pay anything for storing the Bitcoins. There is no need to pay for a secure bank account since they can be stored online or in USB or even in your brain if you use a deterministic wallet. In this case you only need to remember the passwords.
This also means that you can bring them to any country easily without paying any fees.
They are easy to hide. Nobody will know how much you store or how to get them.
This will make them impossible to steal.
Your funds cannot be seized by any bank or government.

The downside is the fluctuation in value.

But if Bitcoins are here to stay they will increase in value over the years,
perhaps outperforming many other assets.
There is also a small risk that they might get replaced by a more efficient cryptocurrency though; so far several have tried but none have succeeded.


You need to enable REST by setting rest=1 in your bitcoin.conf or startup bitcoind with -rest=1 or bitcoin-qt with -server=1 and -rest=1.

You can access REST by curl (example):
curl localhost:18332/rest/getutxos/checkmempool/b2cdfd7b89def827ff8af7cd9bff7627ff72e5e8b0f71210f92ea7a4000c5d75-0.json

A simple documentation is available here: https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md

EDIT:
There is no REST API for addresses. Bitcoin-Core does not have an per-address index.
If you enable -txindex=1, you can retrieve any transaction with GET /rest/tx/<TX-HASH>.<bin|hex|json> (otherwise only transactions in the mempool).


How can I print these information using this library?

With order.

The world mines multiple blocks at once, with only one block chosen by consensus to be kept.

If you want to get some information from bitcoin’s RPC you should consider using your own node.

You can call the RPC method getmininginfo but this command might not return the mining information you are searching for (an example Previous Block is not correct).

With the following information you can have the following problem:

Previous Block: The Previous Block is not equal to all networks at the same moment;
Merkle Root:  Every block can contain different transactions and in a different order

And on your question of how you can use the library python-bitcoinrpc, you can see my Python3 script for one example. you can find the script here


Without side chains will transaction fees rise as block rewards fall?

You are correct that transaction fees per block are much smaller than block reward, but they are still significant and rising:

https://www.smartbit.com.au/charts/transaction-fees-per-block

Recently the average has passed 0.5 BTC per block. With a 50x rise (easily obtainable if bitcoin use becomes mainstream in certain sectors) the reward would be 25BTC per block based on current fees staying the same.

This would be possible on chain with the combination of SegWit and a higher block size.

Side chains can help slow the growth of the blockchain but how much that is needed and its impact on Bitcoin miner fees remains unclear.


How do bitcoin qt sign signature/messages work?

What you have come across is the yet to be fully explored world of cryptographic signatures - and this is only the beginning my friend.

A cryptographic signature in a very simplistic way, allows you to electronically sign something, usually a string of text. That signature can then be used to prove that the text that you signed has not been tampered with. If you were to even add a comma or a space to the text, the outcome of your signature would be different, and therefore you could prove that the text and your signature were not the same.

Unless you did not know, almost anything digital is at one level a string of text (sometimes human readable, sometimes not) so anything digital can be cryptographically signed in one way or another.

This has absolutely nothing to do with the block-chain or bitcoin per se, but is a side-benefit of bitcoin employing crytographic signatures to allow you to send bitcoins. You do not have to spend bitcoins to sign something.

In short, the mechanism is being used to allow you to crytpographically sign ANYTHING. It is almost too broad a subject to answer fully here, but for example, imagine that you are buying a house, and that you copy paste the contract into the message box and sign it, and then the seller does the same with the result of your signature.

What you would get is a cryptographically signed contract that absolutely could not be tampered with, that proves that both of you agreed to the terms in the contract, and an independent third-party could prove this to be the case.

This opens up a whole new world potentially without lawyers (think of how wondeful that might be) because you would only agree to (and sign) things that you agreed 100% with and understood. You could not be forced to sign anything that you did not agree with.

In the future where cryptographic signatures are used for everything people and companies will be forced to behave fairly in order to get anywhere at all.


Funds received still shows pending and unavailable until confirmed in Exodus. Should I be concerned?

This has me a bit worried that I will not receive my funds, even though the blockchain shows 77 confirmations.

The blockchain is the only truth. Those funds have been received long ago.

The only question is why your wallet isn't showing it.

There are many possible reasons, some are

your wallet is a "custodial wallet" owned by some corporation  - you need to talk to the business involved
your wallet is a "full-node" type of "custodial" wallet - you need to check if it has fully synchronised.
there is some other problem with your wallet.
you have been tricked by a scammer.

For more precise help, you could edit your question to include details of the name and type of wallet and some general description of where the transaction came from (a friend? a customer? an investment manager?)


can man in the middle change transaction before its broadcast?

In order for the transaction to be valid it has to have valid signatures from the public keys associated with the funds being transferred. It is regarded to be computationally unfeasible for a middleman to forge a signature if he does not possess the private key.

These signatures are specific to the transaction and ensure its integrity, i.e., if the transaction is modified (by replacing recipient, amount, ...) then the signature becomes invalid.

There is a small exception to the last point: a signature cannot ensure the integrity of the signature itself, hence we have some minor problems with transaction malleability in which the transaction signature can be modified, but not its effects.


What exactly is checked at various -checklevel's?

The other answer seems to be out of date, even at the time it was answered. The following seems to be a more up to date explanation:
From https://bitcointalk.org/index.php?topic=141200.msg1504768#msg1504768

0: Validate all block headers + compare (by hash) to blocks on disk for the last -checkblocks blocks
1: In addition, verify (standalong) validity of those -checkblocks blocks
2: In addition, verify that undo data matches checksums
3: In addition, check that the current chainstate matches can reasonably be the result of the last N blocks, where N is limited by both -checkblocks and the amount of in-memory cache (-dbcache); typically it's around 150.
4: In addition, for the last N blocks (see above), do full validation (including signature checks).

Note that the new default (3) is in fact a stronger check than the previous highest level (6).


There's also another possibility, that's that you haven't yet downloaded all the block chain with bitcoind.

If you haven't yet started the daemon you must use this command:

bitcoind -daemon

Then, you can use the command:

bitcoind getblockcount

To check the number of blocks that the daemon has already downloaded, and compare it with the lastest block number

Your transaction is on the lastest blocks, so you must wait it to be completed, and this can take many hours.


Unless you're using HD wallets (only if you created the wallets using Bitcoin Core 0.13 or later), two wallets are never the same as soon as they've done a transaction.

Every time an address is generated or a transaction is sent, a new address is added to the key pool of the wallet (a queue of unused future addresses). If you have two copies of a wallet file, and use generate a new address in one, it is instantly different from the older copy, and it will diverge over time (generate different addresses in the future). So the answer is probably: there is no way to compare two wallets because you shouldn't be relying on the ability to compare them. If you do, you may end up with balance surprises or even monetary loss.

If you're using an HD wallet, you can compare whether the key chains are identical by looking at the hdmasterkeyid in the output of the getwalletinfo RPC call (using bitcoin-cli or the debug console in Bitcoin-Qt).


Are there any mining pools operating on the Testnet?

Currently, one can merge mine at this pool on the Test Net:

https://alpha.masterpool.eu/


How to watch for the transactions over blockchain via nodejs?

Consider using bcoin.js which is in pure JS. It fires events when a transaction takes place. Quite simply you can do:

node.on("tx", (tx) => {
   console.log(tx.outputs, tx.inputs)
})

Note that, in bitcoin, each transaction can have multiple outputs and inputs, so these are arrays of inputs and outputs. You can obtain the total output amount by summing across all output amounts. Additionally, in this case you wouldn't concern yourself with blocks - just transactions.


Comparison of different active cryptocurrencies

You probably should start from the source by yourself, look here:

https://github.com/bitcoin/bitcoin/network

2,523 forks of bitcoin. Greatest bump ever.

You should get source of 2 coins that you want to compare, and simply diff it. It is easiest way to understand what's the difference.

# git clone https://github.com/fastcoinproject/fastcoin.git
# git clone https://github.com/asiccoin/asiccoin.git
# diff -Hrin asiccoin fastcoin

92,401 different stings. The more than 70% is a .ts files from /src/qt/locale/. Only names asiccoin and fastcoin are different (:

See,

# rm -fr asiccoin/src/qt/locale
# rm -fr fastcoin/src/qt/locale
# diff -Hrin asiccoin fastcoin

16,955 different strings.

etc.

Look, here you can get algo:
http://www.dustcoin.com/mining

Very good comparison list: http://www.coinwarz.com/cryptocurrency

The third one: http://coinchoose.com/

Also, check this bitcointalk thread:  Cryptsy Survival Guide.

However, nowhere you can get full list. Forks are born every day, not only on github. There are 10-20 forks that I have meet, with hosting on google disk. 20-30 without sources.

Edit1: At the end, read this thread.

Edit2: Look what I've found http://www.poolwarz.com


Help - transfering bitcoin old bitcoin core 0.12.0 wallet

Export your private key(s) from 0.12.0 and import into a more recent version of the wallet, send from the newer version.


Bitcoind server spontaneously shutting down

Add some swap space and your problems will disappear.


How to calculate the Average velocity and the Average acceleration of Bitcoin transactions

You can calculate an average velocity/flow of bitcoin to an address/user by summing all bitcoin received that address/user in a given time period and dividing it by the time period. I think your issue is that you don't have the time each transaction was made. The easiest way to get a rough time (+/- 2 hours) a transaction was made is to look at the timestamp field in the header of the block that transaction was included. So, for example, with if you have the transaction 58513acbb340fd24d2b27d8680961196f0363b79f90ee34a974d6593bf64559b, you can get the time of this transaction in bitcoin core by running this command:

>bitcoin-cli getrawtransaction 58513acbb340fd24d2b27d8680961196f0363b79f90ee34a974d6593bf64559b true | jq ".blocktime"
1576581288

This timestamp is the UNIX epoch timestamp that the miner chose for the block. Bear in mind that miners can choose a timestamp that is off by about up to 2 hours and the block would still be valid, so don't take this the last two/three digits of this timestamp very seriously - this value is mainly used to calculate difficulty adjustments in bitcoin which occurs only about every two weeks. Another way to assign a time to a transaction would be to know when that transaction entered the mempool but that information can be extremely hard or impossible to get a posteriori and can have less practical meaning than the block timestamp.

With an approximate instant when each transaction was made, you can group all transactions done in a day or week, for example, and divide the total bitcoin amount by the time period. To calculate the acceleration takes two consecutive velocities and divide them by the time period again.

Be careful not to confuse the velocity of money, which is an economic concept, with the velocity that you are trying to calculate which is specific to your data set.


Miners keep the bitcoin network running

Miners create new bitcoins, but
Bitcoin network adjusts its own mining difficult so that more there are miners less bitcoins each miner receives. This keeps the money supply steady (not inflatory - you simply cannot "print more bitcoins" like you do with fiat currencies as USD).
Mining requires a lot of power, so miners face the rising cost of electricity and how much you need to invest into mining equipment to have your mining operations profitable.
Miners also confirm bitcoin network transactions. When you send someone bitcoins, miners check that your transaction is genuine and not double-spent attempt.

Here is also related question How does a difficulty increase affect a miner's income?


how to cancel unconfirmed transaction in blockchain.info

I upped it to 0.00011 but apparently that amounts to about 57 sat/B which is way too low to get confirmed in a timely manner.

According to the 21.co fee estimator:

https://bitcoinfees.21.co/

A 57 satoshi per byte transaction should be confirmed within 35 to 600 minutes (10 hours). It should go through.


Are public keys and their corresponding hash values both added to a BitcoinJ Bloom filter?

Does the current release of BitcoinJ add both a public key and its hash value to its Bloom filters? If not, which release stopped it from occuring?

Yes. The following code implements it:

/** Inserts the given key and equivalent hashed form (for the address). */
public synchronized void insert(ECKey key) {
    insert(key.getPubKey());
    insert(key.getPubKeyHash());
}

(Source.)

  Also, why were both public keys and hashes added in the first place?

I'm not the guy who wrote this (Mike Hearn). That said, I would guess that it's difficult to tell whether deposits to an address will be in P2PKH or P2PK form. Pay to Public Key is really uncommon, but it is legal. Given the choice between having some of his customer's money go missing for mysterious reasons, or reducing their privacy, he chose the latter.

Now, if you're asking why filterload doesn't just take the HASH160 of a key before comparing it to the bloom filter so that a thin client can look for both the hash and the key at the same time, I don't know. That seems like it would fix the problem mentioned in that paper for a pretty reasonable amount of CPU time. I would blame the author of BIP37, but that was written by the same guy.


How many times of validation needed for a whole payment transication?

In theory, a transaction is validated before it is sent, when a transaction is accepted into a node's mempool, when it is selected for inclusion in a block, when the block is verified before being broadcast, and when it is in a block that is received by a node. However, there really is no need for doing this validation multiple times because the same validation is done every single time.

So instead many node software will validate the transaction only when it is received in the mempool and only keep valid transactions in the mempool. When a new block is received, the transactions that were in the mempool need to be removed from the mempool, and because it knows that those transactions were valid because they are in the mempool, it does not need to re-validate the transactions from the block. The only transactions that need to be validated in the block then are the new transactions which the node did not have in its mempool.

For miners, the transactions they select will be from the mempool which only contains valid transactions. Thus this removes the need to validate transactions before selection and after block creation.

Additionally, the node can cache validation results for invalid transactions so that if it sees such transactions in a block it can look up the result in the cache instead of re-validating the invalid transaction. They can do this for valid transactions too to skip some validation steps.


How does headers-first prevent fill-disk attack?

since checkpoints are removed, we would be vulnerable to this attack

Where did you see that checkpoints are removed?  They're still in src/chainparams.cpp as of current master (commit f8bcef38f).

  How does the headers-first synchronization prevent the fill-disk attack?

Headers-first prevents a related attack where the client would accept "orphan" blocks---block with no known parent---and store them until their parent was received.  This prevented wasted bandwidth and sped up validation in the normal case but made disk-fill attacks easier in the pathological case.

Headers first allows Bitcoin Core to discover the most proof of work block chain (headers chain) that its peers know about before downloading any blocks, which allows it to ensure any blocks it receives are on that chain.  This, in turn, means that it never needs to download or store orphan blocks.

  A syncing node downloads all headers from a single peer. If that peer only sends headers from its malicious low-difficulty branch, won't the syncing node try to download all those blocks, and get it's disk filled?

That's correct, and that's why checkpoints are still used in the code as far as I know.  My understanding is that, for the ultimate removal of checkpoints, three things were desired:

Minimum chainwork: a feature coded into a node that tells it the legitimate chain must have at least X amount of chainwork, with X being set to the value for a recent block near the time of a software release.  This replaces the original use of checkpoints in preventing network-level attackers from feeding clients long, low-PoW chains containing valid blocks but which aren't the consensus best block chain.  This was deployed in Bicoin Core 0.13.2.
Assumed Valid Blocks: a feature designed to replace the secondary use of checkpoints for (optionally) speeding up Initial Block Download (IBD) by skipping validation of signatures in old blocks.  This was deployed in Bitcoin Core 0.14
A minimum difficult soft fork: a change to directly address the block-fill (or header-fill) attack you described by raising the minimum difficulty at various epochs in the block chain to correspond roughly with the actual observed increases in difficulty.  This would make it more expensive for an attacker to feed fake blocks to a node.  To the best of my knowledge this has not yet reached the BIP stage and I'm not sure it's currently being actively championed.

For reference, this topic was discussed in the 2017-03-02 Bitcoin Core developer meeting: https://bitcoincore.org/en/meetings/2017/03/02/#discussion


how generate  part of scriptSig in bitcoin transactions

The data to be signed is called Hash Preimage. Then you sign the double SHA256 of hash preimage, which is 256-bits long. Before hashing, the data must be formed as shown in this answer. If you're signing a SegWit transaction, the contents of the preimage changes, as defined in BIP 143.

Then you can use the formulae here, Eq. 2:

(x1, y1) = k × G(x, y) mod p
r = x1 mod n

k is a random number, G is the generator, p is the prime modulo, etc.

Then,

s = (k^-1 (h(m) + d * r)) mod n

d is the private key, h(m) is the double SHA256 result. Now, you can use r, s to create the DER-encoded signature.


You might want to check out btcdeb from kallewoof. It's a set of tools used to construct or debug bitcoin script.


Where are block announce times recorded?

The creation time is recorded in the block:

https://en.bitcoin.it/wiki/Protocol_specification#block

And since there's no benign benefit in deferring announcing it, it would seem likely creation time and announcement time would be pretty close.  But I accept there are variations, and pretty close may not be good enough.

However there is another approach.

You can use the bitcoind/bitcoin-qt -blocknotify option, described here:

github.com/bitcoin/bitcoin/pull/743

To record the time of new best blocks (which seems to be the like what you want.)

I used

blocknotify=echo date", %s" >> /home/userid/.bitcoin/blocknotify.log

And got:

Sun Jun 23 20:14:15 NZST 2013, 0000000000000069a26870e6f6693d733e32d57174bebb7d21f0fac1212fd83b
Sun Jun 23 20:33:04 NZST 2013, 000000000000003359dff8a8bd1033b02a52c6c2ff3ebb2f8dbffd171c97e83c
Sun Jun 23 20:43:11 NZST 2013, 000000000000004ec1559bd7e955ce8914a29a04b378bbcc34adf5bea077f73d

To clarify, that example of blocknotify was in bitcoind.conf, but it works on the command line too, with appropriate quoting of shell significant characters.