text:
Is it true that the rate of finding a new block is constant, but just that the bitcoin reward become less and less?
Can somebody ELI5?  Is it true that every block that is discovered, the person that discovered the block will be awarded 12.5 bitcoins?  But to discover such a block, somehow the person has to get a SHA256 number that has all 0's for the first 72 bits?
What if somehow, in that 10 minutes, two new blocks are discovered, or likewise, what if a new block took 20 minutes to be discovered?
And it is 10 minutes per block discovered? So in the year 2022, when the number of bitcoin awarded is halved again, to 6.25 bitcoins, does that mean it is still 10 minutes per block, but now the award is 6.25 bitcoins?
Or does the 72 of 0 bits now become 73 of 0 bits?
So is it true that even in year 2140, when all 21 million bitcoins have been rewarded, then new blocks will still come out every 10 miniutes, and good for recording transactions?
It is said that 1 block is 1MB, and each transaction is about 0.25kb, so 1 block = 1MB, is good for 4000 transactions.  So in year 2035, or in year 2140, we can still record new transaction at a rate of 4000 transaction per 10 minutes?

Does this answer your question? What exactly is Mining? and What keeps the average block time at 10 minutes?

@RedGrittyBrick do those answers talk about 72 bits of 0's?

72 bits of  0s is not a special number overall. You are talking about a difficulty level which is readjusted every 2016 blocks based on prior 2015 block times. At some time the difficulty level might be a number that has some specific number of leading zeros at other times it will be different. It effectively adjusts depending on the combined total hashing power (total hashrate) of miners. It is adjusted to whatever number would be sufficient to keep the block production rate near 10 mins. This is explained in answers to the linked questions.

P.S. to attract better answers, you can try to ask only one question at a time (I count eight question marks in your question above). This is explained in the [help]

If I ask one question at the time, are you sure there will be no issue about "asking too many questions"?

I find it best to search for similar questions here before asking, then choose and compose question carefully to minimise the number - focus on the most important. Your mileage may vary

sometimes, a question has 5 answers and 2000 words and you still can't find what you are looking for


text:
Is it a relatively big fee buying Bitcoin on bitcoin.com?
I bought some Bitcoin on Robinhood for $0 fee, and about $2.99 fee on Coinbase.com, but since bitcoin.com seems like an official website, I tried installing the app to buy some Bitcoin, but for $180 of Bitcoin, the fees are like $13.50 + $2.32 = $15.82   (as paid by Apple Pay).
It seems such as big percentage (8.3%) of fees just to buy $180 of Bitcoin.  Is that just the way it is on bitcoin.com or any method to make the fees at most about 3%?

Bitcoin has no official website, and bitcoin.com isn't anywhere near it.

bitcoin.com has bitcoin wallet... so if I don't use bitcoin.com, how do I get a Bitcoin wallet? (it seems Coinbase has a wallet app on the App store... Robinhood has an app but I am not sure if it is also a wallet)

Install one of your own. I like Electrum (electrum.org) personally. Also, I'm confused, it looked like Robinhood fulfilled your question requirements of <3% fee, I haven't tried it myself but why not just keep using it if it worked for you? I also would recommend staying far away from bitcoin.com.

@ieatpizza because I am just exploring the options and the pros and cons.  Robinhood seems to only buy it in their name and they said they store it "cold" for me. But they don't allow me to transfer to my wallet... unlike Coinbase... so Robinhood is like buying it and selling it only, like a stock

bitcoin.com seems like an official website

No, it is in no way official. If I remember correctly it was started by a group of people who created a new cryptocurrency by forking Bitcoin, they wanted to take over the name Bitcoin for their altcoin. They are not well regarded by the Bitcoin community. Their altcoin is not Bitcoin
There are no officials and no official websites for Bitcoin. This is because Bitcoin is intended to be completely decentralised.

Is it a relatively big fee buying Bitcoin on bitcoin.com?

Your numbers for other currency exchanges suggest that this is the case.

Is that just the way it is on bitcoin.com

Yes, apparently they are a business that charges higher fees than some other businesses.

how do I get a Bitcoin wallet?

A good place to start is https://bitcoin.org/en/choose-your-wallet but also see
I am new to Bitcoin, how can I get started?

source: Stack Exchange

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

sort: votes


text:
Cannot access balance in BTC Core/Sparrow Wallet/Seedsigner
My saga begins thus - February 2024 i make a series of deposits from my Trezor wallet to my newly formed Seedsigner/Sparrow Wallet/Bitcoin Core node using Seed-Words & Passphrase in BIP39, everything is good & i can signin & out of my new wallet with full balance showing after the transactions with Trezor,after this last viewing of those successful transactions i do not use that node again, i just left it running & never attempted to check the balance again until 2 days ago, in the last 9mths i have had another separate node running specifically in BTC Testnet, running weekly practice transactions for the sake of keeping up to speed, both nodes are HP T630 Thin Clients running Linux Debian 12, please note i updated all software including BTC Core/Seedsigner/Sparrow Wallet to the latest versions on time.
The Crux is...when i decided to log into the Mainnet Node i forgot to change the setting on the Seedsigner from Testnet to Mainnet, so i entered the correct Seed & Passphrase with both fingerprints correct only to see a wallet with no transactions...i shortly thereafter found my error in not changing the Seedsigner setting from Testnet to Mainnet, so i promptly changed it back to Mainnet, deleted the wallet from Sparrow Wallet then entered my Seed & Passphrase in correct order with Fingerprints matching only to come across the same uninviting wallet that had appeared before, namely no transactions being listed, everything else had been changed correctly namely the BTC Core Config to server=1 etc.
I had the original Trezor Seed which i had used to transfer earlier in Feb 2024 so i entered that Seed into Seedsigner/Sparrow/BTC Core & up came those transactions i had sent in Feb 2024 to my SS/Sparrow/BTC Core wallet.
The question i am asking the Learned Folk here are, is there a way i can regain my wallet back with its full balance? i am NOT tech Savvy & any advice is appreciated! thank you.

is there a way i can regain my wallet back with its full balance?

You could restore your wallet backups on new equipment.

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


text:
Bitcoin wallet showing balance, Blockchain receiving address shows 0.00, wallet is from 2009 and hasn't been synced
Old wallet, like from the first client, Has not been synced for at least 7 years. BTC balance shown, 0 pend, 0 available and blockchain address shows 0 balance. Still waiting for entire blockchain to sync but its passed the deposit date by years with no confirmations. 0.00 pending/avail am I boned?

It is incredibly unlikely you have a wallet from 2009, this predates transactions even using addresses for most transactions.

does a block explorer say no balance or there is balance?

Blockchain says 0.00 balance in address it was received on. Wallet shows balance with no confirmations. Transaction was in 2013, I sent myself coin from somewhere but cant really remember from where.

If you can still log into the OLD wallet that has the BTC in it, you could try to set up a New Wallet under a different email address and then pay yourself. It will move the currency you have in that wallet to the new one.
You'll have to pay a fee though, unfortunately but if that's the only way to get it back and on a New Wallet where you can access the BTC again and have it synced up with the rest of the blockchain... that's what it may come down to.
If you're still having trouble let me know, I have an old wallet with scrap coin I'm gonna try a few things to see if it's been updated ever and see if I can send it to my new wallet.

Hi Robb, thanks for taking the time to answer techyguy's question. Please refrain from begging for money, we do not allow that here. Our site works a bit differently than a forum. Questions collect competing answers, they do not form threads. Please edit your prior answer to include more information rather than posting multiple answers. Check out our [tour] to get more info on how our site works.


text:
My Bitcoin transaction remained unconfirmed for 20 days now
I sent a bitcoin transaction from one of my wallets into another wallet meant for trading. Its been 20 days now and the transaction remained unconfirmed. Please I need help because I sent this coin from my blockchain.com wallet. I need step by step assistance on how to use the RBF or CPFP on blockchain.com wallet

I need help on how to either use the RBF or CPFP on the blockchain.com wallet

@Awales if you click the [edit] link and change the title of your question above to specifically  "How do I use RBF or CPFP in the Blockchain.com wallet" your question might be kept open and answered. You ought to be able to get help from support at blockchain.com too


text:
Can a unconfirmed transaction be lost or modified?
I am beginner and I am still learning fundamentals of block and bitcoin network.
Suppose, I do a transaction on bitcoin network, it is marked as unconfirmed transaction and is stored in mempool of full nodes.
This unconfirmed distributed over network, at some point a minor will create a block which will contain this transaction.
My question is where these unconfirmed transactions are stored before being included in block or hence block chain?
Can they be modified before a minor put them in blockchain?

where these unconfirmed transactions are stored before being included in block

Mempool
Each node (wallet, miner, etc) stores them in a local collection called the "mempool". The name implies these are typically kept in memory (RAM) but the developers of each wallet software can decide whether to also store the data onto non-volatile storage such as disk.

Can they be modified before a [miner] put them in blockchain

No, because they are each signed
Modifying the transaction would make the transaction signature fail verification.  Only the person who knows the secret number known as a private key can produce a valid signature for a transaction. The inputs to a transaction are locked by a script that can only be satisfied by a number resulting from the use of the private key.
Every other node (wallet, miner etc) would reject a modified transaction and start to suspect the source as being potentially malicious.


text:
NBitcoin how to send a transaction?
The verification passed. But nothing happen after that. The balance in both accounts remain the same.
Anything wrong in the way that I build my transaction?
var fpk = new BitcoinSecret("<my private key>", Network.TestNet);
var fspk = fpk.GetAddress(ScriptPubKeyType.Legacy);
var api = new QBitNinjaClient("http://tapi.qbit.ninja/", fpk.Network);
var fbal = await api.GetBalance(fspk, true);
var fcoin = new List<ICoin>();
foreach (var o in fbal.Operations)
{
    if (o.Confirmations < 2) continue; // 2 confirmations
    fcoin.AddRange(o.ReceivedCoins);
}

var builder = fpk.Network.CreateTransactionBuilder();
var tx = builder
    .AddCoins(fcoin)
    .AddKeys(new ISecret[] { fpk })
    .Send(new BitcoinPubKeyAddress("<To address>", fpk.Network), Money.Coins(0.001))
    .SubtractFees()
    .SendFees(Money.Coins(0.00001))
    .SetChange(fpk)
    .BuildTransaction(true);

Debug.Assert(builder.Verify(tx));
var r = await api.Broadcast(tx);

The response was success but with error code:
ErrorCode: INVALID
Reason: "Unknown"
{
  "hash": "a7d08d4f1993ea1b4143738c9ebf7cb4a04cd26fae7e97e3fa0dd0994718cf70",
  "ver": 1,
  "vin_sz": 1,
  "vout_sz": 2,
  "lock_time": 0,
  "size": 225,
  "in": [
    {
      "prev_out": {
        "hash": "a98e4e3ad94d69f415c3849aedfb3d371afb24f49096b4b6de250c52ea9e7608",
        "n": 0
      },
      "scriptSig": "304402201064fbd041900c2fe594a46cd4e0536427c94c82934bd125b3d5efd2863838d802206256840d67972126470443c71cfe1b72d2198a1d771a5eead54123573bafe87a01 030e9c36c9e37c2047f8c42cc5d56ff5ab1fc1b51b716fbbb2fc20201618401c0c"
    }
  ],
  "out": [
    {
      "value": "0.00998000",
      "scriptPubKey": "OP_DUP OP_HASH160 35343be6a983983c1a69871ddf3d604126a8e06f OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value": "0.00009000",
      "scriptPubKey": "OP_DUP OP_HASH160 6652f3e81f9f8a832fecf707fc7b5757bf7faff5 OP_EQUALVERIFY OP_CHECKSIG"
    }
  ]
}

I have just noticed that my ErrorCode = Invalid, and Reason: Unknown, but my transaction did went through. I am confused now.

@Prayank You need to put in your own private and public keys into the code.

@Prayank I tried to run your code, but there is no balance in the account. May I know which faucet is able to drop coins for segwit address?

Not working. In fact I am using the private key that shown in your code.

@Prayank I have confirmed that sending to a SegWit key will returns with Error = null, but Legacy keys will result with Error = Unknown, even though the transaction is successful.

I don't like the way that bitcoin-cli works, it forces me to create a wallet which I think should have let us handle ourselves. I am using QBitNinja.GetBalance(<pubKey>, true) to get all the unspent amount for particular address.


text:
What is the downside of not using Proof of Work for validator selection?
Bitcoin uses Proof of Work for two things: one is to secure the blockchain with strong cryptographic signatures like a Merkle tree, and the other is to crown the validator which "mines" a solution as THE validator (dictator) who determines which transactions to broadcast in that block. If they blacklist your address (or charge large fees) and don't want to accept your transaction then maybe another validator will eventually accept it.
But why do we need Proof of Work for the second thing? What's wrong with Proof of Correctness as Ripple uses, or Delegated Proof of Stake as LISK uses, for example? Why are they considered "not decentralized" while Bitcoin is said to be "decentralized" despite the arms race that has caused a few mining pools in China to control more than 51% of the mining power in practice?
What is wrong with a community electing 101 random validators like with LISK for example? How can this be gamed to reduce people's freedom to transact or have their transactions confirmed? The worst thing is some address may be blacklisted by a few validators (eg under pressure from a government law) but the same can happen with bitcoin miners, since we know who they are. So what's the disadvantage of Delegated Proof of Stake?
Here are the advantages: less waste of electricity, faster consensus, and possibly more decentralization in practice.
If I am right and this doesn't have any serious disadvantages, it should be rather trivial to make a cryptocurrency with delegated proof-of-stake electing N (odd number) validators.

Proof of Work is needed to inventivize miners to not fork and, if there is a fork, some metric for determine which fork is the real blockchain (assuming no consensus changes in the fork).
Proof of Work incentivizes miners to not fork (i.e. see someone else's block, ignore it, and create their own block at that height) because of cost. It costs resources in order to produce a fork and stick with it. If their fork has no value, then they are wasting money on something that is worthless. However with other consensus systems like Proof of Stake, there is no cost to make a fork. Making a fork does not cost anything as there are no resources for you to spend to make the fork. In some systems, you can make a fork and still be mining/staking/minting/whatever on the original chain at no extra cost and no opportunity cost.
Proof of Work also provides a metric to determine which chain is the correct chain. Given two blockchains with the same consensus rules, the one with the most work (the sum of the difficulties of all of its blocks) is the one that is considered "the blockchain". In other consensus systems like Proof of Stake, no such metric exists for determining "the blockchain". This results in centralization as someone or something is needed to say "this blockchain is the right one". In some coins, a signer (usually the developer) must sign all blocks for the block to be considered valid, so that signer determines what "the blockchain" is and is a point of centralization.

Sorry, I fixed up the wording in my question. I didn't mean the miner is the ONLY validator, just that it is the validator that chooses which transactions to include in the broadcast of that block! Please, can you update your answer to reflect my change?

Edited. Your change does not really effect my answer.

So with LISK for example you have 101 validators that others vote for, delegated proof of stake. Are you saying that this system is more susceptible to forking than Bitcoin? In practice, after the arms race Bitcoin has only a few mining pools that control things and so a fork has already been done - Bitcoin cash. And more to come.

Yes, LISK and other coins using some sort of Proof of Stake are more susceptible to malicious forking. Whoever is the one to mint/forge a new block (e.g. in LISK the current delegate) can create two blocks and thus create a fork. However that person can continue to mint/forge on both forks of the blockchain. In Bitcoin with PoW, that is impossible. You can either point your hardware and mine on one fork. There is no way to mine both simultaneously as you can with PoS systems.

If one of the 101 delegates creates a fork, how will they broadcast it to the others? If they broadcast different things to different people then their broadcast will simply be IGNORED in the consensus protocol.

How do nodes know to ignore the different blocks broadcast? If I give you block A and give Bob block B, how do you know that I gave Bob block B and vice versa? According to the DPoS system described by bitshares (and cited by lisk), in the event that a fork occurs, witnesses will just forge blocks on top of the most recent one that they have. There is nothing saying that conflicting blocks will be dropped. If list added that, then they have done a horrible job of documenting it (I looked at their docs and they are horribly unspecific).

You may be right about LISK. But I am still not sure how the nodes can introduce a fork, if after every block the nodes simply merge everything they saw from everyone. If node A broadcasts different things to different nodes, they will eventually compare notes and realize that A said different things (A signs all its broadcasts) and simply ignore A's broadcasts from then on. I think that's what Ripple does (one of its features).

Here's the deal @Andrew Chow .... the 30% defector thing only applies in Byzantine Consensus if messages aren't being signed.

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


text:
Finding the purchase values of all currently held bitcoin
Since the full Bitcoin transaction history is public, is it possible to calculate the values that all currently held Bitcoins were acquired at (in USD). For example, if a Bitcoin has been held since Jan 11, 2011, then it was acquired when the exchange rate was $0.32. But if a bitcoin was acquired today, then its acquisition price was ~$7000 (today is a bad example because it was so volatile).
If so, I was wondering if anyone could point me in the right direction? I know I would need to parse the full transaction log, but I'm not sure:
1) Are there timestamps on the individual transactions? If not, what is the best way to infer the transaction date? Just using the block number?
2) Is it easy to identify transactions for the various exchanges (Coinbase, etc)? How would I do this?
3) I am assuming I can find the historical exchange rates somewhere, but if anyone can point me to this, it would also be helpful!
Any other advice? Thanks! I am new to Bitcoin, but very interested in learning more.

You cannot do this for a number of reasons.

Bitcoin is mined - There are many bitcoin around that have never passed through an exchange (all of Satoshi's, for instance). Since they've never been traded, you can't find any trade data for them
Exchanges operate offchain - You cannot link an onchain transaction to an offchain trade and its price easily. Many people only withdraw when moving between exchanges, or to cold storage. This could mean that they traded BTC months/years ago, but an onchain transaction only appeared yesterday
Onchain transactions don't have to be from exchanges - Transactions could simply be moving money between the user's own wallets, or exchanging for other goods/coins. Once again, you can't look at a transaction and know what it's for.

Exchange wallets are usually identifiable for most major exchanges. However, it's going to be nearly impossible to link individual transactions on the chain to individual trades without extensive raw data from the exchanges itself. Even after that, you will be missing data on OTC and other non-exchange trades.

Raghav, thanks. A few follow-up questions. 1) If I understand correctly, mined bitcoin doesn't immediately show up in the transaction history? It only shows up after it's been used in a transaction with another private key? 2) When you buy bitcoin from an exchange, they do not make an on-chain transaction? So this means they have not actually purchased bitcoin for you - all of the accounting is done internally within the exchange? If I buy 1 bitcoin from CoinBase today, when does this transaction actually show up in the Bitcoin transaction history?

Mined bitcoin shows up in the block it is mined as the first transaction. Here's an example of newly created BTC: https://blockchain.info/tx/d1a2408cecfacdbb50c99200fee5820fecae6bfaa091596c576fd71e3fa982a5

That's correct. Exchanges use internal accounting systems. No transaction on the Bitcoin network is made until you deposit or withdraw coins. Until you withdraw coins from an exchange to your own wallet (where you control the private keys), you are trusting the exchange to not default on their promise that you own X bitcoin.

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


text:
How to: Check whether or not transaction inputs have been previously spent
Maybe I have overlooked it, but I think the "Bitcoin Developer Reference" does not specify how a miner has to check whether or not transaction inputs have been previously spent.
How is it done?
And espacially how is this enforced in the process?
All I found is 5.2 "process" 2.) in the 2016 paper.
I think, the miner has to look at every block after the "oldest" referenced transaction input and make sure no transaction in no block has the appropriate transaction as input. Is that true?
In that case, what enforces the miner to do so?

Any node (not just a miner) can check whether a transaction's inputs have been previously spent by looking through the entire blockchain to see if any transaction has spent that input. There is no correct or incorrect way to do this; not all nodes have to do this in the same way.
The common way to do this is to trust yourself (as a node) to have verified the blockchain correctly in the past. What Bitcoin Core (and other software that follow Bitcoin Core's methods) does is it maintains a separate database that contains all of the unspent transaction outputs. So if the previous outputs that a transaction's inputs references are not in this database, then the node declares the transaction invalid. It assumes that its database is correct because it built that database.
There is nothing that forces miners to do anything. A miner could create an invalid block that contains an invalid transaction (e.g. one that spends from a non-existent output). However all nodes (not just miners) verify that blocks and transactions are valid. So the Bitcoin network will reject any invalid blocks and thus the miner will not actually get his reward for his work. This incentivizes miners to verify block and transactions, but they aren't forced to.


text:
Problem with balance of my address
I have a problem that wallet does not recognize transactions of my address. The problem is present on testnet.
Relevant address is n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj (https://testnet.blockexplorer.com/address/n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj).
bitcoin-cli validateaddress n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj
{
  "isvalid": true,
  "address": "n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj",
  ...
  "ismine": true,
  ...
}

Transaction 405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850 (https://testnet.blockexplorer.com/tx/405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850) is having my address as an output:
bitcoin-cli getrawtransaction 405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850 1
{
  "txid": "405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850",
  ...
  "vin": [
  ...
  ],
  "vout": [
    {
      "value": 0.49953560,
      "n": 0,
      "scriptPubKey": {
        ...
        "addresses": [
          "mxiFoE5bNxXMRdgXyFrc6zW3aw7zsuynSK"
        ]
      }
    },
    {
      "value": 16.05588800,
      "n": 1,
      "scriptPubKey": {
        ...
        "addresses": [
          "n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj"
        ]
      }
    }
  ],
  ...
}

But my node does not recognize it:
bitcoin-cli listunspent 0 9999999 "[\"n3qPR7uHUSoqnd8DZpE8GVhqnmrMzYu7Vj\"]"
[
]

bitcoin-cli gettransaction 405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850
{
  "amount": 0.00000000,
  ...
  "txid": "405920020c236f3faa483b72baf5181955ac25f8946323f9f0827b94e08a2850",
  ...
  "details": [
    {
      "account": "",
      "address": "mxiFoE5bNxXMRdgXyFrc6zW3aw7zsuynSK",
      "category": "send",
      "amount": -0.49953560,
      "fee": -0.00046440,
      "abandoned": false
      ...
    },
    {
      "account": "",
      "address": "mxiFoE5bNxXMRdgXyFrc6zW3aw7zsuynSK",
      "category": "receive",
      "amount": 0.49953560,
      ...
    }
  ],
  ...
}

Rescan of the node didn't help.

The interesting thing is that if I export (dumpprivkey) the private key (from this problematic address) from my wallet and import to some other wallet (node) then the balance for this address is correct and I can spend that amount.

The transaction I mentioned is from my address to my address and therefore gettransaction returned amount = 0.
It seems that my node recognize spending but not receiving of BTCs by that transactoin.

Copying a wallet.dat file from one node to the other didn't help.


text:
Why can't timestamps be a substitute for blockchain?
I'm super fascinated by the entire concept of proof of work and how it allows for a trustless, decentralized system. Despite knowing that proof of work (or proof of stake) can be an inevitable necessity to having a cryptocurrency like Bitcoin, I'd like to fully understand where other methods fail.
The first problem Bitcoin addresses from my understanding is signatures with each transaction. To me, this completely makes sense, as it is completely necessary to be able to verify that the sender indeed was the creator of the transaction. But then the next problem is transaction order and validity to prevent double spending. I don't understand completely why a timestamp can't just be included for every broadcasted transaction, and the transaction could have the correct, universally agreed upon time, and each ledger gets sorted chronologically. Is this because it requires a centralized system to prevent people from forging timestamps? Or what am I missing? To me, it seems like if the transactions were broadcast publicly to the entire network, there wouldn't be conflicts in ledgers / double spending.
And how exactly does the main blockchain stay decentralized? Let's say I go offline and miss transaction broadcasts, and now I want an updated version of the main blockchain. I would have to rely/trust others for this main blockchain, which seemingly is centralized now in the way that all new users are pulling from this same copy of the blockchain. I don't quite see how that's different from the analogy with a community ledger with everyone just keeping their copy updated with that, or a main branch on a git repo which everyone continually pulls from. There is no single point of failure, but it seems to still be a community ledger in a sense.
I am completely well aware that the "solutions" I presented above have faults somewhere that I'm missing / scenarios in which these will fail which I haven't considered, and I'd like to understand exactly why a proof of work system is necessary in these scenarios. And, how it can stay decentralized and trustless despite having characteristics described in the above paragraph. This, I believe, will help me understand the true beauty of it.

But then the next problem is transaction order and validity to prevent double spending. I don't understand completely why a timestamp can't just be included for every broadcasted transaction, and the transaction could have the correct, universally agreed upon time, and each ledger gets sorted chronologically. Is this because it requires a centralized system to prevent people from forging timestamps? Or what am I missing? To me, it seems like if the transactions were broadcast publicly to the entire network, there wouldn't be conflicts in ledgers / double spending.

You need to remember that communication networks aren't perfect. There are latencies, and there are nodes connecting and disconnecting. The system needs to be robust to these dynamics.
You also need to remember that the problem Bitcoin set out to solve is how can a merchant know that a payment to him is final and will not be reverted.
Suppose a double spender pays a merchant, with a tx timestamped at 13:05. The merchant see the tx and provides the goods. The attacker then broadcasts a conflicting transaction timestamped at 13:04.
A node receiving this new transaction has no way of knowing whether the timestamp on this tx was forged, or if it was indeed broadcast at the specified time, and he has simply missed it so far. Since the rules say earlier txs take precedence, the payment to the merchant will be reverted.
And that's when the node was actually connected to the network at the time these transactions were broadcast. What if it's a new node, or it had downtime at that point? How could he possibly ever know which of these transactions actually appeared earlier on the network?
That's exactly what proof of work and the blockchain are solving - they are a permanent record that everyone can agree on, which is hard to forge because it includes proofs that actual computational work went into verifying it.

And how exactly does the main blockchain stay decentralized? Let's say I go offline and miss transaction broadcasts, and now I want an updated version of the main blockchain. I would have to rely/trust others for this main blockchain, which seemingly is centralized now in the way that all new users are pulling from this same copy of the blockchain. I don't quite see how that's different from the analogy with a community ledger with everyone just keeping their copy updated with that, or a main branch on a git repo which everyone continually pulls from. There is no single point of failure, but it seems to still be a community ledger in a sense.

The blockchain actually contains proofs. I don't need to trust any node - if I get conflicting blockchains from different nodes, I know which one is the correct one because it has proof of more computational work. This allows all nodes, everywhere, no matter when they connected, to agree on the same shared ledger.
And that's all that matters - agreement. As long as everyone agrees on which order of transaction is correct - in particular, the person who gave goods in exchange for bitcoins and the people he will later want to send these bitcoins to - the payment network works.

Perhaps interesting to point out that the only we way we know of to actually give strictly sequential timestamps to each transaction is using a central timestamping service, which indeed solves the same problem as PoW... but is not decentralized and effectively creates a trusted party with censorship rights.

But then the next problem is transaction order and validity to prevent double spending. I don't understand completely why a timestamp can't just be included for every broadcasted transaction, and the transaction could have the correct, universally agreed upon time, and each ledger gets sorted chronologically. Is this because it requires a centralized system to prevent people from forging timestamps? Or what am I missing?

Because timestamps can be forged and not everyone is using the same time. Due to latency, clock inaccuracies, etc. not everyone is on exactly the same time. In order for everyone to have uniform timestamps, there would need to be some centralized system. Also, timestamps can be easily forged.

To me, it seems like if the transactions were broadcast publicly to the entire network, there wouldn't be conflicts in ledgers / double spending.

But you can broadcast multiple transactions spending the same coins. Which one is correct? If they are all broadcast simultaneously and they have the same timestamp, which one is the "real" one? Due to network latency, some nodes on the network may receive one transaction first, but other nodes may receive the other one first. There is no way to determine which one is the "real" one. That is part of what the blockchain solves, being the authority which says which transaction is "real".

And how exactly does the main blockchain stay decentralized? Let's say I go offline and miss transaction broadcasts, and now I want an updated version of the main blockchain. I would have to rely/trust others for this main blockchain, which seemingly is centralized now in the way that all new users are pulling from this same copy of the blockchain. I don't quite see how that's different from the analogy with a community ledger with everyone just keeping their copy updated with that, or a main branch on a git repo which everyone continually pulls from. There is no single point of failure, but it seems to still be a community ledger in a sense.

It isn't centralized. The blockchain is not being downloaded from some central source. It is being downloaded from multiple peers, and if they differ, then the valid chain with the most work will be the chain that your node uses. Your node is not just blindly accepting the chain that its peers give to it; it is also validating the chain according to its consensus rules.
The blockchain certainly is a community ledger. But it is one where you can't forge transactions and can't change the transaction history without performing a lot of work.

Satoshi Nakamoto originally worked to overcome the problems inherent with a timestamp server in his whitepaper, "Bitcoin: A Peer-to-Peer Electronic Cash System," so it is obvious that more than a timestamp server is required to be a blockchain.  Fortunately, the prevailing implementation of his concept has multiple methods to prevent timestamp fraud, as I explain here.

authors: Максат Аннаев


text:
Bitcoin Cash: how to check address balance / transactions?
BlockExplorer (https://blockexplorer.com) provides a way to check bitcoin balances.
What is the alternative to check for transactions in Bitcoin Cash addresses?

Bitcoin Cash block explorers are (sorted by usefulness and features):

✯ BlockChair: blockchair.com/bitcoin-cash/blocks

✯ BTC.com: bch.btc.com

✯ ViaBTC: www.viabtc.com

✯ Bitcoin.com: explorer.bitcoin.com

*✯Coin Dance: cash.coin.dance/blocks

✯ BitInfoCharts: bitinfocharts.com/bitcoin%20cash/

✯ BitBox: explore.bitbox.earth

BlockDozer: blockdozer.com

Blockexplorer: bitcoincash.blockexplorer.com

CoinSpace: bch.coin.space

BitPay: bch-insight.bitpay.com

Yours: insight.yours.org/insight

* Shows only blocks, doesn't show transactions.
✯ The ones without star use the same Insight UI, so that websites may not show interesting data.


text:
Passing bitcoins on to heirs
What's the most foolproof way to ensure your bitcoins can be passed on safely to your heirs in the event of your death? Note this question has two levels of difficulty:

safely passing on bitcoins to someone and
passing them on according to the terms of your will, which may
split the "bitcoin estate" two or more ways, and not necessarily in
the same proportion.

Point 2) implies giving control of the wallet to a Trustee in a sufficiently transparent way that the heirs can check the wallet amounts to ensure they receive all the bitcoins available.
A complication I'm aware of is that as I'm using my bitcoin wallet, any transaction wipes the existing key and transfers the balance to a new key. So storing a paper wallet is not really an option unless I intend to never touch the bitcoins in it during my lifetime.

See https://bitcoin.stackexchange.com/questions/38692/estate-planning-how-can-i-ensure-my-bitcoins-are-inheritable?rq=1 which answers at least part of this.  You may wish to edit your question to focus on what remains.

Are you familiar with HD wallets? This avoids the "transfer to new key" issue.

Thank you for the pointers Nate Eldredge - I'm a bit new to the deeper issues involved so I'll read around some more. Bitcoins are interesting but require significant investment of brainpower....


text:
Reading a block
I am trying to grasp basic concepts and wanted to know if miners can read contents of a block, if not, how is block validation done. As I understand each transaction is encrypted, how is decryption done by the miner for validation, without a private key?

As I understand each transaction is encrypted, how is that decryption done by the miner for validation without a private key?

That is incorrect. Transactions are not encrypted. No part of the Bitcoin protocol or consensus rules specify that anything should be encrypted. In fact, nothing can be encrypted as the protocol relies on the fact that everyone is able to read all blocks and transactions in order to validate them.
You may be confusing digital signatures with encryption. Digital signatures in Bitcoin are used to ensure that a person is allowed to spend some coins. Signatures are used as a proof that the person who created a transaction is allowed to actually make that transaction and spend the coins that it spends.


text:
Does P2PKH substitute P2PK in any circumstances? Why?
Does P2PKH substitute P2PK in any circumstances? Why? I know address(public key hash) was invented later than the official implementation released. Is it the reason?

Did you mean P2SH instead of P2KH?

Or did you mean "P2PKH instead of P2PK"?

Both P2PK and P2PKH were part of the first bitcoin 0.1 release, so that second point isn't true.
P2PKH is theoretically safer because the pubKeyScript only reveals the hash of the public key rather than the public key itself (which only matters in the case that the elliptic curve crypto involved is broken). So as long as you don't reuse the address, no-one else will know the public key before the money is spent.
All bitcoin addresses encode public key hashes so only P2PKH can be used with an address, as the public key is not known. P2PK were mainly designed for IP-to-IP payments, which is no longer possible in Bitcoin Core since version 0.8.0

Pay to IP was disabled by default in 0.3.20 (feb 2011!). It was only some leftover code that was removed two years later in 0.8.0 (feb 2013).

Pubkey scripts are created by spenders who have little interest what
  that script does. Receivers do care about the script conditions and,
  if they want, they can ask spenders to use a particular pubkey script.
  Unfortunately, custom pubkey scripts are less convenient than short
  Bitcoin addresses and there was no standard way to communicate them
  between programs prior to widespread implementation of the BIP70
  Payment Protocol discussed later.
To solve these problems, pay-to-script-hash (P2SH) transactions were
  created in 2012 to let a spender create a pubkey script containing a
  hash of a second script, the redeem script.
The basic P2SH workflow, illustrated below, looks almost identical to
  the P2PKH workflow.

Read More Bitcoin.org


text:
Does changing mining algorithm(SHA256) of bitcoin cause any side effect?
One example is bitcoin gold change SHA256 to Equihash, does it cause any side effect?
Edit:
To be more specific.
What should participants of bitcoin blockchain, especially coin owner and miners, need to worry about when they take part in(e.g. trading, mining) a forked bitcoin blockchain with different mining algorithm?

Apart from GPUs being more viable for mining, no, there isn't.
And asics being less viable, or more or less useless..
Apart from maybe a difference in difficulty etc, but blocktimes and blocksizes should be the same.
Unless ofcourse they changed it in the hardfork itself, but that has nothing to do with the mining algorithm.
EDIT:
Note: I've answered this question in technical terms, not economic/emotional terms.

Note, that algorithm should be strong crypto, not any. Hash function f (any) = 0 may cause some problems :)

I disagree. If the Bitcoin algorithm was changed, miners being outraged because millions of dollars worth of their hardware can't earn a profit any more is a significant side effect. A smaller hashpower base may also reduce network security (although you could argue the existing consolidation of mining has already reduced network security)...


text:
getting balance from my address using bitcoinj
I can get my bitcoin balance from private key but when i tried retrieving from my address its not possible posted below my code can any one tell me what i'm doing wrong
public static void main( String[] args )

        {
            NetworkParameters params = TestNet3Params.get();
            WalletAppKit kit = new  WalletAppKit(params, new File("."), "sano");
            kit.start();
            kit.isRunning();
            Address address = new Address(params, "mj255GgoGKN6uTjtWdNcF7obu88iLSTZdm");
            boolean add =kit.wallet().isAddressWatched(address);
            Wallet wallet = new Wallet(params);
            DumpedPrivateKey key = new DumpedPrivateKey(params,
                   "cTH6YyRZSqF8VvtjkfqABqjGF682cQkW3mMuageraH4CEzCrweqT");
            wallet.addKey(key.getKey());
            wallet.addWatchedAddress(new Address(params, "mj255GgoGKN6uTjtWdNcF7obu88iLSTZdm"));
            BlockChain chain = new BlockChain(params, wallet,
                   new MemoryBlockStore(params));
         PeerGroup peerGroup = new PeerGroup(params, chain);
         peerGroup.addPeerDiscovery(new DnsDiscovery(params));
         peerGroup.addWallet(wallet);
         peerGroup.start();
         peerGroup.downloadBlockChain();
         BigInteger balance = wallet.getBalance();
         System.out.println("Wallet balance: " + balance);
}

Edit 1: The below given code retrieves balance from address but each and everytime it is creating a new address.
public static void main(String[] args) {

    NetworkParameters params = TestNet3Params.get();

    String filePrefix = "forwarding-service-testnet";

    WalletAppKit kit = new WalletAppKit(params, new File("."), filePrefix);

    // Download the block chain and wait until it's done.
    kit.startAsync();
    kit.awaitRunning();

    List<Address> list = kit.wallet().getWatchedAddresses();
    if (list.size() < 2) {
        kit.wallet().addWatchedAddress(kit.wallet().freshReceiveAddress());
        System.out.println("New address created");
    }

    System.out.println("You have " + list.size() + " addresses!");
    for (Address a: list) {
        System.out.println(a.toString());
    }

    String balance = kit.wallet().getBalance().toFriendlyString();
    System.out.println(balance);
}

@alcio I did check that one but still I'm not getting my balance

I can offer you the workaround for this problem. I used web API for this feature. For example https://www.blockcypher.com/dev/bitcoin/#address-balance-endpoint.
It will allow you refuse block chain downloading part and make your code more simple.

Thanks @Konstantin ,But I need it this way "using bitcoinj" as mentioned


text:
Send and Received BITCOIN
I have been working on Ethereum for years. Now assigned to work on Bitcoin. The way that BTC handle transaction is vastly different and utterly complicated.
After reading for quite sometime. Can I assume that for a simple website to receive and send bitcoin, I only need to handle the scenarios below:

Coin only. No colors, no assets.

Receive coin using P2PK and / or P2PKH only?

For sending I can always stay with P2PK or P2PKH is that correct?

Are the above sufficient for me to handle coins sent to my website and subsequently transfer to another account?

You ask how to handle sending and receiving, then give a way you want to handle receiving and ask whether you're done. To be honest, it feels too obvious to say "no, you also need to cover sending". If you're looking for a solution to set up a webshop or smth, perhaps you should take a look at BTCPayServer? Otherwise, you may need to elaborate your question a bit to clarify what you're trying to learn more about.

Thanks Murch. I am assuming sending is more straight forward right? I can choose to stay with P2PK or P2PKH whenever I wish. Anyway let me update my question.

Coin only. No colors, no assets.

Yes, the bitcoin baselayer facilitates payments. You will find however, that Bitcoin on-chain payments are not cost efficient for micropayments as fees would eat large portions of the received funds.

Receive coin using P2PK and / or P2PKH only?

There is no address standard for P2PK, so receiving to P2PK is not trivial at all. You could use P2PKH, but it is more than twice as expensive as more modern address formats. I would suggest to go with P2WPKH instead.

For sending I can always stay with P2PK or P2PKH is that correct?

Yes, inputs must satisfy the locking script the output used which is defined by the address the receiver chose. If you receive funds to a P2PKH address, you have to spend them as a P2PKH input. I'd say receiving is easier, since it only requires deriving a new private key and the corresponding address, then polling whether the address got paid. Sending on the other hand requires you to estimate an appropriate feerate, select inputs to fund the transaction,  support a number of different output formats for compatibility, produce the correct signatures, build the transaction, and submit the transaction to the network.
You don't have to reinvent the wheel. There are libraries that will solve most of these issues out of the box, or you can set yourself up with a BTCPayServer which solves all of the above and enables you to send and receive Lightning Network payments.

thanks for the initial reply. I have tried, and found that BTCPayServer is overkilled. I can get it done easily with NBitcoin library


text:
Secure Bitcoin Core
For example, take two PC (online, offline) with the last Bitcoin Core.
Online PC has only public keys and the updated blockchain. It will use to watching for balance and create and send transactions.
Offline PC has only public/private key. It will use for sign transactions.
Questions:

Is it possible to realize that case with Bitcoin Core?
If yes, How can I export/import the master public key of HD wallet?

Does this answer your question? How to send bitcoin from an offline Bitcoin Core that doesn't have a synced balance?

@RedGrittyBrick this answer gives me part answer my question. Until now I cannot find info about the import/export master public key. Also, I don't know possible it at all. I mean import/export master public key.

@BL Bitcoin Core doesn't support exporting/importing master public keys because it doesn't have one (unless you use the experimental new descriptor wallets).

@PieterWuille How is it possible? BC is an HD wallet. How I understand HD wallet the first generate Master keys and then simple keys. Or I don't understand something?

Bitcoin Core's wallet indeed is an HD wallet (for wallets created after 0.13 at least), but it uses hardened derivation. Hardened derivation does not permit computing addresses from the xpub; it needs the master private key to do so.

@PieterWuille I.e. I can't export the master public key. I can export the public keys of addresses. Do I right understand?

Not sure I'd call that "exporting"; it's just generating addresses - but yes, if you'd watch all addresses one wallet generates, you'd have a functionally equivalent watch-only wallet. All of this will be much easier and flexible (including support for xpub export/watch, multisig, ...) with descriptor wallets (new in Bitcoin Core 0.21, but still experimental with lots of missing functionality to make it convenient).

@PieterWuille Thank you a lot for your explanation.


text:
What do the options in Bitcoin Core's wallet creation mean?
I'm a newbie and today I have wanted to create a new wallet and I have confused when Bitcoin Core (v. 0.21) has asked me for additional information.
It asks me:

Encrypt wallet - Encrypt wallet by a password.
Disable Private Keys - ???
Make Blank Wallet - ???
Descriptor Wallet - ???

What do these ??? mean?
What is the difference between Enable\Disable Private Keys?
Whare can I read detailed information?
I have found reviews only on the Internet and they have had two or three sentences about my questions.
Can anyone explain to me what does it mean?

Disable Private Keys
the wallet is set in watch-only mode, only public keys can be imported into wallet.
You can use it, for example, to track transactions or generate PSBT transactions to be signed elsewhere.
(if this option is enabled you don't need Encrypt Wallet, because only private keys are encrypted)
Make Blank Wallet
the wallet starts out with nothing in it, but private keys can be added later to the wallet via import or sethdseed.
(this is needed if you set Disable Private Keys)
Descriptor Wallet
A descriptor wallet is one which stores output descriptors and uses them to create addresses and sign transactions.
Wallets that use descriptors internally shouldn't have any noticeable effect to the user, they should only be handled when users want to import their wallet.
(for further info you can see here:  What are output descriptors?)
You can also find other useful info here:
Bitcoin Core 0.21.0 Release Notes
What's Coming To The Bitcoin Core Wallet in 0.21 by Andrew Chow

As I understand if I want to create an encrypted wallet with addresses and non-watch-only mode I have to click on the Encrypt wallet only. And then click OK. Am I right?

yes, exactly.     .


text:
Transferring bitcoin from old bitcoin core wallet to electrum
I have a 7 year old wallet.dat file that was created by the bitcoin-qt program (https://bitcoin.org/en/bitcoin-core/).
Downloading the blockchain takes too long and I experienced that the downloaded chain risks getting corrupted. I decided to use Electrum so I can access the wallet's contents sooner.
I tried following the steps from https://en.bitcoin.it/wiki/Transferring_coins_from_Bitcoin-Qt_to_Electrum, but I'm stuck at the step dumpprivkey, because I don't know what <your bitcoin address> means. I have installed a new bitcoin-qt version so naturally the list of receiving addresses is empty.
I have also tried another approach with dumpwallet. This yields a 250 kb file with thousands of lines and I don't know what to do with that. Surely sweeping every single private key from that file isn't feasible?
Edit: with the command listreceivedbyaddress 0 true bitcoin-qt shows all addresses that once received bitcoin. I supplied them to the dumpprivkey function in order to get the corresponding private keys. This allowed me to finish the steps as described in the wiki article.

I have a 7 year old wallet.dat file

I guess that predates HD wallets. Which I think means you'll need to sweep all private keys which have money (UTXOs) currently associated with them.
For an HD wallet I believe you can probably sweep the Extended Private Masterkey shown at  the top of the dumpwallet output.

I'm stuck at the step dumpprivkey, because I don't know what <your bitcoin address> means.

listunspent should help by giving you a list of addresses which actually have money associated with them.

Command listunspent shows an empty array, although the wallet cannot be empty.


text:
Bitcoin smart contract for wallet income distribution based on specific conditions?
XY-problem
To improve the transparency and payout automation of funds that are raised for a small SAAS project, I would like to enable (micro)-investors to invest with bitcoin whilst providing a transparent & automated payout-mechanism/contract. The SAAS revenue that is received from users paying for the product, is then automatically partially distributed back to the investors. The users are not investors, and pay to a different wallet address.
Note this has little to do with trust, as the developer still needs to be trusted to not switch the SAAS revenue wallet address for new customers after receiving investments. It is mainly for transparency and automation purposes.
Question
Is it possible to set up a Bitcoin contract that enables lightning wallets to act according to the following behaviour?:

Person A creates a wallet with wallet nr A_WALLET_NR
Person A creates a wallet with wallet nr INVEST
Person A creates a wallet with wallet nr REVENUE

Person B with wallet nr B_WALLET_NR inputs 1000 Satoshi into INVEST.
For all other persons `C` adding 50 Satoshi into Wallet `REVENUE`:
    Until (`B_WALLET_NR` has retrieved 2x1000 Satoshi from REVENUE):
       - wallet `B_WALLET_NR` gets half of REVENUE income automatically.
       - wallet `A_WALLET_NR` get half of REVENUE income automatically.
    After (`B_WALLET_NR` has received 2x1000 Satoshi from REVENUE):
       - wallet `A_wallet_NR` gets all income.

Where:

The revenues are split, with multiple investors (that have not yet been payed off 2x their investment) according to key: 1/(nr_of_investors+1)
A minimum investment amount into INVEST is set of 999 Satoshis (to prevent a single investor with multiple wallets from flooding the distribution key).

Related Contracts
This article describes payout schematics based on (oracle/external) data in discrete log contracts. However, in this question there is no need to receive data from outside the chain, as all the data/wallets are already on the lightning network.

I think this question is based on a false premise. The lightning network is not a platform for building novel smart contracts. It is a payment network built on top of the smart contract functionality that Bitcoin's blockchain offers.
It may be possible to design a bespoke system that offers the functionality you seek, but it'll likely require its own off-chain communication to negotiate the transactions.

Thank you for the clarifications. I mistakenly assumed it would be possible to deploy contracts to the lightning network. Based on this article, and your answer, I understand that any smart contracts that may be used by the Lightning Network, (such as the Discreet Log Contracts and Hashed Timelock Contracts), are deployed to the Bitcoin blockchain (instead of the Lightning Network). I have updated my question accordingly.


text:
bitcoind daemon mode

When running bitcoind from a systemd service, as in https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service, what is the role of the -daemon flag?

Basically I'm asking what does -daemon do in a situation where bitcoind is run as service, and not as a wallet. And what happens if -daemon is not used -> in a systemd service file.

If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting

When running bitcoind from a systemd service, as in https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service, what is the role of the -daemon flag?

-daemon starts bitcoind in the background as a daemon. So if you run bitcoind -daemon in the terminal, the program will exit immediately but bitcoind is still running in the background. Without -daemon, you will see that bitcoind appears to hang in the terminal, but that just means it is running. If you stop the command, then bitcoind will stop as well.

If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting

Yes. This applies for all command line options.

Yes, I see that the terminal seems 'occupied' or 'hanging' when the daemon setting is turned off. But my question was not about starting the daemon in terminal, but in a systemd service. In this case what is the consequence of running with the daemon setting turned on, or going instead Type=simple and no daemon does the job correctly also?

As I explained in your other question about this, you cannot use Type=simple without -daemon. Systemd will not work with that.

In the other question about forking vs simple, you made a case against using Type=simple together with daemon=1. In my comment above I was asking for Type=simple together with daemon=0.

I see. There is no difference between using Type=simple and daemon=0 and using Type=forking and daemon=1.

From my experience Type=simple and daemon=1 in btc conf file, makes daemon shotdown just after start with systemctl start

I just tested Type=forking is needed when daemon=1 flag is used

I think understanding the hierarchy of how software works would be helpful here. You're interacting with the software, Bitcoin Core. While you're experiencing either a GUI wallet and network stats or interacting with the bitcoin-cli, your OS is experiencing bitcoind, the bitcoin daemon. It is--in the scope of this scenario--the fundamental piece of your bitcoin node or wallet.
Wikipedia introduces Daemons nicely:

a daemon (/ˈdiːmən/ or /ˈdeɪmən/)[1] is a computer program that runs
  as a background process, rather than being under the direct control of
  an interactive user

Spooky. In Unix systems specifically, it is a daemon if

the process is started from the command line or from a startup
  script such as an init script

The init script in this case is the bitcoin.conf file. If it initiates the daemon, it is doing it's thing running in the background. All the core processes that are required to run the underlying code and for a GUI and command line to be used on top of that are active, silently.
Any interaction that you have with the software requires the daemon to be running. If it's not already, it will start it. Once running, you can change the bitcoin.conf file or variables dynamically through the command line as you see fit during your session.
Then when you're done, whatever state the bitcoin.conf file is in when the computer or daemon begin will determine it's behavior.
If you want bitcoin running in the background always, ensure that the config file runs the daemon on startup or that you start it yourself if it's not running. It is redundant to do both.


text:
How to claim BCC/BCH having BTC in MultibitHD without having a seed, but having a password?
I wanted to add a comment here, but I do not have enough reputation, so please forgive me.
So I am using MultibitHD wallet. I have access to my bitcoins after I type my password. I can send then to new address, so I think this mean, that I have there my private keys.
However I discover that I do not have saved those 12 words from seed in place where I thought I saved them.
Question is, how can I extract keys and claim BitcoinCash?
Disclaimer: I have there 0.25 BTC. I will give 0.025 BCH to someone who help me discover the solution :)
I would like to dump my BCH, to support BTC, but first I need to know how to claim them. Please help me support BTC!

Unfortunately there is no easy way to do that. MultiBit does not allow you to export private keys and they use their own implementation of AES to encrypt the wallet files so no third party tool (like bitcoinj' wallet tool) can be used to extract the private keys. All you can do is modify the MultiBit source code and run it yourself in order to dump the private keys to a file.

just made it. MultibitHD is not working so you need to transfer it to electum wallet:
1. In Electum create a new wallet, select I already have seed,
2. Type in your seeds (security words) click option button and select BIP39 seed. 3. It will ask for a derivation path, you need to use: m/0' (note the ' is important m/0')
4. your wallet with your btc should appear
now follow the steps from official electrum to receive bcc
https://electrum.org/bcc.txt

as I said, I do not have a seed.

@lenka Without the seed you cannot recover BCH. More importantly multibit is dead, so move them to a better wallet

This answer got 50% of my coins into electrum. Any idea where the other half are? Presumably they are change address derivations?

Answering regards:
This answer got 50% of my coins into electrum. Any idea where the other half are? Presumably they are change address derivations?
It seems they are in the external addresses. Your transactions are split in internal (your local wallet) and external addresses.
More about how to find your external addresses is at How to sweep private extended key from mycellium into coinomi for bitcoin cash coins?

Extracting your bitcoin cash without your wallet words, as answered here works, but requires knowing how to edit and compile code: https://bitcoin.stackexchange.com/a/51297/64842
Because installing maven, java, modifying and compiling the JAR, and using the private keys is a bit beyond most non-developers, I've created a comprehensive guide, along with a pre-built JAR file to walk you through it:
https://github.com/josephduchesne/multibit-hd/blob/develop/README.md
The summary is:

Get a patched version of MultiBit-HD based on redee's answer linked above
Get your wallet addresses
Extract your private keys
Import into electron

You should expect the linked files to be coin-stealing malware.

I agree, it's a bad idea to use any bitcoin applications that you haven't verified the signature of or  compiled yourself. That said, for people that are less technical what can they do? If they can't compile the code themselves, there was previously no option to recover their BCC since the author abandoned the wallet. Would you like to audit my 1 line diff, compile the code and post a checksum? Why trust you, my potential puppet account? I'm open to suggestions.


text:
Minimum and maximum values of "all" cryptocurrencies?
I can't find a "cryptocurrency" stack exchange, and I have a question that spans all cryptocurrencies, in particular, how to handle them programatically - one database column to rule them "all"!
I say "all", because it's becoming super-hard to keep track of them all, so I don't expect anybody to know the whole story.
So, we want to store an amount in the database - the implication for BTC is that we should store values from 1e-8 to 1e8 - but what about other cryptocurrencies?
I'm looking for a value which would be enough for all of the current mainstream coins, and if possible (fingers crossed!) a rationale why that value would be enough for at least 90% of any future currencies that might appear?

I can't answer for all cryptocurrencies, but for bitcoin, you shoud store values as long and not doubles. The unit of account of bitcoin is the satoshi, a hundred millionth of Bitcoin. Since there can only be 21M BTC ever, that's a maximum of 2.1 quadrillion (2.1 * 10^5) satoshis. That number fits in 64 bits.
For Ethereum, you need 256 bits unsigned integers IIRC.


text:
How to prove wallet ownership?
Context
I would like to verify being A has access to a wallet and hence would like to ask them to pay a minimum amount to a particular wallet address owned by someone other than me, e.g. 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, with a signature ThisIsUnexpected that I gave to the being A.
The basic concept I believe is quite simple, if being A agrees, they share with me their bitcoin wallet address:being_A_bitcoin_wallet_address. Next, I would share the expected signature, and selected recipient address (e.g. 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa) with being A. Being A then pays a minimal amount of bitcoin to 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. After the transaction is completed, I look at the transaction history of the received donations to 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa and find the transaction made by being_A_bitcoin_wallet_address. Next, I look at the signature of that particular transaction and verify it reads: ThisIsUnexpected. If the transaction indeed has that signature I have a high certainty being A has access to being_A_bitcoin_wallet_address and I can verify their amount of funds.
Challenge
Though the idea may be relatively simple, I am experiencing some challenges in the execution.
To test the verification procedure, I thought I would look up the signatures of past transactions to that address. Hence I went to: https://www.blockchain.com/btc/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa and looked at the list of transactions. At the moment of writing, this is the most recent transaction, so I thought I could perhaps take the Sigscript of the transaction (with index 1) and put it into this signature verification tool to get a human-readable signature. However that tool does not seem to provide a human-readable signature, nor do I know whether the arbitrary transaction I selected contains a "Thank you Satoshi"-like signature.
Question
How could I practically verify the signature of a bitcoin transaction (if it has one)?
Subquestions
I think this question could be segmented in the following sub-questions:

How can I verify that an arbitrary transaction contains a human-readable signature?
Which information of the transaction data should I use to obtain a human readable form of the transaction signature?
Which online resources could be used to verify a signature?
Is there a python script that provides a function: being_has_access_to_wallet(claimed_wallet_access_address, recipient_wallet_address,human_readable_signature, amount=0.0001) that returns True or False using something like a block explorer?

I am not sure what exactly you mean with the ThisIsUnexpected bit but the fact that he can send coins from claimed_wallet_access_address to recipient_wallet_address proves that he owns the address.

How can I verify that an arbitrary transaction contains a
human-readable signature?

There is no such thing as "human-readable signature". The signature is just a very big number. Or we can treat it as a pair of very big numbers. Usually we encode it in hex, so it looks like 3044022007ae5e36b79303f992e153798061458b435d34285c5fddc20655451ac71b49f6022079421d162cad51db0daa0a934cbf5261d4b53f185604e9790094a49145f3812f01

Which information of the transaction data should I use to obtain a
human readable form of the transaction signature?

Input scripts

Which online resources could be used to verify a signature?

Google for "ecdsa verify signature online". But I am not sure that these resources are suitable to verify bitcoin signatures.

The question was based on an invalid assumption. I incorrectly thought/assumed that it was possible to include a public message in a bitcoin transaction. The accepted answer to this question indicates that it is possible to include a message in a transaction, but that those messages are private (between sender and recipient).
Instead, from sources like this it seems possible to prove one is the owner of a wallet without having to do a transaction.  I initially was not in favor of entering ones private key in someone else's website, but that is not necessary as one can download the source code of the website that can be used to generate such proofs here. So to answer the XY-problem of the question:

Being A could download that code, or got to: https://reinproject.org/bitcoin-signature-tool/#sign
Fill in its private key in Private Key.
Fill in its own Bitcoin wallet address.
Fill in the ThisIsUnexpected signature in the Message field.
Click Sign Message
Share that Signed Message with me.
Then I could download the code of that website or go https://reinproject.org/bitcoin-signature-tool/#verify
I could copy that Signed Message and click verify/see if the code/website says the Signed Message is verified.

This allows being A to prove ownership of a wallet (without for example paying money to scammers that ask it to prove ownership to get the minimal transaction  amount, and without losing transaction costs.


text:
spending unconfirmed utxos which exist in the tail of mempool queue
I have some unconfirmed utxos with: sat_per_vbyte=1, which probably exist in the tail of the mempool queue, e.g. 22300/22385. They are being kept in: "unconfirmed" since 3 months ago. And getrawtransaction txid returns: 'No such mempool or blockchain transaction' for these utxos in my bitcoind node, the mempoolsize=300MB.
Now if I create a new transaction spending these utxos with much higher sat_per_vbyte in cpfp style, will sendrawtransaction successfully broadcast the transaction or end in error?

The mempool of a node is limited in size (300MB by default). Once it's filled and the node keeps receiving transactions it will start evicting some transactions. The transactions less attractive to miners are (supposed to be) evicted to let room for higher-fee-paying transactions.
As pointed by @Murch in his own answer, there has been more than 300MB of backlog across the network at many points in the past 3 months. Most of it paying more than 1sat/vb. Your transaction must have been evicted from your node's mempool (and most likely from the mempool of its peers as well).
Therefore a sendrawtransaction of a child (a transaction spending some of its outputs) will fail, since the inputs of the child would appear to be inexistent to the node. You should first rebroadcast the parent (the initial transaction), and then the child, for it to succeed.
Note you're only able to do this because your mempool isn't actively purging transactions at 1sat/vb at the moment. Otherwise you would have to submit both your transactions as a single package. This feature isn't available yet (as of October 2023).

"You should first rebroadcast the parent (the initial transaction) and then the child for it to succeed."  i should be able to rebroadcast the parent's inputs and new outputs at higher feerate ?

If you want you can re-broadcast the parent at the same feerate and create a higher fee-paying child. This is called CPFP.

"You should first rebroadcast the parent (the initial transaction) and then the child for it to succeed."
i think this should work for me, i could get the parent's rawtransaction from a blockbook with larger mempoolsize

Since transactions bidding 1 ṩ/vB were dropped from almost all mempools in the past few months, most nodes would no longer know about the transaction that created the UTXO you are trying to spend (the “parent” transaction). If you still have a copy of the parent transaction, you could use the sendrawtransaction rpc to resubmit the parent to your own and other nodes’ mempools. Then, a transaction spending the output of the parent should propagate fine, as long as the parent transaction’s feerate is not under most nodes’ dynamic minimum feerate.

Were they? I couldn't find any historical data that the backlog went over 300MB in the past 3 months? (See the links in my answer)

@AntoinePoinsot: Yeah, it’s been above the limit almost the entire last six months. The mempool limit is not 300 MvB of transaction weight, but 300 MB of memory for the mempool data structure. mempool.space runs with a much bigger memory limit, but they show their memory use here: https://i.imgur.com/qj30FXI.png (it’s over the limit right now). On JoHoe’s you’d want to look at the “Default Mempol” rather than the standard view which also has a higher limit.

Oh, right! I was comparing vMB to MB.


text:
How to compute the expected number of sats to arrive in a probabilistic payment flow?
Look at the following network example:

Assume S wants to send 3 sats to R. You can further assume that S has enough liquidity in each of its local channels to send up to 3 sats. Also assume the liquidity in channels (A,R), (B,R) and (C,R) is uniformly distributed.
one optimally reliable payment flow in this diagram looks like this:
1 sat: S --> A --> R   probability: 2/3
2 sats: S --> B --> R  probability: 3/5

This flow has a total probability of 2/3*3/5 = 2/5 = 0.4 = 40%
The question:
How to compute the expected value of Satoshis to arrive at R if S sends 3?
Option A
(which I already know is wrong but I write it down because I suspect some people might have a similar first thought)
Initially I thought this would just be 3 sats * 2/5 = 6/5 sats = 1.2 sats which is what one gets from multiplying the amount to send with the probability of the flow. This seems strange as sending 2 sats along S-->B-->R has a probability of 3/5 and with the reasoning of above an expectation value of 2 sats * 3/5 = 6/5 sats = 1.2 sats. as the expected value for 1 sat along the S-->A-->B path is larger than 0 this would be a contradiction to the additivity of the expected value.
Option B
Starting from the above reasoning we add the expected values for the disjoint paths so:
E[3 sats] = 1 sat * 2/3 + 2 sat * 3/5 = 10/15 sats + 18/15 sats = 28/15 sats

Option C
Of course the 2 satoshi path S-->B-->R does not have to be sent as one onion but could be sent as two onions with 1 sat each:
The first has a probability of 4/5 and the second has a conditional probability of 3/4 which is extensively explained at this issue. With the logic from option B one should be able to add those expected values.
so we have the expected value for sending two sats in two seperate 1 sat onions along S--> B --> R would be computed as:
E[2 sats] = 1 sat * 4/5 + 1 sat * 3/4 = 31/20 sats

If we add the 1 sat onion from the S-->A-->R which was 2/3 sats
we would expect to have
E[3 sats] = 31/20 sats + 2/3 sats = 93/60 sats + 40/60 sats = 132/60 sats = 33/15 sats

This is 5/15 sats = 1/3 sats more than the answer in option B
Option D
To make things worse I am confused if the expected values of dissecting the 2 sat onion in option C into two 1 sat onions can just linearly added up as the second onion is conditioned on having 2 sats of liquidity in the channel. If the first onion has failed the second one will certainly fail. Thus one would have to compute expected value for sending two 1 sat onions like this:
E[2 sats] = 1 sat * 4/5 + 1 sat * 3/5 = 7/5 sats

this would result in a total expected value of:
E[3 sats] = 2/3 sats + 7/5 sats = 10/30 sats + 21/15 sats = 31/15 sats

Thoughts
just for comparison here are the results

Option A: 18/15
Option B: 28/15
Option C: 33/15
Option D: 31/15

While Option B seems certainly right it makes sense to further dissect the 2 sats onion. In simulations I did it seems that Option D is correct which is a bit surprising for me. Using the formalism of probability theory the difference for the 2 sat path is:

Option C: E[2 sats] = 1 sat * P(X>=1) + 1 sat * P(X>=2 | X >= 1)
Option D: E[2 sats] = 1 sat * P(X>=1) + 1 sat * P(X>=2)

As said the simulated setting indicates that Option D is the correct answer but that is highly surprising to me as I would expect the second term to be a conditional probabilty.

Let's review the definition of expected value.
The expected value of the random variable X given the state of the system O,
denoted as E(X,O) is computed as:
E(X,O) = \sum_i p_i(O) X_i

The sum is over all microstates (all ways in which liquidity could be allocated in the channels) or equivalently one can choose to sum over all possible observable outcomes. The p_i(O) is the probability of verifying i given the state O, and X_i is the value that X takes if i is verified.
Using this definition, one immediately sees that E(.,O) is a linear operator:
E(X+a*Y,O) = E(X,O) + a*E(Y,O)

That would be enough to answer your question.
You get different answers because you have constructed your observables differently.
Case B
Your observable is the sum of two flows x that goes through S-A-R with 1 sat and y that goes through S-B-R with 2 sat.
E(x+y,O) = E(x,O) + E(y,O)

Now, x either fails (prob. 1/3) getting us 0 sat or it succeeds giving us 1 sat (prob. 2/3).
E(x,O) = 0*1/3 + 1*2/3 = 2/3

Similarly with y
E(y,O) = 0*2/5 + 2*3/5 = 6/5

Adding up to
E(x+y,O) = 2/3 + 6/5 = 28/15

But be careful, that here we are assuming that x outcome is independent of the outcome of y. This is the case if you are sending two single path payments.
Case A
If you instead consider an atomic multi-path payment in which either both x and y succeed or none will, then the two outcomes for x are again 1 sat and 0 sat, but with probabilities 2/3*3/5=2/5 (both x and y succeed)
and 3/5 (all other cases) respectively:
E(x,O)= 1*2/5 + 0*3/5 = 2/5

similarly for y
E(y,O)= 2*2/5 + 0*3/5 = 4/5

Adding up to
E(x+y,O) = 2/5 + 4/5 = 6/5 = 18/15

Case D
You are building your observable as the sum of three single path flows (non-atomic):
x representing 1 sat over S-A-R, y representing 1 sat over S-B-R
and z representing 1 sat over S-B-R AFTER y. This is different from case B because y and z are not attached to each other, y might succeed and then z could fail.
Usual computations
E(x,O) = 0*1/3 + 1*2/3 = 2/3

for y
E(y,O) = 0*1/5 + 1*4/5 = 4/5

Then comes z, which will succeed only if there is enough liquidity for 2 sats on channel B-R, then
E(z,O) = 0*2/5 + 1*3/5= 3/5

Adding up:
E(x+y+z,O) = 2/3+4/5+3/5 = 31/15

Case C
Is similar to case D but the math is wrong.
You are correctly computing E(x,O)=2/3 and E(y,O)=4/5, but with
E(z,O) you are messing up with the conditional probability.
Let's see all possible outcomes:

y fails, then also z fails, prob. 1/5, (having exactly 0 sat liquidity)
y succeeds, but z fails, prob. 1/5, (having exactly 1 sat of liquidity)
y succeeds, z succeeds, prob. 3/5, (all other cases which correspond to having enough liquidity for 2 sat)
which is the same as the multiplication of y succeeding and the conditional prob. of z succeeding after y does (3/5 = 4/5 * 3/4).

E(z,O) = 0*1/5 + 0*1/5 + 1*3/5 = 3/5

It is important to state that z is tried after y or we get into race conditions.
Summary

Case A is right if you send a two flow atomic payment,
Case B is right if you send two single path payments,
Case C is wrong,
Case D is right if you send three single path payments.

I am confident that if you run the experiments you'll confirm.


text:
How are the connectors batched in Ark pool transactions?
According to https://www.arkpill.me/deep-dive, pool transactions contain 2 main outputs related to the protocol:

The vTXOs output
The connectors output

I understand that vTXOs output is a partially signed bitcoin transaction (psbt) binary tree where 1 leaf = 1 vTXO.
Is it the same format for connectors (binary tree)? Or is it a single (virtual) psbt splitting the connectors output into X dust outputs?

Good question. There are different options that are being considered that each have their own set of trade-offs. Let me dig into the main options.
The first and most obvious solution is to use the exact same construction as is used for the vTXO output: a transaction tree, built using a covenant, so that each leaf output is a connector and each connector is used for a single forfeit transaction.
Similarly such a pre-specified transaction tree can also created without a covenant, but to be entirely pre-signed by the service provider. Because no one else in the protocol cares whether this transaction tree can be broken down but the service provider, this is safe. Similarly each leaf in the tree would be a connector for a single forfeit transaction.
When using a tree of N items, that means that to use a single connector, the service provider would have to broadcast and finance log2(N) transactions. This is unfortunate and can be optimized. An alternative solution is to use a single series or chain of N subsequent transactions, each of which create a single connector output. In the previous solutions, we asked each user participating in the round to sign a single forfeit transaction using a single connector input; in this solution we will ask them to sign N different forfeit transactions using each of the N connectors that were created in this chain. This means that the service provider can always unlock a working connector for any forfeit transaction by broadcasting just a single transaction. The trade-off is that users have to do a little bit more work to sign many different transactions.


text:
Interfacing with fulcrum personal server
I'm trying to interface with my fulcrum personal server that's connected to my node but having issues getting a json response from my RPC call.
To enable RPC commands my understanding in the fulcrum.conf file I enabled:
admin = 8000
and then sending commands port 8000 doesnt work.  I'm able to connect via port 50002 but my json request is returning an empty response.  Any guidance would be helpful.  I realize this isn't technically related to bitcoin core.

Enabling TCP over port 50001 with tcp = 0.0.0.0:50001 in the fulcrum.conf file fixed the issue.
I removed admin = 8000 in the fulcrum.conf file, as it is not needed.


text:
Why is difficulty measured in a hash’s leading zeroes?
I understand how generating a SHA-256 hash containing any specified sequence requires lots of guessing and checking. The longer the specified sequence, the more rarely that it will appear.
And I understand how inserting random nonces into a block until its hash happens to begin with a certain number of 0s is a computationally expensive and ultimately random process, which demonstrates proof of work.
What I’m wondering is: why zeroes, and why leading?
Could mining work just as feasibly if the challenge were to produce a hash with, say, ends in a certain number of Fs, or has the digits 314159265358979... starting at index 32?
Or is there a technical reason why miners’ goal is to produce a hash which begins with 0s, and not any other character at any other location in the hash?

The "leading zeros" are a simplification. The difficulty is encoded as a target which is essentially a 256 bit number. Since block hashes are produced by SHA-256, they're also a string of 256 bits. If a block candidate's hash interpreted as a number is numerically smaller than the target, the block candidate is a valid block.

Sensical! So if I know a target has n leading zeroes, that's shorthand for saying that the actual specific target lies somewhere between [ 16^(63-n), 16^(64-n) ), yeah?

I'd have said [ 2^(255-n)-1, 2^(256-n)-1 ), but besides that yeah.

Leading ones or trailing ones will work as well as leading zeroes or trailing zeroes, it looks like a random choice from four equivalent cases.
Starting index from middle point might limit that value of maximal hardness of the mining, unless using of some sophisticated bit shifts for overcoming the limit, which may be slightly awkward for supporting in future. Non-regular patterns, like mathematical constants, might add even more pain for some kinds of developers and will not be obvious at all when looking at bit string of hash sum.


text:
Calculating the target from the hash leading off bits
I'm implementing my own cryptocurrency and I found it that saving the "hash difficulty” as the leading off (0) bits of a 256 bit number in a SHA-256 hash is the most intuitive.
I'm struggling to find a way to calculate the bitcoin equivalent “target” from that number.
Additionally I wonder why it is not implemented that way in the bitcoin protocol? Does it cause too harsh steps of difficulty?

I'm struggling to find a way to calculate the bitcoin equivalent “target” from that number.

Your difficulty recalculation algorithm will need to be completely different then. The easiest way to change it is to just start with an initial difficulty with all bits set and then bit shift this number as needed to get a target with some set number of leading zeros.

Additionally I wonder why it is not implemented that way in the bitcoin protocol? Does it cause too harsh steps of difficulty?

Because it only allows for the difficulty to double or halve. Furthermore, there are only 256 possible difficulties so this is not at all ideal nor would it work particularly well. This means that the target would usually be too high or too low. By using a target value, the difficulty can be adjusted to far more levels (2^256 possible difficulties) to better match the network hashrate.


text:
What this param in chainparams.cpp do?
consensus.nRuleChangeActivationThreshold = 6; // 75% of 6
consensus.nMinerConfirmationWindow = 8; // nPowTargetTimespan / nPowTargetSpacing * 4

For what this rule exit ? How to calculate this rule for find valid
value for altcoin.
What can be happen if it's value to low or to high ?

Is this value attached to the nPowTargetTimespan / nPowTargetSpacing * 4
Or is it completely unrelated to them?

Those parameters are for BIP 9 soft fork deployments. For a BIP 9 soft fork with these deployment parameters, the fork will transition from the STARTED state to LOCKED_IN when 6 blocks (nRuleChangeActivationThreshold) out of an 8 block non-overlapping window (nMinerCOnfirmationWindow) signal for that soft fork.
These values are not necessary for normal operation. They are only used for soft forks, so unless you are deploying soft forks, these values don't matter at all.

Is this value attached to the nPowTargetTimespan / nPowTargetSpacing * 4

No, it is not. There is no relation between these parameters at all.


text:
Question about retarget system bitcoin, add hardcodet block to exist blockchain
the standard values
    if (nActualTimespan < params.nPowTargetTimespan/4)
        nActualTimespan = params.nPowTargetTimespan/4;
    if (nActualTimespan > params.nPowTargetTimespan*4)
        nActualTimespan = params.nPowTargetTimespan*4;

but if i use
        if (nActualTimespan < params.nPowTargetTimespan/4)
            nActualTimespan = params.nPowTargetTimespan/4;
        if (nActualTimespan > params.nPowTargetTimespan*2)
            nActualTimespan = params.nPowTargetTimespan*2;

It's be valid or it's can broke diff system ?
What values can i add for diff is not grow very quickly, but drop faster than grow for it be more stable for fast block time.
setting of block time is
consensus.nPowTargetTimespan = 10 * 60; // 10 min
consensus.nPowTargetSpacing = 5 * 60; //5 min

And another question
I try use the exist function low diff block what created for testnet for only block with Height 2001 .
Previous exist block is 2000  and latest now in blockchain.
if ((pindexLast->nHeight+1) % params.DifficultyAdjustmentInterval() != 0)
{
    if(pindexLast->nHeight+1 == 2001)
    {
        // Special difficulty rule for testnet:
        // If the new block's timestamp is more than 2* 10 minutes
        // then allow mining of a min-difficulty block.
        if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
            return nProofOfWorkLimit;
        else
        {
            // Return the last non-special-min-difficulty-rules-block
            const CBlockIndex* pindex = pindexLast;
            while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit)
                pindex = pindex->pprev;
            return pindex->nBits;
        }
    }
    return pindexLast->nBits;
}
else
{
    if (params.fPowAllowMinDifficultyBlocks)
    {
        // Special difficulty rule for testnet:
        // If the new block's timestamp is more than 2* 10 minutes
        // then allow mining of a min-difficulty block.
        if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
            return nProofOfWorkLimit;
        else
        {
            // Return the last non-special-min-difficulty-rules-block
            const CBlockIndex* pindex = pindexLast;
            while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit)
                pindex = pindex->pprev;
            return pindex->nBits;
        }
    }
    return pindexLast->nBits;
}

And use new rule retarget for new block's after 2001 and accept old block with old retarget rule.
   if(pindexLast->nHeight+1 > 2001)
    {
        if (nActualTimespan < params.nPowTargetTimespan/4)
            nActualTimespan = params.nPowTargetTimespan/4;
        if (nActualTimespan > params.nPowTargetTimespan*2)
            nActualTimespan = params.nPowTargetTimespan*2;
    }
    else
    {
        if (nActualTimespan < params.nPowTargetTimespan/4)
            nActualTimespan = params.nPowTargetTimespan/4;
        if (nActualTimespan > params.nPowTargetTimespan*4)
            nActualTimespan = params.nPowTargetTimespan*4;
    }

About what i asking , is this solution is right and it will work, or this solution is wrong end exist another way to do this ?

    if (nActualTimespan < params.nPowTargetTimespan/4)
        nActualTimespan = params.nPowTargetTimespan/4;
    if (nActualTimespan > params.nPowTargetTimespan*2)
        nActualTimespan = params.nPowTargetTimespan*2;

This does the opposite of what you want. It increases the difficulty quickly, but decreases the difficulty slowly.
Here's what you meant to do:
    if (nActualTimespan < params.nPowTargetTimespan/2)
        nActualTimespan = params.nPowTargetTimespan/2;
    if (nActualTimespan > params.nPowTargetTimespan*4)
        nActualTimespan = params.nPowTargetTimespan*4;

what parameters need to use for decrees it quickly , but increase slowly . End exit any alternative  method to add on blockchain - mine block with low diff for reset diff  for new block's ?

I do not understand if it's only for increase , where the decrease setting's ???
I think it's rule with /4 it's for decrease end rule with* for increase :/

The code you posted caps the measured timespan at one fourth target, or twice the target. This limits the difficulty change in one retarget period to increasing by a factor of 4, or decreasing by a factor of 2.

I need use
/2 /2 *4 *4 or it's again wrong ? You can make little example with any setting how it be correct :/ Or for decrease x4 end increase only x2

See edit I added.

End about block , it's possible to add low diff block after huge to blockchain ? For new rules start work after this block, i try with low diff block with parameter only for they height ,  but it's stop accept old block's and how i understand it's wrong to.  But cannot find any information about this.

Bitcoin's rules require a miner to set a difficulty before trying to mine a block, and the difficulty must exactly match what the validating node expects. That is why it won't accept old blocks.

I understand this , but with retarget system it's work , why not work with min diff block's  , for example the latest block is 2000 , i try == 2001, and >2000. Maybe exist other way to do this and I simple not find it.

I'm not sure I understand the question. Can you rephrase?

Example on fist post , latest code
if(pindexLast->nHeight+1 > 2001)  code else code
i try this trick to min diff block  to , but it now work , but for retarget work perfect

Ok. What's the problem with that code?

code before retarget with this trick, i try do the same with min diff block's ... For mine  new block after block with huge diff and after this block disable low diff block's for normal mining with normal diff.

I need low diff only for one block after 2000 for drop diff. But rule with block height not work for this function, but perfect work for retarget.

So you want a one-time difficulty drop at block 2000?

Yes this why i try use function low diff block with rule only for block after 2000. for fully reset diff, then  new block's start work with new retarget rules  for more stable diff increase.

I try find solution to do this , but not find any solution and try this.

exist any solution for this ? :/

what i try to do , create new block with low diff and start calculate new diff from them.


text:
Get a programmatical notification when an address receives a transaction
I am experimenting building an in-house Bitcoin payment system.
What is currently the recommended practice to get notifications to your web server when a certain Bitcoin address receives a transaction? E.g. trigger an action from somewhere which results a HTTP call made to a web server.
Are there any better alternatives than polling bitcoind?
External systems (blockchain.info) are good to go too for me.
Any way to filter for certain confirmation threshold (e.g. need 6 confirmations)?

Blockchain.info provides exactly this functionality: https://blockchain.info/wallet/payment-notifications
With the HTTP post method, you just need a web server listening for POST data.
Regarding the 6 confirmations, you could easily achieve this by waiting 60 minutes (or so) after the data came in from blockchain.info. Or you could periodically lookup the transaction identifier on blockchain.info using its API to check when it has reached 6 confirmations.

authors: Борис Станкевич


text:
Extract lightning network funding transactions with python bitcoin blockchain parser lib
My ultimate goal is to parse funding transactions (as well as channel closes in a later step) from the blockchain. In order to do so I wanted to start with a funding transaction and disect it. Unfortunately I am kind of stuck and hope you can help out.
via #recksplorer I clicked on an edge and found this transaction to be the funding transaction of a payment channel.  I found this transaction in my local copy of the blockchain using bitcoin-blockchain-parser (in python) lib
using this code
for i,h in enumerate(tx.hex):
    print('{:02x}'.format(h),end=" ")
    if i%8==7:
        print(" ",end="")
    if i%16==15:
       print()
print()

I get the following hex representation of my transaction (the two asterix ** where included to emphasize the output script of interest):
02 00 00 00 00 01 01 e3  3d f6 39 1a 02 5c 79 b3
1a 2a ab 94 9f b5 6d f8  f9 2d 9f 3a bb ab 7d d3
92 47 7f 31 9f b6 69 01  00 00 00 00 ff ff ff ff
02 21 4e 00 00 00 00 00  00 22 **00 20 98 2b 53 22
31 08 07 d3 68 d1 dc 26  11 43 09 5d c7 d0 2f ba
6d 67 08 bb 76 21 51 9f  31 29 08 b2** e1 99 0d 00
00 00 00 00 16 00 14 8c  35 c6 98 4d f9 d6 a2 9e
4e 7d 76 21 19 3c fe 53  82 ce 60 02 48 30 45 02
21 00 ba 9e 6e 56 a6 4f  a2 53 4a 02 e9 30 20 8e
80 38 f6 f0 7c a8 d2 0e  b3 e4 03 59 99 20 8f 9d
a1 15 02 20 3a 12 73 72  c4 bc ee 6f 76 9e 07 fd
05 0e f0 62 9b 4d e8 e6  43 84 26 46 53 56 03 46
07 f3 9a eb 01 21 03 0c  fa b1 4c d0 4a 01 5a 58
40 2a 5e a6 84 e4 d9 b3  4b 33 23 73 04 0c 57 5e
83 b1 0a d3 90 79 66 00  00 00 00

I also found the two output scripts in particular the first one (after byte 58!) which sends 20001 satoshi to a payment channel:
output = tx.outputs[0]
for x in output.script.hex:
    print('{:02x}'.format(h),end=" ")

00 20 98 2b 53 22 31 08 07 d3 68 d1 dc 26 11 43 09 5d c7 d0 2f ba 6d 67 08 bb 76 21 51 9f 31 29 08 b2
I have not been able to understand the format of the funding transaction itself. according to BOLT3 it should look like this:

2 < pubkey1 > < pubkey2 > 2 OP_CHECKMULTISIG

I asusme that 2 means OP_2. However with the help of bitcoin wiki I cannot find the hex values of OP_2 and OP_CHECKMULTISIG.
I guess (but can't verify this at the moment) that I am running into problems similar to this question here on this site. Or I am messing up with the endian notations? As mentioned my future goal would be to automatically extract all funding transactions therefor I need to be able to pursue my endeavor and would appreciate your help a lot! Thanks!

Firstly, you are off by two bytes. The output script is 0020982b5322310807d368d1dc261143095dc7d02fba6d6708bb7621519f312908b2, but you have selected 00220020982b5322310807d368d1dc261143095dc7d02fba6d6708bb7621519f312908b2.
Secondly, complex output scripts are never just put in the output. They are always wrapped in some form of Pay to Script Hash. In this case, because it is segwit, it's Pay to Witness Script Hash (P2WSH). So you can't know the actual script used without the output being spent from. Everything in LN is P2WSH, no scripts are just put in the outputs.
To break down this script, first you have 00. This is the witness version number, version 0. Then you have 20 which is a length indicator for the next chunk of data. In this case, that is 32 bytes. Lastly 982b5322310807d368d1dc261143095dc7d02fba6d6708bb7621519f312908b2 is the SHA256 hash of the script itself. That script will be a 2-of-2 multisig, but you won't be able to know what it actually is until this output is spent from.

just to make sure I get this right: as long as the channel is not closed (forcefully or collaboratively) meaning the commitment transaction is not published it will be impossible to know more information about the payment channel? This would mean I can't parse the blockchain for open lightning channels since the SHA256 could be the SHA of any complex script and not only that of the funding transaction?

Yes, that is correct.