Some technical questions about Bitcoin I'm a developer. I've read a lot about Bitcoin structure and how it works. But yet something confuse me.
I would like to share them with you and read your answers:

When a miner solves a block, how other nodes reward it? If they have the source code to generate Bitcoin, why don't they generate it for themeselves?

I know 6 confirmations are enough for a transaction to be valid. What If I run 6 full nodes by myself and hard code their addresses in a wallet to create a fake transaction?

3 . When 51 percent agreement is made? On every transaction? Or each block solved?

When a new transaction is made, do miners check all previous transactions in blockchain for maker person to check if it's lying or not?

If more than one miners create a new block and broadcast it into network, how other nodes would find out which one was the first?

I'm very curious about Bitcoin technology but I couldn't find a source that satisfies me.

The first transaction in the block is one created by the miner, it pays the miner the current block reward + sum of transaction fees for other transactions in the block (if any). If that block is accepted by other nodes, after 100 more blocks the miner can spend the money. Other nodes check that spending of this new money meets all the rules.

Each confirmation is a block added on top of the prior block. You can't fake that, you have to mine it. You have to provide the needed proof of work. Ordinary non-mining wallets can verify a transaction but can't confirm it.

Each node works separately to decide what is valid and what isn't. The 51% attack refers to percentage of hashing power not percentage of nodes. Consensus is more of an emergent phenomenon, it isn't like explicit vote counting.

They already checked them and don't need to check them again. Nodes typically each keep and maintain a list of unspent transaction outputs (UTXOs) - you can think of a UTXO as a valid coin.

They don't care. They keep track of both. They pick one arbitrarily as true.  They regularly compare amount of work in each branch. It's only later that a branch with more work may require a reorganisation (e.g. of UTXO set etc). This happens automatically and isn't a problem.

Before asking follow-up questions you will find it best to  read some existing answers such as

What exactly is Mining?
How many nodes need to validate a newly created block?
51%


Bitcoin client downloads blocks from different peers When a bitcoin client downloads blocks from different peers, how does it determine the number of blocks to download from which peer?

Since Bitcoin Core 0.10, the following mechanism is used:

We start off by asking peers for their best headers, and thus learn the most-work chain's headers quickly, and which peers have which parts of it available.
In the background, we continually ask peers for their blocks, in sequential height order, under the following conditions:

If a block is already asked from another peer, we don't ask for it again.
If a peer's known best block's corresponding chain has less total work than our currently active (fully downloaded and validated and accepted) chain, we ignore that peer - they'd only get us onto a fork that's worse than what we have.
If the only available blocks from a given peers that aren't already being downloaded already, are more than 1024 blocks ahead of our currently active chain, we don't ask anything (more) from that peer.
If there are already 16 or more blocks in transit from a given peer, we don't ask any more blocks from that peer.

All of this is subject to various timeout rules. In particular, when we're waiting for blocks from a single peer before we can download more from everyone else (because every other block in the 1024 that succeed our active chain is already downloaded), we disconnect that peer, and mark all its in flight blocks are available for fetching again from others.


Why is the Winklevoss ETF decision so important, when this tracker certificate already exists? The Winklevoss ETF and the SEC decisions regarding it seem to be on everyone's lips and the influence of the bitcoin price are apparent.

However there seems to be this tracker certificate already:
https://zertifikate.vontobel.com/DE/Produkt/DE000VN5MJG9
(Site is in German, sorry. Basically a tracker certifate on BTC/EUR with a factor of 1/10. ISIN: DE000VN5MJG9)

Why do I not see it anywhere in the news and why is the Winklevoss ETF so important then?

This ETF is for US people and would be traded on BATS exchange. US is a big financial market. Plus it's a hot topic because famous Winklevoss brothers are behind it.


Is there a Wiki comparing different wallets? I am new here so please go easy on me if my question is not written to your standards. If you ask me to make changes, I will make them so that my question is more suitable for this SE.

If you look at Wikipedia's Comparison of numerical analysis software or Comparison of smartphones, you quickly see information (such as whether the software supports GPUs or only CPUs, or what year the software was first released), that is by no means not available elsewhere, but is probably unmatched in how well it's organized.

I wonder if there is such a Wiki (website where users can make their own edits, not necessarily on Wikipedia) for comparing different cryptocurrency wallets. For example the table could include information such as the year that wallet first became available, whether they currently charge a fee for transactions, etc.

Wikipedia does have a List of cryptocurrencies but doesn't seem to have a list of wallets.

There is a bitcoin-specific Wiki site which has a page on "wallets", but it only lists wallet formats, so none of the top wallets listed for example here, such as Coinbase and RobinHood are listed there.

I have done some research before coming here.

1) Is there a comparison between different blockchain.info's wallets? - is specific to blockchain.info
2) Is there a website that compares the features of different cryptocoins? - is asking about cryptocoins, not wallets (and also doesn't have any answers).
3) Comparison of different active cryptocurrencies - asks about different coins, not wallets.

Question (1) did not end up getting closed, but in the comments it says "Questions seeking product or service recommendations are off-topic because they tend to become obsolete quickly. Instead, describe your situation and the specific problem you're trying to solve."

I am therefore not seeking a product recommendation, but rather I'm asking whether or not there exists a page where I can go and study the different products myself easily. Such a page would not go "obsolete quickly" because on a Wiki, people can constantly update it to include new wallets or remove features no longer offered. I did start this research because I wanted to find something like RobinHood but not requiring for me to have an SSN card from the USA, or like Coinbase but without requiring me to be able to receive text messages (I only have a land-line phone) but still allows free transactions, but some link to a Wiki page would suffice if I can't ask directly whether or not the type of wallet I want exists.

To my knowledge, there is no such list, although many comparisons between a subset of wallets and services are available.

Although one could conceivably build such a list, perhaps on the Bitcoin wiki, there would be limits to its benefits for actual wallets.

Wallets vs. Wallet services vs. Custodians vs. Exchanges

Services such as Robinhood do not qualify as a wallet, since there is no way to send or receive bitcoin. These are simply exchanges, and you usually have no way to verifying that the bitcoin you supposedly own are actually there, or to access them.

You also have custodial services, most of which offer exchange services as well, such as Coinbase, Bitfinex, and other popular exchanges. Via these, you can send, receive, and trade bitcoin. However, you are still not in control of your keys, and are subject to a significant counterparty risk.

You then have wallet services, such as Bitpay and BitGo. These services provide mobile and desktop apps, and also allow you to maintain control of your seed words, which lead to your private keys. Here, you are still implicitly trusting that their apps will not steal your BTC, but are free to move your keys to another application if you wish, or if the service shuts down.

Lastly, you have programs that are not centralized, and allow you to maintain full control of you coins, such as Bitcoin Core and Electrum. Here, there is no single point of failure, the code is open source, verifiable, and can be compiled directly by you. Backend services are also distributed and redundant, and your keys never leave your machine. This is the only stage I would consider to be a true wallet.

At this stage, any wallet would achieve feature parity fairly quickly, since the underlying transaction mechanism of the blockchain is the same for everyone. As such, a comparison would be limited to the code/ease of use/team, and other such factors.

At higher levels where custodian and exchange services are involved, a comparison makes more sense since features diverge a fair bit. However, this is hard to put into a wiki, since it is not often black and white - for instance, some exchanges only offer certain features to residents/citizens of specific jurisdictions for legal reasons.

Moreover, such a list would also be more prone to defamation and spam attacks with competitors/bandwagons trying to artificially make someone look good or bad, which would be hard to moderate quickly and effectively - On a popular list like this, listing a scammy wallet for even a short while could easily cause someone to lose a lot of money.


History of transactions in Lighting Network I'm just a beginner in lighting network. Have some questions about transactions in LN when im doing the research

Transactions in LN are off-chain, so transactions couldn't be stored in main-chain, so how could you look-up the transactions history?
Payment channel is private for someone outside, and if there is no transaction history, how do i give the information to others to proof that I've just made a payment in LN.

Any helps, tks

Transactions in LN are off-chain, so transactions couldn't be stored in main-chain, so how could you look-up the transactions history?

You cannot view the transaction history of any node except your own. Transactions in LN are private and sent encrypted over an onion routing layer. It is up to the software client to keep track of payments if you want your own payment history.

  Payment channel is private for someone outside, and if there is no transaction history, how do i give the information to others to proof that I've just made a payment in LN.

Every payment on LN uses a 256-bit random number, called a payment_preimage. The preimage is hashed using SHA256 to produce a payment_hash. The intended recipient of funds initally witholds the payment_preimage, but gives you the payment_hash and asks you to make the payment.

When you make the payment, it is made for a specific payment_hash. This is done with a Hashed Time-Locked Contract (HTLC), which is a conditional payment. The payment expires after a timeout, unless the intended recipient accepts the payment by surrendering the payment_preimage for that payment_hash. If the recipient does not accept the payment, they must fail the HTLC before the timeout, else their channel may be forcibly closed and they will not receive the payment.

Once the recipient has accepted a payment by sending the payment_preimage, it is trivial for you to prove that you have paid payment_hash, because anybody can perform the SHA256 on the preimage and assert that it matches payment_hash. The assumption here is that SHA256 is cryptographically secure and it is not possible to brute force a payment_preimage to produce an expected payment_hash.

By surrendering the payment_preimage to accept the payment, the recipient has provided proof that you have paid.

Note that this must assume that a preimage is never reused. Every payment must use a unique random preimage else it may be possible that funds are stolen.


How does each miner know when to create a block? I have been trying to understand the protocol and reading related documents, there is a point where i get stuck.

As far as i understand (correct me if not), when a transaction occurs, it is broadcast to the network and some miners receive it. When a certain number of transactions is reached, they are packed in a block and hash race begins.

What i fail to understand is; in this scheme, don't all the miners have to be in perfect memory coherence and time sync, so that they know when a block is to be sealed and start to iterate for hashes? Or do they not need to mine and hash the same global block, but have separate blocks which are later validated by other miners and interblock transaction collisions don't matter?

I know i misunderstand a very basic point in the protocol, but i can't figure what.

A miner begins creating a new block as soon as it receives a valid block from another miner.  It then begins to construct and hash the next block on top of the block it just received.

You were correct when you thought that each miner has a separate block from the rest.  Don't look at it as if miners are all cooperating to find a hash for the same block, but rather are competing against each other to make their own block the next in the chain.  If they find a valid block, they broadcast it, and other miners give up their efforts, and instead focus their hashing power on the next block.


Do I need to be synced with the network to make remote RPC calls? I want to make some RPC calls from my local computer to a server I have which is currently syncing with the network via $ bitcoind

I am trying to make RPC calls for things like getinfo but my request are failing. I just want to double check if it's even possible to hit it with a request and receive data back if its not synced up. I would have thought no, but I can use the bitcoin-cli from my server to get things like getinfo without an issue.

Yes it is possible.

Using the rpcwait flag will prevent calls from failing while bitcoind is starting up.

Aslo, make sure you have configured your bitcoin.conf file correctly.

rpcuser, rpcpassword, and rpcallowip need to be set and these params need to be passed to bitcoin-cli during an api call.


How to Recovery passphrase bitcoincore i dont remeber my passphrase of my  bitcoincore wallet.
I try with an hex editor but i don’t know wich string i have to search.
how can i recover it?
Thanks to all can help me.
I’ve followed some post in various forums but I find only instructions for various wallet but nothing for bitcoincore.
I know that is possible to find a pass phrase with an hex editor but I don’t know what searching for

No it is not possible to find the passphrase with a hex editor.
Bitcoin core encrypts your private keys with a random key. This random key is encrypted (AES-256-CBC) with a key derived from your passphrase.
If you remember something from the key (parts of it, letters, even length) you need a program that permutates what you know. If not you can try brute force starting with 1 character and up. Unfortunately when you chose a good key (length>15 characters) this is a near impossible task.


Possible to temporarily reduce the supply of a cryptocurrency? Does a cryptocurrency that can have its supply be reduced based on some factor currently exist?

If not, is this possible?  If so, how?

This is possible through the use of a multiplier. For example, you could add it to Bitcoin as follows:

You add a "currency multiplier" and "next currency multiplier" to the block header.
All Bitcoin amounts presented are multiplied by this multiplier.
You have a set of rules for how the next currency multiplier changes. For example, miners could be permitted to change the "next currency multiplier" by a small amount in each block.
Periodically, say every time the difficulty is adjusted, the currency multiplier is also adjusted by up to 2% (or whatever) towards the next currency multiplier and the next currency multiplier is set to the new currency multiplier.

So if I want to pay you "1 Bitcoin", I actually have to pay you an internal amount that depends on the multiplier. Changes in the multiplier would change everyone's displayed balances. This way, if miners believed there were too many Bitcoins in circulation and the value was dropping, they could "vote" to reduce the multiplier. This could result in a more stable price and thus make it easier to price goods in Bitcoins. At least, those would be the arguments in favor of such a scheme.


Accessing a wallet from multiple devices I'm using an Electrum wallet on my laptop. I'd like to have the functionality available on my phone (i.e. send/receive bitcoins - to the same wallet).

Is there a way to install one of the myriad of Android wallets, and "import" my wallet into them? Is that even the right approach? If not, what's the best way to use wallets on multiple devices?

There is an Android version of Electrum. Just enter the seed words.


How to monitor balance for addresses other than by using importAddress? Is there any way, other than importaddress, to watch balances of specific addresses?

If not, how it is possible for wallets and explorers to give information (balance, transactions) about specific addresses even though importaddress takes some time?  Because we have to rescan sooner or later.

Is there any way, other than importaddress, to watch balances of specific addresses?

No, creating a watch-only address is the way to do this using a wallet such as Bitcoin-core.

  how it is possible for wallets and explorers to give information ... even though importaddress takes some time?

Once the blockchain has been initially scanned for transactions involving an imported address, the wallet need only check new blocks for mentions of that address as it receives the new blocks, there should be no need to rescan the blockchain.

Blockchain explorers can maintain an index per address and continuously keep track of balances for all addresses. They don't need to recompute this from scratch for every new enquiry.


Is there any wallet that that sets fee based on input amounts (not tx size)? Generally the fee is based on tx size in the wallets I am aware of. Is there any wallet that allows setting fee based on a fixed fraction of total input value (say, 1/1000th of the inputs value)?

Please include wallets used by developers also (Bitcoinj, bitcoinjs, etc).

Most wallets that allow you to specify a custom fee would support this, technically. The fee is simply totalInput , totalOutput, so you can easily adjust it a fair bit.

However, miner's select txs based on sat/byte. In the system you described, some txs will end up severely underprices, while others will be massively overpriced.

Wallets currently just take the size of your tx, multiply it by a fee rate, and deduct that from the change outputs. This ensures that you are paying a fair fee for the tx size.


Which bitcoin miner ASIC can use without leave power on computer? after search and read a lot of bitcoin miner posts in the web, yet I have one doubt before buy bitcoin hardware...

I have read about ASIC Hardware of ButterFly Labs, Avalon, Knc, USB Erupter and others... But anybody specify if the computer have be power on all time...

Can I use ASIC bitcoin miner without leave power on PC 24/7?

If is possible can quote some example...

Thanks!

The computer has to be on while you are mining.  As part of the way mining works, you need block headers as your input data.  For solo mining, these block headers are computed from transactions and other blocks coming from other peers on the network, and you need to update that data frequently.  (If another miner finds a block and you don't update your header to link to it, any block you find after that will be orphaned and likely rejected, making your mining a waste of time and energy.)  For pooled mining, you need updates for similar reasons, except that the updated headers come from the pool operator.

For most such devices, collecting this data from the Internet is handled by the host computer, so it has to be on and running the whole time.

It is possible to use a small low-power computer for the host.  One popular choice is the Raspberry Pi.


Will Electrum mnemonic seeds be forward compatible with all future versions of Electrum? If I use the newest version of Electrum (2.6.4) to create a mnemonic seed and the current source code (2.6.4) later becomes unavailable, will I be still able to use a mnemonic seed I create now with all future version of Electrum?

I know that Electrum has changed the type of mnemonic seeds it uses at least once (from 12 to 13 words). Should I be concerned that future updates will eliminate compatibility with current mnemonic seeds?

Are there any advantages of my retaining a copy of Electrum (2.6.4) if my only purpose in doing so is wallet recovery several years from now?

In fact, the reason Electrum 2.x changed to a 13-word seed* and is incompatible with BIP39 is because they added a version number to the end of the seed. This has the purpose of allowing future versions of Electrum update the seed format while still understanding how to derive all the addresses from previous seed versions.

  Standard Electrum seeds have 128 bits of entropy, plus 8 extra bits
  for checksum and seed version. Mycelium uses BIP39, which does not
  include a seed version.

https://github.com/spesmilo/electrum/issues/1733#issuecomment-200782966

Other clients rely on the community's formalisation practice through BIPs, where we all agree on a way to describe and encode/decode HD wallets. Years down the line, you should always be able to say "hey this was derived from BIP39" and everyone should still know what you mean. The developers of Electrum believe that including the version number and checksum is more important than adhering to a formal BIP format. There are no plans to propose a BIP for the Electrum convention.

"How do I make sure my cold storage wallet seed will be recoverable in x years?"

The standard answer is that Electrum is open source, and you should be able to find an archived version or at least find documentation on how to recover your wallet should the project shut down.

*It's not actually 13-words, it's just happens to have 13 words right now. In the future this may change to greater or fewer number of words, but it won't matter because the software will know the version/checksum.


How to get legacy address and private key from Segwit P2SH address? I have a Segwit P2SH address (starting with 3...) with the corresponding private key and need to obtain the legacy address (starting with 1...) and the private key. Is this possible?

You have the private key so you can just derive the address from there. Get the corresponding public key, hash it with SHA256 and then that result with RIPEMD160. Then perform Base58Check Encoding on it.


What does the term "Electronic Cash" stand for in computer science lingo? Very often in various online discussions, people cite the word "cash" from the Bitcoin whitepaper title as evidence that Bitcoin should be used for everyday transactions.

I've seen mentions that the term "Electronic Cash" as it appears in the whitepaper title has a very specific meaning in the cypherpunk/computer science community. I've tried looking for a definition online, but I couldn't readily find a more elaborate definition of the term.

What is the meaning of "Electronic Cash" in the computer science lingo?

Digital cash is supposed to be a digital equivalent to our legacy physical cash (coins and banknotes).

Therefor digital cash needs to fulfill certain criteria:

payments can be made without a middleman
the receiver has a means of verifying the transaction and be sure that they have been paid
the transaction cannot be reversed

These criteria are met no matter if I hand you a banknote or send you a Bitcoin transaction. They also create privacy and non-confiscatability as no middlemen carry out the transaction for you or hold your money for you.


What is Transaction Malleability? The Bitcoin exchange MtGox has stated in this press release that "transaction malleability" caused them to stop sending bitcoins. A recent question asked if it really is an issue. But what is transaction malleability in the first place?

Bitcoin transactions have a transaction id (txid) formed as a hash over the data involved in the transaction. That suggests that it is a unique identifier for a transaction.

However, the tx-id of a transaction is only unique once the exact data in the transaction has been finalized by being incorporated into the blockchain (and confirmed). Until then, there are hacks that allow altering the underlying data and hash. This is not a security issue because it is not possible to alter how many bitcoins are transferred from what input to what output. But details such as what format the cryptogaphic signature confirming that the input authorizes the transaction takes, or the exact signature script used, can be changed: They are malleable, making the hash or transaction id malleable as well.

This should not be a big issue at all. But it is if you built your Bitcoin handling on the assumption that transaction ids are not malleable, as MtGox may have. You also need to be careful about spending unconfirmed transactions, because this only works if nobody changes the intermediate transaction ids. None of this is an issue in the standard Bitcoin client, but if you roll your own, especially if you wish to use only a single Bitcoin address to handle many individual transactions, rapid-firing transactions directly building upon the unconfirmed previous one is an easy mistake to make. If people altered transaction ids from MtGox withdrawals, and MtGox adopted such a rapid-fire approach, this may explain why there have been many complaints of never arriving withdrawals: Altering one transaction id in the chain of unconfirmed transactions invalidates all successor transactions, until the originator resynchronizes with the blockchain rather than its own idea of which transaction ids it has sent.

EDIT: A much more elaborate explanation can be found in this Quartz news article


Python - Querying bitcoin's block header using leveldb I am facing a stupid problem. I am trying to read bitcoin/blocks/index leveldb using plyvel. I've set up a regtest and i know there is a block with the hash :

27ce8199dee22f96e4f392dec29ef207fcd8a3c9e43b7d58cb40a5ba01af674b

I am trying to query it using plyvel.

Note that I already read the topics :

How does Bitcoin read from/write to LevelDB

What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?

https://en.bitcoin.it/wiki/Protocol_documentation

Then, I know I have to swap the endianness so it becomes :

MYVAR = "4b67af01baa540cb587d3be4c9a3d8fc07f29ec2de92f3e4962fe2de9981ce27"

Thus, I should query something like :

b + (byte) MYVAR

However I do not get how. I guess I missunderstand something in encoding. I tried :

db.get(b'b4b67af01baa540cb587d3be4c9a3d8fc07f29ec2de92f3e4962fe2de9981ce27')
db.get(b'b'+b'4b67af01baa540cb587d3be4c9a3d8fc07f29ec2de92f3e4962fe2de9981ce27')

..

Then, I opened the bitcoin/blocks/index leveldb using a gui explorer and I noticed the key for this block is :

\x62\x4b\x67\xaf\x01\xba\xa5\x40\xcb\x58\x7d\x3b\xe4\xc9\xa3\xd8\xfc\x07\xf2\x9e\xc2\xde\x92\xf3\xe4\x96\x2f\xe2\xde\x99\x81\xce\x27

which is \x62 corresponding to the "b" + the hash with \x (escaping caracter ? I know here is my misunderstanding on hex encoding)

and obviously

db.get(b'\x62\x4b\x67\xaf\x01\xba\xa5\x40\xcb\x58\x7d\x3b\xe4\xc9\xa3\xd8\xfc\x07\xf2\x9e\xc2\xde\x92\xf3\xe4\x96\x2f\xe2\xde\x99\x81\xce\x27')

perfectly works

I also tried these methods :

https://stackoverflow.com/questions/5649407/hexadecimal-string-to-byte-array-in-python

No one of them works and I really don't get why :

bytes.fromhex(hash)
bytearray.fromhex(hash)

Thank you in advance

The leveldb databases are serialized for optimization and do not work well with attempting to manually parse the data. You can more easily get details on a specific blockhash using the built-in JSON-RPC API and use the getblock call.


"Failed to subscribe" - poclbm over SSL - Ubuntu So I have setup bitcoind -daemon on a server. On plain HTTP, I can connect to the server from my machine and start mining with poclbm.py (at a slow rate but I am preparing my environment before upgrading H/W)

Then I have created the self-signed certificate successfully, and from a remote machine I can get the SSL certificate validation using openssl s_client command. I had trouble with the openssl s_client command when not including the

rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH

part in the conf, but after adding it it as ok.

Then added option rpcssl=1 in bitcoin.conf.

Now I get a Failure to subscribe followed by IO errors - 1, tolerance 2.

Is there anything else to check? Running poclbm with -verbose doesn't show more output.

After looking at the (quite old) source code of poclbm, there is a commented line that creates the SSL connection. Not sure it is the reason but I guess it doesn't support HTTPS in its last version.
I changed to DiabloMiner (I had to add my self-signed certificate using the InstallCert.java tool)

I can now mine over HTTPS. Next step is a pool...


How get outpoint from txIn I'm from Ukraine and do not know much English, sorry. I'm not understand where in transaction keep outpoint.

Please give me example or manual how get outpoint from input.

Every transaction input consists of a number of fields:

The txid of the transaction whose output is being spent.
The index of the output being spent (also called vout).
The scriptSig, or unlocking script.
The sequence number.
(SegWit inputs only) The scriptWitness.

The first two (txid, vout) are called the outpoint.


bitcoin-cli not found on OSX I have a Qt testnet3 node synched and running on my mac.  In the terminal, when simply trying:

$ bitcoin-cli getinfo

or

$ ./bitcoin-cli getinfo

I get:

-bash: bitcoin-cli: command not found

Anyone know why the command could or would not be found?  (server=1 in bitcoin.conf as well)

There is a bitcoin-cli available for OSX. I also ran into this issue, and it is because I missed one of the setup steps. Here they are for posterity!

Install Xcode:

$ xcode-select --install

Install Homebrew =>
 https://brew.sh/

Clone the repo:

$ git clone https://github.com/bitcoin/bitcoin.git

Navigate into bitcoin directory, and run the autogen script:

$ cd bitcoin
$ ./autogen.sh

  The autogen.sh script creates a set of automatic configuration scripts
  that will interrogate your system to discover the correct settings and
  ensure you have all the necessary libraries to compile the code.

Run the configure script:

$ ./configure

  This will automatically discover all the necessary libraries and
  create a customized build script for your system.
  If all went well, the configure command will end by creating the
  customized build scripts that will allow us to compile bitcoind.

Compile the bitcoin source:

$ make

Install the executables on your system:

$ sudo make install

Default install location of bitcoind is /usr/local/bin.
Confirm Bitcoin Core is installed:

$ which bitcoind
/usr/local/bin/bitcoind

$ which bitcoin-cli
/usr/local/bin/bitcoin-cli

Full disclosure this information worked for me, and it is from Andreas M. Antonopoulos' Mastering Bitcoin book!


I use Litecoin Core wallet on my PC and need to have it on laptop to take away on holiday I am using Litecoin Core wallet on my PC,  and I need daily access to it.

I am travelling away from home at Easter and taking my laptop with me.
I downloaded Litecoin Core Wallet to my laptop,  but there is no balance showing up.  Is there a way to sync the two wallets?
Or if not,  can I transfer the balance to a Receive Wallet on the Laptop Wallet?

Thank you
Margaret.

Yes.  You'll need to backup the wallet.dat file from litecoin core on your PC, transfer it to your laptop, then replace the wallet.dat file in your laptop with the one you grabbed from your PC.

How to Backup Litecoin Core

Open Litecoin-QT
File-> Backup Wallet
Save it
Grab a USB
Drop the newly saved wallet.dat file into the USB

How to Insert wallet.dat into New Litecoin Core

Download Litecoin Core but do not open it.
Open your file explorer and type the following line:
C:\Users\YourUserName\Appdata\Roaming\Litecoin
Delete the wallet.dat file in the Litecoin folder. Rename your wallet.dat file from your PC to "wallet.dat" if you need to.  Drop it in the Litecoin folder.
Open Core and if you see unconfirmed tx it worked.

Another Option

You can dump priv keys to the addresses that received LTC and sweep it into Electrum-LTC.  Only download this from Electrum-LTC.org.  Electrum-LTC is a light-weight client that references other Full Nodes so you don't have to use your own.  This means you don't have to keep your laptop on to stay up to date with the most recent blocks in order to send LTC.  But if you want to keep supporting the LTC network by running Litecoin Core, then kudos to you!

How to Dump Priv Keys from Litecoin Core

Go to console in Litecoin-QT
type: walletpassphrase "your walletpassphrase here" 600
type: dumpprivkey [your Litecoin address here]

Sweep into Electrum-LTC

Open Electrum-ltc. Go to Wallet-> Private Keys-> Sweep.
Input the private key and an LTC address you want to send it to. Often times, Electrum-LTC provides one for you.


List of current opcodes? Anyone know how / where to run

enum optypecode

(or some other method) to get a list of current opcodes? Like this result...

https://www.slideshare.net/gvrooyen/20140220-bitcoin/34-We_just_used_4_opcodesenum

I don't think there is a command you can run, besides looking at Bitcoin's source code. (look for enum opcodetype)

Note that a lot of the opcodes listed there

are disabled to reduce complexity, (OP_CAT)
change meanings depending on which softforks are applied, (OP_CHECKLOCKTIMEVERIFY and OP_NOP2 have the same opcode) or
may have no meaning in a script. (OP_SMALLINTEGER)

To get a list of ones that can actually be used without making a script fail, you need to look at the code that actually evaluates scripts. (look for Bool EvalScript)

Here's a list of legal opcodes, as of time of writing:

(direct push, opcode 0x01-0x4b)
OP_PUSHDATA1
OP_PUSHDATA2
OP_PUSHDATA4
OP_0-16
OP_TRUE
OP_FALSE
OP_1NEGATE
OP_CHECKLOCKTIMEVERIFY
OP_CHECKSEQUENCEVERIFY
OP_NOP
OP_NOP1-10
OP_IF
OP_NOTIF
OP_ELSE
OP_ENDIF
OP_VERIFY
OP_RETURN
OP_TOALTSTACK
OP_FROMALTSTACK
OP_2DROP
OP_2DUP
OP_3DUP
OP_2OVER
OP_2ROT
OP_2SWAP
OP_IFDUP
OP_DEPTH
OP_DROP
OP_DUP
OP_NIP
OP_OVER
OP_PICK
OP_ROLL
OP_ROT
OP_SWAP
OP_TUCK
OP_SIZE
OP_EQUAL
OP_EQUALVERIFY
OP_NUMNOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_WITHIN
OP_RIPEMD160
OP_SHA1
OP_SHA256
OP_HASH160
OP_HASH256
OP_CODESEPARATOR
OP_CHECKSIG
OP_CHECKSIGVERIFY
OP_CHECKMULTISIG
OP_CHECKMULTISIGVERIFY

Bitcoin Wiki has an excellent page on this subject, if you're trying to figure out what is possible in Bitcoin script.


BTC Treasure Hunt Volume 2 Similar to Whoiszo, I too am helping a friend locate a bitcoin treasure.
In a period between 2010 and 2011 my friend owned a blackberry curve 8330. At the time she was into some online gambling and because many of the gambling sites were becoming illegal in the US, she thought she would try putting some money in Bitcoin, which seemed like it would be easier to use on the gambling sites. She remembers buying the bitcoin and even had an app on her blackberry that she could access the exchange to keep an eye on the value. She decided to never spend it and eventually got a new phone and forgot about the bitcoin, which is reasonable considering it wasnt worth much at the time.  Fast forward to 2017 when bitcoin began to move rapidly, she remembered the bitcoin she had and tried to locate it. Unfortunately the phone was gone, the email service she had at the time was no longer in business and the email account could no longer be accessed. To top it off she cannot remember the name of the exchange or the app she used to access the bitcoin.
When I was speaking the other day about investing cyrpto market she explained her situation to me and she asked for my help. Of course I was very intrigued but skeptical. I thought surely she is mistaken. However she mentioned a few numbers , How many she bought and the amount she owned and after checking  the numbers are consistent with what the price of BTC was at that time. Also the fact that she said she could access it and monitor the value for that time means she would have had to definitely have purchased it. So now I have decided to help
what we have done so far:

tracked down the email service provider and followed the trail through about 3 different acquisitions of the company to arrive at the one that is currently functional. We got them on the phone and they said they have access to the @ ###.com email accounts however, hers for some reason could not be located.

Gone through years of bank statements searching for the transaction, hoping for a clue of the location or exchange with which it was made. - Nothing found in the bank statements, working on collecting all credit card statements from this time period now. (hoping it was not purchased with a gift card)

found and accessed her ###@sprint.blackberry.com account over the phone but was told there was no information there except the email address she had on file (same one as item 1).

Contacted Blackberry to see  if blackberry ID was required at the time she set up her phone and if so,, would that profile log information such as which apps were downloaded on the phone.
(waiting on reply)

What I would like to do now is start from the opposite end and try to make the connection  back to her . my Plan is to try to figure out which exchanges  it could possible be  and see if an account was made in her name at any of them , however I am having ttrouble determining which exchanges it could possible have been. Does anyone recall any early cryptoexchanges  from this time period which  would be worth looking into?  does anyone recall accessing bitcoin holding account through aa blackberry app in this time period? which exchanges were even in existence in 2010 & 2011?
Im running out of  ideas and leads to pursue, where would you go from here?
Your assistance would be greatly appreciated and if wyour suggestions lead me  on the trail to finding the lost bitcoin I will  dmake sure that you are rewarded!!

If it was between 2010-2011, it must have been MtGox [dead], Britcoin [dead], Bitmarket [dead], Bitstamp [alive], Kraken [alive]. If she's lucky, she used Bitstamp or Kraken.
She stored the BTC on the exchange or did she ever transfer any to a wallet?
If you know the company or individual who owns the domain her email was registered on, I'm sure they'd be willing to register her username (probably would need to add some motivation by way of money).
I don't know of any exchange that would accept giftcards to fund your account, so there must be something in her bank statement or credit card statement to reveal where her funds went.
Also did she use her legal name to register on the exchange?


when a miner solves the problem in less than one timestamp then what does it do with its extra capacity? If a miner solves the problem in less than one second then how does it use the extra capacity.

The resolution of the timestamp in a Bitcoin block header is one second.  However, if a miner should find a valid proof-of-work and create a valid block, they do not have to wait one second before starting work on a new block.  It is perfectly legal for two successive blocks to have identical timestamps.  In fact, it is legal for the succeeding block to have a timestamp that is earlier than that of the preceding block by up to 7200 seconds.  See Why is two hours the maximum acceptable offset for Bitcoin blocks?

So a miner can immediately start work on a new block, and this is normally what they actually would do.  Hence there is no "excess capacity" at all.


Can I send message inside the transactions script? I would like to send transactions with messages as described in the wiki. In Transaction with slightly changed script is never relayed, someone answered that non-standard transactions are not relaid by the client. I was wondering if this will affect this type of transactions.

Also, I would like to know if there is a source code that implement this functionality. I need to send small data (SHA256) as a digital signature that can be view by all the peers in the network and is associated to this specific transaction.

Thank you very much and your help is very appreciated

You will find that non-standard transactions are very hard to get into the block chain. Instead, encode the additional information as accounts and send a single satoshi to each account needed to convey your message. That way, you can use standard transactions.

Transaction 28ccf29cfcc9f82d42793db770e7c7894d61ccf3d18299f34bda2e54415da287 is a particularly silly example of this.


Wallet backup in heterogenous environment Can we restore a windows environment .dat backup file into linux environment?

Assuming you mean the wallet.dat file, yes, you can do that. There are no Operating System restrictions on the wallet.dat files (or any other files in the Bitcoin Core data directory).


Can zero-transactions block generation be called as a Sybil attack? Imagine a malminer with two important abilities: having enough hashrate for producing blocks in a single-miner mode in reasonable amount of time and having a malconfigured miner software which doing somewhat a usual mining job, but including no transactions in the block except of reward. It might be more productive (from malminer's point of view) way of converting a computational power into some bitcoins, because changing the nonce only looks much easier than downloading and ledgering the real-world transactions. Can I call such intentional easy-mining a Sybil attack?

Can I call such intentional easy-mining a Sybil attack?

No. Because mining is a memory-less process, it is quite possible that subsequent blocks be found while the mempool is empty. Furthermore, the idea that verifying transactions takes away mining resources is moot since the SHA256 hashing is typically done on specialised hardware that can't do anymore than SHA256 hashing, so verification effort and mining effort is mutually exclusive.


Does BIP39 mnemonic construction avoid repeating words? Will all 24 words of a seed-phrase be unique by specification? Or is it possible for a word to occupy two positions (ie the word "tool" is #8 AND #20 in a valid, securely generated seed)

There is nothing stopping a word to be repeated more than once. In a 24 word mnemonic, with 2048 possible words in the dictionary (BIP 39), there is a probability of at least one duplicate around 12.7% of the time (variation of the birthday paradox).


How can a X-coin market cap go down while its value goes up? Quoting Wikipedia, Market cap is given by the formula

MC = N × P
where N is the number of shares outstanding, and P is the closing price per share.

In the specific case of a crypto currency, one could assume that N is the amount of coins in circulation and P its current value.

How can the image below happen, given that Zcash, being a fork of Bitcoin, cannot (unless I missed something very important) be destroyed, thus N can only grow.

Source: coinmarketcap.com, a few minutes before this post

As Nate Eldredge pointed out, the chart you're looking at is denominated in BTC, while the market cap is denominated in USD.

If you look at the chart below, you'll see that the price in USD (green) behaves exactly as you describe in your question.

On the other hand, the price in BTC (orange) does not behave like you expected, because it combines the price movement of Bitcoin with the price movement Zcash respective to the Market Cap denominated in USD (blue).


Which price need to be taken for bitcoin analysis I'm doing a bitcoin statistical analysis using Python. The bitcoin prices consist of close,open, low, high prices per an hour. For statistical analysis, which price do I need to take to consider. Is it close price? Or the mean prices.

Many of the analysis had used the closing price as shown below. What is the base for that? What if we consider the mean of them?

https://medium.com/spreadstreet/bitcoin-madness-how-to-simulate-bitcoin-prices-in-google-sheets-c61cb42f26ed

Sorry if this is not the write place to post this question

I worked in IT in the traditional finance industry for a while many moons ago.

There is no 'right' answer to what you want. What's important is not that you use one or other, but that you are consistent and reasonable in your choice. Being consistent example: if you use the open price, always use the open price. Being reasonable example: if you are analysing for highs, then use the highs that come in.

Bitcoin is a 24 hour market unlike traditional trading where they will often use the close. There, the close has a particular meaning: people have often borrowed to trade a position and they want to leave that position before the close, particularly at the end of each session or before weekends. If they do not, they risk the market moving against them at the next open, and risk additional costs for holding borrowed money during a period where there's no trading. Thus, you may prefer to use the close because that's what many traditional traders do, even though it has less meaning to Bitcoin, and even less meaning for hourly closes.

If your analysis is directed at trading, you might want to try https://quant.stackexchange.com/


How to sign a transaction using BitcoinJ I am having problem signing the transaction using BitcoinJ library without the Wallet instance, I only have the Transaction class instance and the ECKey in order to sign the transaction.

Is there a way to implement it ?

Good day. You shoud have list of unspent outputs, for adding them into inputs of your tx. Also you should generate private keys and use special privKey for every input you have.

Try it out:

TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash());
byte[] privKeyBytes = HEX.decode(privKeyAsHex);
ECKey ecKey = ECKey.fromPrivate(privKeyBytes);

transaction.addSignedInput(outPoint, utxo.getScript(), ecKey, Transaction.SigHash.ALL, true);


Visualize Merkle tree Do you have any ideas or suggestions how to visualize Merkle trees?

For our open source project "Open Tracking" we create Merkle trees for thousands of tracking counters before putting the root hash to a bitcoin transaction with OP_RETURN script.

Each hour we merklize state of all active counters for ~20,000 domains and thus we have the tree with 20k elements at the base level.

My first idea was to visualize it in spreadsheet-style. A first column will be level one, a second column will be level two etc.

You can serialize a binary tree with n leafs (such as a merkle tree) as an array of 2n-1 entries. The root is entry 1 and for each node the left child is at position 2n and the right child is at position 2n+1. This gives you a compact representation of the entire tree.

Another option would be to just have the n leaf nodes in a list since the inner nodes are actually generated from the leafs.

Both need to be checked by a program, since checking the validity of a tree involves computing cryptographic hashes. Visualizing them in a human readable format does not really provide any security if it cannot be verified.


MultiBit with multiple addresses to Electrum I have an old MultiBit Classic wallet, where I have received some BTC to two addresses (same wallet). When I import the private key from MultiBit (seems it's the compressed variant) to Electrum desktop, Electrum imports it correctly, but shows only transactions and balance from the first address. Transactions received by the second address (which happened years later) are not shown and I can't import the second address into Electrum, because the wallet is non-deterministic.
I would like to simply send all the money from MultiBit to a new Electrum wallet, but the old MultiBit has trouble synchronising with network.
Please help - how to move all the BTC associated with my private key to a new Electrum wallet?

go to Tools-> Export Private Keys
After you find the .key file, open it in a text editor. The key file should start with the line: “KEEP YOUR PRIVATE KEYS SAFE !”
The keys start at the last # line


Do payment processors who convert bitcoin to dollars (like Coinbase and Bitpay) devalue bitcoin? My understanding is that Coinbase and Bitpay process payments made in BTC.  They receive BTC from a buyer (for example someone buying patio furniture) and send USD to merchants who don't want to keep bitcoin (for example Overstock.com).  In order to get the USD to send to the merchant these companies must be constantly selling BTC on an exchange and thereby devaluing bitcoin.  Is my logic correct?

For every Bitcoin they sell, someone else had to obtain that Bitcoin. So they increase the demand for Bitcoins by at least as much as they increase the supply.

In addition, they increase the utility of Bitcoins, which increases their value. All other things being equal, a currency you can spend at more merchants is more desirable than one you can spend at fewer merchants.


How are transactions from incoming blocks verified? Since only  the  hash of public keys are stored on the chain (as address), which could be validated only by miner who have access to signed transactions (which includes public key), how do other miners validate new incoming block, when they have no access to raw transactions (with public keys) ?

Thank you!

The blocks contain the complete transactions. When you validate a block, you validate every transaction in it the same way the miner who mined that block presumably did.

To spend a previous transaction's output, you must provide a valid signature.
Every signature is accompanied by a public key in the transaction. If you have a signature to verify, you also have a public key.

On the other hand, it's just for the outputs of a transaction that you have only an address. However, there is nothing to verify then since there's no signature. There is no need to validate an address. What would an invalid address be?

The only thing they need to validate are signatures and, as I said, signatures are always accompanied by a public key. When a transaction contains a signature, that signature is accompanied by a public key. Where a transaction does not contain a signature (such as for its output addresses) there is no signature to validate and hence no need for a public key.

The important thing is that the miner validates the transaction and then includes the transaction in the block, so everyone else has everything the miner had.


An updated forkcoins tree chart (only blockchains) Where can I find something conveying this information, but up to date?
digraph {
  # rankdir = LR;
  splines = polyline;

  # Bitcoin is the original chain.
  node0 [label = "Bitcoin\n~15000 $ US (BTC / Nov 2020)"];

  # Bitcoin Cash was a first successful fork.
  node1 [label = "Bitcoin Cash\n~250 $ US (BCH / Nov 2020)", color = "#333333",
         fontcolor = "#333333"];
  node0 -> node1 [label = "Aug 2017", color = "#333333",
                  fontcolor = "#333333"];

  # Bitcoin Gold was a second try to make a successful fork.
  node2 [label = "Bitcoin Gold\n~9 $ US (BTG / Nov 2020)", color = "#999999",
         fontcolor = "#999999"];
  node0 -> node2 [label = "Oct 2017", color = "#999999",
                  fontcolor = "#999999"];

  # Subsequent forks were tried, but most have been low valued.
  node3 [label = "Bitcoin Diamond\n~.5 $ US (BCD / Nov 2020)",
         color = "#bbbbbb", fontcolor = "#bbbbbb"];
  node0 -> node3 [label = "Nov 2017", color = "#bbbbbb",
                  fontcolor = "#bbbbbb"];
  node4 [label = "United Bitcoin\n~.6 $ US (UBTC / Nov 2020)",
         color = "#bbbbbb", fontcolor = "#bbbbbb"];
  node0 -> node4 [label = "Dec 2017", color = "#bbbbbb",
                  fontcolor = "#bbbbbb"];

  #   There were more forks in Dec 2017 but I think they're all low valued.
  # Ignoring Bitcoin X, Super Bitcoin, Bitcoin Hot.

  # Bitcoin SV was forked from Bitcoin Cash.
  node5 [label = "Bitcoin SV\n~150 $ US (BSV / Nov 2020)", color = "#666666",
         fontcolor = "#666666"];
  node1 -> node5 [label = "Nov 2018", color = "#666666",
                  fontcolor = "#666666"];

  #   There was a second Bitcoin Cash fork (Node / ABC) but it seems that Node
  # got almost all of the hashing power and ABC is not an exchanged token right
  # now, if ever.
  # node6 [label = "?"];
  # node1 -> node6 [label = "Nov 2020?"];
}

Please note this aims discussion on the forks of the original Bitcoin blockchain (forkcoins, specifically), not discussing the codebase forks bootstrapping a different blockchain.

As far as I'm aware, the newest graph mapping forkcoins which spun off from Bitcoin is Bitcoin Magazine's Map of Bitcoin forks infographic. It was published in April 2019, so it will not include newer forks like the upcoming BCH split. It does include the major project forks, but doesn't list all forks (there have been over 40 mostly irrelevant forkcoins).
I looked up a prior project called Map of Coins which was aiming to collect the full pedigree of altcoins that forked from Bitcoin's codebase (and other original projects) but it appears to not have gotten updated since 2017.


What is the benchmark that mining ASICs are measured with to determine the hash rates? When a mining ASIC claims to run at 1 MH/s or 10/MH/s or even 1000 GH/s, at what difficulty and with what algorithm is that measured against?

When a mining ASIC claims to run at 1 MH/s or 10MH/s or even 1000 GH/s, at what difficulty

10 MHash/s means that the chip can do 10 million hashes per second, regardless of what the difficulty is. The difficulty changes how many blocks you find, but it doesn't change how many hashes the chip performs.

  and with what algorithm is that measured against?

It'll usually say what algorithms it's capable of mining, but if it doesn't, you can usually assume it's SHA256. There are a couple of odd ducks, like hybrid ASICs that can mine multiple algorithms at once; those are actually two different mining circuits put on the same chip.

  cgminer shows the ASIC running at the hash rate claimed. But when mining in a pool, the pool shows a hash rate of roughly 1/3 what cgminer says.

There are three possible explanations:

The chip is lying about how many hashes it's doing, but the pool can't be cheated in this manner, because it relies on shares. (unlikely)
You're failing to submit otherwise valid shares, because of some software misconfiguration. (slightly more likely)
You've been unluckly, and have gotten less shares than average. This will even out over time. (most likely)


How does a mining pool coordinate with different Javascript clients? I've been reading a little about those web sites taht surreptitiously had Javascript running on the page that is mining cryptocurrency.  How do those pieces of JS work code generally?  Specifically

Do all pieces of Javascript code report back to a central server which maintains a mining pool?
Does each piece of code get a separate piece of work to do (and get assigned a different worker ID) so the malicious web site can mine faster?

The web site doing this don't need to be considered malicious, the visitor could willing agree to do the mining in order to help it. Said that,

Yes, they need to, to know the hash of the merkle tree of the block the pool is trying to mine. Otherwise they would have to download the blockchain in the browser themselves, and that would take hours or days. They also should somehow receive transactions to include in their blocks. Javascript running on a webpage can't typically comunicate with a cryptocurrency node directly, only via http requests to the same page domain.
Yes, they also need to, otherwise they would be wasting CPU time doing the same work. For example, visitor A could receive instructions to compute hashes for a block X with nounces ranging from 0 to 15999, visitor B with nounces from 16000 to 31999 and so on.


Processing two successive transactions? Is it possible to process (stored in the same block) two successive transactions simultaneously?

'Two successive transactions' means that the second transaction's input is the first transaction's output.

Thanks!

Yes, multiple transactions building on each others' outputs can be in the same block. However, they have to be in the correct order inside of the block.

The order of transactions in a block can be freely chosen except for two rules: the coinbase transaction must be the first transaction, and parents must be before children.
Note that the order of transactions in blocks is explicitly specified by the positions of the leaves of the Merkle tree.


How to convert regular transaction to MULTI-SIG one? Assume, I received a bitcoin in a regular transaction: T1. But I need to make MULTISIG transaction. so there should be at least n out of m signatures in new transaction :T3, to redeem it.

Am I right that to turn T1 to a MULTI-SIG one I need to do as follows:

1- I create new transaction T2, that points to T1, and includes all the m public keys and it pays to myself.

2- When I want to pay someone, I create new transaction: T3 (pointing to T2) includes n signatures and pays to another party.

Yes, you are right. There are two ways of doing so:

You can create a multi-sig transaction as you mentioned, including a m-of-n script in which you will define the number of signatures (m) of the total n that will be necessary  to redeem from the transition. The script structure from T2 will be:

ScriptPubKey: <m> <PubKey_1> <PubKey_2> ... <PubKey_n> n

And the redeem script from T3 will be:

ScriptSig: <Sig_1><Sig_2> ... <Sig_n>

Notice that, in order to be valid, the signatures in T3 must be in the same order as the public keys in T2.

On the other hand, you can encapsulate the multi-sig scripts mentioned avobe in a Pay-to-scriptHash, in that way the first transaction script (T2) will simpler, since it will be just a hash, and the transaction will look more similar to a traditional Pay-to-Publickey-hash.


How to getheaders from blockchain? I have run a full node on linux
now I can run commands with bitcoin-cli like:

bitcoin-cli getbestblockhash

it returns:

0000000000344240308f54ded700542571b3df9efe05fab92e669099e20e0d92

or

bitcoin-cli getblockcount

82273

but I can't know where should I change get block to get headers:

https://bitcoin.org/en/developer-reference#getheaders

I want to get all headers instead of total blocks to have a SVP node.

You can use the command bitcoin-cli getblockheader "hash" ( verbose ) to return a specific block header. For more info: bitcoin-cli help getblockheader

but I can't know where should I change get block to get headers: https://bitcoin.org/en/developer-reference#getheaders
I want to get all headers instead of total blocks to have a SVP node.

The getheaders message referenced in that link is part of the peer-to-peer gossip protocol between nodes, not the command line interface. From that link:

The getheaders message requests a headers message that provides block headers starting from a particular point in the block chain. It allows a peer which has been disconnected or started for the first time to get the headers it hasn’t seen yet.


How can you buy XRP with BTC if you don't have any XRP? As far as I know the best way to buy XRP for BTC is from the Ripple client ... which requires some XRP to begin with.

If you own 0 XRP and some BTC, how can you get started acquiring XRP?

You can buy some Ripple (XRP) from Bitstamp. At the time of writing, they were selling 50 XRP / 1 USD.


How does exactly ICO work? What the advantage of ICO for companies? All I know about ICO is that some companies make their own coin and then those coins are bought by investors. So looks cool :) But why the companies should be happy if they will have more investors which will be buy their coins? How will companies get that money from investors?

Cryptocurrencies, and by extension issued tokens, live in a legal grey zone.

ICOs are just a means to use blockchain-issued tokens as a funding mechanism. If it weren't for the legal grey area, it seems to me that they're exactly the thing that investor accreditation laws are intended to prevent: raising money from people who are vulnerable to being scammed.

From what I've seen so far, almost every ICO is just lots of talk, without any indication that there is a plan or competence to implement anything but the off-the-shelf ICO smart contract. In other words, a modern incarnation of a pump-and-dump scam.

So to answer your question: the advantage is raising lots of money quickly, without needing to follow up on any promises.

I believe that ICOs are putting the whole ecosystem in a bad light, and are likely to result in legal problems.


I just compiled bitcoind and run for the first time. Do I already have a private key? Since I have a wallet.dat I suspect I already have a private key and so I could extract it for backup purpose (on paper).

How do I do it via terminal with bitcoin-cli?

Bitcoin Core will automatically create a new wallet on first start. This wallet will contain 2000 private keys (unless otherwise specified by the -keypool=<n> option) and the seed used to generate those and future keys, at least until you encrypt the wallet.

As such, there is not just one private key that you need to backup, rather you need to backup 2000 keys and the seed. Otherwise, restoring a backup will not restore all of your private keys.

The easiest way to backup your wallet is to just copy the wallet.dat file to a safe place. I would not recommend that you try to create a paper backup of your wallet.

If you insist on a paper backup, then you should record the seed. The seed can only be gotten by using the dumpwallet RPC command and then finding the private key labeled hdseed. The seed is a private key and cannot be used in any other wallet software since they do not accept the seed as a private key. You will need to remember that it specifically is not just a normal private key and that it only works in Bitcoin Core. To restore the seed, you can use the sethdseed command in a new wallet.

I really don't recommend that you try to backup the seed. There are changes happening to the Bitcoin Core wallet soon that may make your seed backup unable to work. The recommended way of backing up is to copy the wallet.dat file, and to do so periodically. This will guarantee that you have your private keys, guarantee that it is compatible with future versions of Core, and also backup transactions and metadata (such as labels).


How to do a market trade in bittrex? I am not sure how to set to do market buy and sell
Please help

Bittrex doesn't let market trading at the moment. So you can't. Yes, it sucks.


Cryptocurrency with less deflationary properties I wonder what is the benefit of having Bitcoin reduce the coins mined per block over time?

Suppose a slightly less deflationary growth scheme was possible (and keep other properties that make Bitcoin desirable), that might encourage more people to use it as an actual currency and less as a hoarding item.

For instance, can another blockchain-network be created that increases 0.5% the coins mined per X number of mined blocks?.

It's technically possible to have a blockchain with any generation schedule, such as X% inflation per year or constant reward per block.

The main reasons for a schedule with an upper bound is:

The Austrian economics school, to which apparently Satoshi and a large part of Bitcoin's early adopters subscribe, says that the optimal situation is that the monetary supply is bounded.
If you want to have some long-term inflation you will need to choose what it is, and any choice will be arbitrary. "0% inflation" is a bit less arbitrary option to anchor on.
One of Bitcoin's key properties is that the monetary is supply is not manipulable, and it's perceptually easier to sell it on this point by saying "The protocol guarantees there will never be more than 21M bitcoins" than "The protocol guarantees that in the long term, there will not be more than 3% monetary inflation per year".


What python code is necessary to convert the integers of a bitcoin public key into the proper hex version thereof? If I get a public key of two integers, x and y values what code is necessary to convert them into their hex versions without any additional letters, or numbers?  This is half a Python programming question and half a bitcoin question though I think it is better asked here due to the familiarity with bitcoin requirements.
Pseudo code:

xpublickey = 20091690549896866803343277351761137627937393619088856147056855893222768847187
ypublickey = 69823032225116710867248379519530157435196049639426167980995931003755153241086
hexpublickey = "04" + hex(xpublickey) + hex(ypublickey)

I don't know what code is necessary to turn it into (as the above code does not work):

042C6B7E6DA7633C8F226891CC7FA8E5EC84F8EACC792A46786EFC869A408D29539A5E6F8DE3F71C0014E8EA71691C7B41F45C083A074FEF7AB5C321753BA2B3FE

y = hex(xPublicKey).rstrip("L").lstrip("0x")
z = hex(yPublicKey).rstrip("L").lstrip("0x")
hexpublickey = "04" + y + z


What are the arguments for and against the increase of the block size limit? Can someone give a quick point by point list, what arguments the proponents and opponents of increased blocksize have for their case?

Please note, this answer was written in Februar 2015. The debate has significantly evolved since then, but I haven't gotten around to updating this answer, yet.

I'm sorry, this kinda turned out less brief than it started.

TL;DR: Very briefly, it is an issue of opposing ideologies:
Proponents wish to provide a common good to everyone and believe the increase in blocksize to be necessary to that end.
Opponents feel that a) it is impossible to introduce a change of that magnitude to Bitcoin at this stage, b) bigger blocks will mess up mining dynamics, or c) the increase changes properties of Bitcoin that shouldn't be changed.

What happened before

Originally, there was no blocksize limit. In fact, Satoshi Nakamoto was envisioning "100 million transactions per day, [...] taking 100GB of bandwidth" even in 2008. The blocksize limit was introduced later, when people where starting to play around with bitcoin, but before the value picked up significantly, when a worry came up that people might bloat the blockchain with cheap "spam transactions".¹
The problem is that 1MiB of transactions provides such a small capacity that, we'd be limited to seven transactions per second at minimal transaction size, or extrapolating from current transaction sizes, around four transactions per second. The block limit has not been encountered yet, and is therefore not yet a serious restriction, however this is significantly less than competing global payment networks can handle.
The thing is, that Bitcoin has become fairly valuable, and people want different things out of Bitcoin. The "apolitical money" is very political suddenly (as it always has been).

Arguments against increasing

There are quite a few different concerns here:

Bigger blocks will destroy the market for transaction fees
Increasing blocksize will make more room for transactions, which could reduce competition to be included in a block, in turn lowering transaction fees. In the long run, the block reward will dwindle, therefore less money would go towards mining, and the security of the Bitcoin network would wither with the lower income.

Bandwidth requirements are too much for full nodes
At 20MB per block, full nodes would have to download 2.8GB transaction data per day. This will be not only challenging data storage, but might actually be beyond the bandwidth capacity/datacap of some full node maintainers. One must consider especially that full nodes also serve the requests of thin-clients, so upload capacity might be more important than download capacity. However, on internet contracts for home-users upload speed is often significantly lower than download speed.
It has been suggested that a larger blocksize would quickly lead to a large increase of transaction numbers due to induced demand.
"Bigger blocks will lead to centralization."

Consensus may not be achievable
Once the first block larger than the 1MiB limit will be mined, a hardfork will occur between the network participants that refuse blocks greater than the limit, and network participants that accept it.
Blocks mined on the old network remain compatible to the new network, but not the other way around. Some voices have announced that they would use the fork as an opportunity to double-spend all their Bitcoins, spending them to themselves on the 1MiB-chain, and selling them on the 20MiB-chain, to profit and drive the new chain in the ground.
Some users suggest that this supporters of that proposal have sufficient Bitcoin holdings and support that they can essentially force failure of the blocksize increase, they presume that exchanges would land on different sides in the discussion, but all users would quickly flock to the "safe old chain", once the "civil war" starts.

Bitcoin is destroying viability of altcoins
An increased Bitcoin blocksize would decrease demand for other blockchains, hurting investors of altcoins.

Bitcoin is not meant for every person on the planet to pay for their every cup of coffee
Some people feel that Bitcoin should be an exclusive privilege for settling between companies and the super-rich. A bigger blocksize would dilute the exclusiveness. They argue that something that is useful, but universally available is worthless. Bitcoin instead is meant to "force the poor to yield to the rich, universally, as a matter of course".

People are feeling that something is being decided without them being consulted

"There is only one proposal, we have no choice."
"We cannot predict how quickly bandwidth will grow, the proposed increase it too much."
"There is no consensus, forking without community support is a dead-end."
"There will be huge problems if we do this."
"Why haven't the miners been asked?"

I have trouble relating to these last statements, as the discussion about the blocksize limit has been going on for years.

Arguments for increasing

The transaction capacity is too low to support a global payment network
4.4 tps (transaction per second) are too few to support a global payment network.
At current network capacity, a bigger demand for transactions would cause regular users to be priced out of the blockchain. One would have to wait forever to have a transaction included in a block, and Bitcoin would eventually only get used to settle between banks, mayor corporations, and the super-rich. The blockchain instead should be accessible to everyone, and therefore the blocksize must be increased. Often, this is followed by the argumentum ab auctoritate, that the blocksize limit was always meant to be temporary, and the fork being necessary to achieve the vision Satoshi outlined in the original whitepaper.

Greater blocksize will increase total transaction fees
Even in a bigger block, transactions are not a free resource, as they cost bandwidth, data storage, and cause slower block propagation. Already, miners are not always including all transactions. Therefore, a market for transaction fees would exist even with bigger blocks, and more transactions would cause a higher total of transaction fees.

Effective blocksize will not increase over night
The blockchain of the past six years is smaller than 30GiB. It is wrong to assume that with the introduction of a larger limit, the blocks would suddenly fill up quickly, when they haven't done so before.

Consensus will be achieved before the hardfork is initiated
Major payment providers, exchanges, and mining pools will side with the hardfork supporters, causing the opponents to find themselves to be such a small minority that they will be stuck on an irrelevant alternative chain.

Technical issues will be fixed
Slower block propagation due to bigger blocks will be mitigated by Header-first synchronization and Inverted Bloom Lookup Tables. Internet connections will speed up sufficiently in parallel to increasing traffic demands on the network. Datastorage issues will be solved by introduction of a pruned blockchain, where most "full nodes" only keep a limited number of the last blocks, and few full nodes maintain the complete blockchain.

Conclusion

Personally, I think it is the natural progression of Bitcoin to increase the blocksize, as I see potential for Bitcoin to serve a broader audience. However, I do get some points of the contrarians, especially that it is hard to make predictions about how this will all play out.

Further reading is found here (and in a million other places):

About discussion:

Tim Swanson: What is the blockchain hard fork “missile crisis?”
Reddit: Should the maximum block size be increased soon
Quora: Who will win the Bitconi blocksize war?

Pro increase:

Gavin Andresen: A Scalability Roadmap
DeathAndTaxes: Permanently keeping the 1MB (anti-spam) restriction is a great idea,… if you are a bank.

Contra increase:²

Mircea Popescu: Let's address some of the more common pseudo-arguments raised by the very stupid people that like the Gavin scamcoin proposal

¹ Does anyone have links to the discussion on the introduction of the blocksize limit? I was looking for that.
² I'm still looking for more representative contra-positions. Wading through a few threads of some forums gave me a skin rash, but hardly anything useful.


Making money with bitcoins I heard stories of people on the Web making money with Bitcoins. I heard the term "mining", with bitcoin mining, but I don't really know how it works.

Can someone explain to me the process and what equipement I need to do this?

i just want to make a few hundred bicks/months, steady, and I know that some people deal with Bitcoins and similar virtual currencies.

Honestly your question show a lack of research but anyway.

Mining Bitcoins is basically letting your GPU run so you can earn a few amount of Bitcoins each x amount of time (keeping it simple).
Mining bitcoins is no longer worth it considering the difficulty of the actual blocks, you won't make money with mining unless you have a few thousands ready to invest in mining rigs.

If you want to make money with Bitcoin, you may want to buy it from specialized websites (Coinbase, Circle, Localbitcoins) for price+1-3% and then resell it on forums for price+10-15%.

If you want to make money with mining in general, try to search which currencies are actually skyrocketing (today it's Ethereum, yesterday it was Litecoin, who knows what it will be tomorrow?) and rent mining rigs - it might be profitable but it'd still be an investment. You might lose it all.


Understanding BIP 143 [hash computation, lockTime, sequence number, witness format] I'm trying to grasp some of the concepts presented in BIP 143. These are the things I'm stuck on:

(1) A new hash format is presented. This new format is used to create a hash, which when signed with a private key, acts as a signature for an input. If my transaction contains a mix of input types (e.g. P2PKH and P2WPKH, for example), and I'm signing the P2PKH input, do I still use the original hash format that was used in the past or shall I use this new format? It appears the new format is only used when signing the P2WPKH inputs, correct?

(2) In the past, I've always set lockTime to 0x00. Why is it set to 0x11 in the BIP 143 example?

(3) In the past, I've always set sequenceNumber to 0xffffffff. Why is is set to 0xeeffffff in the BIP 143 example?

(4)I can't quite figure out the format of the witness section. Clearly, there should be one entry for each input. And for the P2PKH input it's just set to zero. But what comes next? According to this, each entry consists of an integer indicating the number of "stack items for the corresponding txIn", and then each stack item consists of a size indicator and the payload of the stack item. But what are the stack items and what is their order? Presumably this is where I'd put my input script and signature, right?

I believe you can use either at this stage. The marker and the flag show let the client decipher which scheme is being used and interpret appropriately.
lockTime sets when the transaction is valid from. 0x00 is from the first block, 0x11 is from a later block. You can continue to use 0x00 if you wish. https://bitcoin.org/en/glossary/locktime. Most transactions are published with a locktime in the past so that they are immediately mined.
The sequence number: https://bitcoin.org/en/glossary/sequence-number
The stack items depend on the type of transaction. See the examples in bip 141. For example the witness for p2WPKH nested in BIP16 P2SH is "signature" "pubkey"


Bitfinex - 25% annual funding fee for margin - Fiat vs crypto - how to minimize cost? On bitfinex, funding fee for USD is around 0.05% (daily) while that for other crypto like BTC is 5-10x smaller (around 0.008%).

In my margin account, i have positions in few crypto currencies and i have posted some USD and BTC collateral in margin account. Rest gets 'funded' with USD at 0.05% funding rate daily (thats almost 25% annual cost!).

Is it possible to fund this with BTC instead of fiat and will it reduce my daily funding cost by 5-10x. If so, what do i need to do?

What you fund your account with is irrelevant to this question.

If you take a long position against a USD pair, you'll borrow USD and pay USD interest. If you short a Coin you will borrow that coin and pay its interest.

Eg. Open long position on BTC/USD for $1000, you'll be borrowing $1000 for your position and would have to pay back $1000 + Interest.

If you short BTC/USD for 1 BTC, you'll be borrowing 1 BTC for your position and would have to pay back 1 BTC + Interest.


How to delete wallet without deleting blockchain I am registering some addresses as watch only addresses and I would like the ability to reset my wallet without having to sync again. Can I just delete my wallet.dat?
I use Bitcoin Core version 16.1.
This wallet does not handle any private keys with a non-zero balance.
Warning: Deleting wallet.dat will make you lose your Bitcoins if your wallet has a non-zero balance!

As Raghav already commented:

Yes, you can delete the wallet.dat file as long as you don't have any private keys in it. Once you restart Bitcoin Core it creates a new and wallet.dat.


Which bitcoin script forms should be detected when tracking wallet balance? I am implementing a library for tracking wallet balance of given bitcoin addresses.

How should the transaction output script be parsed to find if the output belongs to the given address?

Is it dirty if I just match pay-to-pubkey-hash and pay-to-script-hash transaction by simply matching

OP_DUP OP_HASH160 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OP_EQUALVERIFY OP_CHECKSIG

and

OP_HASH160 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OP_EQUAL

or should I implement more sophisticated script parser which can detect "non-standard" scripts as well?

These are the scriptPubKey's that are standard, arranged in order of popularity:

P2PKH (Pay to public key hash)

OP_DUP OP_HASH160 <20 bytes of public key hash> OP_EQUALVERIFY OP_CHECKSIG

P2SH (Pay to script hash)

OP_HASH160 <20 bytes of script hash> OP_EQUAL

P2PK (Pay to public key)

This is now mostly unused, except by miners, but there are still unspent outputs in the form:

<33 or 65 bytes of public key> OP_CHECKSIG

Segregated witness outputs

There are two ways of signaling that a scriptPubKey should be interpreted as a segregated witness program:

Native witness program

<version byte> <2 to 40 bytes of witness data>

The version byte must be equal to or less than 16.
P2SH wrapped witness program

OP_HASH160 <20 bytes of script hash> OP_EQUAL

The scriptSig must have exactly one item. That item is interpreted as a witness program, as above.

Once you extract the witness program, you must match it to one of the witness program types:

P2WPKH

0 <20 bytes of public key hash>

This is hashed identically to P2PKH.
P2WSH

0 <32 bytes of witness script hash>

This is pretty similar to P2SH, except that the script hash is SHA256, not HASH160.
Other version 0 scripts, not 20 or 32 bytes in length, are nobody-can-spend, so ignore them.

Note that any witness program format can be combined with any witness program. For example, you can have P2SH wrapping P2WSH, like this:

scriptPubKey:

OP_HASH160 <20 byte hash of scriptSig element> OP_EQUAL

scriptSig:

<34 byte serialized witness program>

unserialized witness program:

0 <32 byte hash of first witness item>

Then, the first witness item is unpacked and interpreted as the actual program.

More information here.
m-of-n bare multisig

Also pretty rare.

<m> [n <public key>s] <n> OP_CHECKMULTISIG

Data-carrying output

Only one of these is allowed per transaction. These outputs can never be spent, so you probably don't need to detect them.

OP_RETURN <less than 80 bytes of data>

  Should I implement more sophisticated script parser which can detect "non-standard" scripts as well?

No. It's a waste of development time, when nobody uses transactions like that. (If they did, those transaction types would be added to the list of standard transactions. :))

It's also going to be very difficult to implement correctly. If you don't do it correctly, then you'll think you have coins when you really don't. For example, imagine someone sends you a transaction with a scriptPubKey like this:

OP_DUP OP_HASH160 <20 bytes of public key hash> OP_2DROP OP_CHECKSIG

Note that this is like a P2PKH output, except that OP_EQUALVERIFY has been replaced by OP_2DROP. That means that the script checks that the signature is correct, but doesn't check that it's signed by the right key.

That means that anybody can spend it, not just you. Correctly detecting edge cases like these make writing a program that can understand nonstandard outputs more trouble than it's worth.


How much time does it take for a Lightning node to forward an HTLC? How much time passes between the moment an intermediary node receives an HTLC and the moment it forwards if to the next hop? At least what order of magnitude is it? Is it comparable with network-latency (tens to hundreds of milliseconds)?

Short answer: Yes network Latency is should be the dominant factor here. (I have not profiled it and I am not aware of benchmarks)

If you look at bolt 02 https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc you will see that update_add_htlc message including the onion and commitment-signed message will have to be sent / exchanged. (revoke_and_ack is for settling the htlcs) while decrypting the onion and producing signatures are computationally rather expensive operations (we should not forget encrypting and decrypting the lightning messages themselves according to bolt 08 and noise_xk) these operations even on a local area network should not exceed the time for network I/O.


What is the best way to recover from an accidental double-spend? Came across an issue where I was given the message:

"Error: The transaction was rejected.  This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."

It appears that the 2nd amount was deducted from my total balance even though it still sits at 0/unconfirmed status days later even though the unconfirmed transaction has disappeared from the blockchain.

Any suggestions?  I've also installed Python and tried running a script provided by someone else (within Windows 7) and cannot seem to get the script to run properly.

Any help is greatly appreciated.

Apparently to get the RPC command removeprivkey you'll need a build of the Bitcoin client which includes pull #220 (which has been merged into main).  The latest version (currently v0.12.1) contains this feature.

Here are the instructions to do that:

Step 1. Back up your wallet.  You are performing wallet surgery here, ... and doing things you might not have intended.

Run Bitcoin as a server, e.g.,

  $ ./bitcoin-qt -server

Then

If you've encrypted your wallet you'll need to open it for RPC

  $ ./bitcoind walletpassphrase [passphrase] 1000

Then

  $ ./bitcoind dumpprivkey [bitcoin address]

Then copy and paste the private key it provides.
Then

  $ ./bitcoind removeprivkey [bitcoin private key]

Then close bitcoin-qt.

After that

  $ ./bitcoind -rescan


Formal security analysis of Bitcoin I was wondering if there is any in depth (with formal theorems) analysis of the security of the Bitcoin system.

The analysis in the original paper by Nakamoto is quite empirical and not that formal. I would love to see a detailed statement of what the actual assumptions for Bitcoin security are and what these assumptions imply about the security related to the "corruption" of the block chain and double spending problems.

I can deduce the respective theorems from Nakamoto's security analysis but I am not an expert in this area and there could be some hidden assumptions/implications I could overlook.

So I am wondering if someone else already tried to do a formal and detailed analysis of the  security aspects of Bitcoin perhaps in the same manner as some textbook treat other cryptographic applications?

Currently I'm in the process of finishing my master thesis on the topic of Bitcoin security, and I know there is one more person making a similar master thesis. While it might not be as in-depth of an analysis as a professional cryptography expert might perform, it should be fairly extensive.

Over the course of working on the subject I haven't found any article more comprehensive than the Bitcoin wiki page on Weaknesses of Bitcoin. A lot of problems have been covered in depth on this Stackexchange, as well as some topics on the Bitcoin forum.

EDIT:

My master thesis is available to read in this thread on the Bitcoin forum. It covers a wide analysis of many aspects of Bitcoin, from its cryptography algorithms, through the protocol, the standard client, Bitcoin-related applications, and even users' behaviours. I hope that answers your question better.


How is a transaction formated/signed? Every transaction takes unspent outputs as inputs and creates new outputs. The creator of the transaction uses his private key to sign the transaction and nodes validate that transaction by using the public key of the creator.

But how excactly are transactions formated? I have seen this on the bitcoin wiki:

Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:
Value: 5000000000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG

If we use this transaction as an example, how do we take the data from this and format it into a RAW signed transaction that I could send straight into the network without the need of a wallet?

Also, after creating the signed RAW transaction, is it just hashed by SHA256 to create its hash ID or does creating the ID consist of other steps?

Lastly, what is scriptSig? I don't quiet understand scripts in general so if someone could give me a brief explanation of that as well I'd be grateful

Thanks in advance!

Fihdi

If we use this transaction as an example, how do we take the data from
  this and format it into a RAW signed transaction that I could send
  straight into the network without the need of a wallet?

The referenced tx is already spent. So it cannot be re-used. Also you cannot reformat it into a RAW signed tx. There would be 2 steps required. First reformat into a "RAW UNSIGNED" tx, and then this would run through another set of commands to get it signed. Only then it could be sent to the network.
In the example, there is a bit of data missing, I'll add quickly. It becomes clear with the two links below:

version       01000000
Input(s):     1
Previous tx:  f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index:        0
script length 48
scriptSig:    304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Sequence      00000000
Output:       1
Value:        5000000000
script length 19
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG
Locktime:     FFFFFFFF

now you have chosen a coinbase tx as reference, which adds some more difficulty, but ignoring this, then next step would be serialization. Instead of repeating, here are links to  amaclin's work or runek's work.

  Also, after creating the signed RAW transaction, is it just hashed by
  SHA256 to create its hash ID or does creating the ID consist of other
  steps?

No. Not that easy :-) See the link above, and what also gave me a very good hint was Ken Shirriff's blog "Bitcoins the hard way". There is many different data representation involved, including reversed hex and more, which adds layer(s) of complexity.

  Lastly, what is scriptSig? I don't quiet understand scripts in general

Basically it makes sure, that the condition to spend the transaction's funds are verified. This has been asked several times in bitcoin.SE, so I provide another link (see my answer further down):
Why does Bitcoin uses a Script language?

And as said in this link, the book from Andreas answers all these questions very well. Really highly recommended.


Several Q's about consensus about the longest chain and when this chain be confirmed? According to:

How Does the Blockchain Work?

Each node will adopt the longest chain as the only option.

But what will happen if 2 (or more) nodes will solve the next block at the same time,and they will start to build their own chain ?

Which longest chain (if their chains has the same size) will be adopted ?
When (and who) decide to confirm the longest chain ?

But what will happen if 2 (or more) nodes will solve the next block at the same time,and they will start to build their own chain ?

Nothing. Nodes will temporarily disagree on the longest chain, but only in the very last block.

  Which longest chain (if their chains has the same size) will be adopted ?

Whichever one happens to get a block mined after it first. That chain will then be definitively longer than the other one.

  When (and who) decide to confirm the longest chain ?

Every node all the time. Of course, for blocks very close to the tip of the chain, you can't be confident they'll remain in the longest chain. But once you go back three blocks, confidence reaches will in excess of 99.9%. For very high value transactions, you could wait as much as six blocks.


I used a local honey badger bitcoin atm to buy 250.00 CAD worth of bitcoins, where did it go? Ok, so it's not my first time buying/using bitcoin. However, this is the first time I've used my own wallet and purchased bitcoin solely for myself. I downloaded the app Bitcoin_wallet and used a HoneyBadger bitcoin atm to purchase 250 CAD of bitcoin. After I inserted the cash and pressed the done button I printed out a receipt which listed the transaction ID, the address of my wallet, the cash rendered (250), the exchange rate plus FEE($20198.9 + 0.00010007), and the bitcoin purchased amount was displayed. I assumed this information was confirmation that my purchase was complete. However, I still have not Recieved the funds in my wallet.... I guess what I'm getting at is "Does anyone know how long it should take for the bitcoin to show up in my wallet?" I realize that it is not an instantaneous process, but I don't know how long I should wait before contacting honey badger? If it makes any difference I am located in Calgary, Alberta, Canada.

It is advised to put your address into a block explorer such as https://blockchair.com/bitcoin (or several block explorers) to see if the network is aware of a transaction sending money to it.
You should also double-check that the address on the receipt is one of your wallet's addresses. (The main address displayed by the wallet may have changed by now, but it should be possible to open up a list of past addresses).
Most (all?) explorers show transactions even if they are unconfirmed. So if there is no such transaction on the explorer, you should take up the issue with the operators of the ATM.
If the transaction appears on explorers unconfirmed, it may mean you will see it in your wallet when it is confirmed.
If the transaction is confirmed but you still can't see it in your wallet, it may be an issue with your local wallet.


Is it necessary for all miner to reset mining when the tip of blockchain has changed? Each block in the blockchain contains a pointer to the previous block (block header). If multiple blocks reference certain block as their parent, only the one that is part of longest chain is accepted.

Suppose that the hash of the current blockchain tip (last block) is 'A'. Two miner concurrently works on new blocks (containing different transactions) referring to A as a parent. Is it necessary for the slower miner to reset his work when faster miner finishes his block (with hash 'B') and broadcasts it, because the next block has to reference 'B' instead of 'A' as a parent?

If this principle holds, does it mean that slower miners have to restart their work more frequently because they are outrun by faster miners who publish their blocks and so change the blockchain tip?

Correct: when block B is broadcast and validated, all miners need to construct new blocks containing a hash of block B's header.

However, it takes only a minuscule amount of computer processing time to construct a new block, so there is effectively no such thing as "restarting work".  Mining is specifically designed to be progress-free: you have the same chance of finding a valid block after a millisecond of work as you do after an hour of work.

Progress-free mining means that a miner with x hash rate should produce n blocks over time, and a miner with 2x hash rate should produce 2n blocks over time---there should be no special advantage to the more powerful miner.


what are the chances of vanitygen address - private key pair collision? With no random number seed specified, assuming all vanitygen runs start with specific chunk for iteration, what are the possibilities of two different vanitygen runs to end up with the same address - private key pair?

Samr's vanitygen gets its initial private key from OpenSSL's random functions, which have been well vetted. Even if you specify a random seed (which is a good idea to add even more randomness) the entropy generation random libraries from the crypto is still used. It has equal randomness and strength as Bitcoin's address/key generator, with the exception that you are discarding millions of addresses that don't start with your vanity phrase.