Who got the bitcoins when nobody was mining it in the very begin? Who got the bitcoins when nobody was mining it in the very begin?

If nobody mined it what used to happen to them?

Cheers

In the beginning, the Standard Client mined blocks by default. The difficulty was low enough that a single computer could reasonably create blocks just with its CPU. The Standard Client stopped CPU mining by default when GPU mining became prevalent.

Early blocks were most likely mined by Satoshi and other first adopters. One can see that the Genesis Block was created on January 3rd, while the next block was mined on January 9th, showing that most likely the blocks would not be mined unless there was someone on the network - Satoshi was probably running a node from the start, second person joined the network a week later.

Bitcoins are only generated when a block is mined. If a block is not mined, no new coins are generated. The system does not generate new coins every 10 minutes, but every block, which is designed to be mineable on average in 10 minutes.

If blocks would stop being generated for some time, creation of new coins will be halted until a new block appears. Worst case scenario if a lot of computing power drops from the network, the system will be slowed down until the Difficulty is readjusted. This happens every 2 weeks worth of blocks.

On TestNet, if a block is not generated in 15 minutes, Difficulty is dropped to 1 automatically to make it a more efficient testing environment. MainNet does not do this.


How does BIP9 handle expiration dates over retargeting periods? Suppose a BIP9 feature is set to expire on day T. Suppose further that the retargeting period before T actually ends on day T+5, but the retargeting period (2016 blocks) actually signals for the BIP9 feature 95%+. Does the feature get activated or not?

I ask as this is a realistic scenario should BIP148 gain traction.

As per BIP 9, the transition to FAILED takes precendence. Which means that the feature will not be activated via BIP09.
The relevant part of the code.

case STARTED:
            if (GetMedianTimePast(block.parent) >= timeout) {
                return FAILED;
            }
            int count = 0;
            walk = block;
            for (i = 0; i < 2016; i++) {
...


My sync wont start, what can I do? I have used Bitcoin previously via Windows GUI miners, but never faced an issue like this before. I am now running Ubuntu 12.04 amd64 and using an updated 0.7.1 Satoshi client.

The sync looks like it is working, but the first block never loads. I have had the wallet synchronizing, but it is forever stuck at zero. My Internet connection is fine and have cleared the bitcoin directory and rebooted with no change.

While I am writing this I am watching my other rig drop blocks fine and its running Mint 13 with about a third of the resources I have on the computer giving the issues.

Any help will be greatly appreciated. Thanks.

Specs:

UBUNTU 12.04 updated
AMD Phenom IIx4
4 GB ddr3
Nvidia EVGA 9800GTX

Do you have the exact same configuration on your other rig? If you do, copy the configuration exactly. Sometimes if you don't have long-polling turned on and using the correct port, in some rare cases you will keep going if you are using the wrong protocol for a said port.

In general, if you are doing Bitcoin mining on a Phenom of your type, and you are doing SHA256D hashes, you should wait around 5 minutes.

If it doesn't immediately say long-polling activated, you've got a problem and need to configure your mining application to do so.

From the time you get the Long-Polling started message, anywhere from 30 seconds to 5 minutes is normal.

I have my scan time set for 1 second, by default it's set for 5 seconds but depending on your hardware and the pool you're in they might tell you to set it for 10 to 30 seconds.

Are you using Slush's Mining Proxy too? I know that can stall out if you're not using the correct configuration for that too.


A question about transaction broadcasting and block creation Let's say we have transaction X and transaction Y. The timestamp of X is chronologically earlier than that of Y. X's spender broadcasts X to the network and the same goes for Y's spender.

Let's say that miners receive Y first and they add it to the next block, which reaches the max number of stored transactions. Will X be included to the block after this one? Will it be discarded?

If X will be included to the block after this one, isn't it a problem that it happened before Y?

Thanks in advance for your answers!

If I undestend the your question, you referer to the lockTime inside the  transaction and not the block timestamp.
The lockTime is a int value, and this value rappresent "When the transaction can be unlockd to an inputs" and not "When the transaction was published"
Lock time: Defines the first instant in which the transaction is considered valid and can be transmitted on the Bitcoin network, represented by an integer value between 0 and 500 million, assuming different meanings based on the value assigned, that is:

Lock time = 0: the transaction is propagated and executed at the instant of
creation.
0 < LockTime <= 500: the value is interpreted as a block height, ie the
transaction will be valid only after the block with height
equal to the lock time value has been published.
Lock time> 500 million: the value is interpreted as a unix timestamp and
therefore the transaction will be valid only after the
date represented by the lock time value.

If you mean if the transaction has a timestamp, the answer is two:

Within the structure the transaction does not have a timestamp, but
rather a lock time.

The transaction could have an insertion moment in the block, which
depends on the block, because it is he who holds the timestamp as a
value.

A real use case:
  My transaction has a block timestamp equal to 8/23/2019, 2:08:43 PM GMT + 2, this represents the time in which the miner started the cryptographic challenge, and it is the instant in which the miner has also taken into consideration my transaction including it in the block.
My transaction has a lockTime of 0 because it is an immediate execution transaction.
No one excuses that my transaction before the block was published was ALSO inside some other block with a slightly different timestamp
If you want have turned a detailed explanation of what and how a transaction works, I recommend this reading on bitcoin book
Update from Bitcoin Dev
In the comment, Pieter Wuille in the comment below post the following answer and explain that my answer is wrong, and a very precise answer is reported below

The nLockTime of a transaction determines the earliest possible time
it can be included in a block. It is illegal to have a block which
includes a transaction whose locktime has not passed yet. There are
however mechanisms to forcing a transaction output to be only be
spendable with a future transaction which has a certain locktime - the
net effect being that this output can be included on chain, but
transactions spending it cannot until such time passes.


Bitcoin privacy - current state of privacy BIPs - is mimblewimble broken? Community,
what is the current state of privacy related BIPs? Anything on the roadmap by core devs to be deployed on main chain within the next year?  IF yes, could you link me to this BIP(s)?

And regarding mimblewimble: you are aware i assume on the latest researcher claims about broken privacy model of mimble wimble? This guy's analysis looks convincing.

  "As Bogatty put it, all transactions on Mimblewimble are put into a
  single CoinJoin, which leaves anonymity set with all the transactions
  being located on one block. Unlike other privacy cryptocurrency
  networks and cons which shield their anonymity sets and transactions,
  Mimblewimble has this inherent flaw, and he was able to exploit it and
  access those transaction details."

quote from: https://insidebitcoins.com/news/litecoin-ceo-defends-mimblewimble-against-privacy-critics/242702

Now, I think the current BIPs have all somehow a mimblewimble-like or CoinJoin-Like approach to solving privacy, right??
Would above quote from BOgatty also apply to the current privacy BIPs (or to the majority of them)? Without claiming whether it is a flaw or not, just the basic fact: do the currently leading privacy BIPs have this approach of "putting transactions  into a single CoinJoin"?

Would be nice if someone can clarify the state of privacy with Bitcoin, or the future state.

Thanks

Community, what is the current state of privacy related BIPs?

CoinJoin related ones:

Adam Gibson's SNICKER draft, which permits a simple unidirectional CoinJoin construction.
BIP 79, Bustapay, a standard for CoinJoined payments.

P2P improvements:

BIP 156, Dandelion: routing newly broadcast transactions a few hops before broadcasting.
Draft for BIP 324: encryption of the P2P layer, making transaction origin harder to find for passive attackers
Draft for Erlay BIP: (less directly privacy focused) introduces a lower-bandwidth, less directed, transaction broadcast mechanism

Consensus rules:

My own draft for BIP-taproot

The first set of these are not consensus or protocol changes to Bitcoin's network. They're merely standards that wallet can choose to implement to improve privacy of their own transactions. There are many more techniques that may or may not be implemented by wallets which aren't written up as formal BIPs, see this great article on the Bitcoin.it wiki by Chris Belcher with an overview: https://en.bitcoin.it/wiki/Privacy

  Anything on the roadmap by core devs to be deployed on main chain within the next year?

Privacy is a complex topic, and while there are some things possible at the protocol level where core developers may be more involved, there is far more to be done at the wallet level. The taproot proposal is an example of a protocol level change: it aims to improve a different type: on-chain policy privacy. This is the problem that the type of scripts your wallet chooses to use on the network reveals what kind of things it is doing (e.g. Multisig, Lightning, 2FA, ...). The goal of Taproot is to make sure that in cooperative cases, all transaction outputs and inputs look indistinguishable. This is completely distinct from the type of privacy leak that CoinJoin-style approaches (which expose linkage between transactions).

As for when it might activate on the network, I doubt anyone can tell you. That is up to the community.

  And regarding mimblewimble: you are aware i assume on the latest researcher claims about broken privacy model of mimble wimble?

I think that's a highly confused statement. Mimblewimble itself does not provide any privacy improvement. It is an improved designed over Confidential Transactions (which is a privacy technique, hiding transaction amounts), making it more scalable and enabling non-interactive CoinJoin.

If you look at the original Mimblewimble paper by Tom Elvis Jedusor, or the more formal paper by Andrew Poelstra, you'll see that privacy is only mentioned in the context of what is provided by CT, or enabled by CoinJoin.

CoinJoin itself is not broken, but how it is used matters a lot. In correct usage, participants interact privately to jointly construct a single transaction, which, when revealed to the public, cannot be disassembled into the individual participants' contributions. What happened in a particular Mimblewimble implementation was they use CoinJoin on the public network. It should be obvious that this does not grant any privacy to anyone observing the network, as they can easily see all individual contributions to transactions. This is not a bad idea either, but it's only a scalability gain. For privacy, CoinJoin needs to happen elsewhere too.

So again: CoinJoin is not broken; it helps when used right. Mimblewimble or its privacy is also not broken - Confidential Transactions and the ability for non-interactive CoinJoin are great. Mimblewimble also enables non-interactive CoinJoin, which happens to be usable as a scalability improvement as well, but when done publicly, does not improve privacy.

  Now, I think the current BIPs have all somehow a mimblewimble-like or CoinJoin-Like approach to solving privacy, right??

You don't "solve" privacy. Privacy is a goal to achieve, but it's multifaceted, and isn't solved by a single piece of technology. Significant parts of privacy are about education and incentives, not a magic bullet technology that suddenly hides everything.

Also, to the best of my knowledge nobody has seriously proposed Mimblewimble in Bitcoin.

  Would above quote from BOgatty also apply to the current privacy BIPs (or to the majority of them)? Without claiming whether it is a flaw or not, just the basic fact: do the currently leading privacy BIPs have this approach of "putting transactions into a single CoinJoin"?

No, because it doesn't apply to CoinJoin. It applies to the use of a scalability improvement inherent to Mimblewimble implementations, which has been misrepresented by some as a privacy gain.

  Would be nice if someone can clarify the state of privacy with Bitcoin, or the future state.

It's hard, but we'll get there.


I am wonder why this works.

Because all options have the default value.

  The question is what txindex=1 do.

I can't find this option in the documentation

From the documentation

  -txindex Maintain a full transaction index, used by the getrawtransaction rpc
  call (default: 0)

If you're using Bitcoin Core just for your own personal use, you probably don't need the -txindex=1 option. But, if you're using Bitcoin core for development or blockchain analysis of some sort, you will need to set -txindex=1 to be able to get transactions data for any transaction in the blockchain.


Exchanges and security How can I ensure that my crypto-assets are secure when trading in a certain exchange? Even when I have my private wallet, I should deposit into theirs before trading.

That is the risk you take when giving someone else control of the private keys to spend your coins. When you transfer them to an address in custody of a centralized exchange, that means they have the corresponding private keys to spend it. You need to do your own research and determine if the exchange has good security measures to protect from breaches.

Many decentralized exchanges let you retain control of the private keys, but you also have to do your research on the software implementation to make sure it's design is secure with your keys.


can someone give me an example on how collaboration is difficult without the Blockchain? i understand the technology and i understand how it helps in two domains which are voting and currency but i don't understand how the Blockchain helps in other domains such as health care or supplychain, i mean what is wrong with today's health care and supplychain !

Short answer: Nobody can give such an example.
Simple reason: Collaboration existed long before blockchain was invented.
Satoshi Nakamoto started chapter 12. Conclusion of his paper with the sentence:

We have proposed a system for electronic transactions without relying on trust.

If you take a deeper look into the technology you realize trust got in fact replaced by distributed computing power. Causing another problem. Namely, how to distribute this computing power in a trustworthy way.
Since voting (as we usually do in democracies) and health care heavily rely on trust in the persons involved I find it difficult to see any reason why and how a blockchain could help in these fields.
Satoshi Nakamoto's paper


Why does transaction activity show on the blockchain for my Bitcoin address at my hosted (shared) E-Wallet service? I have an online wallet at localbitcoins.com (address 12pHFR5yv2KGqck5N8teb5MgoRtzAgLRn2).

I made three transfers to it, for a total of 0.5 BTC + 0.5 BTC + 0.3031 BTC = 1.3031 BTC.

Blockchain.info did show my address receiving coins. However, it is showing my address sending coins to several addresses after receiving them https://blockchain.info/address/12pHFR5yv2KGqck5N8teb5MgoRtzAgLRn2:

Is someone using my online wallet at localbitcoins.com to withdraw money?

You do not have a Bitcoin wallet at LocalBitcoins.  Instead you have only a ledger account with their hosted (shared) Bitcoin E-Wallet.

What this means is that you cannot use the blockchain to track your balance.  You can only use it to determine how many confirmations your transfer (deposit) has received.

The E-Wallet provider simply credits your account when they see a confirmed deposit transaction (e.g., 6 block confirmations) to a Bitcoin address associated with your E-Wallet account.

To know your balance, you will need to login to your E-Wallet account on LocalBitcoins.  That will show you your balance.  The account details will show deposits, withdrawals, purchases and sales.


How to create a bootstrap.dat file? I want to create a new bootstrap.dat file for a Dogecoin. How do this kind of files are created and how can I create one? What tools should I use? any answers/links/references are appreciated. I have searched here, but I haven't found any satisfying answer. I saw this post: Creating my own bootstrap.dat but there is no method mentioned of putting the block in the bootstrap.dat file. Saw this post too: How do you generate a bootstrap.dat file? but the tools mentioned are for Bitcoin and I'm not sure how to use them.... can anyone create a more explicit, step-by-step tutorial for doing this? something that anyone can understand? thanks in advance!

Since van der Woerdt's answer in first question you link to indicates you can simply concatenate the blk files, you can open a DOS window (if your using windows), then type

CD C:\Users\<my_user>\AppData\Roaming\DogeCoin

(if you're on Win7+)

And then

COPY /b blk0001.dat+blk0002.dat bootstrap.dat

And that would be it!


What does "Not yet redeemed" mean in a BlockExplorer transaction output? Just digging around BitCoin Explorer and I came across a neat transaction. More so, curious, does the second output where it lists "Not yet redeemed" mean that someones BitCoin wallet didn't accept that transaction or something?

http://blockexplorer.com/tx/01ccb4aff48836c9ebe93caa83d7090eb2f76fa71275a9d6766cc8f32c82af39

No, it means that those coins are not yet spent.

Bitcoin transactions work with inputs and outputs. Every transaction can have one or more inputs, and it may then create one or more outputs of which the total amount adds up to the sum of the inputs (minus the transaction fee).

Only coinbase transactions do not require inputs. Those are the first transaction in every block that gives the miner of the block his block reward and all the fees from the transactions in the block.

When you want to spend bitcoins from one of your addresses, you will have to find an "unspent transaction output" for that address, make a transaction with the output and assign new inputs.

What this means is that an address does not really have a balance stored in the block chain. There is just a list of unspent outputs, and those that are bound to some address add up to this address's balance.


Tracing Bitcoins to their original blocks Can I find (always, without fault) the specific set of blocks from which the Bitcoins that I hold originated?

If yes, would such a trace-back be computationally costly?

Yes you can, every transaction in the bitcoin network is registered in a public ledger called blockchain. You can query this ledger via http interface like https://blockchain.info/api/blockchain_api

I don't think will be costly but it depends how many hands your bitcoin passed. When you find transaction without a sender, you have to stop, this are mined (generated) blocks


What RBF policy will be default on SegWit v1 nodes? What RBF node policy will be applied by default in order for a SegWit v1 transaction to relay when encountered. Full RBF, or Opt-in RBF?

As far as I'm aware, there are currently no formal proposals to introduce Full RBF. Therefore, I'm expecting that the default behavior of upcoming nodes will remain to forward and create transactions according to the rules specified in BIP125, Opt-in RBF.


sendrawtransaction without downloading blockchain Is it possible to use sendrawtransaction without downloading the blockchain? Or will bitcoind reject the broadcast since it can't validate the inputs?

If the client does block it by default, is there any way to force it to send it?

The RPC call sendrawtransaction tries to broadcast the raw transaction you give it by first adding it to its own mempool of transactions. If you don't have the UTXO database, then you won't be able to validate the inputs of the transaction, so your node will reject it from its mempool. So, essentially, no, there isn't a way with the default client.

You could modify your client to have a new RPC call that just sends the raw transactions without checking it. But then you run the risk of broadcasting an invalid transaction and having your peers increase your ban score.

Also see: Pushing tx to the network via AJAX, without installing bitcoin. That question lists a few APIs that have support for broadcasting a raw transaction, which may be helpful to you.


Creating a custom transaction? I am trying to create a custom transaction. I am using c# and I will code the signature code myself since no library currently allows this. The transaction involves 3 players; a buyer, a seller and an escrow. The transaction must do the following.

Transaction skeleton:

1. The buyer will send 2BTC to the escrow.

2. The seller will sends 2BTC to the escrow.

3. At a later point in time, the buyer may choose to
        send 1BTC to the seller, or not.

4. If he does, the BTC placed in the escrow are
        returned (2BTC are kept by the escrow
        as commission).

5. If he does not, the BTC in the escrow are lost.

To implement this, it gets complicated. The escrow would need to run a daemon in a loop that would check to see which transaction are been placed in order to return the BTCs correctly.

Is there a way to use the advanced scripting and contract capabilities of bit coin to make it so the escrow doesn't have to run a daemon, and to simply the process as much as possible?

The prices you present are pretty steep, but hopefully this is just for clarity;).

If you don't want to run a daemon yourself in a loop, you can always try using Strongcoin's API:

https://strongcoin.com/blog/bitcoin_micropayments_with_strongcoin

It sends notification to your website when a transaction that you are interested in appears (whether it is to one of your addresses or anyone else's). It might not necessarily be exactly what you want (say, if you require 6 confirmations), but it definitely is a good place to start if you just want some notifications.


Two if's before sending an inventory message Going through main.cpp I couldn't completely understand the purpose of a double barrier coded as if-statements:
I'm referring to ...

if (pto->setInventoryKnown.count(inv))

and

if (pto->setInventoryKnown.insert(inv).second)

What is the idea behind checking if an inventory is known to the target peer twice? I'm aware that if (pto->setInventoryKnown.count(inv)) only checks if entry is known to target peer and if (pto->setInventoryKnown.insert(inv).second) inserts the inventory item after checking its uniqueness.I mean couldn't one just use only one if-statement combining?

I don't see any reason for the second if statement, either. I'm not speaking from any form of authority here, but it looks like a (tiny) efficiency bug to me.

The second if statement has been around since the first commit. The first if statement was inserted about a year later when "trickling" of tx inv messages was added, presumably to check the set membership earlier to avoid running through the trickling logic when it's not necessary. I'd guess that the removal of the second if was simply overlooked.


How are p2sh address spent So, I was looking into how P2SH transactions are working and by looking at different blog post and in particular to this answer, I have the following question.
So, let's take the same transaction:

What I am not getting is how the operation are done.

Is the scriptSig executed first?
What is checked to be equal to 0b49fe...df1? How is it calculated ?

What I am not getting is how the operation are done.

The address encodes the hash160 of the redeemScript. That address was given to the sender, who used it to construct an output scriptPubKey of the form OP_HASH160 <scripthash> OP_EQUAL. The scripthash is really hash160(redeemScript), but the sender does not know that, as they aren't given the actual redeemScript, just its hash160. The <...> notation here means "script opcode that pushes ... onto the stack".
The redeemscript is OP_2 <pubkey1> <pubkey2> <pubkey3> OP_3 OP_CHECKMULTISIG. This script was created by the receiver, encoding their policy for spending, and then its hash160 was given in the form of a P2SH address (3...) to the sender.
The scriptSig is what is created by the receiver when they want to spend the coins. In this case it consists of OP_0 <sig1> <sig2> <redeemScript>.
During validation, what happens is:

First the scriptSig is executed, which pushes 4 items onto the stack (0, sig1, sig2, and redeemScript).
Then the scriptPubKey is executed, starting with the previous execution's final stack as initial state. It contains 3 opcodes, each modifying that stack:

OP_HASH160: takes the final element of the stack (the redeemScript) and replaces it with hash160(redeemScript).
<scripthash>: pushes the scripthash onto the stack, so now the stack is (0, sig1, sig2, hash160(redeemScript), scripthash).
OP_EQUALVERIFY: removes the top two items on the stack and compares them. If they are equal, a 1 is pushed onto the stack, otherwise a zero. In our case, the scripthash is equal to hash160(redeemScript) (because the spender revealed the correct redeemScript) and thus a 1 is pushed. The stack is now (0, sig1, sig2, 1).

The final stack is examined: validity rules require that the stack is not empty, and that its top element is nonzero. That is the case here: the top element is 1. If that wasn't the case, the spend would be marked invalid and execution would stop here.

That's it for the ordinary execution. However, because the scriptSig is exactly of the form OP_HASH160 <20-byte scripthash> OP_EQUAL, the BIP16 P2SH validation rules trigger for a secondary round of processing. This time:

It is verified that the scriptSig contains only push opcodes, and no other opcodes. If this is not true, the P2SH validation marks the transaction as invalid.
The stack we had just after executing the scriptSig is restored (0, sig1, sig2, redeemScript).
Its top element (the redeemScript) is removed from the stack, and reinterpreted as a script, and executed, with all the other stack elements as input. It consists of 6 opcodes:

OP_2: pushes a 2 onto the stack, which now becomes (0, sig1, sig2, 2).
<pubkey1>: pushes pubkey1 onto the stack, which becomes (0, sig1, sig2, 2, pubkey1).
<pubkey2>: pushes pubkey2 onto the stack, which becomes (0, sig1, sig2, 2, pubkey1, pubkey2).
<pubkey3>: pushes pubkey3 onto the stack, which becomes (0, sig1, sig2, 2, pubkey1, pubkey2, pubkey3).
OP_3: pushes a 2 onto the stack, which now becomes (0, sig1, sig2, 2, pubkey1, pubkey2, pubkey3, 3).
OP_CHECKMULTISIG inspects the stack, sees a 3 on top, removes it, as well as the 3 pubkeys that precede it. Then it encounters a 2 on top, removes, as well as the 2 signatures that precede it. Then it removes one more element (a historical bug that is very hard to fix). Then it checks those signatures against every subset of 2 of those 3 pubkeys. If matches are found, it puts a 1 on the stack, otherwise a 0. In this case, the signatures are valid for some subset of the public keys, and the stack becomes (1).

The final stack is inspected, requiring that it is not empty, and its top element is nonzero. As it is a 1 here, that is the case.


What part of the transaction is scriptSig in? I was reading this paper
https://web.archive.org/web/20140331191527/http://bitcoinhistory.net/Technical_Papers/ProgrammingBitcoinTransactionScripts.pdf
and I have the following question:

ScriptPubKey accompanies a transaction output and specifies under which conditions it can be claimed. ScriptSig accompanies a transaction input and is used to prove that the referenced output can be rightfully claimed.

So in page 2 the ScriptSig should be in Input TX and ScriptPubKey should be in output TX? Author says that scriptA is ScriptSig.

I was confused by that too. Here's the picture with some more labels on it.


What was the goal of creating the feature of immature coins? I just ran into the idea of immature coins. Can someone explain to me the idea behind immature  coins and what was the purpose of it?

Immature coins are coins that were created in a block reward and haven't aged sufficiently, yet. The problem with block rewards is that they could still disappear again, if the generating block ends up being invalidated by a competing block chain.

In order to minimize the confusion and subsequent problems from someone spending coins that end up disappearing later again, block rewards are considered immature until another 100 blocks descend from the generating block. After this approximately 16 hours and 40 minutes, the coins are mature and considered safe to be spent.

On the other hand, regular transactions that were confirmed in a block that got invalidated by a longer competing chain would just be picked up by another block. The difference here is that a regular transaction is based on prior knowledge of the coins, even if it is through a chain of transactions, while newly created coins would not be there to fund a transaction.


Import private key in HSM Luna SA I need some clarification on how keys are imported into a HSM Luna SA. I should import BIP 32 private keys of multisign wallets. There are currently two keys: one for the user and one held by the company that would like to start using HSMs.

I start with a general question: is it better to keep all the
individual private keys in the hsm or a single master key that is used
to encrypt the private keys of the wallets?
How are BIP32 keys imported into an HSM? Is the serialized format
used?
Are there any other keys that are needed for the import (wrap for
example)?

I accept other advice on implementing the BIP32 with the Luna.

This is what is reported in the thales documentation:
Private Key Import/Export Private keys can be imported and exported with existing PKCS#11 functions.
They can be imported and exported only if the HSM uses the key wrap model instead of cloning.
Import a key by calling C_Encrypt*() on the serialized key followed by C_UnwrapKey(). Exporting keys by calling C_WrapKey() followed by C_Decrypt*().
Use C_WrapKey() and C_UnwrapKey() to store keys off the HSM, or to move them between HSMs.

I don't know the use of PKCS11;

which key is used for the wrap?


Where are transactions to be confirmed stored? When a bitcoin client sends a transaction to its connecting full nodes, before that transaction is confirmed, where is it stored? on all full nodes?

Full nodes keep a "mempool" of unconfirmed transactions, so yes, but every full node chooses its own rules for how many transactions it keeps in the mempool, e.g. minimum fee, maximum number of transactions, amount of time before the transactions drop out, etc. So not every full node keeps every unconfirmed transaction. If a node doesn't have a transaction in its mempool when a block is mined, it will just request that transaction.


Transaction Input - previous hash size? I am reading the bitcoin developer reference and having a look on the transaction input structure. If you have a look here https://bitcoin.org/en/developer-reference#raw-transaction-format it says that the previous output  has 36 bytes. I am confused, because I read also the 'Mastering Bitcoin Book' and this wiki page (https://en.bitcoin.it/wiki/Transaction) and they state that the size is 32 bytes.

Is this a mistake in the reference or is it something new which did not propagate to the other sites? Would be nice if someone could clear that up for me :)

It is because in the developer guide they are referring to the outpoint, not the output. The outpoint is a data structure used to refer a particular output, that consists of:

outpoint = txid(32 bytes) + output index (4 bytes)


Where does Trezor get UTXOs from? Since UTXOs are required to spend funds, where does Trezor get the unspent outputs from?

Storing them in the hardware requires you to plug it in from time to time to update the UTXO set. You could even run out of UTXOs!
Host-side blockchain scanning for UTXOs from a given deterministic wallet is very expensive (if not impossible since there are infinite addresses in a deterministic wallet).
You can't build a "wallet -> UTXO" index for the same reasons above.

What am I missing? I'm assuming Trezor's primary use case is in PoS. Pehaps I'm wrong there?

As explained in their FAQ, Trezor works together with existing wallet software, it's not a standalone wallet.

What happens is that the wallet you use gets the addresses from your wallet from Trezor and can display your balance with that information. When you want to spend money, it will create a transaction as it would normally do,  but instead of signing the transaction itself, it sends it to Trezor. Trezor will show the transaction on the display and ask for your confirmation. When you confirm, it will sign the transaction with the private keys (that are only stored on the Trezor) and send the signed transaction back to your wallet software, which will broadcast it to the network.


What is the strategy behind a sell wall? I understand the idea behind 'bid walls', but on Kraken, prices are being kept low through the use of 'sell walls'.  The volume on this exchange is too low to have a chance of getting through these walls, even when prices on other exchanges are skyrocketing. Every so often, when the price falls a bit, up comes a new 'buy wall' keeping it there. The price on Kraken falls when other markets fall, but gets stopped at the wall on the way back up.  I am curious to know what the strategy behind this tactic could be.

Added 21 Nov for elucidation

On this small volume exchange, a 30 BTC ask equals 10% of the 24hr. volume.  It is the equivalent of a 4500 BTC ask on Bitstamp.  It alters the way bidders approach the market.  When you see such a wall sitting just above the current price, you can be sure the price will not be rising beyond it for at least the next few hours.

I watched this person re-position this block four times over the course of the day.  Each time, lowering it to sit just above the current bid price.  It was altering the dynamics of this small volume exchange.

I am not asking for you to read anyone’s mind.  I was baffled by this behavior.  I had not seen this strategy before.  I thought that there must be some method to this madness, but I could not see what I might be.  I thought that somewhere in the collective experiences of Stack Exchange there might be someone who was familiar with this strategy and might be able to provide some insight, not necessarily on this person’s behavior, but on the theory behind the strategy being employed.  Assuming, of course, that there is one.

A large investor might be trying to move the market.

Sell walls create an impression of a strong supply. This makes some people, unwilling to wait for the wall to break down, pitch their sales offers below the wall. By moving the wall closer to the current bid again, a large investor might be able to move the market to a small extent and then buy at a lower price. The investor's goal is to move the market, not to actually sell his supply at that price, so when the price gets too close, such walls often disappear or move to a higher price. Especially, if you see the same amount popping up at different prices, there is probably someone trying to move the market without actually fulfilling orders or bids.

Another type of sell wall is composed of many combined sales offers at certain landmark prices, e.g. $600. These usually don't move around.


Can same private key generate multiple addresses? Is this possible using some clever bitcoin script? The intention is to get more privacy. I can give different addresses to different people still no one can guess how much I make in total. I can do this by generating several key pairs but I will have to save all the private keys somewhere. If I can come up with a way to generate multiple addresses, I will have to save guard only one private key.

One private key maps onto two addresses - one that uses an uncompressed public key, and one that uses a compressed public key.

What you might also be interested in is a deterministic wallet - a Bitcoin wallet holding multiple addresses generated from one private key / secret. This will let you secure multiple addresses and store only one key.


As of today (2015-Nov) how many different anonymous type altcoins are there? How many anonymous type altcoins are there out as of 2015-Nov? Also what were their release dates and community size? I'd like to get into an anonymous coin, but I'm unsure which one has the most activity and community support.

Here are a few I have heard of, some are in development some are already being used.

ZeroCoin:
http://zerocoin.org/

whitepaper:
http://zerocash-project.org/paper

  The road ahead

  The plan is to make an altcoin, powered by the new Zerocash Protocol,
  that provides consumers with the financial privacy they expect from
  debit cards, credit cards, and cash. To do this, we plan on release a
  working, non research code quality client based off the bitcoin 0.9.1
  codebase integrating the new Zerocash protocol.

Monero:
https://getmonero.org/home

  WHAT IS MONERO ? Monero is a secure, private, untraceable currency. It
  is open-source and freely available to all.

  With Monero, you are your own bank. Only you control and are
  responsible for your funds, and your accounts and transactions are
  kept private from prying eyes.

  Want to find out more? An overview of Monero's main features are
  below. If you'd like to try Monero for yourself the Getting Started
  section is an excellent launching point.

ShadowCash:
http://aboutshadow.com/

  SHADOWCORE

  An entire privacy-based platform which aims to establish an anonymous
  economy, with multiple features that give people all the financial
  freedom and privacy they should have.

  Shadow is a decentralized anonymous communication, commerce and
  currency platform through which the virtual currency, ShadowCash, can
  be transferred. One of the significant advantages of Shadow is its
  deep integration with the rest of Shadow's features as well as
  offering native TOR support for IP obfuscation.

DashCoin:
http://dashcoin.net/

  Dashcoin (DSH) is an automatically mutating anonymous cryptocurrency
  Dashcoin is a Next generation anonymous cryptocurrency and the first
  automatically mutating cryptocurrency created with CryptoNote
  technology. What does this really means? Our network code is always up
  to date with minimal developer cost and close to 0% errors. You are no
  longer depending on developers good will. Concentrate less on
  developers and more on your trades and projects.

Here seems to be page that has gathered a few more anonymous altcoins:
http://www.altcoinfever.com/anonymous-cryptocurrency-altcoin/

As for the size of any of these communities, that I am unsure of. I just wanted to present you with options I have found. I cannot guarantee the validity of any of these altcoins and their claims of anonymity.


How can i consult my transaction history via Bitcoind/JsonRPCClient? If you go to your Bitcoin-qt wallet, there is a list of all the transactions you have ever made, you can even see the transactions detals.

Well, i cant find the way to get from bitcoind that same list. I want to know the transaction id of every transaction ever made in my wallet, there should be a way to get it since Bitcoin-qt has that list. Anyone knows?

Thank you!

Wow, sorry guys, for some reason i checked like 3 times all of the Bitcoind commands and didn't see it, but here it is:

listtransactions [account] [count=10] [from=0]

Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account] not provided will return recent transaction from all accounts.


It's in form of

{block_height, uint256S("0xblock_hash")},

For example,

{134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")},

If you search for "00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe", that block's hash on Blockchair,
you'll find the block with the height 134444.

Simple, huh?

EDIT: Your edit is partly corrected. Note that when you add a checkpoint, you don't hardcode the block into the client. When a user opens it for the first time, they'll download all blocks starting with the first block. Checkpoints allow the clients to verify if someone who created his/her block chain completely different than the main chain is sending you the fake chain. The clients do download the whole chain and verify the blocks with checkpoints (also see: assumevalid)


Bitcoin: error parsing json in bashscript to send BTC using sendmany command I am simulating a bitcoin network on my machine for which I have written a bash script to simulate the transactions between the nodes. When I use the sendmany option of bitcoin-cli to send transactions I am getting an json parsing error reported by bitcoin-cli.

Code:

#!/bin/bash
MAX_NODES=2
MY_PATH=/home/ubuntu/test
CLIENT=/usr/local/bin/bitcoin-cli

declare -a addr

function fcomp() {
        /usr/bin/awk -v n1=$1 -v n2=$2 'BEGIN{ if (n1>n2) exit 0; exit 1}'
}

json="'{"

#get addresses to send
for ((i = 1; i <= MAX_NODES; i++));
do
    addr[$i-1]="$($CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i/ getnewaddress myaccount)"
    if [ "$i" -lt "$MAX_NODES" ]
    then
        json="$json\"${addr[$i-1]}\":0.00001, "
    else
        json="$json\"${addr[$i-1]}\":0.00001"
    fi
done

json="$json}'"
echo $json

#loop to send money to other nodes
for ((i = 1; i <= MAX_NODES; i++));
do
        balance=`$CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i/ getbalance`
        if fcomp $balance 0.002; then
                $CLIENT -regtest -rpcport=$((16500 + $i)) -datadir=$MY_PATH/$i sendmany myaccount $json
    fi
done

echo json output:

'{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001, "mkxnkT3kx9dsFS8V3qYydpL1o5F5MfwCvM":0.00001}'

This gives me an error as:

error: Error parsing JSON:'{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001,

I tried all possible combinations of quotes, double quotes and escape sequences but failed. If I copy paste the output of echo $json to a manual bitcoin-cli sendmany command it works perfectly fine.

If this is your echo output:

'{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001, "mkxnkT3kx9dsFS8V3qYydpL1o5F5MfwCvM":0.00001}'

Then you have too many quotes.  When you run echo, you should see:

{"mj2FrDhEomSzyQtRoGY78oVRPcQs5L5o95":0.00001, "mkxnkT3kx9dsFS8V3qYydpL1o5F5MfwCvM":0.00001}

That's because the shell strips off the outer set of quotes; it does that when you send the JSON to bitcoin-cli too.  Because you have the quotes there in the echo output, it implies that they're there in the bitcoin-cli command, so what you're sending Bitcoin Core looks like a JSON string rather than a JSON object.

This isn't asked in your question, but you might also want to look into the Debian/Ubuntu packages and commands named jshon and jq.  These help you process JSON in shell scripts.  Because they understand JSON, they tend to be a lot more robust the sed and awk.  I don't know if you need them for this script, however.


Copying my Blockchain account to Multibit Please can you tell me if it is possible to transfer my Blockchain account to Mulitibit.I want to keep my bitcoin address but back it up on Multibit.

You are looking for the export section on blockchain.info. This will provide you with your private key(s) so you can then import them on Multibit.

If you go to the "import/export" tab there will be an option to export your private-keys for every address in your wallet. There is also an import function that allows you to import a private-key into your blockchain.info wallet. You can click on export unencrypted and it will display your public and private-keys in a JSON output. The long string of what seems to be random characters after the "priv" is actually your private-key. The string of characters after the "addr" is your address. As you can see in my example there is more than one key exported. If you wanted to you could copy the private-key and then import it into another wallet program. This would allow you to access this address from more than one wallet service.

Never show anyone your private-keys.
I am only showing these keys for demonstration purposes.


Calculating Midstate in Python I'm trying to figure out the internals of hashing. I've read through a lot of the documentation but unfortunately most of it tends to gloss over the details. In fact I've yet to find a complete and accurate portrayal of a hashing procedure in an easy-to-read language like Python. So I thought I would try to do it myself. I am starting off by trying to verify the "midstate" that comes in every call to getwork (although soon to be removed completely as I understand).

I have been referencing this example in Go: https://stackoverflow.com/questions/9245235/golang-midstate-sha-256-hash/9322486#9322486

So I just hardcoded in the first half of the "data" field which would be returned by the getwork call

So here's what I've got so far:

#!/usr/bin/env python
import json
import binascii
import hashlib

#This function takes a hex string and reverses the order of bytes in every slice of 4 bytes
def hexbyteswap(string):
  swapped_string = []
  n = 8
  split_string = [string[i:i+n] for i in range(0, len(string),n)]
  for piece in split_string:
    binary = binascii.unhexlify(piece)
    binary_r = binary[::-1]
    swapped_string.append(binascii.hexlify(binary_r))
  return "".join(swapped_string)

#This is the first half of the data string, i.e. the first 64 bytes of the data field
fhalf="00000001c570c4764aadb3f09895619f549000b8b51a789e7f58ea750000709700000000103ca064f8c76c390683f8203043e91466a7fcc40e6ebc428fbcc2d8"

# run the byteswap
fhalf_bin_r_hex = hexbyteswap(fhalf)

#These following steps are where I'm having the problem
print hashlib.sha256(binascii.unhexlify(fhalf_bin_r_hex)).hexdigest()
print hashlib.sha256(fhalf_bin_r_hex).hexdigest()

So according to the Go article referenced earlier, I should get this out of my SHA function:

69FC72E76DB0E764615A858F483E3566E42D56B2BC7A03ADCE9492887010EDA8

Then if I run the byte swap again I will get the real midstate which is:

e772fc6964e7b06d8f855a6166353e48b2562de4ad037abc889294cea8ed1070

But I am NOT getting anything resembling that at all. I've tried two ways first putting the hex string into the Sha function and getting:

d3092f90cd1940d050b7a6f43063b081a82bc43c7fe202a5920721b858462a49

Then I also tried running unhexlify first and putting it into Sha (shown in the code above) which yields:

b55c86ea0314d1dea431923d46a18feed832f15ad535256516b796f6909e0dd0

Neither one of these is correct. What am I missing?

Trying to find this answer myself.  Noticed that the stratum_proxy is written in python and thus has the answer we are looking for.
https://github.com/slush0/stratum-mining-proxy/blob/master/mining_libs/midstate.py


What is the significance of Bitcoin Pizza Day, and when is it celebrated? Today, at Consensus 2017, some people were talking about getting Pizza to celebrate Bitcoin Pizza Day. What is the  story behind  that, and when is it celebrated?

Bitcoin Pizza Day is celebrated on May 22nd. On this day in 2010, a BitcoinTalk member bought pizza in exchange for 10,000 BTC. This represents more or less the first known transaction using bitcoins for actual goods.

The original post: Laszlo announcing his purchase in 2010

The significance has been growing especially now, because... of how much that 10,000 BTC would be worth today.


Shared Wallets and Syncing A few clarifications about running the bitcoin client (let's say bitcoin-qt) on multiple machines on a private.

Question is sort of hypothetical but I was hoping to get some insight into best-practices.

Suppose I want to share a wallet between 2 machines and have both automatically update whenever there is a send/receive.  I imagine one way to do this is to have a single wallet.dat file available on one of the machines and have both clients point to it.

Or on another server somewhere or even some cloud storage account.  So my questions are:

Is this even possible?
If so, is it considered safe or a good practice?  Should/can you share the blockchain db files as well?
Would the wallet encryption cause any issues with this?
What if the clients are running on different OS?
Any alternative non-cloud solutions ?  Like keeping it on one machine that will allow (secure) remote access from the other?

Of course one could just use a blockchain.info or other e-wallet and problem-solved.  Although that solution has its own inherent issues as well.

yes, it's complicated, you need to run the equivalent of remote desktop to gain access to the user/date file where the wallet.dat file is and the related block chain information.  Even with Linux, you can not set multiple users with the same block chain information and wallet with out some form of ' fake access ' to that particular machine as that particular user.

2.Considered extremely unsafe and bad practice.  Anyone with the right network tools could intercept your contact to the host and copy enough to log in as you and send the whole wallet to their own with no way of reversing the transaction.

no, once you have access on the host machine for what it cares is that user typing in to it, no stopping someone from remotely sending all your coins to their wallet or you sending your transactions from that one wallet if there is the coins for it.  The passwords and such would seem to the host system that the user was at the keyboard typing.
I recently switched to Ubuntu ( Linux ) from XP due to the amount of times remote assistant or remote desktop kept re-re-re-installing itself.  Any operating system that allows remote access will not have an issue with any other operating system connecting to it, passing authentication, then treating the incoming commands ( no mater how self destructive ) as if they were at the keyboard.
Alternatives is to have the ' current ' block chain on the systems, close Bitcoin, replace the wallet.dat from a backup ( each time ), wait for the rescan, do the transaction, close Bitcoin, put back the non-shared wallet.dat file so that it prevents any one else accessing that unit from getting a copy of your wallet to spend hours hacking.  The wallet info is the wallet, the block chain is the copy of ALLLL transactions.  No wallet, no way to send from that address, Bitcoin will create a new ( empty ) one on start up if there isn't already one.

Agreed on the Blockchain wallet option, every online wallet has the cost per transaction issue and you can set so few transactions as a bulk send with it.  The best option is just have one wallet on one system that has remote administration removed, no remote desktop and you physically at the keyboard to send.  The VPN ( Virtual Private Network ) option still would require remote desktop ( SSH connection as ROOT in the Linux world ) to log in and open the Bitcoin Client as a specific user on that system to gain access to that particular copy of the block chain and that particular wallet.  Part of the built in security is where the wallet is stored.  In Windows, it is in the logged in user's application storage directory  ( documents and settings\user\Bitcoin ) and only THAT user can get Bitcoin-QT to access that particular directory.  As an option to look in to, the owner of Slush's Pool ( Bitcoin mining pool ) was working with some people on a portable wallet.


Something similar to blocknotify but for new transaction Based on bitcoind, I noticed several derivative work like bitpay insight has the ability to push new block and transaction realtime to browser.

Reading document of bitcoind I see that bitcoind have blocknotify which let me achieve similar thing for block. But there is no equivalent for transaction. I would like to be notified whenever a new transaction is sent to my node, how can I do it with bitcoind?

Have a look at the Bitcoin Core ZMQ possibilities. Using blocknotify (or walletnotify) seems very inefficient (the fork a new process each time).

ZMQ does allow to have a IPC push channel from Bitcoin-Core to your client application (from there you could emulate a websocket or something that talks to your web-clients).

https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md

ZMQ is fast and relatively reliable, although has currently no wallet features (you can't get notification on wallet events, only on "global" events [new tx, new block]).


How would a centralized block chain work? If I'm a company who pays my employees and my supply chain with my own currency created on a block chain and they can spend it wherever it is accepted, would I need a POW or POS scheme to maintain the veracity of the ledger of transactions?  Or is there a way to validate the transactions and history of the ledger via centralized control?   Could it work like this:

Only my company could create my currency, so there's no way to counterfeit it.
Everyone who accepts my currency uses software at the point of sale that verifies the transaction and the history of the ledger.
Each unit of currency is embedded with personal ID that transfers to the next person with their personal ID until it eventually recycles back to me, the issuer.

Would I be able to eliminate double spending and fraud in a centralized system without the miners?

Sure. You just use a database that keeps track of who has how much money. You can do this any way you want. You don't need anything fancy like POW, POS, or even a blockchain. The only reason you would need or want these things is to permit decentralized operation without a central authority. If you are the central authority, what you say is law just because you said it. So no need for anything fancy.


When the UTXO in the cache is full, what strategy is used to replace one UTXO with another in the cache? The UTXO set is stored on the disk, but some UTXOs are also stored in the cache. When validating a transaction, you need to query the UTXO pointed to by the input of the transaction. First, you go to the cache to find it, if it's not found, you need to go to the disk to find the UTXO. Due to the characteristics of levelDB, the UTXO searched on the disk needs to be written into the cache. If the cache is full at this time, how does the node make room in the cache for the UTXO just found?

The UTXO set cache is not a fixed size and the limit isn't a hard limit. New entries can be added to the cache without regards for the maximum cache size. In fact, the cache object itself doesn't even know what the limit is.
Rather what happens is that the cache is flushed periodically. Because the UTXO set only changes during block validation (mempool UTXO set is handled separately elsewhere), this periodic flushing is primarily tied to incoming blocks rather than a timer. After each block is validated, the node determines whether it should flush the cache to disk. There are several conditions that would cause a flush, including being close to the cache limit, and being over the cache limit.
So if during the validation for a block, the cache became full, it would actually just keep growing until the block is fully validated. Then at the end, the entire cache would be flushed to disk and the cache emptied.
Note that LevelDB itself has a cache that is independent of the UTXO set cache.


When will the public key of an address used in the network? On block explorer there are some address with public key available, and some without.

(e.g. this one has public key:

http://blockexplorer.com/address/1HBheYzvX7NDtcwVrMS7gxReNRVezYS7w2 ,

and this one doesn't:

http://blockexplorer.com/address/1111111111111111111114oLvT2)

Why is that?

Is it because one has money sent out and one doesn't?

If I understand correctly then the public key is included in the transaction out of an address, is that right?

The 1111111111111111111114oLvT2 hasn't been spent yet whereas 1HBheYzvX7NDtcwVrMS7gxReNRVezYS7w2 has.

To spend, the public key is part of the INPUT's ScriptSig:

http://en.bitcoin.it/wiki/Transactions#Explanation

So until there is a spend transaction, the public key isn't known to the network, just the Bitcoin address.

Related: Why is it impossible to derive public key from address?


Getting a crypto proof UTXO set How to get a list of unspent transactions outputs (UTXO) from local files?

Where is stored this data? In what files this data is fully present?

I understand that this list is in "chainstate". But may be there is a more secure way to get it?

I try to extract it from the local files which Bitcoin Client dumps on disk.

I think there would be a "Crypto-proof UTXO set".

I've been working on this as a part of a bigger Bitcoin tools Python 2 library for a while. You can find it on github.

You can run the code on ldb_parser.py which will give a txt with all the UTXOs from the chainstate parsed in a json. (Notice that this is a huge amount of data.)

Then you can call the decode_utxo function using the data from the json and store the result in a file to analyze it. (This file will be even bigger!).

Here you have an example (once you have run ldb_parser.py):

from bitcoin_tools.utils import load_conf_file, decode_utxo
from json import loads, dumps

fin_name = "utxos.txt"
fout_name = "parsed_utxos.txt"

# Load config file
cfg = load_conf_file()

fin = open(cfg.data_path + fin_name, 'r')
# Output file
fout = open(cfg.data_path + fout_name, 'w')

for line in fin:
    data = loads(line[:-1])
    utxo = decode_utxo(data["value"])

    fout.write(dumps(utxo) + '\n')

fout.close()

And each line you will get in parsed_utxos.txt look like:

{"coinbase": 0, "version": 1, "outs": [{"index": 1, "amount": 14250000, "out_type": 0, "data": "865e218ff25929eee880e0e3b6f95280b2d05443"}], "height": 468349}
{"coinbase": 0, "version": 1, "outs": [{"index": 0, "amount": 132000, "out_type": 1, "data": "0b2a00367244680f6da18acd861a08f0a89cb3b4"}], "height": 449294}
{"coinbase": 0, "version": 1, "outs": [{"index": 1, "amount": 2423800, "out_type": 1, "data": "7f172a63c49c5d03e3307d432bd6b784b69d0e0d"}, {"index": 2, "amount": 10000000, "out_type": 1, "data": "1d0c4b60e8270f9b6ca5f167f08a5466a0cee565"}], "height": 474328}
...

Where each entry in outs in an output and, and data corresponds to the transaction data (hash160 of the address for P2PKH transactions).

Now, you have to take into account some considerations:

Not every single UTXO is a P2PKH, so what you will find in data depends on the out_type field.

out_types 0 and 1 correspond to P2PKH and P2SH respectively, and will have 20 byte of data (hash160 of the public key for P2PKH and scriptHash for P2SH).

out_types 2,3,4 and 5 correspond to P2PK outputs, and will contain 33 bytes of data (1 byte for the type of public key and 32 bytes for the actual key).

Finally, any other out_type will imply that the data hold by the UTXO is not compressed, and the value will correspond to the data size + the number of special scripts (nSpecialScripts) which is currently 6). This is the case of P2MS transactions and non-std transactions.

All this has been directly extracted from the Bitcoin Core source code.

Finally, notice that in order to use the library you will need to install the python dependencies in requeriments.txt and create a conf.py file to set your chainstate path and data path (or modify the code to not use the config file).


Wallet passphrase uniqueness (noob question) The Mycelium Wallet has created a Bitcoin wallet for me, then I've written down a 12-word passphrase for the wallet backup. However it looks like a set of words (in the Mycelium) to generate these phrases is limited - at least I've got a passphrase with one word repeated two times.

How can I make sure this passphrase is unique in our world where more than 7 billion people live?

The chances of someone "brute-forcing" or guessing your seed is extremely slim. There are more than 5 duodecillion possible combinations of twelve-word seeds. Just so you get an idea of how big that number is, it's more than 1 thousand million million million million million million possibilities.


How can I create the input of raw transaction through the previous UTXO hash and the unspent index in bitcoinj？ I want to create a raw transaction’s input and output, and sign it then broadcast to testnet. Now I know how to create the output, but I want to refer the transaction that I can input the UTXO hash and the unspent index, then add the input to this raw transaction.

here's how to create an unsigned raw transaction in typescript with one input and one output.

import * as bitcoin from 'bitcoinjs-lib'

const reverseHexBytes = (hex: string) => {
  const buff = Buffer.from(hex, 'hex')
  return buff.reverse().toString('hex')
}

const fixedPoint = (num: number): number => {
  return parseFloat(num.toFixed(8))
}

const outputAmount = 100
const inputTxHash = 'tx-hash-goes-here'
const index = 5
const fee = 0.001
const numOutputs = 1
const outputAddress = 'address-to-send-to-goes-here'

// input
const txInputs = '01'
const txHash = reverseHexBytes(inputTxHash)
const outputIndex = '0' + txIndex.toString() + '000000'
const script = ''
const sequence = 'ffffffff'
let tx = txVersion + txInputs + txHash + outputIndex + script + sequence
// output
const countHex = numOutputs.toString(16)
const countByte = (countHex.length === 1) ? '0' + countHex : countHex
tx += countByte
const amount = fixedPoint(outputAmount - fee)
const outputAmount = Math.floor(amount * (10**8))
let outputAmountHex = outputAmount.toString(16)
while (outputAmountHex.length < 16) {
  outputAmountHex = '0' + outputAmountHex
}
const outputAmountBytes = reverseHexBytes(outputAmountHex)
tx += outputAmountBytes
const pubkey = bitcoin.address.fromBase58Check(outputAddress).hash.toString('hex')
tx += '1976a914' + pubkey + '88ac'
// lock time
tx += '00000000'

check out the protocol documentation for more specific information: https://en.bitcoin.it/wiki/Protocol_documentation#tx

note: i copied and edited from something i've implemented previously, so if there's a mistake just let me know and i'll update it.


Why is sharding not possible with a distributed blockchain? Hi guys I've been reading a lot about the problem of scalability in crytocurrencies and how to run a full bitcoin node is not a possibility on a mobile device for example, as a result we become relient on centralised 'power nodes',

My question is: what is it about the datastructure which makes sharding the full blockchain across many lite devices not possible?

For example node 1 stores blocks 0-100, node 2 blocks 101-200, etc. A node wishing to verify some transaction can then just keep pinging nodes until they connect with a node which is storing the data they're interested in.

Apologies if this is a noob question, still got a lot of learning to do!

Your question is a little unclear as it only talks about storing, and not really about validating the entire blockchain. Storing is actually not the problem. Recent versions of Bitcoin Core support crude pruning and work is underway to make it more flexible.

However, to be truly trustless a full node still needs to download and validate the entire history of all blocks (even if deleting that history seconds later). This is what David Schwartz answer comes from: you need a complete history to know whether a transactions was NOT in it.

So in that regard pruning doesn't help mobile devices much.


Why does coinbase make 2 transfers instead of one I'm new to bitcoin in general and coinbase.com in particular. Can somebody explain what happens when I order a payment (in bitcoins) from their web interface?

Say that my acount owns 1 BTC. I create an address AAA to pay 0.1 BTC for my loaf of bread to my baker's address BBB. I order the transfer from coinbase.com web interface, and looking at blockchain.info, I see the following (amounts rounded):

// webUI says I own 1.0 BTC

AAA  pays 0.1032   --> X = 0.1     BTC to BBB (my baker)  // what I wanted
                   --> Y = 0.0002  BTC as network fees    // fine with that
                   --> Z = 0.003   BTC to CCC             // what is that ?

// after payment, webUI says I own 0.8998 (= 1.0 - X - Y)
// The mysterious Z = 0.003 BTC have *not* been removed.

But what is that 0.003 BTC transfer to an address I don't know CCC? Apparently I own this address, or at least coinbase.com does on my behalf. Is it a standard way of processing I'm not aware of? Is it a safety feature managed by coinbase to authenticate the transaction?

Obviously there are a lot of informations on this reddit, but it's too technical for me.

When you receive money, a UTXO (unspent transaction output) is generated and assigned to your address. When you want to spend money, you can only ever spend entire UTXOs. However, you may have received 1 BTC but you only bought goods worth 80 mBTC in an online shop, so you don't want to send your entire 1 BTC UTXO to the merchant.

Enter change. A transaction can have an arbitrary number of outputs. 2 outputs to different addresses are very common. In the scenario described above, you send 80 mBTC to the merchant and 920 mBTC back to you. The latter is called change.

Now, it is possible to send the change back to the address you sent the money from. This way, it's possible to only ever use one address to hold your money. However, people could learn that that you always send from that address and associate it with you. This means reduced privacy.

It's of course not as bad as with banks where it's cumbersome to open a new account, everyone who sends money to you or receives money from you knows your name, you even have to use your ID to get an account in the first place, and in most cases people can even steal money from you when they just know your bank information which everyone you ever exchanged money with using that account knows.

But if it's worth doing, it's worth overdoing, because people. companies, and governments are still trying to figure out who made which transaction. To make this harder, wallet software uses new addresses for each transaction. You cant still receive money again and again payed by different people to the same address and will be able to spend it but if you get an arbitrary number of addresses completely for free, why not take the opportunity to improve your privacy? Some wallets let you control where the change goes but there aren't many reasons to not use a new address each time.


How will X509-validated payments request work? (AKA "The Payment Protocol") I'm looking for an overview and requirements on how this will work... including

Root CA selection (across the platforms)
What does the request look like?
How does the payment "flow" look like?

The main benefit of the Bitcoin Payment Protocol (seen in BIP 070)  is to provide for a better customer experience and better security against man-in-the-middle attacks on the payment process.

See this BitcoinTalk announcment and information from the Bitcoin Foundation.  The code for this is located in the PaymentServer.cpp file

  How are Root CAs selected?

Root CAs are selected from this Mozilla root CA list.  Although I haven't seen anything to verify this, but I hope there is a way to account for Certificate "extended key usage" in the PKI hierarchy.

  What does the request process look like?

No GUI screenshot of this process is available (yet), but a workflow of the process looks like this:


Multibit client synchronizing since 10 Days now I can not access my wallet, since 10 days now, I have downloaded the bitcoin-qt multibit version 0.5.13. On my HP-window 7- 32 bit laptop successfully and I immediately received 2 transactions simultaneously which was successful too, I could only rehearse with my transaction on the screen for just few hours, since ten days now.
I have been trying to open my wallet and make some transaction with my coins, but when I launch the multibit client platform as usual the screen start downloading blocks and synchronizing with network, this will go on for the whole day and stop at a particular point without access to my wallets, it has finally stopped at synchronizing with network 119 blocks to download.

I had mistakenly created 3 more empty wallets with my first and original wallet while looking for means to bring back my wallet to life. The four icons of the wallets are visibly displayed on screen, I have even tried to reset my block chain and transaction to see if any of the wallets can pop up, but they seems to be clinically dead, because the synchronizing therein always stop at 88%.
The download and synchronizing manner of this multibit client platform had finally exhausted my internet bandwidth for the month, I think the slow performance of my computer may have contributed to this drama also.

MY COMPUTER: HP LAPTOP CORE 2 DUO T5750 - OS WINDOW 7 ULTIMATE SERVICE PACK 1, 32 BITS, 2GHZ, MEMORY RAM 1GB, I am using a 3G broadband HSDPA 7.2MBPS network.

disk transfer rate 4.8mbp/s, graphics 4.0mbp/s, ram 4.5mbps/s, processor 4.7mbps/s and the total base score 4.0

Computer troubleshooting report -- programme compatibility details --incompactible application -- (multibit) detected.

I am not too familiar with IT technical jargons, but this information might be usefull to whomever would help me out.
I do not even have the address of my first and original wallet off-head, but the wallet was protected with a password before it disappeared.

Questions: how can I recover my address and my first wallet, and how can I migrate with my wallet to a light client or hassle free web-wallet.

Concerned people, if there is anything like going to the 'file' in my download to recover my wallet there, please help explain in details as am new to the whole computer stuff. thanks in advance.

I haven't used MultiBit, but according to the Exporting private keys page in the documentation, you should be able to get the private keys. You can then import them to another client (local or web) and sweep the coins. For an example of how to do this with blockchain.info, see the Moving a wallet between MultiBit and blockchain.info.


What contributes more to bitcoin network? Using Bitcoin-Qt or running a miner? What would make a better support for bitcoin?
Does it really makes any difference to store blockchain locally instead on a remote server?

What do you mean contribute to Bitcoin? What is your goal?

If the goal is to help with the propagation of nodes, then setting up a bitcoin-qt on a server is nice for the infrastructure and probably the best for a long-term, good guy greg operation. Become a trusted node, add to the infrastructure.

Coins are mined at a steady pace. There's no threat of them being disrupted or mining operations to discontinue. If anything there's a growing number of miners and the difficulty rate is adjusting to match that.

The best thing you can do for Bitcoin is to continue to use it (marketing), or apply one of your skills to its community (entrepreneurial, development, marketing, design, or other). Make a cool Bitcoin t-shirt (and sell them), buy something using Bitcoin, sell something using Bitcoin. When you encounter something difficult in your use of Bitcoin, make suggestions on how it could be improved. People will listen. Your opinion is valuable and matters.


How can I pick up the blockchain download where it left off on another computer using an EHD? I started downloading the Bitcoin blockchain via my MacBook Pro onto my 1TB external hard drive. I want to use my iMac to finish the download. I plugged my EHD into my iMac and checked to blocks folder and it contained the previous transaction I downloaded (86GB). The wallet.dat, peers.dat, chainstate, banlist.dat and fee_estimates.dat files. I opened Bitcoin Core and moved the directory to the blocks folder where the previous transaction I downloaded are. I followed the steps to start the sync. I expected the blockchain to recognize the blocks and start where it left off on my MacBook but it started from the beginning. Any ideas on how to pick up where I left off?

Even if you transfer all the data from a fully synced client, the bitcoin client still needs to validate those blocks. It will still take a while, but should be quicker than downloading all the data and verifying.

ANSWER IS NOT ACCURATE.
EDIT: If you copy the chainstate, there shouldn't be any work the receiving system should perform anymore - the software wouldn't even know it was moved. It's possible the wrong directory was used.


What exactly is a "blockchain developer"? Hello everyone. This isn't specifically a bitcoin thread but due to recent events I think it is important that people get an understanding of the real Elon Musk as I have no doubt he will try and reenter the cryptocurrency space again in the future as some kind of figurehead. This is of course despite the fact that he is not a blockchain developer and has made no real contributions to the space but he appears to find the need to attach himself to any kind of new technology and take credit for it. This is a familar pattern, he is neither an expert on artifical intelligence, neuroscience or infectious diseases such as Covid-19 but is able to convince people that his opinion is always worth listening to.

Source: https://old.reddit.com/r/Bitcoin/comments/nbq16s/the_real_elon_musk/
(Emphasis added by me.)
Every time I hear somebody mention "blockchain", it always comes off as if they have no idea what they are talking about. Have I missed something? Why is there such a focus on something they refer to as "blockchain", sometimes "Blockchain", as if this is some sort of "service" that magically exists somewhere on the Internet and which Bitcoin and other "cryptocurrencies" build on?
Isn't "blockchain" just a simple word to refer to the "chain of blocks" that make up the technical structure of Bitcoin? If so, why does this person and many others use it in such a strange manner? A "blockchain developer" makes as little sense as a "TCP/IP developer"; it's just a technical, non-tangible "infrastructure" of sorts. It sounds to me like referring to a plumber as a "pipe developer", even though they never touch or create any of the pipes in the ground, but merely fix clogged ones in individuals' homes.
But since I'm asking, I'm obviously doubting myself. Maybe I have actually missed something?

In bitcoin core "block chain" is used at lot of places and all the pull requests to change it since 2014 got NACKs so never changed
https://github.com/bitcoin/bitcoin/pull/5242
Satoshi mentioned 'timechain' : https://bitcointalk.org/index.php?topic=382374.0
The timechain is a tree shaped structure starting with the genesis block at the root, with each block potentially having multiple candidates to be the next block.  pprev and pnext link a path through the main/longest chain.  A blockindex may have multiple pprev pointing back to it, but pnext will only point forward to the longest branch, or will be null if the block is not part of the longest chain

Isn't "blockchain" just a simple word to refer to the "chain of blocks"

Yes
According to a definition mentioned in one of the slides used by Andreas in video: https://youtu.be/FYo5E7zT-vM
Blockchain is the public ledger where the network records are written.

Why is there such a focus on something they refer to as "blockchain", sometimes "Blockchain", as if this is some sort of "service" that magically exists somewhere on the Internet

Not sure when people started using the word "blockchain" as technology, became a buzz word and now used for lot of things related to applied cryptography and cryptocurrencies.
There are few more concepts which use 'chain' in it: sidechain, statechain, spacechain, softchain, etc.
So I am assuming few developers that are involved in something related to cryptocurrencies categorize themselves as Blockchain developers.


transaction creation failed I am using bitcoin Qt
version v0.7.0-beta and when I tried to send a transaction (1.5 bitcoins) I received a message

transaction creation failed

what can be the reason? Few minutes ago I sent 0.1 bitcoins and it was accepted. Three hours ago I sent 0.3 bitcoins and it was accepted and received on the other side.

I tried to restart the wallet but this still happens.

P.S. I do have more than 1.5 bitcoins when I am trying to send them.

Just a few observations. I tried to send 0.3 and 0.5 bitcoins one more time and it works with both of them.

Just tried one more time to transfer some bitcoins to another account in BitCoin Qt (version v0.8.3-beta - the newest at the time of writing).

This time I am getting some additional error message, which is still is not useful.

Transaction too large

and right after it another one

Error: Transaction creation failed!

P.S. just few days ago I updated the client to v0.8.5-beta but the problem still exist.
I really want to spend my bitcoins, but can not do this. I also tried different addresses.

Transaction too large

Is your wallet made up up of many, many small amounts? Have you visited any sites giving small amounts of Bitcoin away for "free"? If so, your client is coughing up on the fact that all the small transactions are costing more than the fee they incur to spend.


Get confused on the merkle tree algorithm From page https://en.bitcoin.it/wiki/Protocol_specification , I understand the merkle tree works like

  merkle([a,b,c,d]) =  h( h(a,b), h(c,d) )

But when I do the stratum protocol http://mining.bitcoin.cz/stratum-mining/ , it works something like this

  merkle([a,b,c,d]) = h(h(h(a,b),c),d)

And here is the code

def build_merkle_root(self, merkle_branch, coinbase_hash_bin):
    merkle_root = coinbase_hash_bin
    for h in self.merkle_branch:
        merkle_root = doublesha(merkle_root + binascii.unhexlify(h))
    return binascii.hexlify(merkle_root)

Do I miss anything?

The Stratum server is delivering a partially hashed merkle branch in the response… for which the miner needs to provide, ‘A’ (the generation/coinbase transaction) concatenated with the ‘first’ transaction (B). The remaining elements of the array are ‘pre-computed’ portions of the merkle tree. As indicated on slush’s bitcoin.cz site (http://mining.bitcoin.cz/stratum-mining) “merkle_branch - List of hashes, will be used for calculation of merkle root. This is not a list of all transactions, it only contains prepared hashes of steps of merkle tree algorithm.”

The items returned by the Stratum server for the merkle branch are essentially [b,h(c,d)…] pre-computed to reduce the number of calculations required later to complete the merkle root.


Checking for confirmations using getrawtransaction and decoderawtransaction I am trying to check if a transaction is confirmed or not via RPC commands. At first I tried to use gettransaction, but it doesn't work.

Then I use getrawtransaction and decode it:

{
   "lock_time":0,
   "size":192,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"5352d8186b825128a7d4a0df0a8c105da70c81ec763209271566a512fee14cee"
         },
         "script":"483045022100fae0b1dbe08f79a92debde8f3a8e955bcff9ce928b86fb217cfd830af6937386022072386b28a288408bad05426704b55f14a4ad4bf3927ac053facda4478c467eae0121034756f0f954f40ed7dabcaa80c4212a240e4b2c1eee7532bd06cac58c173faf3f"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"931d220f622a9b029cea3e09ca7a9c11f3714c68f9bd272ca97cd915b518050d",
   "vout_sz":1,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 0f14a815e42dcdff9c8239a7393b2a9a63a8b68d OP_EQUALVERIFY OP_CHECKSIG",
         "address":"12Njt85fc9Kr7s8tr3Eug4tvkZQUhcGXfz",
         "value":100000000,
         "script":"76a9140f14a815e42dcdff9c8239a7393b2a9a63a8b68d88ac"
      }
   ]
}

And I got the above result. But I don't understand what is written, how can I know if it has been confirmed without relying on Blockexplorer?

Thanks

The decoderawtransaction RPC call oddly omits the confirmations field in the resulting JSON output. Instead of using decoderawtransaction, try this:

$ bitcoin-cli getrawtransaction <tx_id> true

(Notice the "true" at the end, which means "output as json")

This will return JSON that has a "confirmations" field in the top level of the returned object.


Is there a risk of double-spending when making a face-to-face transaction? When exchanging funds or services face-to-face, is there a risk of a double-spending attack? If there is, how could it be technically done?

I proffer that it would depend on the tools used to make the transaction and broadcast it.

Assuming use of something like Bitcoin Wallet for Android or even a laptop running Bitcoin-Qt, the chances are very unlikely.

A malicious user would have to connect to the network with two devices simultaneously and broadcast the real transaction (the one being "sent" to the vendor) milliseconds after the malicious transaction. The vendor's client would have to see the real transaction before the malicious transaction, give the item to the malicious buyer, and depart company before realizing he's been had.

Simply put, a malicious user would have to be connected to more nodes in the network than the vendor and NOT be connected to any of the nodes to which the vendor is connected when broadcasting the malicious transaction, probably out at least one or two degrees of separation. This would ensure enough latency to ensure the vendor sees the real transaction first and surrenders the goods before the vendor's client says that other nodes think another transaction is of higher priority.

All of this can be avoided by waiting for a confirmation, but in real commerce, that may not feasible.


What happens if there are no transactions in a block? What happens if there are no transactions in a block?  Suppose there is a 10 minute time frame  in the middle of the night, maybe on a holiday, and there are no transactions made.  Do the miners get paid 50 bitcoins for processing a zero?

The mining reward must be collected with a transaction, so technically there is at least one transaction in each block.

The mining reward was designed to enable the initial distribution of bitcoins and to encourage the creation of a powerful bitcoin network with a lot of computers to support it, therefore it makes perfect sense that a miner gets the block mining reward regardless of how many transactions were included.


What is the most optimal way to parse a raw bitcoin block with python? Let's say one is connected to a zmq socket and listening for rawblock. How you'd parse the block header is as follows:

block_header = raw[:80]
version = block_header[:4]
prev_merkle_root = block_header[4:36]
merkle_root = block_header[36:68]
timestamp = block_header[68:72]
bits = block_header[72:76]
nonce = blockheader[76:80]

But, what is the best way to parse all the transactions in the block? Converting a rawtx to a tx object is easy, plenty of libraries do it. But what is the best way to parse a variable length block of txs?

We will compare modern libraries with segwit and bech32 support.

First will be pybtc from bitaps.com, second will be btcpy from chainside.net

Our test code:

import time
import pybtc

f = open('raw_block.txt')
fc = f.readline()
qt = time.time()
block_hex = fc[:-1]
bt = pybtc.Block(block_hex, format="decoded")
print("pybtc library parsed block in decoded format", time.time() - qt )

qt = time.time()
bt = pybtc.Block(block_hex, format="raw")
print("pybtc library parsed block in raw format", time.time() - qt )

from btcpy.structs.block import Block as btcpy_block

qt = time.time()
block = btcpy_block.unhexlify(block_hex)
print("btcpy library parsed block", time.time() - qt )

Raw block that used you can download here

Test results:

pybtc library parsed block in decoded format 0.3380300998687744
pybtc library parsed block in raw format 0.0953378677368164
btcpy library parsed block 0.6518878936767578

You can see that pybtc block parse performance is better. Decoded mode means that all bytes converted to hex and addresses to base58 or bech32. Raw mode faster, but all objects in raw bytes, addresses stored as hashes.


Am I legally allowed to accept fiat currency online and return a counterparty asset/token? I want to sell the tokens (counterparty asset) for my online game via standard shopping cart. Is that "legal" or is my only option to trade BTC for the token via exchange?

It depends on where you live, where you sell and who the buyer is.

If your jurisdiction regulates this stuff or your buyer is say, a US citizen, regulations may apply. You may be able to work around that by implementing certain basic rules such KYC/AML, either full blown, or basic (such as the user confirming they're not a US resident or citizen, etc.)

There are several games that do exactly that on the Counterparty platform without issues, but that doesn't mean anyone can do it.

Recently there's been a growing number of regulations about ICOs and "tokens", so best check with someone who understands laws and regulations that apply to your territory and is qualified to give legal advice.


Does Proof of Stake Lead to a Positive Feedback Loop? (I may have horribly misunderstood PoS, so be gentle!)

Reading about PoS, the general idea seems to be that each miner has a "hit rate" proportional to their coins / total coins in the system.

Now, if there is a reward (generation, fees, etc.) for successfully mining a block, we seem to have a positive feedback loop. A richer miner has more chance of solving a block and so their wealth would increase at a greater rate than a poorer miner.

Does this means that the richest miner in the system only needs to keep mining till they are rich enough to mount a 51% attack?

Even if the dynamics are interpreted in the most basic way, it does not lead to this positive feedback, rather it maintains the status quo. If there are miners with stake of 40%, 30% and 30%, they will get 40%, 30% and 30% of the rewards respectively, so the ratios will remain at 40%, 30%, 30%.

For example, if they start with 40, 30, 30 BTC, and 10 new coins are generated, they will be distributed 4, 3, 3, so the new wealth will be 44, 33, 33, which is still a ratio of 40%, 30%, 30%.


lower bound of block size towards increased speed of propagation As far as I know there is an upper bound of a block, which is one megabyte, is there a lower bound?

It was in terms of a race condition that I was considering this.

Imagine you make a double spend and then you try to propagate a block that contains only your second transaction. If so it would be much smaller, ipso facto easier to propagate around the network and get validated by nodes, isn't that right?

Maybe someone in the mean time would find a valid block for one containing many transactions, in which case it would be longer than yours, and maybe other miners would extend that- but maybe not.

Does anyone want to try this out on the testnet with me?

There is a lower bound: Blocks must include at least one transaction, the Coinbase. ;)

The advantage of a smaller block has been somewhat overstated in the past, as it usually doesn't matter much, especially since the relay network got improved with Compact Blocks, a compressed block format that significantly reduces the peak bandwidth required to propagate blocks.

Basically, for a smaller block to have a relay advantage over a larger block the two blocks would have to be found within less than 5 seconds of each other. This only occurs once every two to three days and thus is hardly a significant quantity to optimize for in comparison to the chance of even finding a block to double spend with in the first place.


Will cryptocurrencies that have a finite supply (like 21m btc) cause deflation? I figured out that cryptocurrencies can cause a deflationary spiral, since the cap is the same (eg. 21m BTC) but the economy is growing. That would only happen if all coins are mined.

But deflation would usually lead to a recession. Is there a way to prevent that?

I've done some research, like on the Bitcoin Wiki page deflationary spiral, but I don't seem to understand why deflation won't happen.

  The ‘deflationary spiral’ is a real condition that affects the popular fractional reserve backing system. Bitcoin is not affected by this because it is fundamentally different from popular currency.

Yes, cryptocurrencies that have finite supply are bound to create deflation. This is because the same finite supply of coins will represent an increased economic output that results from technological innovations. Thus the value of a coin is worth more tomorrow than today thereby increasing its purchasing power. However, if this deflation is bad is highly debated in the economic circles and there seems to be no concrete consensus on it.

The critic about deflation being linked to deflationary spiral stems from the great depression of 1929. The deflation in the economy post the great depression increased the real value of debt thereby compounding the problems of economic recovery. Moreover, because of deflation people hoarded money rather than spending it exacerbating the effects of recession. If you look at deflation from this lens then it could be deemed as hurtful as it prevents actions that could potentially stimulate the economy.

However, this can also be viewed from a different angle. We have seen the effects of deflation only in times when our economy was in trouble and there was a complete collapse of demand. Deflationary characteristics of Bitcoin is not based on collapse of demand, but a very predictable supply.

You will also see that a lot depends on the type of money used in the economy. Fiat money is based on debt: government issues bonds and the central banks buy these bonds by printing money. However, Bitcoin has properties that makes it resilient to credit expansionary forces thereby delinking it from public debt. Thus comparing the deflationary aspects of fiat money to the deflationary aspects of Bitcoin is like comparing apples to oranges.

Some people point out that deflationary nature of Bitcoin will lead to hoarding practices and hence lead to fall off in demand. I think it's a fallacy, since purchases related to houses, food, cars etc. will continue to happen. They help you make investments that could produce a higher return than the appreciation in the value of Bitcoin over the same period. For example, using a car helps you get to your office faster and be more productive, there by increasing your year-end bonus. I believe, only investments in assets that people currently invest to protect them from inflation (second home, gold, arts etc.) will reduce. Demand related to consumable/depreciable goods will continue to remain steady.

I'll sign off with a food for thought. The price of electronics gets cheaper every year, still you do not postpone the purchase of your electronic gadget in anticipation of price reduction as it helps you achieve other important goals whose return is higher than the price decrease over the same period. This can be extrapolated to the spending characteristics in hyperbitcoinized world.


What is the maximum size of the memory pool? The memory pool holds unconfirmed transactions in RAM. It seems that memory pool storage could overflow if no block is solved for a very long time and many transactions are published within a short interval.

In browsing the source code, I found no mention of a cap on the memory pool size:

https://github.com/bitcoin/bitcoin/blob/v0.10.1/src/main.cpp#L934

Does such a cap exist? If not, couldn't an attacker use the unbounded size of the memory pool to overflow the RAM of a large number of nodes, knocking them offline?

I noticed two proposals that seemed to address this issue, but neither has made it through the approval process:

Mempool Superblock
Mempool Janitor

There is no cap on the maximum size of the mempool, nor a janitor which cleans up transactions which are not confirming. Loss of unconfirmed transactions isn't a problem as wallets are supposed to rebroadcast transactions if they don't confirm within a reasonable time frame, so it wouldn't be unreasonable to drop them in a critical low memory situation. The limit on free transaction relay is there partly to prevent this from being an issue, it would be fairly expensive to pack the mempool with junk from a fee standpoint.


How to create the data parameter for a PSBT? I am sure this is a dumb question but if using:

bitcoin-cli walletcreatefundedpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"

How do you create the data parameter? Where does it come from?

\"00010203\"

Edit:

I should have read the BIP first, it looks like it is an unsigned tx. So in order to create a PSBT you need to first create an unsigned tx? And include the hex as an argument.

A PSBT contains an unsigned transaction that has all of the inputs and output that you want. The other data PSBT allows for are put in around that unsigned transaction.

Here, data just means that the unsigned transaction will have an output that has an OP_RETURN followed by whatever data you want. This directly reflects what createrawtransaction. data is not specific to PSBT nor is it necessary.


What's the consensus on using a non-networked VM as a cold wallet/airgapped computer? I'm wondering if connecting a hardware wallet like a Ledger Nano S to the Ledger Live desktop app running on a computer that's connected to the internet not considered a 'fully cold' wallet setup. How about installing/running the Ledger Live app inside a VM that has the networking components disabled? I know that there is a possibility that VMs can be breached or compromised but I'm thinking that the probability of accessing the private seed or spend key would be low to non-existent.

Has anyone have experiences or research data on this subject?

The host running a virtual machine has complete, unfettered access to its guest, there's no breaching or compromising necessary. It provides absolutely no additional security in your described situation. It is likely trivial to access ECDSA private key material even between two unrelated virtual machines on a single host due to sidechannel attacks.


UTXO Model and Trans Fee / Kb Clarification I have been working on understanding the inputs/outputs and transaction details as according to the UTXO model which is discussed in this question and also thinking about how it relates to transaction fee based on size in kb of the transaction which is discussed in this question. I want to clarify a few things, feel free to pick apart anything I say that is wrong in addition to answering my questions - since the questions are derived from my understandings.
It seems that the transaction size is mostly a function of number of inputs and outputs (in the sense that those are the things I as a sender have control over, where the other components contributing to size are more or less static).
Clarification 1: (ignoring the fee and change)
Suppose Alice sends me (Bob!) 2 btc. She got these 2 btc as a result of Larry and Greg each sending her 1 btc. This means she has these two UTXO outputs each for 1 btc associated to her wallet, and when she sends them to me the transaction will have 2 inputs and 1 output, kind of like this transaction I found on a block explorer.

Once this transaction is processed, does my wallet remember that these 2 btc came from separate UTXO's? Or does it "get melted" as someone alluded to in my first link. More precisely, if I send these 2 btc to Gerald, will it show 1 input or 2?
Clarification 2: (with fee and change)
Alice wants to send me 2 btc. She has previously been sent 1 btc by each of Larry, Greg, and Allan. So she has 3 UTXO's associated with her wallet, each worth 1 btc. She goes to send me 2 btc, but needs to cover the fee. For convenience lets say a .5 btc fee. Does this mean she now has 3 inputs and 2 outputs contributing to the size of the transaction (and thus contributing to the size of the fee) (she needs all three coins to pay me and cover the fee, and then I will be one output and her "change address" will be the other.
Lastly, I think I understand that most wallet services "handle" all these details for you in the sense that you can just put the btc address and how much you want to send and they handle the rest. Do they typically do this in a most efficient way? For example, say I use a wallet like a Nano Ledger S. If I have a UTXO for 25 btc, a UTXO for 1 btc, and 5 UTXO's for .5 btc and I go to send someone 1 btc, will it choose the UTXO's that result in the smallest transaction size?
Addendum: I do plan on being active on this site, so please do critique if my questions can be improved to better fit this community.

does my wallet remember that these 2 btc came from separate UTXO's? Or does it "get melted" as someone alluded to in my first link. More precisely, if I send these 2 btc to Gerald, will it show 1 input or 2?

(1) Your have a single 2 BTC UTXO, created by Alice's transaction. That transaction spent two UTXOs, but melded them into a single one. Your wallet doesn't care about its history - it has one UTXO, and when spending it, it needs a transaction with one input.
It is possible for wallet or other software to figure out the history of the coins, and figure out that it came from a transaction that spent two. But it has no impact on future transactions with it.

Does this mean she now has 3 inputs and 2 outputs contributing to the size of the transaction (and thus contributing to the size of the fee)

That's right. You'd create a transaction with 3 inputs (each 1 BTC) and 2 outputs (one of 2 BTC, one of 0.5 BTC). The difference is 0.5 BTC going to fees.

Do they typically do this in a most efficient way?

Often, no, actually. Because "most efficient" isn't the only criterion to optimize for. For example, you want to minimize the cost of transactions now, but you also don't want to bring your wallet in a state that increases the cost of transactions later. For example, some strategies for coin selection (as this problem is called) would result in continuously grinding down your coins into ever-smaller change in typical workloads, making it more and more expensive to send out future coins.
Some wallets will take current fee conditions into account to make these decisions.
Overall there is a significant amount of work analyzing various coin selection schemes. Some are featured in Mark Erhardt's master thesis.