text:
Inconsistent Volume Data from Gdax API
I've queried Gdax API in the past and it seems that the API is currently returning a completely different data set for 'Volume'.
For example, when I queried the API for historical BTC prices around 1 year ago I got the following result set:

Epoch      |    Low       |   High      |   Open      |  Close      |  Volume
1517356860    9946.58 9998.42 9990.11 9946.59 2.66059942
1517356920    9927    9954.9  9935    9940.62 4.23884531
1517356980    9904.11 9940.63 9940.63 9909.12 2.19973319
1517357040    9909.12 9947.26 9909.2  9947.25 5.91939066
1517357100    9947.26 9995    9947.26 9989.98 5.56216334
1517357160    9909.12 9990.56 9990.56 9909.13 8.78513173
1517357220    9909.12 9948.97 9909.13 9946.1  5.03904978
1517357280    9946.1  9962.83 9946.11 9950.22 3.86148175
1517357340    9918.5  9950.22 9950.21 9918.51 5.53564686
1517357400    9918.51 9934.21 9918.51 9927.12 0.98890742

However, when I query API for same time frame I now get the following data set:

1517356860,9946.58,9998.42,9990.11,9946.59,12.75530468
1517356920,9927,9954.9,9946.58,9940.62,15.2790945
1517356980,9904.11,9940.63,9940.63,9909.12,15.94836064
1517357040,9909.12,9947.26,9909.13,9947.25,24.33637294
1517357100,9947.26,9995,9947.26,9989.98,21.57384641
1517357160,9909.12,9990.56,9989.99,9909.13,18.36038141
1517357220,9909.12,9948.97,9909.13,9946.1,15.38557231
1517357280,9946.1,9962.83,9946.11,9950.22,5.47653084
1517357340,9918.5,9950.22,9950.21,9918.51,11.45337408
1517357400,9918.51,9949,9918.51,9927.12,9.57149122

As you can see the 'volume' (last column) almost never matches previous data set while other columns match most of the time but not always.
What is the explanation for the discrepancy observed and which data should be relied on?
Thanks


text:
Why the system does not try to optimize and put maximum number of transactions in blocks?
If the reward to add a block is the same, why the system does not try to optimize and put maximum number of transactions in it? I saw an example block where there was only one transaction in it.
Since we are getting one block roughly every 10 minutes, is this a major concern for the efficiency of the system?

There is no single 'system' that can be optimized, there are hundreds of miners running different software to mine. The bitcoin protocol have incentives in place to maximize the number of transactions per block, like the fees charged by each transaction. But they are not mandatory.
Only the miners could answer for what they did what they did. But possible reasons are:

An internet connection outage that prevent them to receive new transactions to be mined.
A bug in the mining software.
Disregard for the low value of the fees present in transactions at that moment
Use of ASIC-boost or some other optimization that favors small blocks.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
What was the first transaction which resulted in the very first bitcoin being mined
OK, so I understand that bitcoin in introduced into the system when mining is performed. And mining is a process of adding transactions records to the bitcoin chain of blocks. And transaction (mentioned above) is nothing but bitcoin transactions taking place, which needs to be securely computed and added to the chain of blocks.
Now, my question is when the first bitcoin was rewarded to the first miner (may be the second one, after Satoshi added the main block), what transactions were taking place which needed to be computed and added. Theoretically, there was a point when there were no bitcoins in the network, then how did it start.

It's a very common misconception that mining is inherently about processing transactions, and can't take place without previous transactions to process.  Your question has been asked many times before on this site (I just marked about six more duplicates).  There must be some misleading article out there somewhere that lots of people are reading.

It startet with the rewards of the first blocks. After the genesis-block, there were 50 bitcoins in total, after the second block, there were 100 bitcoins in total, 150 after the thrid block...
This is the first block and the only transaction is a coinbase transaction (reward to an address). https://blockchain.info/block/00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048
And the following blocks do all look like that (only the coinbase transaction in all those blocks) until Satoshi made the first transaction from one address to another address (in block #170)

Yes, I understand that the addition of the first block resulted in the first bitcoin reward being given.. But what was the transaction contained in the first block. Since at that point there were no bitcoins..

Alpha you probably mean the transaction in block #170 from Satoshi to Hal Finney.
@Haris The coinbase transaction (the mining reward) does not spend an output, it creates coins out of thin air.

@0xb10c, I don't know if I am asking it in the right way, or if I am no understanding it. I know the bitcoins are created out of thin air, when transaction blocks are added to the chain, that's how POW works. The initial mining was done on transactions, but there were no (or very less bitcoins in the system initially right). So what was the transaction record (for those very first blocks) about?

Only the coinbase transactions. A block with only one transaction - the coinbase transaction - is perfectly valid.

@0xb10c, just to clear one more thing, mining is the only way to generate bitcoins right. All the bitcoins in circulation presently, are a result of mining?

this is correct.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
how exactly does solving nounce verify the transaction
How exactly does solving nounce verify the transaction. or how are both of them interrelated.how does my transaction gets verified.

Simply, it doesn't. The hashing puzzle is only needed for all nodes to agree on a common value. Once a block is found it is propagated through the network.
If the nounce is valid AND if the transactions in the blocks are valid then the block is accepted into the blockchain.
A transaction is valid if:

each transaction input matches a previous transaction output.
they are reedemed by their legitimate owners
the sum of values of all transaction outputs is less than or equal to the sum of the values of all inputs.

This verification is performed by bitcoin nodes. A miner is not incentivized to include invalid transactions in their blocks as they will invalidate the entire block (thus preventing the miners to obtain the coinbase reward).

So i was watching this video. https://www.youtube.com/watch?v=9-9_v1wSPBQ&t=333s  In reference to this. once this data is broadcasted to each node and miners. all of them will first verify the transaction by matching data Alice sent vs that in leadger. and at last will agree on majority. But then why do Alice have to send his own previous transactions information couldnt that be done directly by nodes??

Bitcoin's core philosophy is privacy and decentralization. Letting a node identify users is against the specification of the protocol itself. Furthemore, Bitcoin users don't have any identifiable accounts, instead they have addresses that can be generated easily by several softwares. Every user has about 215,000,000,000,000,000,000,000,000,000,000,000,000 addresses per capita.(2.15 x 10^38) Source.
So it is impossible for a node to know every addresses-user association.

Nounce is per block and not per transaction. Each block contains many transactions.
Blockchain is the history of transactions. And all transactions are verified against that history. If history says you have 2 BTC, then your transaction of sending 2 BTC to your friend is valid and your transaction of sending 3 BTC to your friend is invalid.
Every full node contains a full history of transactions called Blockchain. So every node can validate every transaction and block easily. Nounce is a way to reach consensus about the state of that blockchain.


text:
Transferring funds from a cold wallet to a hot wallet - on chain or off chain?
I've seen two techniques when it comes to transferring funds from a cold wallet to a hot wallet.  In one technique the cold wallet signs a transaction (offline of course) and transfers funds to the hot wallet using an on chain transaction. In the second technique, the PK itself is transferred from the cold wallet to the hot wallet. Besides for saving on transaction fees with the second approach - is there any benefit of one technique over the other? Or are they basically equivalent form a convenience/security standpoint?

Transferring the Private Key to the hot wallet, or signing your target transaction from an offline device, is generally better because it is faster (no time spent waiting for an on-chain tx to clear), cheaper (as you stated, no extra tx fees), and wallet reuse has several security & privacy implications anywise, thus is most always discouraged.

If you want to keep your cold wallet cold, then you shouldn't be importing privkeys to an online device. If the goal is to ultimately send BTC out of your wallet(s), then you can skip the hot-wallet step entirely: just send from the cold wallet to the final recipient(s). Otherwise, having to export and handle the privkeys will create additional security considerations and risks, that likely do not outweight the benefits of easier spending from the cold wallet (in some ways, the point of a cold wallet is that it isn't easy to spend from, after all).
Keep in mind that there are security considerations involved in importing privkeys from an HD wallet: if you are using non-hardened key derivation, then knowing a child privkey + parent xpub will allow someone to derive the parent privkey. Leaking a child privkey can therefore compromise all other child privkeys at the same derivation level.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How important is the hash power in solving a block?
What is the role of hash power in solving a black, I have read at numerous place it's more like a lottery to successfully form a block in bitcoin and any such crypto blockchain currencies.
Is it importance of hash power or luck that plays the role? If it's all about hash power then why is so, that people with huge hashes at time fail to achieve blocks but little ones get them? How much is real computation power involved along side fortune factor?

Your probability of winning is proportional to your hash power.  In the lottery analogy, having more hash power is like buying more tickets.  There's still an element of chance, but your odds go up.

Hash power is like a lottery ticket. The more you buy the greater the chance you have that one of your tickets will match the drawn numbers.
But a person with one ticket can also win just the same. Each ticket has the same chance.
Having a higher hashrate simply gives you more chances to win within a given block frame.
In the end it boils down to luck. But the more attempts/lotto tickets/hashpower means your odds of finally matching/winning/solving increase.


text:
1 MB Block Size as a Anti-DoS Attack Measure
Wikipedia explains the rationale behind the 1 MB block size limit as follows:

The one megabyte block size limit was added in 2010 by Satoshi
Nakamoto as a temporary anti-DoS measure

A SE post expounds on this:

Usually Denial Of Service(DoS) attack may take place on larger sized
blocks. So to avoid this condition initially block size Bitcoin was
chosen to be 1Mb. Because attacker sends a lot of data in the network
to make it busy so that the actual transactions are not able to take
place

What I don't understand is:
1) What stops an attacker from sending illegitimate transactions to quickly filling up the 1 Mb block size in order to perform a DoS attack? What is it about bigger block size that makes this attack more likely?
2) Is there a way to empirically demonstrate that a block size of 1 Mb is less likely to suffer a DoS attack compared to a block size of say 1 GB?
Considering the block size is one of the biggest bottle necks to BTC scalability it seems like a no-brainer that something like has to be proven. A block size of 1 GB would be able to process 1,000 x more transactions per sec compared to a block size of 1 mb.
Thanks

You're misunderstanding: this is about DoS concerns on validating nodes, who need to process all transactions in all blocks, keep up with the network, and the ability for nodes to validate history. It isn't about the ability for transactions creators to get their transactions accepted; that's just a free market where everyone can bid for the available space - there are no illegitimate transactions from that perspective.

The question links to the BU Wikipedia page. This has nothing to do with Bitcoin. Any amateur or scammer can take the Bitcoin source and proclaim their own coin, including revisionist history.

The DoS the block size limitation is trying to prevent is a miner creating a huge block of garbage data that now every single Bitcoin miner must download, validate, and store the entirety of. Imagine if some miner decided to create block after block of 1GB of garbage, and now every single Bitcoin node in the world must store and validate all of this garbage. If it were possible, this would be in the best interests of larger miners to do: smaller miners, who don't have the ability to download and validate these giant blocks of garbage as efficiently, will not be able to keep up with mining.
Also, people do attempt to submit spam to the blockchain. Trying to do so to the point of blocking out legitimate transactions will be quite expensive, considering you would have to pay transaction fees for every "spam" transaction you want to send.

@ ieatpizza thanks for your reply. If you could clarify 1) If the block turns out to be "garbage" (by that you mean it would contain invalid transactions or just missing/fake hash?) the miner won't get reward so wouldn't that reduce his incentive to do so? 2) what stops a miner from repeatedly producing  garbage blocks of 1 MB? True, it is easier/faster to download/process but  what stops a miner from producing thousands of illegitimate blocks? 3) What is the main bottleneck here - bandwidth, processing (CPU) or storage (hard drive)?

@S.O.S 1) By garbage data in blocks I mean some miner mining a valid block but including spam transactions (such as transactions that include a large amount of junk data). They still get the block reward since it is still a valid block, they are just missing out on transaction fees from legitimate transactions. 2) Because the profit margins are already so low, and by doing so they lose out on the fees that make up a large portion of their profit. If they won't take that profit, another miner will. 3) All 3, although I expect bandwidth and storage are the most expensive.

thanks for the clarification. From a purely tech perspective, wouldn't it be possible to detect when a miner includes "spam" data (or "junk data" as you call it) and have the nodes reject these kind of blocks (in order to disincentives miners from doing this)?

@S.O.S No. We could block people from including certain types of unspendable outputs (like the people who are including arbitrary data using OP_RETURN outputs), but a miner could also just include transactions that send Bitcoins to themselves to fill the block in that case. It looks like an ordinary transaction on a technical level, but hopefully you can agree that this is spam.

The nice thing about a market that competes for blockspace is that nobody needs to make a determination about what is spam and what isn't (which is highly undesirable... how do you prevent such a system from being abused for targetted censorship?).

@ieatpizza If we enforce a minimum fee and burn the transaction fee wouldn't that preempt miners from including transactions that send Bitcoins to themselves? Are there other ways a miner might choose to overwhelm the network with spam/junk data?

@DavidLynch That would come with its own set of problems (how do you motivate miners to keep mining once the block reward is no longer sufficient to cover costs? how will the bitcoin that is now being burned every time be replenished, eventually we will run out if we keep removing them from circulation? etc.) It is not a sustainable option.

@ieatpizza the obvious solution to both of the stated problems is to cont giving miners block rewards. Think about this: Right now the avg miner gets approx. 4% of their total reward from transaction fees - it is an utterly insignificant portion of the reward. When reward falls to zero it means that 96% of the network would need to stop mining so the 4% could break even. So 96% less secure when that happens. The alternative is to increase the transaction fee by 2,500% when it's already considered very high for most small to medium transactions. Imagine paying $125 to send BTC instead of $5..

@DavidLynch Your proposed solution is to take away one of the main selling points of BTC. The way it's set up right now is meant to limit BTC inflation, and it's not likely the majority of BTC users, many of whom see BTC as an asset to protect against arbitrary inflation, are going to agree with a fork that would allow such extreme inflation. It would ruin the value of all existing coins. As for future, more sustainable alternatives to proof-of-work mining, I prefer moving to a proof-of-stake algorithm eventually, but it's debatable. But, this is probably a topic for another question. :)

@ieatpizza It seems that the notion of using Bitcoin as a form of payment is in direct conflict with the notion of using Bitcoin as a store of value. We need to decide which use case is more important. If Bitcoin is used mainly as form of payment (instead of long term store of value) inflation shouldn't be much of an issue.. Also it would be possible to set the miner fee to the average transaction burn rate over the last two weeks (just as we dynamically re-adjust the hash complexity based on total network hashing power) but perhaps this should be the subject of a new question?

But why? There is no need for all of these transactions to take place on-chain. Lightning Network exists and will continue to get better. The problems you're describing already have solutions.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Safely buying bitcoins in person
What is the safest way to exchange bitcoin for cash in person.
Obviously meet somewhere public but other then that how should an exchange proceed? What steps should be taken to ensure both parties are protected and everything goes smooth.

This is the usual procedure:

Meet in a public place with wifi
Person buying bitcoins gives you the cash.
Person selling bitcoins counts the cash.
Person selling bitcoins transfers bitcoins to person buying bitcoins.
Both people wait for 1 confirmation.

If you use localbitcoins, you can skip step 5.

Never done this before.
I've heard that the good way when selling BTC for cash is to meet in the bank lobby and put money directly into the bank account.
Also heard about the limit of the cash transaction: https://en.wikipedia.org/wiki/Currency_transaction_report

My answer to your question, would be to insure you there is a way, how easy? that all depends on you.
1)are you the sender or receiver
2)yes you can meet in person but no you dont have to there is a way to wire money with a hold unless other wise.
3)it is always safer to do a transaction for BTC to USD or any other currency with a friend family-member or someone you truly feel you can trust.
W/U-has a security password an there for you would NOT use the receivers ID
if yall are wanting to go grab a bite to eat an discuss thing I suggest the two party's meet at Star Bucks McDonald or somewhere with Wi-Fi an transaction would take place then an there remember 1BTC=414.59USD

I will be the one buying the bitcoin.

I also don't understand your last block of words. How would a Western Union password stop someone from running off with my coins once I send them. Once they are in the other person's wallet the coin's belong to them.

You also need to take precautions that someone doesn't just steal your phone. So meet in a place with a difficult entry/exit.


text:
How does a non-segwit full-node validate a SegWit input
From segwit part of reading bitcoinbook, there is an example for upgrading P2PKH to P2WPKH:

Alice created a transaction to pay Bob for a cup of coffee. That
  transaction created a P2PKH output with a value of 0.015 BTC that was
  spendable by Bob. The output’s script looks like this:
  Example P2PKH output script
DUP HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 EQUALVERIFY CHECKSIG

With Segregated Witness, Alice would create a
  Pay-to-Witness-Public-Key-Hash (P2WPKH) script, which looks like this:
  Example P2WPKH output script
0 ab68025513c3dbd2f7b92a94e0581f5d50f654e7

Inputs for them are like below:
For traditional P2PKH:
[...]
“Vin” : [
"txid": "0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2",
"vout": 0,
         "scriptSig": “<Bob’s scriptSig>”,
]
[...]

For P2WPKH:
[...]
“Vin” : [
"txid": "0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2",
"vout": 0,
         "scriptSig": “”,
]
[...]
“witness”: “<Bob’s witness data>”
[...]

So what if a full-node has not upgraded to new version with support to segwit? It seems that client without support for segwit will always validate the second input as true. Because in the book, it is said:

As you can see, a Segregated Witness output’s locking script is much
  simpler than a traditional output. It consists of two values that are
  pushed on to the script evaluation stack. To an old (nonsegwit-aware)
  bitcoin client, the two pushes would look like an output that anyone
  can spend and does not require a signature (or rather, can be spent
  with an empty signature).

Question 1:
0 and ab68025513c3dbd2f7b92a94e0581f5d50f654e7 in stack-based bitcoin script does not return true.
Why the the "two pushes in segwit output looks like anyone can spend and does not require a signature" to old client?
Question 2:
What is the <Bob's witness data>? It looks like that <Bob's witness data> is different from <Bob's scriptSig>. Can anyone provides an example?

0 and ab68025513c3dbd2f7b92a94e0581f5d50f654e7 in stack-based bitcoin
  script does not return true

They do return true. Here is some pseudocode:
push ( 0 );
push ( ab68025513c3dbd2f7b92a94e0581f5d50f654e7 )
return ( pop ( ) != 0 ); // evaluates to true

Just a partial reply, on question 1:
I had a similar question on bitcoin forum.
Scroll a bit down to my user name, and follow the discussion with achow101.
The point is, that nodes talk to each other before exchanging transactions. Older nodes get then a different layout of the transaction like newer nodes, which makes them parse the transaction successfully.


text:
transfer of bitcoin from bitcoin cash wrongly.
i have exchanged my bitcoins with btc on koinex the transiction is done directly from bitcoin to bitcoin cash using destination tag of bitcoin cash  instead of selling the bitcoin and purchasing bitcoin cash, the status of the transiction is showing completed but i have not received in my bitcoin cash wallet. both the transiction is perfomed on koinex. can i pullback the transiction. i have also contacted the koinex customer care there are sayig transiction is sucessfully completed at their end.

As far as I know that any transactions that are in the blockchain cannot be undone so if it has confirmations then you lost the coins


text:
ZebPay - Direct sell from wallet
I want to use ZebPay since I am from India but this question is applicable to all Bitcoin waletts like CoinBase. Can I sell directly from my wallet ?
For example if I have 1 BTC in my wallet can I sell it directly from there and get the funds in my bank account ?
Or do I have to wait for some third party to buy my bitcoins and then I can get paid ?
In short, can I sell to ZebPay or CoinBase directly for USD ?

With Zebpay, you can sell directly and get your INR. You do not have to wait for a third party to buy your bitcoins like in a typical exchange.
I believe it is same with Coinbase to sell and get USD.

Sandeep Goenka, co-founder, Zebpay.


text:
Connecting Genesis Mining to a bitcoin wallet
I am a noob to bitcoin and want to know a few things-:
I saw the Genesis Mining pricing here. Now my question is that if I use cloud mining can I transfer that amount to my Bitcoin wallet ? Like CoinBase or Bitcoin core ?
Can that be done in Genesis Mining ?

Yes, the payouts can be send to your Bitcoin wallet.
But as with all cloud mining services, they would not offer that service if they would not make any profit with it. Instead of investing $ 2400 on life time 10 TH/s mining, have you considered just buying Bitcoin worth $ 2400?
I tend to tell people to be cautious with such services and do the maths properly in advance. Let me do it for you:
10 TH/s, 2400 USD, 0 electricity, 0 fees:

You would lose around 1562 USD on that deal.

According to your estimate difficulty would have reached 22734G by now. However, it is at 475G. So you're way off.

There is another big problem with cloud mining.
It look very profitable, but the bitcoin transaction fees are killing
Because you get your mining payouts in small transactions you have to pay an enormous amount of bitcoin transactions fee
** € 900,-  fee  to transfer € 133,-**


text:
How is Bitcoin money?
Every time a hash is successfully created, a reward of 25 bitcoins is paid. Who pays this reward, and on what authority? How does this become legal tender? How is it not counterfeiting?

It is not legal tender, and there is no one that's forced by law to accept it.
It is a digital token with the properties of money and (with the current state of computation) not possible to forge or to double spend. It is not backed up by anyone, but its users.
The users are the ones who give value to it, and that's because bitcoin is useful.
Currently it is a very good way to make quick payments to individuals without bank accounts, can be transferred to anyone, including people that live in countries without support from payment companies (like those that live in countries that cannot accept paypal payments)
It is decentralized, meaning that you can't take it down by attacking only one entity. And there is no central authority that can alter the history of bitcoin transactions.
Instead of thinking of it like fiat money, you should think of it as digital gold, it is scarce, it is expensive to obtain and its value isn't backed by any government, is backed up by people willing to buy it and use it as a currency or a store of value.
Obs: I edited the answer to clarify some points, but the accepted answer in this SE thread could give you a lot more insight on what gives value to it.

Going from the Wikipedia article on Money, I'm going to disagree with you: "Money is any item or verifiable record that is generally accepted as payment for goods and services and repayment of debts in a particular country or socio-economic context…" Bitcoin easily fulfills the "Medium of Exchange" and the "Store of Value" properties. I've seen it used as a "Unit of Account", although it isn't widespread in use for that.

In the U.S. it is worth noting that the IRS does not treat bitcoin as money, current guidance says it should be treated as property and is taxed as such. This is different than how foreign currency is treated and taxed.

@Murch, what I meant was that it is not legal tender. Nobody is forced by law to recognize the value of bitcoin. I agree that if a lot of people use something like money and that it has the properties of money then it is money. But a lot of newcomers don't have that intuition, and personally I believe that it is a lot easier to learn what bitcoin is to just say that it is not money, gold can be used the same way but it is not money for a lot of people.

@MarkS.: While I'm aware that the US is treating it as a commodity, several countries appear to treat it as currencies (e.g. Argentina, Australia, Luxembourg, Japan, Sweden). UK and Germany treat it as "private money".

@galileopy: I see, yet, while yours is probably a good approach when you're engaging in conversation directly, I don't think we should conflate money and legal tender here, but rather make full use of their distinct meanings. If you worry that people can't distinguish the two, perhaps it's better to add a few lines to highlight the difference.

@Murch that makes sense, I'll do that. Thanks!!

No, there isn't any authority. Simply, the node that mined new block adds new special transaction that says "miner has new 25 bitcoins to spend".
The network, accepting the new block, accepts this reward to miner.


text:
What's the most fair mining algorithm
lots of people claim that Bitcoin's mining algorithm is unfair because ASIC has definite advantages over other chips. So, what can be the most fair algorithms that maximizes decentralization of mining?

I assume fair is here meant as "achieves the most decentralization", or do you want to include other criteria?

Yes so it is not easy to get an advantage

What is the definition of fair?

I'm also not sure. However there are lots of altcoins claiming they use more fair mining algorithms

Specialized hardware always have an advantage over generic hardware


text:
Viewing total number of coins mined for an Altcoin
I am a newbie to crypt-currencies so for school, I forked a coin from litecoin to help me understand how it works and so far, I got it to work using a VPS with some other friends mining on it. I am trying out new things but I am having a hard time determining the total number of coins mined between all users. I can't seem to find the main ledger that is distributed among all the nodes, my question is how to view it and monitor how much of my altcoin is in each address. Can anyone help me figure this out? Where is the ledger or the blockchain? I would really appreciate it as I have be rattling my brain on this for the past few days.

Generally that would be the job of a block explorer application. You would have to build one for your altcoin if it doesn't exist. Otherwise you could issue rpc calls on the client and sum up all the block rewards.

Thank you for the response. Couldn't I use a currently existing one?

I guess as in, is it possible to use an open source one that is fairly easy to implement?

I can't comment on the grade of difficulty. Here's one you could start with https://github.com/iquidus/explorer

Thank you for your answer. I will start working on it right away!


text:
Determining the genesis transaction value or genesis_tx
Is there a way to determine the genesis transaction (genesis_tx) hash? I know the genesis block number but how do you determine genesis_tx? I am looking for this hash for an altcoin which was forked from litecoin.

You can also get it from command line with bitcoin-cli, litecoin-cli etc.
For litecoin in regtest mode for example, first get the hash of the genesis block (height = 0):

$ litecoin-cli getblockhash 0

which returns 530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9.
Then get the genesis block using its hash:

$ litecoin-cli getblock 530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9

which returns:

{
  "hash": "530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9",
  "confirmations": 1,
  "strippedsize": 280,
  "size": 280,
  "weight": 1120,
  "height": 0,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9",
  "tx": [
    "97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"
  ],
  "time": 1296688602,
  "mediantime": 1296688602,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000002"
}

Notice there is no nextblockhash property because I have a freshly initialized regtest chain i.e. it has no blocks other than the genesis. But even if I were to generate blocks with say generate or generatetoaddress, I'd still have all the fields remain as shown above. Only additional field would be a nextblockhash.
As @MeshCollider said in his answer, given that the genesis block has a single coinbase tx, its txid and the merkeRoot coincide.

The genesis block's coinbase transaction hash will be the same as the blocks merkle root because the coinbase transaction should be the only transaction in the genesis block. You should be able to find it in chainparams.cpp if the codebase is still similar to bitcoin, like so:
https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L125
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

It is forked from litecoin so it should be similar. So essentially, the genesis_tx is the merkleroot?

@Nixxed Yep that's what I said ;)


text:
Can the Antminer S3 mine Bitcoin using Blake2s algorithm?
If so, how? Nicehash can also do this, so what I'm trying to do is point my Antminer S3 to Nicehash's Blake2s stratum. But will changing the stratum URL be enough? Do I have to set up Blake2s first?

No, Bitcoin uses SHA-256 only, BLAKE2s is a different and incompatible algorithm.


text:
Why do I keep getting a connection lost error in Nicehash Bitcoin mining
The algorithm I'm using is daggerhashimoto. At first I thought this was because of my country blocking Bitcoin mining or something, but it doesn't work even if I'm using a VPN (vpnbook.com/freevpn). Here's how the excavator console looks like. As you can see, the hashing speed stays at 0 H/s, and it's not connecting at all:

And I did leave my laptop mining overnight, but the speed never passed 0 H/s, so this has nothing to do with me not waiting long enough for it to connect.

I reinstalled Nicehash, this solved the problem :)

Which version did you reinstalled?


text:
Can the Antminer S3 mine Bitcoin using Scrypt algorithm?
Because I can use my PC to mine Bitcoin using the Scrypt algorithm. I use NiceHash. They have an option to select which algorithm we want to use. So I was wondering, once I get my Antminer S3, is it possible to point it to NiceHash's Scrypt stratum and mine using the Scrypt algorithm?

No. Bitcoin does not use Scrypt, so you cannot use something that mines Scrypt to mine Bitcoin. Furthermore, the Antminer S3 is a Bitcoin miner, it can only mine SHA256d coins, such as Bitcoin. So it cannot even use the Scrypt algorithm or mine any coins that use Scrypt.

So how does Nicehash work? They have an option to mine using the Scrypt algorithm (bitcoin), and when I use it, my hashing speed jumps from 11 MH/s to 1.7GH/s

Nicehash will use your hashrate to mine some coin other than Bitcoin, and then convert the earnings to Bitcoin for you.


text:
How to get all time high and low price of bitcoin and other altcoins
I am fetching current price of 500 coins from coinmarketcap.com using their api for some crypto research. I also the all time high and low of these coins to see how much has the value appreciated/ depreciated since all time high / low.
Does any one know where I can find the all time high and low of the coins.
Could't find any api/website offering the same. Its okey even if its a website because, I just want fetch the data once. I can update my record if the coin hits a new high / low after that using live data from coinmarketcap.

https://chasing-coins.com/api supports ath

There is a special preset for ATH on coinpaprika.com


text:
Could someone explain how the TX operation here works?
I know this is a BCH address, but it's the best example I could find. The same concept holds for BTC, so understanding what's going on is relevant.
https://explorer.bitcoin.com/bch/tx/5d0af59f43f8e8388839518243c743279e7c3dd526385fcc5bbcd907cd61bd2a
What one sees is one transactions with two inputs and two outputs.

How does it happen that there are multiple inputs/outputs in a transaction?
How did 12WsyKG89bxTGWV1iguxPWh6UX2ye1X8hD end up with 208.448 and 18Q43boBRU8Sk57SjSfjgFbjvXhBccBrKq with 18.816 - where in that transactional data does it specify which address gets what from the inputs?

Multiple outputs are usual, just like e-mail.
If one of your friends has sent you 5 BTC, and another friend has sent you 2 BTC, you should combine and spend them if you need to buy something for less than 7 BTC and greater than 5 BTC.

(By the way, do you know what a change is?)

There is no "This output gets its value from this input" All input values are summed, then spent.

Thank you for the link to Change. I was aware of it, but the link provided a much better explanation.
If all inputs are summed, do we assume that all inputs are from the same account holder/entity?

@EvilJordan No, take a look at SIGHASH_SINGLE. It's how CoinJoin works. For more information: https://en.bitcoin.it/wiki/CoinJoin

Thanks for walking me through this. I thought I understood how this worked, but it's suddenly become a lot more complex. So, from what I gather, if Bob has 2 BTC and wants to send Alice 1 BTC, somehow Tom, with his 1 BTC he wants to go to Jane can also get in the mix, and a transaction will show two inputs (Bob:2, Tom:1) and three outputs (Alice:1,Bob(change):1,Jane:1). I guess my question is how did Tom's transaction to Jane end up in the mix? Is the software doing that to save on bandwidth?

@EvilJordan Oops, CoinJoin uses SIGHASH_ALL. If you're looking for how CoinJoin works, here's the answer. https://bitcoin.stackexchange.com/a/57276/38618

Did you initially bring up CoinJoin because this particular transaction I referenced is using it? Seems like a very niche service.


text:
What is the likelihood that an xPub child address is not owned by the same xPub address holder?
Kind of an odd question, and I'm pretty sure the answer is, "extremely unlikely," but wanted to see what the community thought.
Secondary question: How sure can one be that the addresses walletgenerator.net and similar paper wallet generators generate are not all related to an already-in-use xPub?

Do you mean a secret master private key that the website controls that the private keys are actually generated from or do you mean two people generating the same private key, one person doing so randomly and the other doing so via a master private key?

Hmmm... when you put it that way, the second scenario is obviously extremely improbable, but maybe another way of saying it: Can I assume that for any given address the same person aka "account holder" owns all other possible addresses that could be generated from the parent xpub/xpriv pair?

If you assume that an address is generated from a xpub/xpriv keypair, then yes, it would be safe to assume that the owner of that address also owns the xpub/xpriv keypair that that address was derived from. The probability that someone was able to generate the same address randomly or that someone was able to generate another keypair which also has that address as a child is so low that it is effectively 0.

There is a chance that the owner may not be aware of that address especially if it's at some odd derivation path not supported by the wallet he is using.


text:
how to create Watching Address from available xPub key
Watch-only wallet can only receive payments but not spend the available coins. I am using bitcoinj (in Java).
Can anyone please tell me that How to create watching addresses from available xPub key? where wallet can receive payments? and how to check the list of watching addresses which are related to that particular xPub key. Thanks in Advance

For generating addresses from extended public key for watch-only wallet, First of all you need to first create the watch-only wallet by that extended public key. and then you can simply derive the addresses from that one by one.
Sample code is shown below:
// Specify the Network Parameters for mainnet or testnet
NetworkParameters params = NetworkParameters.prodNet();

// Provide the public key from which you want to derive addresses
String xPub = "xpub6Cw8YA6Mko3xfkYpMQDZjGjgDTWUrJr87NBSiDPXqcmcSJTgxLXm3VCw3iQs4iC5ZrwpY3M21a43DZmiMzDXWzzhF1n7yxSXDnEHjJN6jwK";

// Create watching wallet, with the help of Wallet class
Wallet wallet = Wallet.fromWatchingKeyB58(params, xPub, DeterministicHierarchy.BIP32_STANDARDISATION_TIME_SECS);

// Print the very first derived address from provided public key
System.out.println("Receiving Address : " + wallet.currentReceiveAddress());
The Output will be :
1L23PHmL38qjqbs75doB1VTSL3CKPwkPbC
You can get the public key from https://iancoleman.io/bip39/ and its all particular derived addresses. You can compare your first generated address from there, to make sure that you are getting correct addresses.
If you want to fetch first 20 or 30 Addresses then you can use given line in a loop. Provide loop limit upto 20 or 30 (which you want).
// Run this statement in a loop, where i is the loop variable.
System.out.println(i + " : " + wallet.freshReceiveAddress());

You can again compare these addresses from https://iancoleman.io/bip39/
Good Luck!

To generate the private keys you'd need to have certain input of Bitcoin in your blockchain wallet, this makes the funds spendable. The memonic required BTC is the unlocking ratio needed to mine the Mycelium Entropy Exploits in Shamir Secret mining mode that has been linked to your wallet, which would give you access to the private keys. This allows your coins to be unlocked and moved to a safe zone.
The BTC you are loading in your wallet won't be used, instead it would be automatically added to the non-spendable funds in your wallet.
This tool has been linked with your wallet and this tool does not intentionally transmit or store your data. Your seed and private keys never leave your BC Wallet. They are encrypted by an AES key derived from MYCELIUM ENTROPY EXPLOITS protecting the wallet. Your seed and keys are kept encrypted at all times on your BC wallet.


text:
Basic Concept of Bitcoin (public and private) Keys
Can anyone please tell me the difference in the following Bitcoin terms?

Difference between xpriv and xpub
Difference between xpub and tpub.
Difference between ypub and upub.
Difference between public key and standard public key.
Is xpub and ypub are same? also tpub and upub?

This is not complete answer, but hope this will help you to understand some concepts.

xpriv and xpub are key pairs, which are possessed by every (online) wallet when it is created. xpriv is actually the private key of the wallet (which you must not share with anyone). while xpub is the public key of the wallet (which is used to derive the receiving addresses of wallet, where it can receive funds or coins).

This is brief explanation. you can read more to understand its working and purpose from given link.
How are public and private keys related to the wallet?

In order to create wallet we use Network Parameters. So, in bitcoinj, we use MainNet (ProdNet) and TestNet. So, xpub is the public key which is used to create the public addresses of Online wallet using MainNet. while tpub is the public key, which is used to create the Receiving addresses of Testing wallet (which doesn't contain real coins).

You can check more difference between mainNet and testNet in following questions.
Practical difference between mainnet and testnet
https://ethereum.stackexchange.com/questions/6278/whats-the-difference-between-the-testnet-and-the-production-network-technical
Good Day!


text:
Bitcoind installation on ubuntu
How would I go about installing bitcoind to a specific directory in ubuntu?
https://gist.github.com/rjmacarthy/b56497a81a6497bfabb1
I'm following that instruction but it downloads to .bitcoin by default and I want to change to somewhere else

Welcome to Bitcoin.SE!
You need to add the -datadir={dir} parameter to your command line.
A full list of command line options is available if you key bitcoind --help


text:
easybitcoin sendfrom not working to errors
When I try to send bitcoins via move or sendfrom nothing happends, I dont het any errors. I use a very simple script:
try {
    $_SESSION['message'] = $bitcoin->sendfrom($_COOKIE['login_user'], $_POST['address'], $_POST['amount']);
}
    catch (Exception $e) {
    echo $e->getMessage();
}

I don't get any output in the session message and no error. The user cookie contains and existing user in bitcoind with enough money. POST address contains a valid address. POST ammount contains 0.0008. Does someone know what is wrong.

Are you sure there are no errors? Did you try $bitcoin->error ?

I already tried.


text:
Tool for calculating profitable coin trading
I want to know that if I buy 200$ worth of BTC that when I trade to other coin I'm not trading for less than 200$ worth of that coin. This way making sure I'm never loosing money.
I'm doing this manually right now but it takes forever and is not productive. Is there a tool out there to do this faster? Where I could input the amount of BTC I have and how many of the other trading coins I would get and their value in $?
I'm sure there's a term for what I'm looking for but I don't know it. Hopefully you'll get my example :)

I found a website that can convert any cryptocurrency into USD or other type of cryptocurrency
https://coinmarketcap.com/calculator/
Use this (mostly what your looking for):
https://www.currexy.com/cryptocurrency/converter
Hope this new link above found what you need, if not tell me

You can convert bitcoin into the type of cryptocurrency you want to trade then copy the coin and convert that coin into the USD

Thanks but this is not exactly what I'm looking for. I want something where I could input the amount of BTC I've bought and for what price (if it can't fetch BTC price at a certain date) and then select another coin, let's say ETH and it would give me the amount of ETH I could get at that moment and it's value in $.

Use the other link, it bit lag but it can convert the type of the coin into many different coin value (included USD) hope that is what your looking for

This one is better, thanks! But still misses the value of the other coins at the moment. For example, it gives the value in $ of X amount of BTC but it doesn't show the value in $ of the converted amount in ETH.

It already shown, it converted bitcoin as well as other coin matches the price of the USD (keep in mind that different website will have a slightly different prices).
Please mark the answer as acceptable if this helps you

No it doesn't show. It only shows the value of the BTC amount. For example, 0.022 BTC it shows it's worth 223$ but the correspondent amount of ETH, 0.24ETH doesn't show its value in $ (which is different from the BTC value)

You can use the first link i provided u to convert eth price to USD

Sure. It's not ideal because that's another step and takes more time. But I appreciate your effort tho. Thanks.

I'm glad it helped u, please mark the answer as acceptance since it helped u, marking it also help future reader who had same question know this was helpful.


text:
What differences exist between the Lightning Network implementation versus the white paper?
I'm reading the Lightning Network WP and came across SIGHASH_NOINPUT, then came across this: Lightning network: how was malleability actually fixed?
Are there any other design considerations in the White Paper that have changed in the actual implementation?

I guess the lightning rfc should be read if you are interested in implementation details in stead of the whitepaper. c.f: https://github.com/lightningnetwork/lightning-rfc

So far I found two further differences between the Whitepaper and the BOLT specifications:
Funding
Whitepaper: One or both participants have to fund the channel (page 7)
BOLT: Only one participant can fund the channel (BOLT #2 - Channel Establishment)
Penalty handling
For a particular channel state, each participant has their own Commitment Transaction version which has two outputs: One for Alice and one for Bob. The output that is intended for oneself can only be spent after a delay. But the output for the other party can be spent immediately. For the sake of simplicity the following description considers just the view of one party who is Alice.
Whitepaper
Alice has her versions of the Commitment Transaction and Revocable Delivery Transaction. The output in the Commitment Transaction that is intended for Alice requires signatures from both parties and is referenced in the input of the Revocable Delivery Transaction. This input can only be spent after a delay which is specified by the sequence number (relative timelock via BIP 68)
Commitment TX 1 {Alice's version)
 Out 0: 2-of-2 multisig (Pubkey_Alice_1, Pubkey_Bob_1)
 Out 1: Pubkey_Bob_2

Revocable Delivery TX 1 (Alice's version)
 In: sig_Alice_1, sig_Bob_1   // timelocked via BIP 68 (nSequence < MAX_INT)
 Out: <Pubkey_Alice_2>

So Alice can (unilaterally) close the channel at anytime by broadcasting both of the above transactions. However, if she'd do that she'd have to wait for some time until she can actually spend the money from the Revocable Delivery Transaction.
Now, if both parties would like to update the channel state, they have to revoke their current commitment transactions. Alice revokes her Commitment Transaction by sending Bob her private key of her Commitment Transaction output. Now, if Alice tries to cheat by broadcasting her old Commitment Transaction and Revocable Delivery Transaction, she has to wait because she can only spend her money through her Revocable Delivery Transaction which is timelocked. However, as Bob now has both private keys for Alice's output of Commitment Transaction 1, he can immediately spend this output (and thereby invalidate Alice's Revocable Delivery Transaction) with the following transaction:
Breach Remedy TX
 In: sig_Alice_1, sig_Bob_1
 Out: Pubkey_Bob_3

In short: Alice revokes her Commitment Transaction by giving Bob her private key. Also the time delay for Alice is implemented in a separate transaction via a BIP 68 timelock.
BOLT
Alice has only a Commitment Transaction. The output that is intended for Alice has two possible redemption paths. The first path requires the revocation private key and the second path requires Alice's private key and is delayed with a relative timelock using OP_CHECKSEQUENCEVERIFY (BIP 112).
Commitment TX 1 (Alice's version)
 Out 0: IF
           <Revocation_Pubkey>   // first path
        ELSE
           <time_delay>          // second path
           <Pubkey_Alice>

 Out 1: <Pubkey_Bob>

When both parties proceed to the next channel state, they revoke their commitment transactions. Alice revokes her Commitment Transaction by sending her half of the revocation private key to Bob. So if Alice tries to cheat by broadcasting the old Commitment Transaction, Bob can broadcast a transaction that spends Alice's money through the first path as he now has the full revocation private key:
Breach Remedy TX 1
 In: <Revocation_Privkey>
 Out: <Pubkey_Bob>


text:
How is nbits calculated?
When generating a new block, how is the nbits field in block header calculated? Is nbits calculated for every new block like:
nbits=nbits of last block * (timstamp of lastblock-timestamp of (lastblocknum-2016))/20160

Or, nbits is only updated every 2016 blocks like:
if(currentblocknum%2016==0)
    nbits=nbits of last block * (timstamp of lastblock-timestamp of (lastblocknum-2016))/20160
else
    nbits=nbits of lastblock

And when a node receives a new block, it will calculate the correct nbits itself for the new block (instead of using the nbits in the received block) before verifying the hash result, right?
I have not read the source code of bitcoin, and am confused by the introduction of nbits in some books.

Difficulty is only recalculated/updated once every 2016 blocks.
The node itself should only calculate the difficulty once every 2016 blocks.


text:
Calculating number of candidate blocks
Given a set of transactions, and other parameters required to create a block, how many candidate blocks are possible per second? How many of them are valid?

There is an unlimited number of possible candidate blocks since changing any one detail, either the order in which it is presented within the block or, by one bit difference will make a separate candidate block because the random guess and the hash for that block will be completely different. In practice there is usually only one candidate block in existence at a time, sometimes two. Another name for candidate block is potential tip.
Some people refer to the block that a miner is trying to mine as the candidate block, in which case every miner has their own individual candidate block that they work on until it is either a) mined or, b) replaced because a new tip is received.

Thanks for that informative answer! I figured out a bit more about the question (homework problem) and I wish to share the details with you:
So we know that the header for a potential tip requires the version, the hash of the prior block, and the target. The question asks us to keep these constant. Next, we also need the Merkle root of transactions, the timestamp, and the nonce value. Since the question says per second, the timestamp can be left constant. If there are n txn we can have n! Merkle roots. But how many nonces can we have. I think that's what the question is asking.

I just found out that a nonce is only 4 bytes (2^32 values) long. So there is a way to run out of them. So I think the total values = n! * 2^32. But the question is, how many of them are valid, given that the target is fixed?

From here: https://en.bitcoin.it/wiki/Block_hashing_algorithm 'Whenever Nonce overflows (which it does frequently), the extraNonce portion of the generation transaction is incremented, which changes the Merkle root.'

@DeltaBourne Reading your comment, it seems that the actual answer is, it depends on the number of hashes computed per second. I presume however that you are supposed to come up with a numeric value meaning what is the technical limit. The answer should be the technical limit of sha256(sha256(x)). The interesting question is, does hashing a hash reduce its resolution? If the answer is supposed to be limited to the number of possible blocks meeting consensus rules per second, then it depends on the current difficulty and the number of hashes computed per second.


text:
What data structure should I use to model a Blockchain
I'm working on a functional mini-Blockchain implementation in Scala. I've given this a lot of thought but still can't comprehend the most suitable data structure to model a Blockchain. Specifically :-
1.) It can't be a simple Linked list/Stack, because there are forks , which means that two different blocks can refer to the same Block.Should it be a List of top blocks , i.e. a list of topmost(heightwise) blocks ? I can then traverse the blockchain by starting my traversal from either of the topmost blocks.
2.) How do I make a block point to the previous block ? I know that every block has the hash of the previous block. But how is that enough for me to go from a block to the block it refers to in my blockchain data structure ?
Would really appreciate any help I can get.

First, a blockchain is it's own data structure.  It's best to think of it as one.  It represents a way to organize data in which desirable properties are gained.  However, that still does not explain how to hold one in memory/storage.
In Bitcoin, the blockchain is stored on disk (not memory) using leveldb.  This is a key/value database where the keys are the block hashes and the values are the blocks.
For an in-memory equivalent, a hash map is what you are looking for.  This is a data structure where the key is a hash of the contents (such as a block header).  From there, the header's Merkel root would point to another hash map of transactions arranged in a Merkle tree (as per the protocol).
However, an in-memory solution (which seems to be what you are after) is a terrible solution for a blockchain.  The data simply grows too quickly.  You will want to store the data to disk and have a fast way to query it.  This is why Bitcoin uses an existing database such as leveldb.

This is a great suggestion. I think I'll go with the leveldb implementation. A couple of questions :-
1.) How would I model a fork, the fact that two blocks can exist at the same height at a given point in time. This is especially important while choosing the parent block to mine against.
2.) If all blocks are stored in disk, isn't validating a new block a very time consuming operation since we need to validate each transaction in the block against all transactions ever done (by querying the DB) to prevent a double spend ?

3.) What do you think of an implementation where I store the block headers (80 bytes each ) in memory and store the transaction data which occupies the bulk of the space in level-db ? This will make it faster  to validate the blockchain by verifying the correctness of the prevHash field of each block.

Actually, it occurs to me, I wonder could you use Git?
You could just use a stacked file naming convention that is the hash of the file contents header (including a Merkle Root or a hash for the contents) and refer in the header section of the file to the previous file. This allows for forks.

Thanks for the reply.
1.) Please can you elaborate a bit on how Git stores it's files ? Even some links would do ?
2) How would you leverage this to store the Blockchain in-memory ?

I was thinking that you were looking for a simple file structure for storing blockchain, I probably could have started the second paragraph with or. Git would allow for some interesting operations. You could probably read Git from the bottom up and Pro git - too big for the inline viewer; you have to download it. Bitcoin blockchain is a little to big to store in memory generally speaking at ~150GB.


text:
Sample worked Stratum example
I need some help trying to verify that my implementation is correct or not. I'm trying to make a Stratum mining client.
All byte orders are as is directly received from the server, without endian swapping
Here's the data:
{"result": [[["mining.notify", "108fa002000000001"], ["mining.set_difficulty", "108fa002000000002"]], "108fa00200000000", 4], "id": 1, "error": null}
{"params": ["1369818357 489", "56d14795eadabe52464b0c6410f8c1f70c0af2c5444379160000002400000000", "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff51039aa3030d00456c69676975730051a5c4f5fabe6d6d28db22e01b9dceb2e0dc8d7cc01bfc4dcdbce7f7a49c57020c827389efdcea970200000000000000002f7373302f00", "[encoded data, 4234 characters]", ["d8481cf9050990f425c82fd0f4b0d1dcd3166435cd56eb8f00c76244704812d8", "815bb21cfd4bf9d26b8b85937390bfb6c39f84a81f8580ba0028c935543cfeec", "1450b5fe41462f25ca2b8f1f8df1fc08732532ec5b72039f5ad1ad1bd0a3546c", "af94c2da313d385e2c0c8812c70f8e86809e90f95e79f25e6cdf6c98eac1232a", "53276d253bee618e675e32b0367e3a786e717bc7e766b165caa8d5de84ef1bf8", "b0e99cef9b6a55684b8a399a54842a5123163c2fe324a9c563f4d5314ff50684", "1b559b9b59306deb2d23716fecd213852efe519cbf297c9b10178be71c1013e9"], "00000002", "1a016164", "51a5c4f5", false], "id": null, "method": "mining.notify"}
{"params": ["redacted", "1369818357 489", "12000000", "51a5c4f5", "41f20233"], "id": 2, "method": "mining.submit"}

I've obtained this from running bfgminer and dumped the share logs and tcpdumped the connection to the pool.
bfgminer has logged the block header as (with padding):
0000000256d14795eadabe52464b0c6410f8c1f70c0af2c5444379160000002400000000751b1aba
ddefb3e3e74c3ac8bbe49787a5ae21703b873e0958a9441a0871d2dc51a5c4f51a01616441f20233
00000080000000000000000000000000000000000000000000000000000000000000000000000000
0000000080020000

Hashing the data as it appears in the usual fashion, ie., sha256(sha256(data)), doesn't yield the hash that it says it obtained, which is d8b5ed97e69707dc17cae1c23e672818a18b75fd362bb698fad4433b00000000.
I thought I could calculate the merkle root by the usual fashion, with the nonces obtained from the above subscription and the submission message:
>>> coinbase = coinbase1 + extranonce1 + extranonce2 + coinbase2
>>> coinbase_bin = binascii.unhexlify(coinbase)
>>> root = coinbase_bin
>>> for h in merkle_branch:
...   root = hashlib.sha256(hashlib.sha256(root + binascii.unhexlify(h)).digest()).digest()
>>> binascii.hexlify(root)
'eed07afc76bc7b15dc5871581a2460c7473ed68573082a0e5864140db0d11803'

which is wrong too.
Can someone tell me what's going on here? What do I need to swap and what do I need to keep as-is? Or can someone give me a subscription message, a work notification, and a submission message, and show me how to perform all the validation steps?

The block output you're seeing from bfgminer ("0000000256d14795...") is the wrong thing to be hashing; it looks like it isn't swabbing the fields when it logs.  The first four bytes of a block are a little endian format version number, and I do not think block format version 33554432 will be released for some time.
Compare the example given on bitcoin.it (https://en.bitcoin.it/wiki/Block_hashing_algorithm): the initial bytes are "01000000" (format version 1 as a little-endian uint32_t).

Thanks. Just for the record, the version field, prevhash, time, and difficulty fields require swabbing. The merkle root doesn't appear to need swabbing, and my error above is failing to hash the coinbase before calculating the root.


text:
berkeley db debian wheezy
I am trying to make a website that supports bitcoin, but I cant install bitcoin core because berkeleydb is under 4.8. I tried installing it via apt-get squeeze repository but that didn't work. I also downloaded the tar.gz file and installed that but that also didn't work. Does anyone know how I can install berkeleydb or what linux distro has full support of berkeleydb?

Here is good guide (read comments too)
https://www.howtoforge.com/tutorial/how-to-compile-and-install-bitcoin-core-on-debian-wheezy/
also you can use bdb 5.1 (./configure --with-incompatible-bdb) if you don't have a plan to move bitcoin data to/from other computer

I strongly suggest that you not use an incompatible bdb. The time it costs you later is not worth the time you save.

@NickODell, isn't incompatible bdb just for compatibility with older wallets? Why would you need compatibility with older wallets if you're starting a new wallet from scratch?

@StephenM347 I was under the impression that later versions like 5.1 weren't compatible with bdb 4.8, meaning that the wallet you created using bdb 5.1 instructions wouldn't be compatible with a bitcoin core client built using bdb 4.8. That's probably worth a question of its own, though. http://bitcoin.stackexchange.com/questions/42965/do-berkley-db-versions-need-to-be-the-same

@Nick Yes, a wallet.dat touched by bdb 5.1 won't be readable by a bdb 4.8 version. However, it's trivial to convert it back if needed (db5.1_dump wallet51.dat | db4.8_load wallet48.dat)


text:
Derive LTC Segwit (M-Address) private key from Trezor
So I'm trying to get my head around this!

I've got my 24 seed for my Trezor.
I got my Segwit account for LTC (Address starts with M).
I also have the P2H equivalent for my address (Starts with 3).

How do I derive using the BIP39? I tried, and I ended up with addresses that start with L. (Legacy ones).
m/49'/2'/0'/0    --> this one is for M Segwit LTC
m/44'/2'/0'/0    ---> this one is for Legacy LTC

When you are deriving addresses, you are actually deriving private or public keys from which an address is derived. However addresses are actually an encoding of what type of script to use in the output, but private keys have no concept of what scripts are. So when you derive your keys, they don't specify what type of address to create. Each private key can actually correspond to multiple addresses.
To specify what kind of address to create, your wallet software must be able to understand what the derivation paths mean or be able to be told what kind of address to be created. Just using a derivation path for keys which were used to derive one type of address does not mean that all software will create the same addresses.
You will need to use a software that knows how to create the address type you want and then you need to be able to tell it to do that.

@AndrewChow♦ explained it nicely.
Another way to see the relationship between keys and addresses is directly using litecoind, if you have one handy.
$ litecoin-cli getaddressesbyaccount ""
[returns list (A) of addresses or none]
$ litecoin-cli getnewaddress ""
[returns a fresh new address ADDR1]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + single entry for ADDR1]
$ litecoin-cli dumpprivkey <ADDR1>
[returns private key PRIV1 that ADDR1 came from]
$ litecoin-cli importprivkey <PRIV1>
[returns nothing]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + ADDR1 + two extra representations]

That last call to getaddressesbyaccount "" shows that when importing a private key, the daemon adds all possible addresses that correspond to it.
The private key in litecoin's case corresponds to:

a p2pkh address (legacy, non-Segwit): starts with 'L'
a p2sh address (wrapped Segwit): starts with 'M'
a bech32 address (pure Segwit): starts with 'ltc'

Note: the ADDR1 returned by getnewaddress will either be an 'L' address or an 'M' address depending on whether the daemon's config contains addresstype=legacy or not respectively. You could optionally define on the command line the type of address you want generated:\
$ getnewaddress "" legacy/p2sh-segwit/bech32

Note 2: as you might have noticed litecoind  (recent versions) avoids altogether the old p2sh addresses starting with '3' as they are trying to get people to move away from them and towards 'M' ones, to avoid further confusion with bitcoin's '3' addresses.


text:
what is "forming a coinbase transaction"?
So based on this after getting the right information from the pool, you will form a coinbase transaction, But how is it done in C lang.
Does the method above also works for altcoins?

If you want c++, the code to form coinbase is here: https://github.com/bitcoin/bitcoin/blob/1afc22a7667a7a5c66b4b5d7f50832356dd5ec12/src/miner.cpp#L161

The link you mentioned has a few code snippets, so I am assuming the code you want to write in C is the simple mining program. The python code can act as your pseudo code and very well write your mining program in C.
Alt coins which have been forked from bitcoin and do not have many changes in the mining algorithm can be very easily mined by the same methods described.
The most you would have to change is the hashing algorithm used which can be different from BTC's sha256.
When connecting with a mining pool,  it is generally advisable to use already existing mining softwares like cgminers wherein you just need to pass the stratum url and port (also  the hashing algorithhm in a few cases). A huge amount of code runs delegating the chunks of the mining problem to the miners connected to it.


text:
Minar cryptocurrencies without software or special hardware
I know that it is very difficult to mine at the moment without special equipment, but I think in a way, even if it is a hobby, to try to mine either by developing a program in Java or with Excel.
I have basic equipment, currently I work with Minergate.
I want to make my own mining system, as I would do the following:

Connect to the cryptocurrency network.
Read the hash
Interpret the hash
Enter the new hash

And which currency would be feasible to undermine.
Thank you

Are you asking which altcoin to mine?
You mainly just need to look at www.cryptocompare.com and find some of the low priced coins.
However, Bytecoin would be a good thing to start with.


text:
Where is the actual data stored and how does that data get stored
How does data get stored for bitcoin?
Does data in the blocks get stored in files or a database and then get referenced by the blockchain?
If data is being stored in file, how does the blockchain create the files, put the data into them, and in what format are the files?
If none of that is true and the blockchain data exists in memory, if all of the nodes went down, how do you bring the blockchain back up?

If you are running a full node you have the blockchain stored on your HDD/SSD. If it was stored in your memory you would lose the blockchain everytime you restart your computer.

If data is being stored in file, how does the blockchain create the files, put the data into them, and in what format are the files?

The blockchain doesn't create the data/files, the blockchain is the data. In case of the Bitcoin Core wallet you can see the blockchain data as .DAT files in your AppData directory under:
C:\Users\fihdi\AppData\Roaming\Bitcoin\blocks

In case you use the standard directory.


text:
Unconfirmed transaction for nearly 3 months
Sorry but I am fairly new to this. I have qt wallet and have done quite a few transactions, but around Xmas time I placed a few payments that didn't go through. After  checking the web, many said just to wait and the coins will come back. But as it's now been 3 months, is there anything else I can do? Please be basic as I'm not that experienced.

Do you have the transactions to show trough blockchain?
Which website did you send the payments to?
Were the transactions confirmed , how many confirms? Your question is a little vague can you please be a little more specific

What you need to do is find the transaction i.d.
There you will see everything if there is no confirmations after 3 months its just well strange , I think you can look for more answers also in bitcoin forums there are alot of people that can help there nad they answer usually instantly

Thanks for getting back to me. I just checked the bitcoin chain and found that the transaction id isn't there and the address the coins were sent to doesn't show and transactions at all (it was a new account set up for this one transaction). But my wallet still shows it as an outgoing transaction with 0/6 confirmations 23/12/15. Obviously its something wrong with my wallet, but I can't find any simple way to reset it. Do you have any ideas? And thank you either way for the help you have given so far, I really appreciate you taking the time to assist a complete stranger.


text:
How can you tell a block is Classic vs Core?
Sites like http://xtnodes.com/ are tracking which versions of Bitcoin software are being used to create blocks. Where are they looking in the block structure to determine which software version generated the block?

Ah, not surprisingly, it's in the block's "version" field. It looks like core blocks are versioned as "v4", while "classic" blocks are versioned as "v805306368" and "BIP109".


text:
BitCoin Core Error Message: "Assertion failed!"
I am experiencing a recurring problem with my BitCoin Core wallet. The main issue here is that I get an error message every so often as the program is updating the transaction blocks.
Please see the jpeg in the link above, this is the exact error message I get when the client is updating.
Details:

I am using BitCoin Core V 12.0
I have tried reindexing using : c:\Program Files\Bitcoin\bitcoin-qt.exe -reindex
I have tried to reinstall the client, then restart my computer, then open and let it update.
I haven't yet tried a RAM test to see if my RAM could be the source of corrupted data
I'm running Windows 7 OS 64-bit, 8Gb DDR3 RAM

I feel its something that can be fixed with a patch, but I could be wrong. If anyone has a solution that I can try myself, that would be most welcome.

It is possible that you are running out of RAM or HDD space.  Check this github report from a user with a similar issue.  If this is not the case then I would run a memtest and see if you don't have an issue with your RAM.

Hi Mark, thanks for the quick reply! I have 90Gb of free space on HDD and will try a RAM memtest next. Will update this post when thats complete

Hello again, I tried to use a RAM test software and mounted its image onto a USB stick. I followed their instructions it and after I went to enter set up, i could see it there under BOOT section but could not activate it when it was highlighted. I pressed enter when it was high lighted and nothing happened. If anyone can recommend another course of action to correct the problem as seen in the JPEG above, please give us your take on this.


text:
How is a transaction formated/signed?
Every transaction takes unspent outputs as inputs and creates new outputs. The creator of the transaction uses his private key to sign the transaction and nodes validate that transaction by using the public key of the creator.
But how excactly are transactions formated? I have seen this on the bitcoin wiki:
Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

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

If we use this transaction as an example, how do we take the data from this and format it into a RAW signed transaction that I could send straight into the network without the need of a wallet?
Also, after creating the signed RAW transaction, is it just hashed by SHA256 to create its hash ID or does creating the ID consist of other steps?
Lastly, what is scriptSig? I don't quiet understand scripts in general so if someone could give me a brief explanation of that as well I'd be grateful
Thanks in advance!
Fihdi

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

The referenced tx is already spent. So it cannot be re-used. Also you cannot reformat it into a RAW signed tx. There would be 2 steps required. First reformat into a "RAW UNSIGNED" tx, and then this would run through another set of commands to get it signed. Only then it could be sent to the network.
In the example, there is a bit of data missing, I'll add quickly. It becomes clear with the two links below:
version       01000000
Input(s):     1
Previous tx:  f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index:        0
script length 48
scriptSig:    304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Sequence      00000000
Output:       1
Value:        5000000000
script length 19
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d OP_EQUALVERIFY OP_CHECKSIG
Locktime:     FFFFFFFF

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

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

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

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

Basically it makes sure, that the condition to spend the transaction's funds are verified. This has been asked several times in bitcoin.SE, so I provide another link (see my answer further down):
Why does Bitcoin uses a Script language?
And as said in this link, the book from Andreas answers all these questions very well. Really highly recommended.

I'm quite sure that the amaclin's provided link is a copy paste of the runek's previous answer though.

You can sign the transaction hash data by pressing the "Sign" button by accessing the details of the transaction with tools such as Electrum. Then do not forget to say live broadcast.


text:
Misdirected Bitcoin?
Good day. I bought 2 Bitcoin from a reputable dealer and asked that they be transferred them to my private Electrum Standard Wallet. The Bitcoin has not arrived in my wallet. The dealer has confirmed sending the Bitcoin to the correct address. The "History" tab of the wallet shows a new line with an exclamation mark inside a triangle with the word "Replaceable" next to it and +0 under the Amount. Is it possible that the Bitcoin has been lost or misdirected? Have I done something wrong with the wallet that must be changed? I would be grateful for any assistance.

there are not many details like tx number or addresses... so an Electrum wallet showing the tx looks primarily ok. Maybe it takes some time until tx gets confirmed. See if you find the tx number, or ask the service provider (aka dealer) to give you the tx number. Then you can take your address or your tx number and verify on "blockchain.info" the status. Let us know what you see, and we might find a proper answer.

I have checked on blockchain.info using the address and it indicates that the Bitcoin was delivered. My wallet however shows zero change to the balance. Apart from the History tab which shows the triangle and the word “replaceable” with a zero balance received.  The Receive tab shows the transaction request. It also shows something that may reflect a problem. When the request for a new receiving address is made on this wallet, a box provides the request to expire within 1 Hour, 1 Day, 1 week and Never.
The “Never” option was chosen . Was it a mistake to use the “Never” option perhaps?

When blockchain.info shows the tx wih the funds of your address (with several confirmations), then you „have“ the funds. This is ok, and your provider obviously sent the funds. Now s.th. in your wallet seems not ok. Have you access to your private key? Or to the initial seed? Then I would create on a different system a restore of the wallet, or use a different wallet and load the private key into it. From there you could spend the funds.


text:
need help in recovering my BCH
i mistakenly transferred 2.0 BCH from a BTC(blockchain.info) address to a Segwit address(Greenaddress)... I need help in recovering my BCH. I'm will to part with 20% if you can help retrieve it. I'm not really an IT inclined person so i'm ready to send whatever infos needed in retrieving to whoever is willing to help.

Welcome to bitcoin SE. Please note: NEVER send you private keys / seed phrase to someone who is trying to help you. If you do that, they'll be able to steal your coins.

thanks for the advise... But i'm clueless on how to go about recovering it.

segwit is not supported for bitcoin cash! did you move it to bitcoin segwit address?

yes i moved it to bitcoin segwit address...

https://www.blocktrail.com/BCC/address/38V1ovQ2sSThDxjt9Bmi3iSY75LZshqobi

You will not be able to do that easily even if you have the private key Since bitcoin cash doesn't support Segwit, so you have to edit source code and mine that transaction by yourself.
Helpful links:
Bitcoin Cash SegWit hack
Recovering BCH sent to Segwit addresses

That's a lot to take in for me... I'm not a programmer and i hardly understand coding and stuffs... I don't mind engaging you to have that done for me then i pay you for your service. Some say its risky to give out personal infos but whats the use of the BCH if i cant have access to it???

stackexchange is not the place to pay for services. please take a look at the links I've attached


text:
How is Bitcoin itself represented (either technically or code level)
I've gone through dozens of videos and texts, but haven't found properly how is the actual bitcoin itself represented technically or at code level?
From what I have understood thus-so-far (if correct), is that a single bitcoin itself is NOT represented by any class/object at code level (or technically NOT represented by a unique ID like fiat money has printed on it), but rather bitcoin is ONLY a figure that's stored in a distributed ledger (blockchain).  And that the creation of a 'new' bitcoin is out of thin air as a reward for verifying transactions together with proof-of-work (i.e. solving a math problem in order to delay the broadcast of verification of transactions) for security purposes (and thus NOT as some put it to discover new bitcoins - as no bitcoin has a permanent unique ID to be discovered).
Is there a bitcoin expert or bitcoin developer that could verify (and possibly add more info) if my understanding is correct, and if not, to please explain how bitcoin itself is represented either technically or at code level (and it will help me understand more clearly if you could also explain the technically process of the creation - or the so-called discovery) of 'new' bitcoins in a way that's related to this question)?
Thanks.

these questions would justify a whole section of a book. To avoid this, I put a link at the end of the message. In between, I'll try to answer some parts of your question.

I've gone through dozens of videos and texts, but haven't found
  properly how is the actual bitcoin itself represented technically or
  at code level?

That is a known problem with all these videos. It is not sufficient :-)
The bitcoin is represented as data in the blockchain. Effectivly, a transaction moves bitcoins around, taking transaction from an address, sending it to a new address. When you take a look at some bitcoin explorers, they provide details, e.g. here as an example. To answer your question, you'd need to understand the details presented in this transaction. In short: you'll discover 2 inputs and 4 outputs. This is, what moves the Bitcoins (or Satoshis). Many transactions can then be combined into a block, which then create the blockchain.

From what I have understood thus-so-far (if correct), is that a single
  bitcoin itself is NOT represented by any class/object at code level
  (or technically NOT represented by a unique ID like fiat money has
  printed on it),

yes, I mean, no serial number on it. But programming wise (there are dozens of implementations), you could think of a class "bitcoin". The default core code has no such thing, code reference is here.

but rather bitcoin is ONLY a figure that's stored in a distributed
  ledger (blockchain).

yes

And that the creation of a 'new' bitcoin is out of thin air

well, thin air is often a repeated idea, which sounds like discrediting distinction to the FIAT world. But effectivly you have to do some work ("mining"), which costs a lot. So thin air is probably wrong.

as a reward for verifying transactions together with proof-of-work
  (i.e. solving a math problem in order to delay the broadcast of
  verificationof transactions) for security purposes (and thus NOT as
  some put it to discover new bitcoins - as no bitcoin has a permanent
  unique ID to be discovered).

somehow - please read chapter 10 of the refenced book :-)

to please explain how bitcoin itself is represented either technically

Yup: here is Andreas wonderful book "Mastering Bitcoin", which has lots of examples relevant for developers.
My proposal to you: start to evaluate transactions in detail (Chapter 6), and work over into wallets and keys. This gives you the picture within 2-3 hours. And then you probably get the idea. Otherwise you extend your question here, or raise a new question :-)

Thank you very much for your directions.  I really do appreciate it.  I found the info I am looking for both in your answers and also in the book that you that you have recommended 'Mastering Bitcoin'.  I thought to read the book first prior to making a comment.

Closest analogue of Bitcoins, i.e what you intuitively imagine as the coins, are the sums (face values) inside unspent transaction outputs (UTXO), or the unspent transaction outputs (UTXO) themselves.


text:
How can I get a private key for my watch only adress
I'm new on bitcoin I have bitcoins that are stored on watch only address and I dnt have a private key for this address even when I add it to mycelium it says warning this address does not have a private key, but now the problem comes when I try to export a private key there is no option for private key from addresses I select manage and it gives this options.. Archive, transfer and spent no option for private key... Please help

welcome to bitcoin.SE! Can you tell us a bit more about your case, why do you want the private keys, and why do you want to export from Mycelium? Are these private keys belonging to addresses, that you might have from an exchange?

I have bitcoins that are stored on watch only address

What are watch-only addresses?
A watch-only address is a public bitcoin addresses you’ve imported into your wallet. This is a cool, useful feature if you want to monitor activity at a particular bitcoin address. You can import any existing bitcoin address.
There is no way to get access to those bitcoins because it's a watch only address. You can only watch it, but you can't do anything else (sending BTC away, exporting the private key, signing something...)


text:
Incremental build for bitcoin
I did use the Make to build bitcoin source  [https://github.com/bitcoin/bitcoin].
every thing went ok.
then I have changed one of file bitcoind.cpp , and issue the Make command again, but this time Make has tried to build all bitcoin source again.
my question is how to do Incremental build for  bitcoin?
my system is ubuntu, and g++ is Ubuntu 5.4.0-6ubuntu1~16.04.6

I'm voting to close this question as off-topic because it is a general how-to-build or how-to-make question and probably belongs on Linux or Ubuntu forums somewhere.

@Willtech,  look, this is explanation regarding "bitcoincore-development". This tag should be used for questions regarding Bitcoin Core development. This includes questions about the source code and development of Bitcoin Core

Kind of, yes ... if make is not behaving correctly, then it must be found why. As explained in “how to raise a good question”, it should show how the OP has given some efforts into debugging the error. Just throwing a problem here is deemed to be unsuccessful- we all are busy working. That said, I guess a fresh start with make/automake and a “hello world” should be first steps. If you don’t know how to do this, then willtech is right. If you were able to do so, next step would be to verify versions and maybe log file of involved tools.

If you don’t know how make/automake/autoconf work, again, willtech is right. And if then an error is in bitcoin code in line xyz, then this is the right platform :-)

AFAIK there is no way to incrementally make. You either make or you don't.
But, you could try >make bitcoin-qt and see if it just makes that module? Nope:
>make bitcoin-qt
make: *** No rule to make target 'bitcoin-qt'.  Stop.


text:
Subscription-based payments
I'm writing a web application that will require subscription fees from users. I'd like to automate this process without relying heavily on 3rd party services (web-based wallets, etc).
Currently, this is how it is designed:

Web app connects to a websocket on the server using a JWT bearer token for authentication and requests an address.
The server calls the getnewaddress method to the RPC daemon and returns this address over the websocket
The wallet's pub (is priv necessary?) keys are stored in the webapp's database as well as the user that requested the address.
The websocket will provide periodic progress updates along with a refreshed JWT (tokens expire every 2 minutes) while waiting for the transaction. If the user disconnects, no harm done.

Once the transaction is completed, a curl command is triggered by walletnotify and submits this TXID to the web server, which ensures "confirmations" are > 0, and the "receive" address is used as the database query to determine which user added time to his/her subscription.
Questions:

Does getnewaddress generate a new wallet? Or am I free to receive as many as I'd like?
Running getbalance <account> shows the summation of all addresses listed in listaddressgroupings. Is this all usable from the same wallet?
How can I consolidate or remove addresses when they're no longer necessary? Do the BTC stay in the "account"?

Quick comment: generally it is not advisable to remove a bitcoin address/keypair from the wallet entirely (unless perhaps it is a BIP32 wallet and you have the seed and derivation saved). Keypairs are not very data intensive to store, the benefits of keeping them probably outweigh the risks of having someone reuse an old address, and then have the funds be unrecoverable because a keypair was deleted.

getnewaddress will generate a new Bitcoin address for your existing wallet, Yes you can get as many as you like.
I would use getreceivedbyaddress which returns the total amount received by the specified address in transactions with the specified number of confirmations or listunspent to get all transactions for specific address with confirmations
AFAICT, You can't remove an address from your wallet using any RPC call, but by editing wallet.dat manually.


text:
Bitcoinj unable to load wallet
So I want to load a wallet and get its balance also sending some funds with the corresponding wallet, here is my code
public class DumpWallet {
public static void main(String[] args) throws Exception {

    Wallet wallet = Wallet.loadFromFile(new File("wallet.dat"));
    System.out.println(wallet.toString());
}
}

Why does it throw these followings error (I am using wallet.dat that created automatically on C:\Users\<username>\AppData\Roaming\Bitcoin\testnet3
Exception in thread "main" org.bitcoinj.wallet.UnreadableWalletException: Could not parse input stream to protobuf
at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:427)
at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:399)
at org.bitcoinj.wallet.Wallet.loadFromFileStream(Wallet.java:1581)
at org.bitcoinj.wallet.Wallet.loadFromFile(Wallet.java:1487)
at org.bitcoinj.examples.DumpWallet.main(DumpWallet.java:33)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
    at com.google.protobuf.InvalidProtocolBufferException.invalidTag(InvalidProtocolBufferException.java:89)
    at com.google.protobuf.CodedInputStream.readTag(CodedInputStream.java:158)
    at org.bitcoinj.wallet.Protos$Wallet.<init>(Protos.java:14789)
    at org.bitcoinj.wallet.Protos$Wallet.<init>(Protos.java:14778)
    at org.bitcoinj.wallet.Protos$Wallet$1.parsePartialFrom(Protos.java:14956)
    at org.bitcoinj.wallet.Protos$Wallet$1.parsePartialFrom(Protos.java:1)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:89)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:95)
    at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
    at org.bitcoinj.wallet.Protos$Wallet.parseFrom(Protos.java:15822)
    at org.bitcoinj.wallet.WalletProtobufSerializer.parseToProto(WalletProtobufSerializer.java:606)
    at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:420)
    ... 4 more

Bitcoinj doesn't read Bitcoin Core wallet.dat files. You need to start a
fresh wallet and move coins into it using a standard Bitcoin transaction


text:
Keeping Track of User Deposits with Bitcoin
I found the following statements about Bitcoin on the Ethereum SE:

When using Bitcoin one can generate new address per user of service
and save pair (address -> userId), so it is always obvious which
specific user sent coins.
Also, all these coins are stored in the wallet as UTXO, so it is easy to send them to another address paying fee once

I need to generate different unique deposit addresses for each user,
so they can send funds to their accounts while I can keep track of how
much each user deposited. This is fairly easy in other cryptos such as
bitcoin

Are these statements true?
If so, can someone explain why it "is fairly easy" to do this in Bitcoin"? Doesn't Bitcoin also require UTXO Sweep when consolidating BTC from many addresses to one address? I was under the impression that BTC does not allow multiple public addresses corresponding to a single private key?

Yes, each UTXO needs to be spend individually, regardless of which address they were received to. I think it would be appropriate to read this advice as "at least one address per customer". Having separate addresses per customer will make it much simpler for you to track which customer's account needs to be credited than having only a single address for your service altogether. However, if you're not in a scenario where you're just taking deposits for a user, but e.g. selling products or services, I would even recommend to use a separate address for each payment process, which would make it trivial to discern not only the customer but also which invoice got settled.
Today, wallets generally use hierarchical deterministic derivation to generate many addresses from one master secret. Under the hood, each address is associated with a different private key, but all private keys can be regenerated from the master secret. This allows you to track many addresses with a single wallet, but simplifies backups and secret management.
Address reuse is terrible for both your and your users' financial privacy and has no palpable advantages when you start to consider the additional overhead of figuring out who paid with which transaction. I can only vehemently dissuade from using the same address for selling to multiple customers. If you get a lot of volume, it will be trivial for people to claim foreign payments as theirs and you will lose a lot of time investigating and acquiring proof from the actual customer. Using separate addresses may be more work in the beginning, but just gets rid of this whole class of issues.

Great response, upvoted and accepted. I agree that unique addresses is the way to go with Bitcoin. I just have one question: You mentioned that "If you get a lot of volume, it will be trivial for people to claim foreign payments as theirs and you will lose a lot of time investigating and acquiring proof from the actual customer" this statement implies that it is in fact "possible" for a customer to prove they sent certain funds  despite multiple customers claiming the same thing. What "proof" can a customer provide (after the fact) that would be sufficient to prove he in fact sent those funds?

Some wallets are able to sign messages with private keys they possess. You could challenge the payer to sign a message with the private key that was used to sign for one of the inputs. Unfortunately, not all wallets have this capability, especially online wallet services don't usually provide that functionality.

Additionally, there is no provision to transfer these sort of challenges or their responses on the network, so you'd have establish an out-of-band communication channel to get that information in the first place. It's just one big hassle. Using distinct addresses for different payment processes is much more straightforward.


text:
How many zeroes does the current target have?
I'm trying to get my head around the difficulty setting of Bitcoin.
How can I calculate how many zeros the target string needs to start with?

17 judging by the latest blocks published on blockchain.info:
https://blockchain.info/block/0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4df598ee

Thanks especially for the link to make it easy to find out the answer in the future, as well.

The future is now ;-)  Changed to 18, https://blockchain.info/pt/block/0000000000000000008be77e83deb352669b55fbe8f5ed208005fc1a9830c06c  (since Feb 2017 as this block, perhps before).

An early block of  Mar' 2009 (block deep 6100) have  8 zeros  (see same at other explorer).

Still 18 zeros in June 2018

December 2018, 19 zeros

Clarifying: difficulty is a more human-friendly representation of the target. Tha target itself is not specified in terms of the amount of zeroes. This seemed to be the case with hashcash.
The more precise definition of the target is a maximum accepted number for the produced block hash. In this sense a certain hash with a certain number of leading zeroes may be accepted and another hash with the same amount of leading zeroes may not be accepted.

Hi Jonathas, we see that the  amount is growing, so, who (authority or Bitcoin-rule) define the amount?

Hum... See current difficulty and target concept, this is the reference for number of zeros (!).