Can an exchange or marketplace benefit from private key encryption? A powerful security technique to prevent theft of Bitcoins from a user's online wallet is to encrypt the user's private key with his password without ever stroring the PK directly in the database. Even if a hacker compromises the server they still won't be able to access the user's wallet without his password.
In case a website needs to have custodial control over a user's funds (for example, an exchange or escrow service in a marketplace) this solution isn't viable as the exchange needs to have complete control over the user's funds to move funds from one party to another (say from the buyer to the merchant or to a trader in an exchange). So it cannot be expected that the exchange must ask one party "permission" to transfer funds to the other party. Of course, the exchange or marketplace can encrypt the PK but since it would also need to host the decryption key somewhere on the server there's little benefit in encrypting the PK in the first place.
Is there a variation of this technique that might work even in a marketplace or exchange environment which requires that the owner (of the marketplace or exchange) maintain full control over a user's deposit?
Thanks

It depends what your goal is. Normally when sites have a user's key encrypted as to be unreadable to the site, it's to have a system where users don't have to trust the site not to steal the key. In that case, then no, because the whole point of a technique like that is to have it so the service provider doesn't have control of the user's keys at all. Any workaround to that would defeat the purpose.
If your goal is to protect the keys from outside hackers, then the site can (and most do) employ cold storage or hardware security modules (basically a fancy hardware wallet) that store the keys. In this case, the site owners still have full control of the keys, and the users have to trust the site owners to be honest. However, the scope of a potential hack is limited, as the keys are stored either on dedicated hardware, or if in cold storage, large withdrawals are performed manually by site staff after review.


What is "Key Splitting"? When would I use it? Here is some github code to create split keys.

Is Key Splitting the same as Multi Sig?
What are the benefits of Key Splitting, what's it used for?
How does it relate to P2SH or any other relevant BIP?
How are split keys used in a transaction?

No. Multisignature transactions involve multiple keys/signatures, whereas this involves splitting up one key.
As far as I know, it's not used at all in production. There are a whole host of issues.
P2SH was created to make multisignature transactions easier to implement for e-wallet providers and merchants, and to move the burden of multisignature transactions from the sender to the reciever.
Like so:

Generate a key
Split the key up, store the pieces in different places
Put the key back together
Sign transactions

The major problem with split-key transactions is that you need a trusted third party. When they generate the key, they could secretly store it. When they put the key back together, they could secretly sign a transaction that stole all of your bitcoins.


Will the 3TH KNC Neptune Miner still be profitable in 2014? I am seriously considering making an investment and buying a 3TH miner. The problem is whether they will still be profitable by the time they arrive...

At today's has rate calculation of 707,408,283 it is expected to return 2.1328 BTC in a 24hr period.

The question is how realistic is this and does anyone own a miner that can confirm whether this profit forcast is achievable?

http://www.bitcoinx.com/profit/

The hard part about pre-ordering next generation hardware is to predict a logical expectation of  A) what will be the total network power (hashrate) be by the time your miner comes online which influences directly B) what will be the difficulty value at that time.

If you assume linear growth in the network vs exponential for example you will arrive at different conclusions. That is the real hard part.

At todays difficulty (now 908,350,862) a 2 THps miner at $1000/btc can expect to break-even in 5-6 days.

If looking backwards is any indication, the difficulty has increased by 945% in the past 90 days so if that is the same as the next 90 days and BTC values are fixed at $1000/btc you can expect to break even in 47 days.

IF you think that the next 90 days will grow faster (say 1.5x as fast) as the previous 90 days then you can expect a breakeven in 75 days.

What if your miner comes in 4 months from now instead of 3? What if a whole lot of people are buying one so that when they all come on line simultaneously the difficulty will spike beyond your projections?

And what if the price of BTC falls again from where it is now and stays lower?

A lot of what-ifs but you must know your variables before investing in mining capital.


Two party payment channels, how to set one up? Most guides to LN describe it working "through 'payment-channels', wherein two parties commit funds", usually Alice and Bob. But I cannot see a way to actually create this scenario. I've just started running my own lnd node and I can open, and fund, channels to other peers, but this always seems to be a single fund of the channel.
As I say, I've just started out in the LN world so I may have missed something blindingly obvious, but how does one go about funding a channel with my friend Bob?

what you are talking about is usually refered to as dual funded channels. This is a feature that did not make it into the current version of the Protocol (BOLT1.0). However it was agreed by the developers that it should become part of BOLT 1.1. Currenly C-lightning has most progress towards this feature.

There is a legacy feature push_msat which opens the channel from one side but allow you to already push funds to your friend. however you should not that these funds lost directly.

If you want to be able to receive funds on the Lightning network there are three options:
1. someone else opens  a channel withyou (for example when they want to send you money anyway)
2. You pay someone on the lightning network or buy something after you have opened channels
3. You use an onchain / off chain swapping service after you opened a channel but this puts requires and additional on chain transaction.


What is the difference between digital signature and a digital fingerprint? I've been reading the book, Mastering Bitcoin by Andreas M. Antonopoulos, in chapter 4, the cryptography used in bitcoin is classified as: keys, bitcoin addresses and digital signatures.
I understand the keys come in pairs of private and public.

The part I didn't understand is where it's written: "the recipient's public key is represented by its digital fingerprint, called bitcoin address"

What exactly does a digital fingerprint mean in this context? How is it different from a digital signature and how does it represent a bitcoin address?

A "digital fingerprint" is a unique identifier that references some particular piece of data. Typically, the fingerprint is fixed in size and the information it references is much larger in size. In this case, a bitcoin address is a 160-bit digital fingerprint of a 256-bit public key created by hashing the public key twice.

The difference between a digital signature and a digital fingerprint is that anyone can produce a digital fingerprint while a secret key is needed to produce a digital signature. Digital signatures are used to prove that a particular piece of data was provided or approved by a particular party. Digital fingerprints are used to ensure that the data provided is the correct data.

When a typical bitcoin transaction is performed, the transaction includes a digital signature. It is not enough to ensure the digital signature is valid though, the signature must be made with the correct key. To determine that, the digital fingerprint of the public key used to sign the transaction is checked against the address. If they match, then the public key is correct, meaning the transaction was signed by someone possessing the appropriate secret key.


Is namecoin a currency? It seems like a very cool way to decentralize a DNS table (name -> IP address, right?) But I don't get why it has an exchange value to BTC or USD... Is there a fixed NMC price to register a domain name? Is Casascius going to stamp NMC keys onto brass coins too?

Not really. According to the Bitcoin Wiki:

  Namecoin is an alternative distributed Domain Name System (DNS) on the
  basis of Bitcoin software.

In contrast to a currency, according to Wikipedia

  A much more general use of the word currency is anything that is used
  in any circumstances, as a medium of exchange. In this use, "currency"
  is a synonym for the concept of money.

It is clear that Namecoin is not primarily intended as a medium of exchange, but with a more specific design in mind. The fact that it can be exchanged does not mean that it is used as a medium to exchange value.

For a more detailed explanation about what Namecoin really is, check out the Bitcoin wiki.


Do transactions in Ripple have a TXID of sorts, or not? Do transactions in Ripple have a transaction ID of sorts just like Bitcoin transactions, or are they identified in some other way?

Ripple transactions have a 256-bit transaction ID that is a hash of the inner transaction and the signature.


Is the minimum fee considered when a full P2P node validates a Tx? So if the core devs change the minimum fee schedule, lowering the maximum "free" tx from 10,000 to 1,000 bytes - how will that not cause a hard fork? Or at least prevent nodes running old software from propagating a new Tx?

https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp

I could be reading this wrong, but looks to me like the minimum fee schedule is part of the "standard tx" test, and so nodes with different fee schedules wouldn't be able to send all tx's between each other.

A bitcoin network fork occur when a block generated by one node is not accepted by a percentage of nodes, those nodes will split and continue working on its own.

This change will not cause a fork, it will cause that some transactions will be discarded by some nodes, older nodes will never include it on a block but newer nodes will and older nodes will accept a block with transactions different transaction fees as those are not checked for block validity.

This has already happened, pools can discard transactions without fees or ask for higher fees than usual for example and the block will be valid and included in the blockchain without problems.


calculate transaction fee in a block I want to know how one can query bitcoin core via json rpc or other methods to find all the transaction fees in a block? API queries are not useful as they have a rate limit.

Here is an example block, for which i want to calculate transaction fees

block number 395545

As the block id is known, the fee can be found from the coinbase itself without an overhead. Maintain a simple map for reward points saying blocks between 0-149 gives 50 BTC, next 149 25 etc.

Now, the first transaction in any block is always a coinbase tran.
Coinbasetran->vout[0] - reward = Fee (actual fee + unclaimed change)


Will the increasing difficulty in Bitcoin mining push miners to a different currency? I've been reading all of the "Is mining still profitable?" questions, and the consensus appears to be the following: Yes, difficulty is increasing, but profitability is uncertain due to the speculative nature of mining.

What incentive is there to keep miners on the Bitcoin blockchain? If their ROI is positive, but marginal return is decreasing, why not switch to mining a new currency?

I'm new to Bitcoin, I apologize if the question is unclear or illogical.

It appears that miners consider Bitcoin to provide the largest ROI.

There are dozens of other coins that use SHA-256D as their hashing algorithm, if it were more profitable to mine any of those, miners would switch.

However, when the hash rate increases in the other coin, the revenue per hash rate decreases. Meanwhile, the decrease of hash rate in Bitcoin increases the revenue per hash rate there. Thus, anyone leaving Bitcoin makes it more profitable to mine Bitcoin and vice versa. Thus, the system self-balances.

AFAIK, most altcoins' exchange rates have been in a downward trajectory which probably doesn't help to entice mining power.


Are Mastercoin addresses Bitcoin addresses? I am reading up on Mastercoin, and I must say, it is quite confusing. Am I correct in saying that your Bitcoin address is your Mastercoin Address? If so, I have one private key that contains two cryptocurrencies?

Yeah, that's right - Mastercoin uses the same address space as Bitcoin.

You can store BTC, MSC, TMSC (Test MSC), and soon many other crypto-currencies on the same address using The Master Protocol.


lost private key...never had it I am a complete newbie. I transferred money to my coin base paper wallet before printing my private key. Now, I see my btc in wallet but could not retrieve my key by going back on my browser...Are they gone?

If you have no record of the private key stored the funds are lost forever, or more correctly you just can never spend them again. As you never had the private key stored on a hard drive, there's not anything you can do to recover it.


bitcoin-cli error: couldn't connect to server on importaddress When I give the import command I get an error after about 15-20 minutes. It's obvious that any other command did't show the same error.

~:./bitcoin-cli importaddress mvcWTfVhCMhwvqQf2TKkEqpLrNdW7Uekod false
error: couldn't connect to server

I found that client is rescanning blocks in debug.log which should not happen because I have added "false" after address.

2018-06-21 08:39:30 Still rescanning. At block 192380. Progress=0.011339
2018-06-21 08:40:30 Still rescanning. At block 218992. Progress=0.024155
2018-06-21 08:41:30 Still rescanning. At block 237569. Progress=0.036879
2018-06-21 08:42:30 Still rescanning. At block 261271. Progress=0.049859
2018-06-21 08:43:30 Still rescanning. At block 279577. Progress=0.061887
2018-06-21 08:44:30 Still rescanning. At block 294150. Progress=0.072921
2018-06-21 08:45:30 Still rescanning. At block 308378. Progress=0.123854
2018-06-21 08:46:30 Still rescanning. At block 321405. Progress=0.177669
2018-06-21 08:47:30 Still rescanning. At block 332018. Progress=0.230362
2018-06-21 08:48:30 Still rescanning. At block 341285. Progress=0.281512
2018-06-21 08:49:30 Still rescanning. At block 349955. Progress=0.329082
2018-06-21 08:50:30 Still rescanning. At block 358093. Progress=0.376275
2018-06-21 08:51:30 Still rescanning. At block 364784. Progress=0.417902
2018-06-21 08:52:30 Still rescanning. At block 370366. Progress=0.450470

The error :couldn’t connect to server shouldn’t happen even though blocks scanned because of import commend. And when running a shell script I wrote for the loop of importing address alarmed another error.

2018-06-21 08:33:57 WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting
2018-06-21 08:34:18 WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting
2018-06-21 08:34:24 WARNING: request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting

I wonder what the default rpcworkqueue is. And I did't find -rpcworkqueue command when I am using -h in bitcoind.

Following is my bitcoin.conf.By the way ,I didn't put block chain data in default place,but I assigned the position of block chain data and bitoin.conf when start bitcoin core.Following is content of bitcoin.conf.

txindex=1
server=1
rpcuser=username
rpcpassword=password
rpcbind=0.0.0.0
rpcport=8545
rpcallowip=0.0.0.0/32

Finnaly ,if adding "false" is useless,import one address about to spent one hour,and I need to import 20,000 adress that may cost 2.2 years.That impossible for me to wait so long.

The arguments for importaddress are:

Arguments:
1. "script"           (string, required) The hex-encoded script (or address)
2. "label"            (string, optional, default="") An optional label
3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions
4. p2sh                 (boolean, optional, default=false) Add the P2SH version of the script as well

So, you need to use ./bitcoin-cli importaddress mvcWTfVhCMhwvqQf2TKkEqpLrNdW7Uekod "" false

Also, you may consider adding a final true argument after the false.

Note that importing without rescan means your utxo's will not be found (using bad terminology, your addresses will have no balance).

Also, note that since you have so many addresses to import you may wish to consider using importmulti the usage of which is described via ./bitcoin-cli help importmulti


EXCEPTION: 15dbwrapper_error I'm running Bitcoind 0.17 on a raspberry Pi 3. Everything ran smoothly until I did something wrong (I guess) but can't figure out what happened. Now I got this error. Has someone experience with this one:

2

018-11-23T13:11:47Z Fatal LevelDB error: IO error: /home/bitcoin/.bitcoin/indexes/txindex/105794.ldb: Bad message
2018-11-23T13:11:47Z You can use -debug=leveldb to get more complete diagnostic messages
2018-11-23T13:11:47Z

************************
EXCEPTION: 15dbwrapper_error
Fatal LevelDB error: IO error: /home/bitcoin/.bitcoin/indexes/txindex/105794.ldb: Bad message
bitcoin in txindex

2018-11-23T13:12:48Z

Thanks in advance for helping me out.

Your database is corrupted. This probably means the RPi overheated, or its storage is crappy.

This is not unusual for RPi class hardware.

To recover, you'll need to reindex.


How to disable initial block download I want to create an original network by forking bitcoind.
I changed chainparams.cpp and other programs for loading it.
Then, I set DNS for my seed node.

When I boot my seed node, my seed node tries to download blocks from others.
However, there is only a single seed node(itself). So, I expected that my seed node loads blocks which are pre-located in the local data directory. But, my seed node executes the initial block download process.

In this situation, other nodes cannot sync with my seed node because bitcoind ignores getheaders message while initial block download.

To operate a seed node, is there any command options for disabling initial block download?

As an additional question, is there any discussions and best practice for operating seed nodes?

For set up the dns seed node, the parameter can be directly specified in chainparam.cpp if you are using bitcoin source in line that reads as "

vSeeds.push_back(CDNSSeedData("someaddress.com or IP addy", "someaddress.com"));

And  you need to add all the seed node IP address to the A records where  you have your domain name from. You might need to do it on your own if you have a privater server or can use cpanel depending on the scenario at your end. I did it via cpanel as I have domains hosted with siteground.


What are the difference between a segwit and legacy wallet I am installing a mobile wallet and it ask me what type of address I want to use, I want to try and use a segwit address but is there a risk that my coins will be lost if I try to transfer fund from an exchange if they dont support it, or if I want to transfer coins from my segwit address to a legacy one.

There are, broadly, three types of addresses in use at the moment:

P2PKH - Pay to public key hash addresses start with a 1, and should be accepted by essentially any service in the Bitcoin ecosystem
P2SH - Pay to script hash addresses are commonly used for multisig, but as of the segwit activation, they are also used for wrapped segwit addresses. These start with a 3. In the wrapped segwit version, you get the advantage of lower fees, while still being able to send to the address from nearly all services.
Bech32 addresses - Starting with a bc1, these are also known as native segwit addresses, and offer the greatest savings in fees. However, a sizable number of services do not support withdrawals to these addresses.

Generally, P2SH segwit addresses offer the best of both worlds at the moment.

When sending coins to a service, your choice of address does not matter. It only plays a role when receiving coins.


What is point of encrypting wallet, if Bitcoin API's sendtoaddress needs passphrase? The Bitcoin API enables programs on the server to use JSON RPC to interact with the Bitcoin wallet.  Most commands do not need the wallet locked (which I assume is the same thing as encrypted).

Though, it would be nice to encrypt the wallet.dat file on the server for extra protection.  However, it doesn't seem that I can get any extra protection if my program needs to use the passphrase to execute JSON RPC commands such encryptwallet and sendtoaddress.  My program and wallet will be on the server.  If a hacker accesses my server, he can get the passphrase from my program file and then use that to access the wallet on my server.

Therefore, is there any point in encrypting the wallet on the server, if I need to use commands such as sendtoaddres which needs the passphrase on the server?

The wallet passphrase is there to protect the wallet file on disk. It is not an authentication mechanism or a security measure against anyone who can see what is sent to it. It does however prevent private keys from hitting disk in readable form.


Same account on different wallets? I have breadwallet on my smartphone and Electrum as Desktop Wallet. Can I share the same account on both? How can I do?

And, is it a good thing to do? Or is it preferred to have some bitcoins on one wallet and some others on the other one?

Thank you!

Simple. Export your private key from electrum and import it in breadwallet.


NBitcoin vs Bitcoin Core RPC I initially thought NBitcoin was a wrapper for Bitcoin Core JSON RPC and that Bitcoin Core was the only way to communicate with the bitcoin network. But now that I've discovered it's not, I'm curious to know how both communicate with the bitcoin network under the hood?

Bitcoin has a network protocol that all nodes use to communicate with each other. So long as a software can speak that protocol, it can join the network. Since Bitcoin Core is open source, the protocol details are freely available for anyone to see and implement themselves elsewhere. The protocol details are also described on bitcoin.org.


Just registered in bitcoin core...Gave my address for receiving, how long it takes for 1st transaction? I am a newbie in bitcoins.Created a btc core, and from file>receiving addresses, i copied and send the address to the sender. Still waiting for the transaction ( 11 hours+), is this normal, and how do we speed up the process?

First of all, your Bitcoin Core client should be fully synchronized with the network, as @PieterWuille stated. This means your client should download and validate the entire blockchain. This may take a while to do because of the current size of the blockchain that is at roughly 124 Gb (Go have a look here). This is why this process might take a long while to complete, and your wallet will only reflect your transaction after it has synchronized.

However there are other possibilities that you can use if you aren't looking into heavy bitcoin mining and usage, or for starting purposes. You can have a look at bitcoin wallets (eg. Multibit, Bitcoin Wallet, and Breadwallet just naming a few) rather than looking at bitcoin core, just for starting out. There are also some nice online wallets and mobile wallets you can use, however, all wallets have some pros and cons to them, and maybe the best thing will be is to first read up about all the different wallets available, the main bitcoin site is a nice starting place together with the bitcoin wiki.

However, there is a small catch. Because your bitcoin has already been sent to your bitcoin core receiving address and is currently in the blockchain, you will have to wait for it to completely download to receive that bitcoin, or you can maybe read up on transferring your private keys but I am not very familiar with this and thus not sure if it will work.


Address generator for Bitcoin wallet As describe by Maxwell here in HD wallets assuming we have a key pair with private key SK.a and public key of PK.a and a seed s and a generator point G, we can generate a new key pair of (SK.b, PK.b) as follows:

PK.b = PK.a + sG
SK.b = SK.a + s

The advantage with this method is that a service provider can generate new public keys without knowing the clients private key.
My question is that, why don't we multiply the seed and private key rather than adding them?

PK.b = PK.a * s
SK.b = SK.a * s

Is there any problem with the later method that I suggested?

A previous draft of BIP0032 did this, actually. (Sorry about linking to the bitcoin wiki - that change was made before we switched over to git for BIP tracking.)

According to the changelog, it was done for speed reasons.

  [30 Apr 2013] Switched from multiplication by IL to addition of IL (faster, easier implementation)

It's much faster when deriving a child private key from a parent private key. The new method requires only a normal addition (mod n) rather than an ECDSA point multiplication.

It's not faster when deriving a child public key from a parent public key. That still requires an ECDSA multiplication followed by an ECDSA addition. (In fact, it's about 2% slower.)

Using addition does not add any security issues. It's possible to get a parent private key from a child private key and an extended public key, but that would also be true if multiplication was used.


Private Keys Relationship in HD Wallets I'm new to bitcoin (core) wallet. I recently begin to use it to store some BTC. I'm using the latest version 0.21.0.
I have some basic questions on the keys/addresses it generated. I use command getnewaddress 3 times, the last item has "hdkeypath": "m/0'/0'/2", and I dumped its private key, and put some BTC in this address.

What's the relationship between the first pkey/addr (the one with hdkeypath: m/0'/0'/0 and the third one m/0'/0'/2? Does the first key/addr is the master (key) who can recover all later keys generated in the wallet.

I only backup the private key of m/0'/0'/2, and removed the whole wallet (the .dat file). Is there a risk of this method? Since I only choose to use this key/addr to receive and store BTC.

I later create a new wallet and restore this m/0'/0'/2 key with command importprivkey. and send some BTC to other people, and found it generate a CHANGE addr, so I also backup this new addr's private key too. Since I mainly use this m/0'/0'/2 to store long term BTC, and will not use it to make a lot transactions. So I keep the privatekey of m/0'/0'/2, and keep backups priv keys of change addresses it generated, then drop all wallet files. Is this method enough to restore all my balances in a futher day.

Can the private key of m/0'/0'/2 be used to recover the change addresses' private keys? (What is the master seed of HD wallet, it is the private key of m/0'/0'/0?)

Thanks in advance

What's the relationship between the first pkey/addr (the one with hdkeypath: m/0'/0'/0 and the third one m/0'/0'/2?

They are derived from the same parent key. Other than that, there is no relation.

Does the first key/addr is the master (key) who can recover all later keys generated in the wallet.

No. They are both child keys of the key at m/0'/0'. The actual master private key (the key at m) is not exportable. There is a HD seed (which is used to generate the master private key at m), but this is only exportable through the dumpwallet RPC.

I only backup the private key of m/0'/0'/2, and removed the whole wallet (the .dat file). Is there a risk of this method? Since I only choose to use this key/addr to receive and store BTC.

Don't do that, you will lose money. When you send Bitcoin, Bitcoin Core will generate new change addresses and send any change there. Those change addresses have different private keys. Without them, you will lose money.
Additionally, by reusing the same address, you are significantly hurting your privacy. By using the same address over and over, anyone you transact with will know how much money you have in your wallet and be able to see all of your incoming and outgoing transactions. This allows anyone to track your spending habits.

I later create a new wallet and restore this m/0'/0'/2 key with command importprivkey. and send some BTC to other people, and found it generate a CHANGE addr, so I also backup this new addr's private key too. Since I mainly use this m/0'/0'/2 to store long term BTC, and will not use it to make a lot transactions. So I keep the privatekey of m/0'/0'/2, and keep backups priv keys of change addresses it generated, then drop all wallet files. Is this method enough to restore all my balances in a futher day.

Bitcoin Core constantly generates new change addresses. The one time you forget means that you will lose money. If you accidentally request a new address and use it, you will lose money.
In general, backing up individual private keys is not recommended. You should back up the entire wallet.dat file itself. There is no need to export each key individually and back it up in that way. That is a surefire way to lose money at some point in the future.

Can the private key of m/0'/0'/2 be used to recover the change addresses' private keys? (What is the master seed of HD wallet, it is the private key of m/0'/0'/0?)

No. The change addresses are unrelated. You would need to have the HD seed mentioned previously in order to derive them.


Why can't mining pools provide fake transactions within the generated blocks? Suppose Alice wants to add a fake transaction where she receives X ammount of BTC. I understand that in order to add that transaction to the blockchain she would have to compete against all the other miners to generate the next block, which makes it improbable to happen as an individual against them.

Now, if we take a look at the next figure (taken from blockchain.info) which shows the mining pools with highest hash rate at the network:

we see that, for instance, the mining pool BTC.com has 26.4% hash rate of the network, and thus comes my question: Why can't all the miners at this pool make an agreement by adding fake transactions to all the blocks they generate? Differently than the previous case, where Alice was an individual with almost no chance to generate a an altered block, the pool could make it very likely.

Suppose Alice wants to add a fake transaction where she receives X ammount of BTC. I understand that in order to add that transaction to the blockchain she would have to compete against all the other miners to generate the next block, which makes it improbable to happen as an individual against them.

No, that isn't correct.  No matter how much mining power she has, or how many miners she cooperates with, she can't add a fake transaction to the blockchain.

It's a common misconception that miners are solely responsible for determining whether or not a transaction is valid, and if they say it is, then everyone else accepts it.  In fact, anyone who runs a Bitcoin full node (e.g. Bitcoin Core) is automatically checking whether each transaction is valid (spends money from a previous valid and unspent transaction, properly signed, etc).  If a miner attempts to include an invalid transaction in a block, this will be detected and their entire block will be ignored by everybody, effectively meaning that they don't get their mining reward.

With enough mining power, or the cooperation of a pool, Alice could create a block with her fake transaction.  But nobody in the world will consider it as valid or accept it as part of the blockchain.  If she tries to spend the proceeds of that transaction, say by sending those coins to Bob in exchange for some goods, Bob's software will simply ignore it.  He'll think that Alice just hasn't paid at all, and won't send her any goods.  So the whole exercise would be a giant waste of Alice's time and resources, without gaining her anything or harming anyone else.

The only special authority that miners have is this: if there are two or more otherwise valid transactions which are in conflict with one another, then miners get to decide which one (or none) goes into the blockchain, thus confirming it.  But they can't confirm a transaction that was never valid in the first place.

A large amount of mining power, or a pool, could help Alice perform a double spend attack, where a valid and confirmed transaction is later replaced in the blockchain with a different valid transaction.  The first one might have gone to Bob, who would have sent some goods, and the second one could effectively take the money back from Bob and return it from Alice, who now has the money and the goods.  But the second transaction is one that Alice could have created all along (of course she can send her own money to herself); it isn't "fake".


Is there anything like a "blank" blockchain? I'm looking to create a coin with my own method of securing the network. Is there anything close to something I could create my own algorithm and replace that portion of the code with my own? Thanks!

Yep. Do all of the normal steps for creating an altcoin. https://bitcointalk.org/index.php?topic=225690.0

Then, replace the CheckProofOfWork function with something else.


Bitcoin Miner Pseudo code I want to understand how the mining process works so that I can code up my own bitcoin miner. Does anybody have pseudo code of a bitcoin miner that will help me achieve this?

Also, help with an implementation in C++ will be helpful.

Please see the following:

What open source miner applications are there?

https://en.bitcoin.it/wiki/Software#Mining_apps

https://github.com/ckolivas/cgminer


Unable to start bitcoind ORIGINAL QUESTION:

Anyone know why I am getting the following error message?

Other possible relevant info:

Config file location

/home/.bitcoin/bitcoin.conf

Config file content:

server=1
testnet=0
txindex=1
rpcuser=[username redacted]
rpcpassword=[password redacted]

bitcoind location:

/home/bitcoin-0.19.1/bin/bitcoind

OS:

Ubuntu 18.04 (fully uptodate)

bitcoin-core download location:

sudo wget https://bitcoincore.org/bin/bitcoin-core-0.19.1/bitcoin-0.19.1-x86_64-linux-gnu.tar.gz

login username:

bitcoin

folder/file permissions (recursive) for bitcoind and bitcoin.conf:

777

After a few seconds, bitcoind automatically stops without warning and allows me to start it again, only to automatically stop again.  How do I figure out why it is not starting, or why it stops after a second or 2?  When it stops, it does not show any error messages in the terminal.  I only know something is wrong if I run a bitcoin-cli command, as seen in the screenshot above.

UPDATE ONE:

./bitcoind output below:

It's possible your blockchain is corrupted or you have multiple bitcoind processes running. Kill the bitcoind process, go to /home/bitcoin/.bitcoin and delete the blocks, chainstate and database directories using

rm -r blocks
rm -r chainstate
rm -r database

then start the daemon again without the '-daemon' flag to see if it progresses further.


Can you crack SHA-256? From my understanding, a hash function is an algorithm that takes a unique input and produces a unique output, and a secure hash like SHA-256 cannot be reverse engineered. I saw this thread Won't ASIC miners eventually break SHA-256 encryption? saying that it would take a ridiculously long time to crack a SHA-256 hash, but can't you just brute force it if the input is short?

For example, if an insecure password such as test123 was turned into a SHA-256 hash, and an average gpu can do around 1000 MH/s, then just by brute forcing alphanumeric characters up to 7 digits (26 + 10) ^ 7, then wouldn't it take only about (26 + 10) ^ 7/(1000*1000)/60/24 = 54 days to crack it (less with a good gpu)?

Basically what I'm trying to say is isn't the strength of a SHA-256 hash directly correlated to the length of it's input? If a really short string such as "idk" was turned into a SHA-256 hash, wouldn't it be cracked in a matter of milliseconds? (and thus proving that you can crack a SHA-256 hash)

There is a large difference between being able to produce the preimage for a single SHA256 hash for which you may know certain factors like length, character set, etc., and being able to break SHA256 as a whole.

Short inputs are naturally more vulnerable to brute forcing, which is why SHA256 is not a recommended hash for password storage - instead, hash functions that are deliberately designed to be slow and adjustable, such as bcrypt, are used where the input size may be small enough for practical brute forcing of hashes like SHA256.

In all applications of SHA256 in the Bitcoin Protocol, all the inputs are large enough to make a brute force attack impractical.


Sample programs written using python-bitcoinlib? Where can I get source codes of programs written using the python-bitcoinlib?

take a look at the example folder in bitcoinlib repo
https://github.com/petertodd/python-bitcoinlib/tree/master/examples


How to mine first block of POS coin I have tried in all the way to do this by using google and other things .but not find something that give me complete idea for doing this . i have created genesis block successfully and coin is working fine now but still i am not able to mine the coin. i have tried by using solo mining using cpuminer and but it giving me errors like downloading blockchain in progress etc,etc,etc. I thing i am trying in wrong way. So please give me some idea its my humble request to all of you.
Any link or reference is appreciable.
Thanks in advance ...

POS coins are not mined in the traditional sense. See, mining is a way to make people expand some energy so no one person can defeat the network by generating fake blocks and appending them to change transaction history. Miners are usually rewarded coins.

See even in POW, the coins aren't mined, they are just generated and awarded to the person who solved the computation. The get the reward because they had to expend some energy to maintain the network
So you see, even in POW, the coins aren't really mined are they?

For POS, you can do an ICO and stake some coins to active wallets. Those people can then begin to use the system. You literally generate coins and issue them out and force people into this staking system in order to make any transaction on the network. Of course, we still haven't solved the distribution issue facing human kinds economic system.

Satoshi did give us a start however.


How to choose the transactions for a block? From my understanding, the memory pool (or transaction pool) contains "open" or "unconfirmed" transactions that have to be validated and can be chosen (arbitrarily?) to be part of a "candidate block". For this block, the hash puzzle in a proof of work blockchain has to be solved before it can be added as a valid block to the blockchain.

How do miners choose the transaction(s)?

Does the difficulty vary depending on the number of chosen transactions? If not, wouldn't it be advisable to include as many transactions as possible when trying to find a new "candidate" block (maybe depending on the reward - just currency units or also (or only) transaction fees for the transactions included in the block)?

If the difficulty varies based on the number of selected transactions, however, wouldn't it be best to just choose one transaction and then "quickly" (i.e. as the first) come up with a valid candidate block to be added to the blockchain?

If it makes sense to choose "all open/unconfirmed" transactions and then try to solve the hash puzzle (by, as I've read starting with a Nonce value of 0 and then sequentially increasing it), wouldn't it simply boil down to the result that the miner with the largest processing power would always win?

How do miners choose the transaction(s)?

However they want. Usually by picking the ones with the highest fees, but also sometimes picking ones that have been unconfirmed for the longest, sometimes prioritizing their own transactions, etc.

Does the difficulty vary depending on the number of chosen transactions?

No.

If not, wouldn't it be advisable to include as many transactions as possible when trying to find a new "candidate" block (maybe depending on the reward - just currency units or also (or only) transaction fees for the transactions included in the block)?

Yes, this is the general idea.

If the difficulty varies based on the number of selected transactions, however, wouldn't it be best to just choose one transaction and then "quickly" (i.e. as the first) come up with a valid candidate block to be added to the blockchain?

The difficulty doesn't vary based on the number of selected transactions.

If it makes sense to choose "all open/unconfirmed" transactions and then try to solve the hash puzzle (by, as I've read starting with a Nonce value of 0 and then sequentially increasing it),

You can't include "all unconfirmed transactions" -- there's a size limit to the block. It's in the miner's best interest to include as many will fit in the block though, since the transactions come with transaction fees that are paid to the miner.

wouldn't it simply boil down to the result that the miner with the largest processing power would always win?

I don't understand what you mean by win, but miners who have the most processing power will mine the most blocks.


Where are my bitcoins after wallet removal I'm a newbee with bitcoins, but there is something I don't understand.

I've downloaded MultiBit, but with this I was not able to see anything on my iPhone. So I also openend a wallet on Blockchain. I transferred the money from MultiBit to Blockchain and this al went well.

Secondly I removed my wallet in MultiBit and now my Blockchain wallet is also empty... How is that possible?

This is my last transfer... https://blockchain.info/nl/tx/b9a85a99f168f9e8fcd5b1385868cdbfc8bcb4f4205e65499bd13a27fc024d95

These two events

removing your wallet from Multibit
observing zero balance in your Blockchain.info wallet

are extremely unlikely to be related. You can see that the transaction went through and has several dozen confirmations.

If your Blockchain.info wallet is appearing empty, you may want to contact Blockchain.info for resolution.


The best JavaScript libraries supporting Bitcoin Core? I have downloaded and installed Bitcoin full node on my Linux server and I'd like to start working with the bitcoin core to create wallet, addresses, and transactions. What is the best JS libraries available to facilitate using all the necessary methods in this regard?

I highly recommend bcoin:
https://bcoin.io/
https://github.com/bcoin-org/bcoin
It is a nodejs library that can also run a fully validating node, SPV node, and BIP44 wallet. It's used in production by many long-standing bitcoin companies such as Purse.io
You can even use the bcoin client to make RPC calls to bitcoin core, and of course you do not need to run the bcoin full node to take advantage of the library for TX construction and wallet functions.


bip39 checksum python Is there any Python package which will allow me to verify if the checksum of a bip39 mnemonic is valid?  For instance, I have a 24-word bip39 mnemonic, and I might have made a mistake for one of the words.  I want to see which words will result in a valid checksum.

I've seen javscript versions, but nothing in Python

Clone/download this code from Trezor (don't forget the word list).

Then check your word-list like this:

from mnemonic import Mnemonic

code = "word1 word2 [...] word23 word24"
mnemo = Mnemonic("english")
isValid = mnemo.check(code) # returns a boolean
print('Checksum is valid: ' + str(isValid))


Electrum "Pending" what does it mean My balance in Electrum shows "pending." What does pending mean?

Virtual Currency wallets show as 'pending' until enough transactions have happened AFTER that one in the block chain.  It is a feature to prevent false sends and doubble spends of wallet to wallet transactions.  Not all wallets let you know how many more blocks need to come after to ensure the transaction is a valid one.  Time and patience will eventualy show that it is complete.  If it is still ' pending ' after 48 hours, contact the other party to see if there is an issue at their end.


Maximum number of outbound full relay connections What is the maximum number of outbound full relay connections a bitcoin core full node can make?
I was assuming it's 8 but then realized we can add another 8 connections using addnode while reviewing this PR: https://github.com/bitcoin/bitcoin/pull/21710
So is it 16 or there is something else that I am missing which can be used to add more outbound full relay connections?
Also do we have any option to decrease the number of MAX_OUTBOUND_FULL_RELAY_CONNECTIONS below 8?

What is the maximum number of outbound full relay connections a bitcoin core full node can make?

Maximum number of outbound full relay connections is 16(8 automatic and 8 manual)
MAX_OUTBOUND_FULL_RELAY_CONNECTIONS 8 (automatic)
MAX_ADDNODE_CONNECTIONS 8 (manual)
If you add 8 trusted nodes with -connect option, those will be the only nodes used for outbound full relay connections and nothing else.

Also do we have any option to decrease the number of MAX_OUTBOUND_FULL_RELAY_CONNECTIONS below 8?

No. And the developers who reviewed PR: https://github.com/bitcoin/bitcoin/pull/21815  think we don't need such option in Bitcoin Core.


How long does it take for a transaction with 0 fees to be confirmed or rejected? I have a problem with a transaction that has 0 btc fees:
https://blockchain.info/tx/256301465d77affb6bc7087432a9130db48dd64efa28b0460fb674eda704f382

From what I understand, eventually this transaction will either be confirmed or rejected. My question is: how long will this take, and is there anything I can do to speed up this process?

(There is an interesting answer to this question here What happens if my transaction is not accepted because I did not pay fees? but it's two years old and assumes that one is running the official bitcoin client, which I'm not)

The time it takes for a fee-less transaction to be confirmed can vary vastly. While sometimes you're lucky enough to have it confirmed within the next block (as if you had paid the standard fee), other times it may take days.

This depends on the current transaction volume and miners' level of altruism. Most notably though, it depends on the number of Bitcoin Days Destroyed. Older coins (coming from older transactions) are conventionally assigned higher priority, and thus will generally be included in a block sooner.

As your transaction is pending (unconfirmed), the coins it is spending are getting older and older every day, so the chance of finally getting confirmed is slightly increasing overtime. This should prevent your coins from becoming completely unaccessible, stuck in the void.

No transaction can be rejected though, there's just no such thing in the protocol.

Finally, if this happens to you and you're not willing to spend some arbitrary time in uncertainty waiting for the confirmation, you can perhaps try to create a double spend transaction with higher fees, hoping it would be picked up by a non-standard (though pragmatic) miner.


How can a miner verify that a UTXOs is not spent elsewhere? How does a miner verify that a UTXO is not spent somewhere else, wouldn't he have to search the entire blockchain from that UTXO and onwards to see if this was the case? Assuming any real scale this would effectively take ages, or am I misunderstanding something?

A miner does so by checking if the UTXOs that new transactions are trying to spend are in the UTXO set.

The UTXO set is the collection of UTXOs that are non-spent, and therefore, can be redeemed by new transactions.

To do so, a miner (as well as any other node) checks the LevelDB database found in .bitcoin/chainstate by default in unix systems.

UTXOs are identified by its txid (Little Endian representation) leaded by a c.

In the answer for this question you can find an extensive explanation of the format in which the UTXOs are stored, with some examples.


Is possible especify the keys rather how many in multisignature wallets? I search about multisignature wallets, but it seems very limited. Far I understand, we can create a wallet with N keys, and specify how many keys is needed to create a transactions.

So, I can create one wallet with 5 keys (K1, K2, K3, K4, K5) and I can specify how many keys (but not which keys!) are needed, so is possible to say: “you need 3 of 5 keys”. However, it makes a K1 + K2 + K3 and K5 + K4 + K2 a valid signature.

It’s possible to specify that which keys are needed rather than how many?

Imagine that have three people (K2, K3, K4) and have a server (K1). Only with K1 + (K2 or K3 or K4) will be valid. It means that K2 + K3 or K4 + K3 can’t be able to create a valid transaction. To be a valid signature we need two signatures, but one of that two need to be the K1.

It’s possible?

One alternative is creating a multiples multi-signatures wallets. I mean, create three addresses one with (K1 + K2), another with (K1 + K3) and so on. But, it will have multiples address, it is what I'm trying to avoid. Another solution is need all keys (4 of 4), but it will need the signature of the three clients, but it’s not easy and will need to wait everyone sign it.

For the background of the history, I trying to use the OP_RETURN. Everyone can access one single address and view all the information, about the three clients. The OP_RETURN value will be generated by the server (K1) and need to be signed with one of the client (K2, K3, K4). But, the client itself can't be able to create a transaction alone, so K2 + K3 need to be an invalid signature.

You are right, multisig as implemented in Bitcoin right now requires M participants out of N to sign. However, the use case you want is doable with more complex scripting.

For example, K1 + (K2 or K3 or K4) could be done with something like:

<pk1> CHECKSIGVERIFY 1 <pk2> <pk3> <pk4> 3 CHECKMULTISIG

That script can be redeemed with the signature of K1 and a signature of one of K2, K3 or K4.


What is the algorithm behind multisignature address and redeem script? I know you can create a multisignature address with the command:

bitcoind createmultisig 2 ["pubkey1", "pubkey2", "pubkey3"]

As described here: https://gist.github.com/gavinandresen/3966071

This command returns the address (starting with character '3') and the redeem script.

My question: how to create multi-signature address and redeem script without using bitcoind? What algorithm is used?

Could you point me to some sources?

I stole most of the answer from Andreas' book :-)

The bitcoin developer docs provide this link here, which goes over P2SH to multisig. The idea is to create a so called redeem script, which is a ripemd160(sha256(sigscript)).

Example from the book:

Redeem Script:    2 PubKey1 PubKey2 PubKey3 PubKey4 PubKey5 5 CHECKMULTISIG
Locking Script:   HASH160 <20-byte hash of redeem script> EQUAL
Unlocking Script: Sig1 Sig2 <redeem script>

see Andreas' book "Masterig Bitcoin, 2nd edition", page 152ff or in the GitHub version here.
The real book at http://chimera.labs.oreilly.com/books/1234000001802/index.html

  how to create multi-signature address and redeem script without using
  bitcoind? What algorithm is used?

you can use any hashing tools or libraries, Andreas shows with the "bx" library, openssl would do as well.


Reject TXs based on fee in comparison to TX size? Is it possible to configure a node to reject junk transactions like this
https://tradeblock.com/bitcoin/tx/6d67480fde2dd484b0ee389a6488db212ea7d0dbd2a11358efcc0b39077407ca

199 inputs, 35kb tx with a tiny 0.0003 fee.

There's minrelaytxfee, but I'm looking for something that is based on both fee and tx size.

minrelayfee is already in BTC/kB, so that's exactly what you need.

  35kb tx with a tiny 0.0003 fee.

Didn't do the math, but I think even the default minrelayfee should block those.


Probablity Distribution of mining What is the probability distribution of solving a block, given the same difficulty.

So if I try to mine multiple times using the same difficulty, is it normal distribution with mean of 10 minutes? What is the variance? Or is it some other distribution? Or maybe even deterministic chaos?

The time between consecutive blocks follows the exponential distribution, with mean (roughly) 10 minutes. This means that the variance is 100 minutes^2.


What is the most effective way to buy bitcoin from swiss francs? The most effective way I could find so far was Mt.Gox. The costs that are involved are still quite prohibitive. But this then boils down to the question: what is the most effective way to get your money out of [Insert your Exchage here]-exchange.

Is there any better way to convert your currency? (Swiss Francs in my case)

Switzerland takes part in the SEPA (Single Euro Payment Area); the Bitcoin exchanges that do SEPA transfers will probably be the ones with lowest costs for you.

I expect your bank will charge you for converting between CHF and EUR. If you want to convert often you may want to open a euro denominated account instead.


Does every transaction have the same signature? I want to know whether the bitcoin network generates the same signature for each transaction, because people have only one signature?

Bitcoin uses the Elliptic Curve Digital Signature Algorithm (ECDSA). While people in the physical world use their unique signature to authenticate when accepting documents or contracts, digital signatures are cryptographic commitments by the owner of a private key corresponding to one specific message (which in this case is the Bitcoin transaction).
As the inputs to the signature generation algorithm are the message and the private key, different messages produce different signatures.


Who enforces new consensus rules in Bitcoin? I have been reading at few places that miners will enforce new consensus rules. Examples:
https://twitter.com/BitMEXResearch/status/1391014115968274433
https://twitter.com/ajtowns/status/1390496379487744001

04:20 < AaronvanW> aj: I think "my" type of futures market could be combined with "your" type of futures market? My futures market would inform miners if the market wants them to activate or not, your futures market would inform them (post-activation) if they should enforce or not. I think the second futures market (enforce or not) would be kinda pointless in this context, since the market already told miners to activate (among other reasons), but hey if people want to bet on that they can. (And I think this should address Matt's point/concern.)

04:32 < AaronvanW> the second futures market would have an asymmetric advantage in favor of enforcing, but I'd say that's a good thing. (again, I think this futures market would be kinda pointless... just addressing concerns here.)

http://gnusha.org/taproot-activation/2021-05-04.log
According to my understanding:

Devs code implementation for a BIP, followed by reviews and discussions

MASF: Miners are asked to signal readiness, new consensus rules are activated if most miners are ready in time. Blocks that do not follow new consensus rules after activation are rejected by full nodes.

UASF: Miners are informed about a deadline, new consensus rules are activated irrespective of miners readiness if enough miners fail to signal before deadline. Blocks that don't follow new consensus rules after activation are rejected by full nodes. (In BIP 148 blocks are rejected that do not signal and BIP 8 has a MUST_SIGNAL phase and lockinontimeout)

In both cases, rules are 'enforced' by full nodes.
Are miners "following" the new consensus rules after activation that they agreed to activate and signaled readiness or miners are "enforcing" new consensus rules? If they are enforcing new consensus rules, what is the role of full nodes? And if miners enforce new consensus rules can we consider miners signaling as voting?

Consensus rules are enforced by economic full nodes i.e. full nodes that are actually using their full nodes to verify and monitor their own transactions. Full stop. In that sense, a theoretical miner not running an economic full node is not enforcing consensus rules, they are attempting to mine blocks with rules enforced by the network of economic full nodes. If that theoretical miner mines a block that doesn't meet those consensus rules the economic full nodes will reject that block.
However, if you are attempting to coordinate the smooth activation of a soft fork one of the ways to minimize the prospect of large re-orgs, confusion and disruption is to get miners to signal readiness. (Signaling readiness is not "voting" for the changes in the soft fork.) Ideally you want all miners to be enforcing soft rules post activation because if a few miners aren't enforcing them a transaction that doesn't meet those soft fork rules could creep into a block and cause a larger than normal re-org. Miners who are enforcing the soft fork rules would reject the block and eventually successfully mine on top of an alternative block but it would need time to work itself out. Of course those miners who have blocks that are eventually rejected lose out on block rewards, transaction fees and transactions that are included in that rejected block will need to be mined in an alternative block.
The focus is only on miner signaling for say the Taproot activation because we want to ensure a smooth activation of a soft fork. We want to know that miners are ready to enforce the additional consensus rules of the soft fork knowing that many economic full nodes may not be enforcing them immediately post activation. However, if there is a "block size war" going on and there are disputes on whether a soft fork should be activated or not (like there arguably were with SegWit in 2017) what ultimately matters is what consensus rules the economic full nodes are enforcing and not what miners signal. In this emergency like scenario you would likely see a lot more economic full nodes enforcing the soft fork rules immediately post activation.
In summary, during peacetime miner coordination and miner signaling does the job just fine and we don't have a problem if a number of economic full nodes aren't enforcing the new soft fork rules immediately post activation. Full nodes aren't creating new blocks and hence can't create a block with a transaction in it that doesn't meet the new consensus rules. (Ideally all economic full nodes would be enforcing them but it is not a problem if they aren't assuming a supermajority of miners are). During wartime however the burden falls onto economic full nodes to determine what consensus rules the network is enforcing. Miner signaling, to the extent that it isn't influencing what consensus rules economic full nodes are enforcing, is irrelevant.


Transaction with highest fee, but stuck, what did I do wrong? I recently sent btc that appears to be stuck (https://live.blockcypher.com/btc/tx/c131d65d933e343f852021830b833123de952c1857f264503388cf642655c457/)

The interesting thing is that I used a higher fee (4.5 sat/byte) which was the highest fee that Electrum's slider would support. I also notice that there are only two transactions in this block. Did I screw up? Is there any way that I can fix this?

Edit: Electrum says that I am only 0.12 MB from tip, however it has hovered around there without moving and sometimes increasing in size.

The hourly average fee when this question was posted was between 9 and 10 Satoshi per Byte (sat/B).

The latest TX's that I just randomly checked all had 10.03 sat/B fee which is higher than the 4.5 sat/B that you sent.

Transactions are at a hourly peak right now. Wait it out and it'll probably go through in the next couple of hours as the mempool empties.

I just noticed your TX went through and has 3 confirmations from the time I started replying to now. So I guess this is a closed issue.


How do wallets know that address is not duplicated if I'm going to make one? Let's assume that I'm going to make a wallet through Electrum that has some Bitcoin address.

So then, How Electrum do know that is not duplicated(Already owned by another person)?

Are we just relying on big numbers(2^160)? or Does Bitcoin system has some function to prevent duplicate?

Thank you for listening my question. No offense! Just curious about the function or how it works!

Are we just relying on big numbers(2^160)?

Yes

  or Does Bitcoin system has some function to prevent duplicate?

No


Cannot get Bitcoin-QT to run in testnet mode I downloaded Bitcoin-QT for Windows 7 into:

MYUSERNAME/Downloads/bitcoin-0.8.6-win32/bitcoin-0.8.6-win32

I want to run Bitcoin in testnet mode, so I created bitcoin.conf with only the following content:

testnet=1

I put copies of bitcoin.conf into the following folders:

MYUSERNAME/Downloads/bitcoin-0.8.6-win32/bitcoin-0.8.6-win32
User/MYUSERNAME/AppData/Roaming/Bitcoin

When I double clicked on the Bitcoin-QT icon to execute the following, Bitcoin-QT starts up but it does not appear to be in testnet mode.

MYUSERNAME/Downloads/bitcoin-0.8.6-win32/bitcoin-0.8.6-win32/bitcoin-qt.exe

Can anyone tell me why it does not seem to go into testnet mode?

I went to Start > cmd to get the DOS prompt.  I entered the following and it worked:

C:\User\MYUSERNAME\Downloads\bitcoin-0.8.-win32\bitcoin-0.8.6-win32>bitcoin-qt.exe -testnet

But going into DOS prompt to start up bitcoin-qt is a hassle.  It would be easier if I can just double click on the Bitcoin-QT icon.

Create a shortcut on your desktop (or somewhere) to:
"C:\User\MYUSERNAME\Downloads\bitcoin-0.8.-win32\bitcoin-0.8.6-win32\bitcoin-qt.exe" -testnet
and name it "Bitcoin-QT testnet"


BIP32 wallet sync with Bloom filters I'm working on my SPV library and I still have a hard time figuring how to approach the BIP32 + Bloom filters combination. Here's how I currently sync an existing HD wallet (after fast catch-up):

Generate a number of watched look-ahead addresses (say 10).
Load a Bloom filter with all used addresses plus look-ahead (N used + 10 look-ahead).
Download filtered blocks with getdata.
Mark watched addresses as used if they're found in any block transaction.
Ensure that the last watched address wasn't used in a transaction.
If so, generate new look-ahead addresses, reload the Bloom filter and download last block again to rematch it. By using a new receive address for each transaction we may have missed other transactions in the same block.
Otherwise, go back to 4 and download new blocks.

Now this sounds quirky and overcomplicated to me. Several discussions on the web talk about "scanning keys" when coming to wallet sync and I don't really understand if they assume a full node or a lightweight SPV node, because I have no idea of how to "scan keys" without a global UTXO database. Also the gap limit only seems to make sense for a full node.

I'm stuck, thanks.

The reason you pre-generate some forward keys is to avoid the situation you describe, if you only looked ahead one you risk missing a transaction in the current block (the order of the transactions in the block are unrelated to the order of your keys).

The term "gap limit" refers to a parameter of non bloomfilter SPV clients which do look ups by querying an address based index on a remote peer. The gap limit is the end stop of the current wallet state, when the scanning wallet sees 10 empty address results in a row they decide that's probably the last used address in the wallet and give up generating further. If there wasn't a gap limit in place they would search unused addresses until the end of time (or 2**128, which ever came first).


Create Multiple Output transactions with Bitcoin Core I am new to multiple output transactions with bitcoind and I want to learn how to implement them.

Let's say I want to create 2-3 addresses and send 1 btc to the generated addresses. If I want to send 0.4 btc to address1, 0.4 btc to address2 and 0.2 btc to address3, should I create a raw transaction specifying each bitcoin address that will be spent?
If so, I have another doubt; if I want to create a raw transaction, I need a unspent transaction and I know that I can list unspent transaction outputs using listunspent, but what happen if I don't have any unspent transaction on the bitcoin server? How can I get a list of unspent transactions from blockchain?

If I understand your question correctly, you want to "spread" bitcoins in a single transaction over several addresses.
I think the question to multi-sig is misleading here, more sophisticated guys to prove me wrong :-).
The standard transaction in bitcoin would have one ore more inputs (from previous transactions), and one or two outputs (with adresses). The first output address is usually the target, where you want to send the satoshis, and the second output is "a return address". A return address in the sense, that you don't loose your funds as transaction fees. Usually this second address is one of your wallets many addresses, that were initially created for you.
Multisig has the goal to lock satoshis to a single adress, and requires 2 or more signatures, to be able to unlock (and thus transfer) the values (there are "n of m" combinations possible, here are further details: https://bitcoin.org/en/developer-guide#escrow-and-arbitration, and limits are discussed here: What are the limits of m and n in m-of-n multisig addresses?). Again, the output part of such a multisig transaction would work in a similiar fashion like the standard transaction. You can define one or two addresses in the same way as with standard transactions.
The last two questions are slightly missing the concept of transactions and blockchain:
1.) ... but what happen if I don't have any unspent transaction on the bitcoin server?
Basically you are not the owner of an "unspent transaction".
You would have a wallet, and in the wallet you would see satoshis. This is the abstraction  model. In reality satoshis are assigned from address to address with the help of a transaction. This means, you need to have an address, to which satoshis are linked, to be able to spend something. Usually this happens, because you bought bitcoins. Therefor you need to have a wallet, and this wallet creates some addresses for you. One of these addresses would be given to the seller, and he would create a transaction with your bitcon address as target address. This "fills" your wallet with an inital amount of satoshis.
How can I get a list of unspent transactions from blockchain?
Purpose is slightly unclear -  maybe it is linked to the previous question.
We usually say "Unspent Transaction Output" (UTXO). This is a value, that can be seen in any transaction, that transferred satoshis. In the example I gave before, the value that you see in your wallet. You can use this to create a new transaction. Details again in the developpers reference link.


How can I get Electrum running under Debian with a restrictive firewall? So I'm running Debian 9.1 with KDE and am using iptables to disallow all outgoing and incoming traffic by default except that which I explicitly permit.

I keep on being disconnected with a red dot in the bottom right. I already tried selecting servers manually and opening port 5002. When running netstat -pln other strange ports show up. If possible I'd like to only use port 80 and 443. Which ports do I need to open in which way to get it working? Or is there anything else I need to configure to get it working?

The solution was to use Tor: under network options set the proxy to SOCKS5 localhost 9050.


What are the standard formats of transaction outputs? A transaction output can have the type

Pay to public key hash, P2PKH, where the ScriptPubKey field has the format:

76 a9 14 <20-byte hash of pubkey> 88 ac
Pay to script hash, P2SH, used for e.g. multisig:

a9 14 <20-byte hash of script> 87

There is also something called P2WPKH and P2WSH. Can you show me how these outputs are formatted, and are there any more possible output formats than these four?

AFAIK there are 5 different standard non-SegWit transaction types, and 4 SegWit ones.

Non-SegWit:

Pay to public key (P2PK)

PUSH (1 byte) + <compressed/uncompressed_pk> (33/65 bytes) + OP_CHECKSIG (1 byte)

Pay to public key hash (P2PKH)

OP_DUP (1 byte) + OP_HASH160 (1 byte) + PUSH (1 byte) + <hash_160(PK)> (20 bytes) + OP_EQUALVERIFY (1 byte) + OP_CHECKSIG (1 byte)

Multisig (P2MS)

<number_of_PKs> (1 byte) PUSH (1 byte) <PK_0> (33/65 bytes) PUSH (1 byte) <PK_1> (33/65 bytes)  ... PUSH (1 byte) <PK_n-1> (33/65 bytes) OP_CHECKMULTISIG (1 byte)

P2MS allow up to 15-15 scripts, however only up to 3-3 are standard.

Pay to script hash (P2SH)

OP_HASH160 (1 byte) + PUSH (1 byte) + <hash160(redeem_script)> (20 bytes) + OP_EQUAL (1 byte)

OP_Return

OP_RETURN (1 byte) PUSH (1 byte) <0 to 83 bytes of data>

SegWit:

Regarding segwit types, there are two non-native and two native ones.

Native Pay to witness public key hash (P2WPKH)

OP_0 (1 byte) PUSH (1 byte) <hash 160(PK*)> (20 bytes)

Native Pay to witness script hash (P2WSH)

OP_0 (1 byte) PUSH (1 byte) <script_hash> (32 bytes)

Pay to witness public key hash encapsulated in a pay to script hash (P2SH-P2WPKH)

The redeem script follows the same structure than native P2WPKH:

redeem_script = OP_0 (1 byte) PUSH (1 byte) <hash_160(PK*)> (20 bytes)

While the external structure of the script (scriptPubKey) is as any other P2SH:

OP_HASH160 (1 byte) + PUSH (1 byte) + <hash_160(redeeem_script)> (20 bytes) + OP_EQUAL (1 byte)

Pay to witness script hash encapsulated in a pay to script hash (P2SH-P2WSH)

The redeem script follows the same structure than native P2WSH:

redeem_script = OP_0 (1 byte) PUSH (1 byte) <script_hash> (32 bytes)

While the external structure of the script (scriptPubKey) is as any other P2SH:

OP_HASH160 (1 byte) + PUSH (1 byte) + <hash_160(redeeem_script)> (20 bytes) + OP_EQUAL (1 byte)

*In P2WPKH scripts the hash 160 should correspond to a compressed public key, otherwise the funds will be lost.


An online wallets that sends transaction change back to the original address Is there any wallet client that conforms to the following:

The wallet client is accessed through a website (for portability).
The wallet client does not store any private keys (I know there is some trust involve). I want to access coins by providing a private key only, not by creating an account on the website.
Most importantly, all the transaction change is to be payed to the original address. I do not want any additional addresses created during a transaction. I want to keep it as idiot-proof as possible and not rely on myself to keep track of any additional addresses.

Thanks

If you don't want the client to generate any private keys for you, it seems what you need is a javascript client that builds and propogates transactions.

http://brainwallet.org/#tx

This is a hosted javascript client (everything happens on the client side so there is no security concerns) allows you to provide a private key and build a transaction that way.


VPS with 80 GB Space, can't download the whole blockchain? I am using an application and WordPress that allows people to pay with Bitcoin in a small multi vendor marketplace for trading hobby items.

The plugin that I'm using is recommending that I run a full Bitcoin node? I don't think I need to, but how does someone do that with a small SSD?

Can you prune and simultaneously download? Is there a blockchain light I don't know about.

I don't want to be running a $60 vps just because of the chain

Thanks!!

Yes, pruning will reduce disk space needs to a few GB.  The whole block chain will still be downloaded (which may cost you something in bandwidth charges), but old blocks will be discarded as you go.

See How can I run bitcoind in pruning mode?


My altcoin bitcoinj fork is failing when trying to compile an Android wallet I've been sent a bitcoinj fork which is meant to work for the android wallet I'm building. Unfortunately it seems to be causing a failure when tests are run during the wallet compile.

I get the following error message when I try to compile the wallet:

Running com.machadocrypto.kobocoin_android_wallet.util.BluetoothTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.052 sec - in com.machadocrypto.kobocoin_android_wallet.util.BluetoothTest
Running com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec <<< FAILURE! - in com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest

formatMKOBOValue(com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest)  Time elapsed: 0.032 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[200]0000000000.00> but was:<[35]0000000000.00>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest.formatMKOBOValue(GenericUtilsTest.java:75)

formatUKOBOValue(com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest)  Time elapsed: 0.003 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[200]0000000000000> but was:<[35]0000000000000>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest.formatUKOBOValue(GenericUtilsTest.java:97)

formatValue(com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest)  Time elapsed: 0.003 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[200]0000000.00> but was:<[35]0000000.00>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.machadocrypto.kobocoin_android_wallet.util.GenericUtilsTest.formatValue(GenericUtilsTest.java:53)

Running com.machadocrypto.kobocoin_android_wallet.util.Base43Test
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in com.machadocrypto.kobocoin_android_wallet.util.Base43Test
Running com.machadocrypto.kobocoin_android_wallet.util.CryptoTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.254 sec - in com.machadocrypto.kobocoin_android_wallet.util.CryptoTest

Failed tests:
GenericUtilsTest.formatMKOBOValue:75 expected:<[200]0000000000.00> but was:<[35]0000000000.00>
GenericUtilsTest.formatUKOBOValue:97 expected:<[200]0000000000000> but was:<[35]0000000000000>
GenericUtilsTest.formatValue:53 expected:<[200]0000000.00> but was:<[35]0000000.00>

Tests run: 13, Failures: 3, Errors: 0, Skipped: 0

The error is coming from the kobocoinj. I've posted the error message on github

https://github.com/machado-rev/kobocoinj/issues/1

Can anyone give ANY tip on how to move forward from this? I'm just looking for the name of a file to edit that will cause ANY of the numbers in the failure message above to change. Once I'm in the right ball park at least I have something to work with. Right now I'm 99% done but dead in the water.

Any tips or pointers appreciated.

You've changed the MAX_MONEY parameter, so you need to change the tests that depend on it.

This appears to be the offending file.

P.S. Changing MAX_MONEY will not change the maximum number of coins. See: Why doesn't changing MAX_MONEY change the maximum number of coins?


How do I trace a bitcoin transaction to find its location in the world I need to trace a bitcoin transaction to find out roughly  where in the world the wallet is located. Is it possible to use a program, or manual-method, to trace/track a bitcoin transaction to find the recipients IP address or which area in in world they are in? If so, roughly how accurate is it?

The Bitcoin blockchain does not have any concept of location, nor could such a thing be added to it.

There is no such thing as "tracing a transaction" in a corporeal sense.

If you had a comprehensive global surveillance network, you could attempt to connect to every Bitcoin node in the network (including all the nodes located in Tor) and use timing analysis to attempt to guess the originating node of any given transaction.

If you had that surveillance capability, it would only tell about the specific outputs which were being spent and nothing about outputs which the user of that wallet might possess which have not yet been spent.

Basically, Bitcoin was designed to make what you're trying to do impossible.


Trying to import from from blockchain.info to multibit, getting error "There were missing dates. Have to go back to genesis block." I have a wallet on blockchain.info. I would like to load it in to multibit. I copied the text of the encryped wallet and saved it as wallet.aes.json. I then try to load it in to multibit. After correctly entering in the password, I receive the error "There were missing dates. Have to go back to genesis block."

I have tried resetting the blockchain both "from the date of the first transaction" as well as October of 2010, which is more than 2 years before the creation of this wallet. However, I still get the same error.

Your assistance is much appreciated!

The format of the blockchain.info wallet isn't ideal for importing into MultiBit. It works but MultiBit has to go back to the genesis block to make sure it gets all the transactions.

That is what the "There were missing dates. Have to go back to genesis block." message is for. It's basically saying - "Hey, this is going to take a while".

When you do the import it is best just to let MultiBit work away through the blockchain. On a reasonable spec PC with WiFi it takes about 30 minutes to chug through the blockchain.

This functionality is mainly in MultiBit so that is something happens to the blockchain.info server, users can still access their bitcoin.


Would it be wise and extra secure to use non-ascii characters in a brain wallet? What are some pitfalls if you use non-standard ascii characters in your brainwallet? Say if you were to use asian language characters? Or even extended ascii characters (http://www.theasciicode.com.ar/ascii-control-characters/delete-ascii-code-127.html) ?

What are some pitfalls by doing this? would it make your brain wallet incompatible in the futre? Pros/cons?

It would not be wise to do this.

"Brainwallet" software is completely non-standardized, there's no guarantee that any two implementations handle the encoding of characters in the same way. Addition of UTF8/UTF16 these characters is also likely to be incredibly confusing, did you mean Tooxy or Тооху? Those strings look the same but one is a completely different set of Unicode characters (and make two entirely different keys).

Even with the addition of non-standard characters it's unlikely any particular human generated string will have enough entropy to avoid attack. Staying far away from the brainwallet concept entirely would be most sensible, it's extremely broken and will likely lead to a loss of money either through theft or faulty software.


What BIP32 derivation path does Electrum use? Electrum 2.0 and up uses BIP0032 internally. I want to write code that generates the same addresses. I can't find any information about this online.

What BIP32 paths does it use to generate addresses?

It uses m/0/<n> for receiving addresses, and m/1/<n> for change addresses.

Here's some example bitcoinj code to generate receiving addresses from an extended public key.

String serialized_xpub = "xpub.....";
unsigned int address_num = 4;
NetworkParameters params = MainNetParams.get();
DeterministicKey root_xpub = DeterministicKey.deserializeB58(null, serialized_xpub, params);

DeterministicKey receiving = HDKeyDerivation.deriveChildKey(root_xpub, new ChildNumber(0, false));
DeterministicKey new_address_key = HDKeyDerivation.deriveChildKey(receiving, new ChildNumber(address_num, false));
String new_address = new_address_key.toAddress().toString();


bitcoind -zmqpubhashtx causes empty raw file I call:
bitcoind -zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw
or even call:
bitcoind -zmqpubhashtx=tcp://127.0.0.1:9050 -
zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw
where 9050 is port from bicoin config.
File /tmp/bitcoind.tx.raw is empty i has lenght=0
How can I dump transactions?
I read, this file is websocket and I must subscribe to it:
Client side, then, the ZeroMQ subscriber socket must have the ZMQ_SUBSCRIBE
option set to one or either of these prefixes (for instance, just hash);
without doing so will result in no messages arriving. Please see
contrib/zmq/zmq_sub.py for a working example."

How can I read it programically?
I try create c++ program from Python sources and https://github.com/plq/zmq.git
include
#include <iostream>
#include <cstdlib>
#include <cstring>

#include "zmq.hpp"

using std::cout;
using std::endl;

void recv_multipart(zmq::socket_t &socket) {
    int64_t more=-1;
    size_t more_size = sizeof (more);
    while(more) {
        zmq::message_t response;
        socket.recv(&response);

        std::string response_str((const char *)response.data(),
                                                             response.size());
        cout << response_str << endl;

        socket.getsockopt(ZMQ_RCVMORE, &more, &more_size);
    }
}

int main(int argc, char **argv) {
    zmq::context_t context(1);
    zmq::socket_t socket(context, ZMQ_SUB);
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashtx");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawtx");
    //socket.connect(/*argv[2]*/"ipc:///tmp/bitcoind.tx.raw");
    socket.connect("tcp://127.0.0.1:28332");

    size_t arg_len= std::strlen("Unknown");
    zmq::message_t message(arg_len);
    std::memcpy(message.data(), "Unknown", arg_len);
    socket.send(message);
    recv_multipart(socket);
    return 0;
}

First ensure, that is 28332 port used: -zmqpubhashtx=tcp://127.0.0.1:28332 bitcoind parameter, next call python zmq_sub.py. This should work


What bitcoin wallets support bip32 extended public key export? I'm looking for a bitcoin wallet, that can export an extended public key. I want to put that key on a server, generate a chain of addresses and receive bitcoins, and be sure, that my bitcoins are safe on the server.

Currently I know, that only Electrum can export extended public keys. Could someone suggest other wallets, that are capable of doing this?

Consider to use a hardware wallet: https://bitcoin.org/en/choose-your-wallet.
IMO all of the available hardware wallet do allow to export an xpub.

But watch out (regardless of what wallet you are going to use)!

Even if you private keys are safe when you use public child key derivation, what happens if an attacker compromises your server and replaces the xpub with a extended key controlled by the attacker?

Be careful and read about "Server Hardening".
Also, if you run a VPS or dedicated root server, your server-center operator may have full access to you file-storage.


How are transaction hashes calculated? I'm trying to calculate the hash of transactions in bitcoin blocks, but I'm not getting the right answers.

For example, the genesis block has a single transaction.

Here's how I'm attempting to calculate its hash...

Transactions are encoded as:

a 32 bit 'nVersion'
a list of input transactions, vin
a list of output transactions, vout
a 32 bit 'nLockTime'

For the transaction in the genesis block, these are:

nVersion: 01000000
inputs

count: 01
1st input:

prevout_hash: 0000000000000000000000000000000000000000000000000000000000000000
prevout_n: ffffffff
scriptSig: 4d:04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
sequence: ffffffff

outputs

count: 01
1st output:

value: 00f2052a01000000 (hex(50*10^8) is 0000012a05f200, and bitcoin puts the bytes in reverse order)
scriptPubKey: 43:4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

nLockTime: 00000000

If I string all those together end to end, I get 204 bytes: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000

Taking the sha256 hash of this gives 27362e66e032c731c1c8519f43063fe0e5d070db1c0c3552bb04afa18a31c6bf.

Taking the sha256 hash of that hash gives 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a.

But the real transaction hash according to blockexplorer.com is 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b.

What am I doing wrong?  How can I get to the correct transaction hash?

Here's my working in Python:

>>> import Crypto.Hash.SHA256 as hash, binascii
>>> tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000'
>>> len(binascii.unhexlify(tx))
204
>>> hash.new(binascii.unhexlify(tx)).digest().encode('hex_codec')
'27362e66e032c731c1c8519f43063fe0e5d070db1c0c3552bb04afa18a31c6bf'
>>> hash.new(hash.new(binascii.unhexlify(tx)).digest()).digest().encode('hex_codec')
'3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a'

Taking the sha256 hash of that hash gives

  3b a3 ed fd 7a 7b ..............

  But the real transaction hash according to blockexplorer.com is

  .............. 7b 7a fd ed a3 3b

The answer I was getting was correct, but bytewise reversed.  I need to get used to Bitcoin using little-endian storage.


How to check if my node is fully sync'ed Using bitcoin-cli, how do I check how sync'ed my full node is?

Calling getblockchaininfo is your best bet.  It includes a field called verificationprogress, which is an estimate of how much of the chain you have validated.

Alternatively, compare headers to blocks.  If headers is higher, it means that your node has validated the headers for blocks that it has yet to validate.  When these numbers match up, it either means you are up to date, or for some reason your node isn't receiving any more block headers.  Unfortunately, this doesn't tell you how much further you have to go, since headers may be well behind the rest of the network.  You can always compare these values to those provided by an online block explorer.  Still, when these numbers match (or are 1 apart), it generally means you are synced.

There are also some good suggestions on this question:  How to know if bitcoind synced?


Re-insalling Bitcoin Core without re-downloading blockchain I had Bitcoin qt installed on my C drive and I downloaded the blockchain onto an external hard drive. I recently had to re-image my C drive. What I want to do is reinstall the Bitcoin software on my C drive without having to re-download the entire blockchain again.

Since you downloaded the blockchain onto an external drive, you do not need to redownload the entire blockchain. When you start Bitcoin Core for the first time, it will ask you to choose the data directory. Just choose the folder on your external drive which contains the blockchain data. That folder should have a folder named "blocks", a folder named "chainstate", a file named "wallet.dat", a file named "debug.log" and a few other files.


What existing businesses or products does Bitcoin compete with? I'm trying to understand who sees Bitcoin as competition to their main product.  For example, I've heard that Bitcoin competes with:

Swiss numbered bank accounts
Deflationary PMs (precious metals)
Money transfers like Western Union, Paypal, SWIFT

What other businesses or "thing" does Bitcoin compete with?

Cash. It competes with cash.

All of these things (prepaid accounts, debit cards, bank accounts, money transmitters, etc.) are sophistications built on top of cash in order to facilitate the transfer of cash from one entity to another. It's not easy to carry cash, nor is it safe to keep all of your cash in one place. It's not feasible to give cash to someone thousands of miles away. The aforementioned services make cash more, well, bearable.

Bitcoin rolls all of these services into one. The only one still possibly useful is a bank, which is merely a trusted, secure storage for a few bytes of data: a private key.

Credit cards and loans are a different concept. Those who have give to those who do not with the assumption that what was given will be returned, and then some. Bitcoin actually may make it more difficult for these kind of firms to operate because of its finite nature. That is, it cannot be created on the record books like fiat currency can. Fractional reserve banking within the Bitcoin model is possible, but there's disagreement on how it may be implemented.


How to remove private keys from wallet.dat and create "receive only" wallet? I want to create a wallet for monitoring incoming transactions. So it should be receive only wallet that will be place on hosting, that is potentially not secure. If I understand it well, this won't allow attacker to stole funds if server is compromised. How I can create such a wallet with only public keys? And can I inject private keys later to spend from that wallet from a secure machine?

You're right, storing your private keys on a server is a bad idea - it means you're liable to lose all of your funds in the case of a hack.

But as you aren't storing them, do you need to install the bitcoin daemon on your server? You could use an API from one of the online blockchains to monitor transactions from your server, and maintain your encrypted wallet.dat on your own computer.


Why are there different prices for bitcoins between exchanges? Ive been looking around at the prices for bitcoins at various different exchanges and they all seem to have slightly (or wildly) different prices, why?

Thanks.

Economically speaking, this can only happen if the expected cost and risk in arbitrage outweigh the expected profit. Arbitrage, in this case, would be buying coins on a cheap site and selling on an expensive one. The risk comes from the high volitility and long confirmation time. In the hour or so it takes to transfer the coins from one site to the other, it's very possible that the price could have dropped enough that you end up losing money. The  aforementioned risk is why no one has tried to take advantage of the price differences and (as a result) equalized the price.


Can the Lightning Network work and live independently from Bitcoin? Is the Lightning Network Protocol capable to serve micropayment services without broadcast any transaction to the blockchain?

No, not without any transactions. The Lightning Network is based on so called channels between 2 users.

The creation of this channel has to be broadcasted to the blockchain (and another transaction is needed to close it again).

While creating the channel, you've also to put some BTC into the channel, which then can be transferred between both ends.

To have an example here:

A and B are creating a channel between each other. A creates the channel and puts 1 BTC into it, B doesn't add any BTC to it. This creation requires a transaction on the regular BTC blockchain.

Once the channel exists, A sends 0.5 BTC to B (maximum is 1 BTC as this was the ammount the channel was created with). A few days later B sends 0.1 back to A and closes the channel.

Now the transaction to close the channel will contain: Transfer 0.4 BTC from A to B (as this is the final balance), and only this transaction will be executed.

No matter how many transactions will be performed between A and B, only the final balance will be mined into the chain.

But that's not the only trick with the lightning network. If A has a channel with B and B another channel with C, A can also send BTC to C (over B) without the need to have a separate channel between A and C, but only the minimum BTC of channel A->B and B->C is transferrable. So if A -> B has a cannel value of 500 BTC, but B->C has only 1 BTC volume, A can only send a max. of 1 BTC from A to C.

While transactions within those channels are free of any transactions on the blockchain, opening and closing will require a transaction. Closing is also required to receive the BTCs initially "stored" in the channel.

Hope this clarifies a little bit how the LN technically works


How is all this bitcoin theft happening? When reading many stories about bitcoin theft, what is the usual gist? Dont most of these hackers get digital wallets that are encrypted? How do they make use of it, crack it...or its not encrypted at all?

There are many ways theft can occur.

Even though the cases where hackers have stolen from exchanges or from individuals, in terms of the number of bitcoins lost that amount is chump change compared to the amount of coins lost to scammers such as PirateAt40 and other scams, including loans not being repaid or currency trades that go bad.

But as far as bitcoins lost to hackings, yes -- the thefts have been due to poor security practices being implemented by exchange operators and other businesses where an attacker takes advantage of that to steal funds.

The list of the top thefts in which these hackings includes some of the details for various incidents.

Security is difficult and expensive, and Bitcoin startups generally don't have the revenue and profits sufficient to attract the capital that would allow top-notch security to be implemented.  As a result, they become juicy targets for the attackers.

Even following the recommendations for securing online services does not ensure that there is no risk of theft, but most losses from theft thus far were because those recommendations weren't followed.

As far as the term "cracking" ... that generally refers to discovering passwords.  In June 2011 when an attacker obtained the list of accounts and password hashes from Mt. Gox, cracking was able to discover passwords for many accounts due to there having been poor security on the password hashing method implemented by Mt. Gox at the time.  Most Bitcoin-related service operators are smarter than that but that incident has helped any that weren't to become a little more aware of proper password security methods (e.g., BCrypt).

Password cracking might also be used by an attacker to gain access to a system which which may hold coins in an unecrypted wallet, or that breach may lead to credential that provide access to additional systems which hold coins in an unencrypted wallet.

The reason hackers are successful when compromising these server systems used by exchanges and other bitcoin businesses is because if software needs the ability to send outgoing payments then the attacker who has compromised the system then gains that same capability.  Even if the wallet is encrypted, the software would use the passphrase to unencrypt it so either the Bitcoin client is responding to requests after the passphrase has already been provided or the passphrase is avaialble to the software to make such requests.  And thus if that system is compromised there is no protection possible for those coins in the wallet on that system.

For this reason, any exchange or bitcoin business using hosting for their systems where the hosting service has any access to the hosted service whatsoever, those coins are at risk.  But most Bitcoin businesses are not at the scale necessary to justify proper security at data centers (e.g., using their own hardware colocated in locked cages in highly secure facilities).

Even with that, that is just the security for the hot wallet containing a fraction of the service's bitcoins needed for daily operations.  Security for the offline wallet might involve using paper wallets stored in bank vaults, or access protected with Shamir's Secret Sharing method even.

Much more common than breaches of security at Bitcoin exchanges and services are compromises of individual EWallet accounts at these online services.   This often happens when an individual shares a username and password for their exchange account with another service.  For instance, after the Mt. Gox passwords were leaked, other exchanges went on lockdown because so many accountholders had common login credentials on both services.  A protection against that is for the exchange to offer multi-factor authentication.

Individual users of the Bitcoin.org client can protect their wallets with passphrase encryption.  This still leaves them vulnerable to a replay attack should their system be compromised with a keylogger or similar malware.  For this reason, offline/cold wallet and "air gap" systems are recommended when the amount of bitcoins held are significant.  A similar recommendation exists for online banking, so compromised systems aren't specific to Bitcoin users.


Segwit transaction from mixed addresses (segwit and non-segwit) Is it possible to have partly segwit transactions? I.e. some utxos from segwit addresses and some from non-segwit addresses.

Asking for the situation of Bitcoin core v0.15 wallet with coins in segwit and non-segwit addresses. If you send a transaction will it use one or both address types for the transaction?

The right way to look at it is that every transaction input has a witness. For legacy outputs being spent, that witness is just empty.

So yes, mixed SegWit and legacy inputs are possible. SegWit transaction serialization will be used, and the witnesses for all legacy inputs will be empty.


Can I write my own pool software by using bitcoin API? Theoretically speaking, if I know programming (C,C++,C# etc.) can I write my own mining pool software/server using only Bitcoin API or I need more information than that?

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

You can, of course! But you may start from some existing programs that do what you say, most are open source and well documented. And ask someone, it's very hard to do it on your own!