text:
How does a full node decide which outbound peers to have?
I understand that a full node can have up to 10 outbound connections (8 full relay peers and 2 block-relay-only peers). I wonder how my full node decides which nodes to connect to for outbound. What are the selection criteria does a node use to evaluate if a peer is good?
If I want to connect to a new specific peer (let's say I know the node's owner IRL or something) but I have already reached my outbound capacity, what specific criteria does my node use to decide which outbound peer to drop in order to make room for the new peer?

Addresses for outbound connections are largely chosen at random. The filtering of addresses comes at the time the addresses are first received by the node before they are added to the address database. This filter checks what services the nodes offer, what network they are on (e.g. IPv4, IPv6, TOR), and the time that they were reported to last be seen. Your node will choose to store addresses that are recent, use a network that your node is connected to, and offers full node services (NODE_NETWORK and NODE_NETWORK_LIMITED). We also avoid nodes that have been recently disconnected or banned.
These addresses are stored in buckets. These buckets are based on /16 for IPv4 and /32 for IPv6. In the future, these buckets will be determined by Autonomous System.
When making outbound connections, nodes are basically chosen at random. Your node will ensure that each outbound node belong to different buckets. If a node is chosen that belongs to a bucket that already has an outbound connection, it is skipped. We also try to choose nodes that we didn't already try to connect to recently unless we have built up a lot of failed connection attempts. Lastly, your node will try connect to nodes using the default port unless there have been a lot of failed connection attempts.
For nodes that you are specifically adding with addnode, these nodes do not take up the standard outbound connection slots. There are an additional 8 addnode connection slots. If these are full, then the node that you are adding will simply wait until one of those nodes disconnects before a connection to it is attempted. So there is no kicking of outbound peers at all.

@Andy Chow, I realize that this is an old post but with regard to the filter checks that determine the services the nodes have to offer, can you help elaborate on the services available? Are you referring to the roles of full nodes vs. lightweight clients, where full nodes can fully validate transactions/blocks, and help lightweight nodes to transmit their transactions to the network and by notifying them when a transaction affects their wallet? By looking at the connected peers through my bitcoin core, is there a way for me to tell if the peers is a full nodes or lightweight nodes?

@TuanP Sservice flags indicate what a node is capable of sending over the network but not whether they validate anything sent. Currently in use are NODE_NETWORK (can serve the entire blockchain), NODE_BLOOM (can serve BIP 37 bloom filters), NODE_WITNESS (can serve blocks and txs with witnesses per BIP 144), NODE_COMPACT_FILTERS (can serve BIP 157 block filters), and NODE_NETWORK_LIMITED (can serve the most recent 288 blocks per BIP 159). You can make assumptions (e.g. lack of NODE_NETWORK and NODE_NETWORK_LIMITED may imply SPV peers), but there are no guarantees.

Thank you so much! I used getpeerinfo via the console and was able to obtain the services names as described. "servicesnames": [ "NETWORK", "WITNESS", "NETWORK_LIMITED" ], Is there any significant info with regard to the "connection type" param? From my peers I got: "connection_type": "outbound-full-relay" (this is the most significant type for my peers ~ 80%), and "connection_type": "block-relay-only"

@TuanP No, there is not. It is just what your node has configured that particular connection to be. Some connections are limited to block relay only, whether that is because the peer requested it, or your node is conserving bandwidth. It has no relation to the services offered and whether the peer is validating.


text:
Some questions about Lightning and Tor
Currently there is a wave of articles claiming the Lightning Network is shrinking. If you look at official statistics, like on p2sh.info, this seems true.
I was told that some of it might be an effect of more and more Lightning nodes using Tor. Imho it is insane to run a LN node at home without Tor, so this might be a good explanation.
But there are some questions left ...

Why do tor nodes don't show up in the statistics? I failed to find a good answer to this.
If tor nodes don't show up in statistics - can non tor nodes route payments over them? Someone mentioned you need bridge nodes for it. Why? And what do bridge nodes do? Are they publicly known, do they have a special setup?

Thanks everybody. Looking forward for your answers.

Generally if you read BOLT 07 you will see that lightning nodes and channels can either be private or public.
This is independent of the fact if they run on tor or not.
The node announcment message explicitly supports announcing that it runs on tor as written in the BOLT 07

The following address descriptor types are defined:

1: ipv4; data = [4:ipv4_addr][2:port] (length 6)
2: ipv6; data = [16:ipv6_addr][2:port] (length 18)

3: Tor v2 onion service; data = [10:onion_addr][2:port] (length 12)

version 2 onion service addresses; Encodes an 80-bit, truncated SHA-1
  hash of a 1024-bit RSA public key for the onion service (a.k.a. Tor
  hidden service).

4: Tor v3 onion service; data = [35:onion_addr][2:port] (length 37)

version 3 (prop224)
  onion service addresses; Encodes:
  [32:32_byte_ed25519_pubkey] || [2:checksum] || [1:version], where
  checksum = sha3(".onion checksum" | pubkey || version)[:2].

However I think most users running on tor like their privacy and don't announce their node.
Generally nodes can only be announced if they have at least one public channel. This is to prevent spam and DoS attacks on the gossip protocol. As some people only have private channels the nodes will not be announced.
Also most mobile nodes like eclair by default open private channels because it might not be so useful for a user that their mobile phone consumes all the data from their carriers data plan to become a routing node.

Tor nodes do show up in statistics, for example, 1ml.com. I do run Lightning Network nodes only behind Tor.

source: Stack Exchange

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

sort: votes


text:
Is it possible to determine the index of a bip32 address?
Let's assume that we only have the bip32 derived btc address, no private or public key. Is it possible to find out its index used for the bip32 generation?

One of the privacy properties of BIP32 is that given two public keys (or even private keys), you cannot even tell whether they were generated from the same xpub or two distinct xpubs. This implies you certainly can't tell their index.

BIP 32 does not derive addresses but derives a series of private keys from which corresponding addresses are then calculated. So there are multiple layers of obfuscations here that would make the index recalculation impossible. First, Bitcoin addresses do not reveal anything about the associated private key (ECC and hash protected) and second, the private key related to the address is in itself derived from the master private key through a function that hashes multiple inputs of which one of them is an index number. Since hash functions and ECC are one-way, there is no way to back calculate this data.

Awesome, thanks for the quick & in-depth reply!

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


text:
How long does it take to find a UTXO in UTXOs set?
to validate a TX, the miner or full node should first find the UTXO. How long does it take to find a specific UTXO in a list of UTXOs set?
Right now, there are around 100 million of UTXOs. Then, how long does it take to find a specific UTXO among 100 million UTXOs? I need to know the accurate time.

It is impossible to answer this accurately without knowing details such as the hardware the miner is using, their utxo storage method, and their validation process.
However, in general, the utxo set can be stored as a list keyed by the utxo identifier (txid:vout). This provides O(1), or constant, look up complexity for a single utxo.
However, the utxo set may not fit entirely in memory on many systems, and the actual retrieval time may be longer than you'd expect in an ideal scenario after accounting for disk access time, and other implementation specific details.
In a miner's case, they validate incoming transactions and prepare a block template by feerate asynchronously from the actual mining operation - this allows them to have a reasonably good chance of maximising their earnings per block without having the mining process blocked by tx and block validation systems.

Thanks. How do the miners can start mining before generating the block?! They need to know the whole block and then try to find a solution to the puzzle. Am I wrong?

They start mining a bare minimum (empty) block, and keep replacing the block header with the header for a more optimal block as better transactions are available and checked. This allows them to constantly be mining some block.

Suppose that they could mine the bare minimum (empty) block very quieckly before they could find enough valide TXs. Then will other miners accept this empty block as a new block?!

As long as the empty block has valid proof of work, it will be accepted. There are many such blocks. Here's one from a couple of days ago: https://www.blockchain.com/btc/block/0000000000000000000da19960ca1695b1ccaf25400050faf29966bd6b3b56c9


text:
Who can predict that a benign attacker has 51% hash rate of the system?
In the Bitcoin network, suppose that there is an attacker who has 60% hash-rate (hr) and then other users have 40% hr. Therefore, it is obcioust if other users generate any new block, attacker can ignore it and then genrates a new block with the same height and then outrun all other miniers.
However, suppose that this benign attacker is not so malicious. I mean that if other miners find new blocks, then the attacker will accept their new blocks. Therefore, in general, other miners can mine 40% of the new block in average.
1) As this benign attacker accept any new block by other miners, is it again illegal to have more than 50% of the total hash-rate?
2) If yes, who can detect such a benign attacker?

Just a note: by definition, an attacker is never benign.

1) As this benign attacker accepts any new block by other miners, is it again illegal to have more than 50% of the total hash-rate?

It is not illegal to have any percent of hash rate, you are allowed to have it. If you meant whether it breaks the bitcoin protocol, then the answer would be no if they are always benign. However, once they do turn malicious, they can harm the network. Refer to this link for what a 51% attacker can/cannot do.

2) If yes, who can detect such a benign attacker?

I will present two arguments, one in a complete theoretical world and another one that uses some information that is not available to the bitcoin protocol.
Theoretically:
You cannot detect them. There could right now be a benign attacker which you describe and we cannot know about them. For a more concrete argument, consider the following two scenarios.
Scenario A: In this scenario, all the miners are honest and create certain blocks and honestly extend each other.
Scenario B: 60% of the miners are malicious(benignly as you describe) but choose to act as if they are honest.
All the block creation and exchanges which take place in scenario A and scenario B are identical. So from the point of view of observer, those are identical. And hence, in theory, we cannot detect such a benign attacker.
In practice:
    However, in practice, I believe that it is unlikely such a benign attacker exists as it would require lots of resources to be owned by a single party.

Great answer. Thanks. Yes, there is not a benign 51% attacker. I just needed to know the whole idea about this attack.


text:
Bitcoin purchased but not received into my wallet
I paid over 12k for bitcoins and it was sent and I have a copy of the bitcoin transaction.  I have not received the amount into my wallet. Is there any way that I can still retrieve my bitcoins?  It has been 3 days now and they provider is one that I have used before and I trust that the bitcoins are there but I need to find a way to access them.

If your wallet is a custodial wallet where the private keys are managed by the provider, your only recourse is to contact the provider.
If your wallet is a non-custodial wallet where you manage the private-keys yourself, there are several possibilities

check that your wallet is fully synchronised.  How you do this depends on which wallet you use.
check the transaction by entering the transaction-id at several blockchain explorers. The business or person you bought the bitcoins from will be able to tell you the transaction-id and receiving address (it might have been printed on a receipt, mentioned in an e-mail or in a text-message etc)
check that the output of the transaction was sent to the correct Bitcoin-address. You can see the actual recipient addresses of the transaction in a blockchain explorer. Your wallet should be able to show you a list of the receive-addresses it has generated. Wallets nowadays generate a new receive-address for every transaction.

If the sender assigned too low transaction fee it may take quite long to receive your bitcoins. Using your receive address check your transaction via blockchain explorer to see the details

The mempool has been quite empty over the last few days, so I don't think low priority fees are the issue for this one.


text:
Blockchain.com API and needed amount
I have installed Blockchain.com platform on our server and ran some codes successfully based on its Wallet APIs. Regarding to what is said here, as we are testing this platform, we charged the created wallet with .00000546 BTC. But while using payment API, we received this result:
{
  "error": "Insufficient funds",
  "available": 0.00000546,
  "needed": 0.00001092,
  "sweep_amount_satoshi": 0,
  "sweep_fee_satoshi": 678
}

I can't understand why am I getting this error, and specially, how the amount of needed variable is calculated? May you help me please?

If you have the  .00000546 BTC inside the wallet, you can not create a new transaction because, if your transaction will have needed the fee, so with your reference in this post, you can not send the 0.00000546 with the blochchain.com because of the 0.00000546 + FEE < YOUR_AMMOUNT

That's correct and we understand it. But the mentioned needed value is strange. Based on https://www.blockchain.com/api/blockchain_wallet_api, miners fee is 0.0001. So we need 0.0001+0.00000546 BTC. I don't know what is sweep_fee_satoshi for. But even if we should add it too (0.00000678 BTC), the final result will be 0.00011224 BTC which is different with the needed value!


text:
In an event when nobody mines the next block in the blockchain, how are the transactions supposed to get published into the blockchain?
I understand that miners are never gonna stop mining given the transaction fee reward for each block. But just in case of an event when nobody is able/willing to mine the next block in the blockchain, what happens to the new transactions, how are they supposed to get published? And also, how is it going to effect the blockchain consensus?

Another not-so-apparent to mine is to spend coinbase coins which have a maturity period of 100 blocks. If miners stop to mine, they not only lose opportunity cost of not mining next block, but also lose previous 100 blocks of reward.

@sanket1729 okay, so basically a miner of a block has to have 100 confirmations before they get rewarded

They don't.  The blockchain is by definition a chain of mined blocks.  If nobody mines the next block, then the blockchain cannot grow, and no further transactions can be included in it.  Transactions will cease to be confirmed until somebody does mine another block.
Transactions can still be relayed over the peer-to-peer network, and nodes will verify their signatures and store them in their mempools, but there will be no real protection against double spending.  Someone might create two or more transactions which conflict; some nodes may store one and others may store the other.  No consensus will necessarily arise as to which one should be accepted as the "right" one.
If this state of affairs becomes permanent then the currency is effectively dead.

"there will be no real protection against double spending" - in this situation there is no need to protect against double spending as there is no spending happening at all :D (if I understand correctly)

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


text:
Modify the number of confirmations for an utxo to be ```safe == true``` in Bitcoin Core
I noticed that when I call listunspent on Bitcoin Core, UTXO with 0 confirmation are labeled unsafe, and thus prevented from being spent with sendtoaddress or fundrawtransaction. As soon as there's one confirmation the tx is safe and I can spend it.
Being able to modify the target for a tx to be considered safe, for example set it to 3 or 6 confirmations instead of just 1, would make my life easier, but I can't find an option for it. Is there some way to do it?

You could set minconf=3 or minconf=6 for that matter; you can also parse depending on the confirmations field instead of the safe one.

From the documentation:

listunspent ( minconf maxconf ["address",...] include_unsafe query_options )
Returns array of unspent transaction outputs
  with between minconf and maxconf (inclusive) confirmations.

so listunspent 3 would work for you?

Yes that's what I do now, but I was wondering if there was a way to modify the safe parameter to totally avoid the risk of picking an UTXO that have less than x confirmations in a transaction.
You can also use the lockunspent command for the same purpose.

You'd need to recompile Core for that.


text:
What is the maximum amount of an Elements asset that can be issued?
Elements allow for assets issuance, and I was wondering what was the limit to the number of units that we can issue for each asset.
There's a limit to the amount that can be issued each time, which is 21 millions, but it seems that by issuing 21 millions again and again I can issue much more than that.
My guess is that the max amount that could be issued is the maximum number of satoshis that can fit in a int64_t, which should be 92,233,720,368.54775807, am I getting this right?

There is no maximum that can be created, however you may run into issues with RPC-APIs in Elements if any wallet contains more than 92,233,720,368.54775807 at any time.
Confidential transactions will function with any realistic amount (you would have to re-issue an asset more times than possible to overload the 256-bit confidential amount type, however the receivers wallet would fail if int64 overflows.

If I remember correctly, confidential transactions do have a limit of its own though, but it is not a problem since it is impossible to make a transaction with an output bigger than 21 millions. Each issuance being a transaction itself limited to 21 millions, there's indeed no problem doing confidential asset issuances


text:
How to represent a taproot output with more than 2 scriptleaves as a descriptor?
I read in the Bitcoin Core doc an example of a taproot output descriptor with 2 script paths :
tr(c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5,{pk(fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556),pk(e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13)})

I tried to pass a descriptor with a third script path, but I'm met with an error tr(): expected ')' after script expression
That makes sense since I read in the same doc that the syntax for taproot descriptor is tr(KEY,TREE), and that TREE is defined as:
* any SCRIPT expression
* An open brace {, a TREE expression, a comma ,, a TREE expression, and a closing brace }

This is consistent with what I saw in the rust-bitcoin library, where a TAPTREE is either a leaf, or 2 trees.
My question is what if I wanted to commit a third script, a very simple one like the 2 in the example?
I think I could compute the root of my tree myself and use the rawtr() descriptor with the output pubkey, but what if I want to prove there's no hidden commitment?
I guess I could give all the scripts and that one could figure it out by recreating the scriptpubkey and check it's the same, but that's cumbersome.

If you want a Merkle tree with script paths S1 and S2 on the second level of the Merkle tree and script path S3 on the first level of the Merkle tree the descriptor notation is:
tr(KEY,{{S1,S2},S3})
where KEY can be any key expression including public key, x-only public key, WIF private key, xpub, xprv or xpub/xprv with derivation path.
Pull request #22051 added support for tr(KEY,{{S1,{{S2,S3},...}},...}) descriptors and the notation was confirmed in pull request #21365.

Thanks, how didn't I think of it facepalm
Maybe we should update the descriptor documentation with an example


text:
How does `createrawtransaction` and `fundrawtransaction` work with Elements?
I know how to create and fund bitcoin transactions using createrawtransaction and fundrawtransaction methods. I tried to use the same methods in Elements to create a transaction on regtest and I'm a bit confused now.
What I'm trying to do precisely is having a node who only have a watch-only wallet creates and funds transactions with the UTXOs it has on watch and sign later on another machine.
So I have this watch-only node, and it watches 2 outputs, one with L-BTC and the other with some asset, let's call it X.
I first create a transaction that have only one output of 0.5 asset X:
e2-cli createrawtransaction "[]" "[{\"$ADDR\":0.5}]" 0 false "{\"$ADDR\":\"$ASSETX\"}"
Now I decode the transaction and I see this:
{
  "txid": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8",
  "hash": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8",
  "wtxid": "4d941354157530580ac49d97fad4690a5aab5b1a3bca4a38d7b26969455edec8",
  "withash": "d0d3b17552f63780c06e5558483412d8384702cd777404f52a8a9680304fe582",
  "version": 2,
  "size": 110,
  "vsize": 110,
  "weight": 440,
  "locktime": 0,
  "vin": [
  ],
  "vout": [
    {
      "value": 0.50000000,
      "asset": "ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74",
      "commitmentnonce": "036c0c488e3bfb29090d0bda8be116088c61dcd3252a949f801972e8dc3f223c70",
      "commitmentnonce_fully_valid": true,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 eee6174735a3d1bca9532e663ec266acd59a6a1c OP_EQUAL",
        "hex": "a914eee6174735a3d1bca9532e663ec266acd59a6a1c87",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "XZ8RJoGpd5GDRBGYuLrRq24bQBNtqCxgXG"
        ]
      }
    }
  ]
}

Then I try to fund the transaction (I want to subtract fee from the change output for some reasons):
e2-cli fundrawtransaction $RTX "{\"changeAddress\":\"$CHANGE\",\"changePosition\":0,\"subtractFeeFromOutputs\":[0],\"includeWatching\":true}"
And I have this error:
Wallet does not support more than one type of fee at a time, therefore can not subtract fee from address amount, which is of a different asset id. fee asset: b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23 recipient asset: ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74

And indeed if I convert it to psbt I see this:
{
  "inputs": [
  ],
  "next": "extractor",
  "estimated_vsize": 78,
  "estimated_feerate": 0.00000000,
  "fee": {
    "bitcoin": 0.00000000,
    "ceefd76de1b71c2bed3de04481826287a80babb6e1f6c9feca14e57597742d74": -0.50000000
  }
}

What am I missing here? I didn't put the "fee" key when I did createrawtransaction, as far as I can tell, so why did my asset X output became a fee output?

Ok it turned out I was a bit confused about the way fees and change is handled here. Here are the commands that worked for me:

createrawtransaction "[]" "[{\"$UADDR\":1.2},{\"$UCHANGE\":1.8}]" 0 false "{\"$UADDR\":\"$ASSET\",\"$UCHANGE\":\"$ASSET\"}"
fundrawtransaction $RTX "{\"changeAddress\":\"$UFEECHANGE\",\"includeWatching\":true}"
blindrawtransaction $RTX
and then on the signing side signrawtransactionwithwallet $RTX

Some comments:

the change address given in the fundrawtransaction command is actually used for the change of the fees paid in L-BTC, since here fees are explicit, not like in Bitcoin. That's why I added an explicit change address and amount for the asset I was sending.
I used unconfidential addresses to create the raw transaction
includeWatching is not implicitly true like in a bitcoin watch-only wallet
the tx worked, it was broadcasted and accepted by the network, but there's still something wrong with the blinding, the destination output has not been blinded, and on the other hand I messed up the change of the fee, it seems I can't unblind it myself


text:
HD Wallets - Why Extend a Private Key with addition? (Non Hardened)
As I currently understand, there exist two methods for extending keys in a hierarchical deterministic wallet: regular derivation, and hardened derivation. Hardened derivation essentially “breaks the chain,” adding security because through normal derivation, a leaked child private key, along with the chain code, could be used to derive any parent private keys through subtraction.
Normal child private key derivation would happen like this: Take the HMAC-SHA512 hash of the parent public key, parent chain code, and index number. The first 256 bits are added to the parent private key to derive the child private key, and the other 256 bits are the child chain code. Using this, an adversary who possesses a child private key and the chain code could use subtraction to find the parent private key.
And hardened derivation is similar, but the parent private key is used as input to the hashing function so it can’t be reversed, even if the chain code is known. The disadvantage is that a parent private key is required to generate child public keys, eliminating the possibility of a “receive only” machine having access to public keys only.
My question is, why is reversible arithmetic (addition of the parent private key and output from the hashing function) used instead of a “one way” function such as elliptic curve addition or others?

My question is, why is reversible arithmetic (addition of the parent private key and output from the hashing function) used instead of a “one way” function such as elliptic curve addition or others?

To allow public derivation.
This means that it is possible to give someone a parent extended key (public key + chain code), and they can derive all public keys in the chain.
If the final secret key is computed by a one-way function directly, no equivalent operations exists with public keys to compute the public version of the result.

We have equations like this, where hash is the first half of the HMAC-SHA512 hash, K, k are parent keys and K1, k1 are children. K+hash = K1, k+hash = k1. There is no one directional arithmetic operation that would allow the same to be true?

No, this is provably impossible with just elliptic curve based derivations. The constructions you will come up with will either be insecure, or impossible to do without the private keys.

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


text:
Unconfirmed Transaction new
can someone help me with this?
thank you
https://blockchain.info/tx-index/1b8e3e8064d28e6728212169f1479c1b359a88452854844afa562de1e6d6d800

Only wait for confirmations, the transfer is fine.
Here you can see that have 0/6 confirmations at this time: https://live.blockcypher.com/btc/tx/1b8e3e8064d28e6728212169f1479c1b359a88452854844afa562de1e6d6d800/


text:
Why can't someone create a valid digital signature without knowing your private key?
I understand from the following two posts that private keys are not displayed by the sender when getting their transaction validated by the bitcoin miners:
What happens to Private Key on Payment
How can transactions be verified without the private key?
Instead a digital signature is provided that is based on the Private Key, and, as far as I understand, that digital signature is verifiable when "compared" to the Public Key.
Why then can't someone generate a verifiable digital signature using only someone else's public key?
Or put another way, quoting an answer from the first post listed above:
"A valid signature cannot be created without access to the private key" - why not?

Bitcoin uses something called the Elliptic Curve Digital Signature Algorithm (ECDSA) for signing and verifying transactions. Read the linked Wikipedia article for exact process of how ECDSA works. If you understand how the modulo operator works, it should make sense as to why you can't make a signature without the private key.

It's kind of hard for me to explain this as it does rely on some complex mathematics, but I will try.
To produce a valid ECDSA signature, you need the private key, which is a large integer. It is explicitly used in the signature creation algorithm, but the public key is not. Furthermore, the public key is not an integer like the private key; rather it is a point on an elliptic curve. So even if you know the public key, you can't create a signature with it because it is not the private key and you can't recover the private key from the public key.
The private key cannot be recovered from the public key because of a problem called the Elliptic Curve Discrete Logarithm Problem. From Wikipedia:

it is assumed that finding the discrete logarithm of a random elliptic curve element with respect to a publicly known base point is infeasible: this is the "elliptic curve discrete logarithm problem" (ECDLP).

The private key is the discrete logarithm. Although this is an assumption, it has been shown in practice that ECDLP is a hard problem, i.e. it is hard to find the discrete log given a base point and public key point. So you can't get the private key that is required in ECDSA to produce the signature.

thanks this definitely helps, whilst I can't claim to fully understand the answer, just knowing that I didn't have some simple flaw in my understanding of how bitcoin works is useful.

"A valid signature cannot be created without access to the private
  key" - why not?

In few words: because there is no known algorithm today to do it.

This is a feature of digital signatures from public-key cryptography. It's probably out of the scope of this site to explain how cryptography works. Maybe https://crypto.stackexchange.com/ would be a better place to ask.


text:
I'm a developer, trying to land a job at an exchange. What type of software would an exchange need? Want to build something to use as a resume
I'd like to give a good impression by solving a problem they already have, but I'm not sure what could it be.
Thanks!

I think there are few values that every exchange is looking for.

ability to work with multiple coins (exchanges = shitcoin casinos)
ability to generate the addresses and manage them securely on-scale within organization
knowledge of API interfaces

Regarding second point (as it's a bitcoin-related board) I'd advise looking at few projects that you can work on yourself, copying the ideas:

Key derivation tool: https://iancoleman.io/bip39/
Bitcoin transaction fee estimate like: https://billfodl.com/pages/bitcoinfees or https://bitcoinfees.earn.com/
Maybe some Lightning Network related project if you know that the exchange you are applying in may be interested

Although it relates to bigger exchanges only, as smaller ones use external order books and usually work only on the frontend.

Thanks Tony, maybe a common interface to operate with different coins would be useful? A common set of commands for tasks like sending to an address, verifying a payment has been confirmed by the network, generating a new private key/address and writing the pair to a DB?


text:
Bitcoin rpc getbalance wrong
I am using v0.11 rpc, In blockchain balance and my rpc balance are different. rpc balance is wrong why?
But transactions are correct.

What do you mean by "Blockchain balance"? Your full node is your source of truth, don't trust what block explorers or other websites say.

You should try getbalances instead. I believe that will include your watch-only addresses as well.

I have deposited some amount of btc and the transaction is confirmed but available balance is low. when i check other source balance is correct.@pinhead

Ok, I will try getbalances thank you.@Pillagr


text:
Can a 0 confirmation Bitcoin Core change output be spent?
I have a Bitcoin Core wallet which has a utxo which I spent from, in a transaction where around 1% was sent to an external wallet address, with the ~99% change output remaining in the wallet, sent to a new internal change address selected by core.
The fee used turned out to be too low and I am still waiting for the transaction to be confirmed, and now when I attempt to spend using the balance that is displayed in the wallet (with getbalance endpoint), I am told there is "Insufficient funds.".
But when I list the wallet utxos with listunspent, "spendable" has value true for the change output mentioned above - this is what I expected since my understanding is the core wallet by default will use CFPF to still spend an unconfirmed change output (please correct me if this is wrong).
My question is:
Why does the output listed by listunspent indicate that the output is 'spendable', when if I try to spend the output, it fails with an 'Insufficient funds' error?
Is there another reason for the wallet complaining that there is insufficient funds? Probably relevant is that it was an opt-in RBF tx, and I have already tried bumping the fee (still too low and not confirmed) but now would prefer to use CPFP as I have another transaction that I would like to make from the same unconfirmed change output.

I think you should try CPFP not using your Bitcoin Core. Sounds like the wallet application is locking that balance rather than it actually being unspendable. Something like this will clear it quickly - https://steemit.com/cryptocurrency/@coincircus/how-to-confirm-a-stuck-transaction-using-child-pays-for-parent-cpfp-the-easy-way

Really useful resource - thanks. To do this all within Bitcoin Core, would the way to do that be with the createrawtransaction RPC or using another method?

That would only be part of it, you would still then have to sign the raw transaction (signrawtransaction) with your priv key and broadcast it (sendrawtransaction). http://coinb.in is quite a good resource for this with a GUI

Spending the whole balance of the wallet will always fail, because you cannot assign the whole balance to an output and pay a fee at the same time. There are two ways to sidestep this issue:

Instruct sendtoaddress to send the whole balance to one of your own addresses, but to take the fee out of the recipient amount per the subtractfeefromamount argument (on send it's called subtract_fee_from_outputs and you need to indicate which output to take from). Be sure to pick a sufficient feerate¹ to bump the parent transaction.
[Not recommended:] Manually calculate the fee you wish to pay and create a transaction with sendrawtransaction that sends balance - fee to a new address in your wallet. Be sure to inspect the transaction before submitting it, manually building transactions has often led to people accidentally sending too much fees.

¹Bitcoin Core has a known issue where it will treat all UTXOs as though they have been confirmed for the purpose of fee calculation. When using an unconfirmed UTXO created by a transaction with a lower feerate, Bitcoin Core will not account for the necessary bump fees to achieve the intended target feerate for the child transaction. You therefore need to choose a higher feerate than where you would actually like to queue the child transaction in order to reprioritize the parent transaction. There is ongoing work to fix this issue and automatically bump unconfirmed ancestor transactions to the requested feerate in PR #26152.


text:
Bitcoin.conf setting for CPFP - how can I enable longer 'chains' of unconfirmed transactions?
I often receive an -32700 'Insufficient Funds' error when attempting to create 'child pays for parent' (CPFP) transactions using unconfirmed change output. This can be problematic since it can prevent me from sending further transactions until the parent transaction is confirmed.
My question:
Is there a bitcoin.conf setting (or other workaround/solution) that would allow for the acceptable length of chains of CPFP transactions/unconfirmed change outputs to be increased, and thereby avoid being stuck, unable to broadcast further bitcoin transactions until parent txs are confirmed?
A related side question - I have not yet discovered the logic behind how bitcoin core decides to allow an additional CPFP transaction to be chained, and when it gives an 'Insufficient Funds' error. It seems to be anywhere between a chain of 1 to ~5 (i.e. sometimes I get 'Insufficient Funds' error when there is only a 'chain' of one tx, other times, up to around 5) and it is not clear to me how this is determined. What is the logic here?

The maximum unconfirmed descendant count is a mempool setting, not a wallet one. Assuming most of the network run with the default of 25, even if you changed your own mempool to accept a longer chain the last child transaction would not relay.
Anyways, in such an extreme case (a chain of >25 unconfirmed transactions) you likely want to bump your fees already. And batch your transaction next time..

how bitcoin core decides to allow an additional CPFP transaction to be chained, and when it gives an 'Insufficient Funds' error.

The wallet will by default spend unconfirmed change (transactions it itself created), but not unconfirmed incoming payments.

Thanks for your answer. Unfortunately this doesn't really explain why I am unable to spend unconfirmed funds with chains less than 5. Currently I have unconfirmed change output from a single transaction ('chain' of 1) which I am unable to spend, with a 'Insufficient Funds' error, despite getbalance showing all of my expected funds. Do you have any idea what may be causing this, or a possible solution?

What command are you using? Do you have spendzeroconfchange=1  (the default) ? Are you sure the wallet is only including this specific utxo (you may be confused by fees, too. Maybe and if possible do a dry run with a smaller amount)

Turns out using replacebyfee alongside CPFP chains was causing bitcoin-core to refuse to spend unconfirmed change, likely because 'conflicting' chains of CPFP transactions could result in chaotic/non-deterministic wallet spending conditions. It's not fully clear to me whether or not CPFP and RBF are simply not designed to be used together, or if there is some better way of benefiting from either together that I do not currently know of.

They are, but the Bitcoin Core wallet may not be ready to handle all edge cases yet (would have to dig a bit to give a more secure answer).

Discovered that I get the same "Insufficient Funds" error, along with getbalance returning an incomplete balance when exclusively making CPFP txs (without doing RBF txs), and only 5/10 transactions of about 10/20 outputs. I'm a bit stumped as to why this issue still arises. Could it be related to using RBF explicit opt-in for all transactions?


text:
How do I check if a particular address is 'owned' by a loaded wallet in Bitcoin Core?
I'm interested in knowing if there is an rpc method to determine whether or not an address was generated, and thus is owned by, a loaded Bitcoin Core wallet.
I have a few addresses that I generated a month or so ago using getnewaddress. These have been stored in a relatively secure encrypted location. In my paranoia, I am reluctant to now use the addresses to receive funds in the wallet, since as far as I know there is no benefit in doing so (besides increasing the gap between used addresses - but I am in no way approaching any gap limit, so this is irrelevant) over simply generating a new address which I can be sure is indeed owned by the loaded wallet. That said, I am curious to know if this is possible (since it may in some cases be useful, if sufficiently trustworthy - which if it were an rpc method for a trusted Bitcoin Corre instance, I'd assume to be the case) and after searching bitcoin.org RPC docs and on here, I have not been able to find an answer to this yet.
Note - I am aware of the validateaddress rpc, but as far as I understand, this only validates whether or not a Bitcoin address is valid, not whether it is associated with the loaded (or any particular) wallet.

You want the getaddressinfo wallet RPC. It will tell you whether an address is considers "yours", along with various other information like whether you have the keys, whether it's a payment address or change, what its label is, and how it was derived.

Thanks, exactly what I was looking for. To any onlookers, the relevant part of the json response to getaddressinfo is 'ismine'

I have written a program where you can search for any address on Bitcoin Core whether the address is yours or not. Actually it'll give you all the addresses in every block if you want. Here is my github link:
https://github.com/ORP967/Bitcoin_Core_RPC_par_address
Let me know what you guys think and any improvements you can come up with.


text:
Multibit transaction is not being confirmed
I'm using MultiBit version 0.5.16 (is this classic?)
I am trying to get my bitcoins from Multibit to Electrum, but my transaction doesnt get confirmed. The current transaction is 1mBTC to test it first, so it's not a huge deal if I lose this 1mBTC.
I saw here something similar: Transactions seen by peers, but not confirming
The answer there is that the version is too old.
As MultiBit is no longer supported, is it even possible to update safely, to make sure my transaction will be confirmed?
Thanks in advance,
RitchBit

Move your private keys to Electrum. I had this issue with Multibit HD since last summer. I sent my bitcoin from Hive (which had just become unsupported) to multibit hd. For over a year the transaction showed up on multibit as unconfirmed. The steps I took were:

Recover the wallet words from the multibit hd wallet file
Use a tool online that converted the multibit wallet words to private keys
Added the private keys to Electrum wallet

As soon as I created the electrum wallet with the private keys it showed up as confirmed in electrum. I would completely move to another wallet altogether as multibit is deprecated, and I’ve seen this unconfirmed bug happen quite often, don’t use multibit anymore.


text:
Why does it cost money to transfer bitcoin?
Noob question here.
Why are there transaction fee when transferring bitcoins and who charges them? Being decentralized does not imply that anyone is able to join?

The transaction (tx) fee is the difference in value between you tx input(s) and your tx output(s). The fee is to incentivise miners to include your tx in a block. Until your tx is included in a block it's not part of the blockchain and the recipient will most likely not acknowledge the payment.
When you see your tx as pending it means it's been added to the mempool but has not yet been added to a block. When you see your tx displayed as 1,2,3 etc. confirmations that means it was included in the block mined 3,2,1 blocks ago (blocks are mined on average every 10 minutes).
You can create a tx with 0 fees and in the past they may have been picked up by a miner. These days with the high tx volume (currently there are 10k outstanding in the mempool) a 0 fee tx would almost never get added (unless a miner had another non-economic motive).
I was able to confirm a tx with a fee of 0.00000226 BTC on the 24 Sep 2017. To do that I was literally watching the mempool and picked a time when it was nearly empty. Currently my Bitcoin-Core wallet is recommending a fee of 0.002 BTC/kB which would work out to a fee of 0.0005 for a typical tx.

Pretty tech savvy! I like! ;)

Well the simple answer is that someone has to validate the transaction: they are the miners.
Miners in turn have to invest in computers, and to make this workable they invest in computers.
So for them not to be bankrupt they have to be paid, and transfer fees do just that! :)
David

But could anyone, crank up a server, become a miner (maybe not for the mining, but for the transactions fees) and start validating for money?

Well yes, you can become a miner by joining a mining pool, that is basically how bitcoin works :) Miners are the ones validating the transactions and they receive a fee for doing that!
This covers some ideas on that for you: link


text:
What would be the consequences to lower the difficulty such that a block is generated every 5 minutes?
The difficulty is adjusted such that a block is generated every 10 minutes.
What would be the consequences to lower the difficulty such that a block is generated every 5 minutes?

The most important consequence:
It would increase the orphan rate, which gives big miners more chance to mine (because they run their own ISP, while a miner with 0.1% hashrate of the network probably doesn't), and this leads to centralization.

1) More transactions can be handled in a shorter time.
2) The difficulty would decrease (as you said).
3) More blocks are created -> the size of the blockchain grows faster.
4) The whole 21,000,000 are available earlier because someone would get 12.5 BTC each 5 minutes instead of 10 minutes.

What about the 51% attack?

51% attack means that one mining company has more than 50% of the whole hashing power, but the percental hashing-power per company stays the same if you decrease the difficulty. So I don't see the danger of a 51% attack in this szenario.


text:
Why does the chart on a coin vary between exchanges?
Look at the BCH chart for instance, the 8 november there is a wild selloff following the cancelation of the new scaling protocol for bitcoin. This has nothign to do with BCH but causes a selloff nevertheless, on big volume with  a long deep red candle. This is on Bitfinex. Then look atr the same
chart at Kraken. No long deep red candle, no selloff.
So I guess either the chart was edited (manipulated) afterwards, or no Kraken customers sold any BCH outside that range on the chart?

There is no central market for the bitcoin or other altcoins.
Crypto currencies are exchanged on each exchange for the price set by people transacting there. This means that the price is set exchange by exchange, not centrally for every coin.
Thus the variance of the graphs.
Cheers, David

So in theory and maybe in some strange situations, the price for a  coin may go in totally seperate directions on different exchanges, if the people transacting in different countries for instance, have radically different views of (future) value .. has this ever happened?

I guess people would buy at the cheap exchange and then move the coin to the expensive one to sell it there, so the price would go up at the cheap exchange until a relative equilibrium was restored  between exchanges ... lol :) its funny stuff ..

@achrp That is exactly it. For instance, in China the price of crypto currencies is typically higher, as there is an increased demand. This happens in other countries too, where the fiat currency is unreliable or cannot be taken out of the country.


text:
Buying Bitcoin Cash
Hopefully my question is relevant based on my understanding I received during the tour. I would like to buy Bitcoin cash. I have GDAX/Blockchain account but Bitcoin cash is not available to buy on those sites. Can you advice? Thank you

There are many altcoin exchanges such as Bitfinex that you can buy the altcoin bitcoin cash, but you should be warey that the price is being heavily manipulated by the project owners

You can buy BCH on other sites, such as https://www.kraken.com.
I hope it helps,
David


text:
Historical intraday data for altcoins that can be exported?
I've been looking around lately for historical data, like opening price, closing, high, low etc for altcoins. All I have come up with is daily data or higher, but what I need is like 5, 10, 15 minutes etc.
I need to be able to have data for at least a few weeks back. And I need to be able to export it as a CSV file or something.
Any ideas?

You can try my website at cryptodatasets.com which has raw and sampled historical data for BTC, ETH and LTC in .csv format.


text:
reviveing a bitcoin core wallet
In 2013 I installed a BITCOIN CORE (V0.10.2) wallet in my netbook computer and purchased 1 bitcoin. Recently I have wanted to sell but found the wallet out of sync and needing to download the entire Blockchain because the computer crashed years ago due to dud battery. when I get past the date when I purchased my bitcoine it appears in my wallet OK but trying to complete the block chain download takes so long that the netbook Locks up before it is complete - why i don't know, but anyway....................
Is there a way to transfer my wallet or its contents to a new BITCOIN CORE wallet (v0.15) that I have in a much newer computer without completing the blockchain in my old netbook? Put another way - what constitutes the identity of my old wallet? - and can that identity be transfered to my new wallet so my bitcoin appears there?

Bitcoin Core 0.10 was not released until 2015. It is impossible for you to have used that version in 2013 as it did not exist.
However the wallet format itself has not changed since at least 2012 (and earlier really) so it is completely fine to upgrade your software. The wallet.dat file can still be used in Bitcoin Core 0.15. All you need to do is make sure that Bitcoin Core is shut down, go to the Bitcoin Core data directory, and copy the wallet.dat file from there to the Bitcoin Core data directory on your other machine.

After long period 'scanning' and some 'program not responding' delay it opened and presto - my wallet from old netbook. now only about a year of the blockchain to catchup and I should be in business - thanks JC

I am not sure on the changes from version 10 to current. But you may try to copy your old wallet.dat file in to a separate folder on the new computer (do NOT overwrite), and start with the "-wallet" option as command line parameter. This would specify which wallet to load rather than having to copy or overwrite files (thx to comment from MeshCollider @ Nov 1 at 18:41).


text:
Peer discovery on a custom signet (custom `signetchallenge`)
I'm experimenting with signet by creating a custom network with a script of my own to validate blocks (signetchallenge in the conf file).
I started a mini network with only a handful nodes for now, but I noticed that they connect to each other if I tell them to with a addnode command (or in the conf file), but then they don't seem to do any network discovery.
To clarify, I manually connect A to B and C to B, but then B never seems to tell either A or C about each other.
As far as I understand peer discovery in bitcoin, nodes should periodically ask each others peer list with getaddr command, and then try to connect to new nodes. Is there a reason for this not happening on signet?


text:
bech32 addresses beginning with "bcrt..." on regtest
I'm playing around with regtest and wanted to generate a bech32 address. My Bitcoin Core version is 0.18.0.
I ran getnewaddress "" bech32 and got an address that began with bcrt, like this one : bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw.
I'm a bit surprised, because I was thinking that testnet bech32 addresses were different, and indeed I checked this page that says it should begin with tb1...
I tried to send some tbtc to this address with Electrum and a faucet, none worked, they indeed both say address is invalid.
So what am I missing here?

Regtest and testnet are different networks. They are not compatible with each other.
Regtest is a private local network which is used solely for testing. It is primarily used for the regression tests, hence the name regtest.
Testnet is the public testing network which is very similar to mainnet, the main network. It has a different genesis block and has actual miners, DNS seeds, and nodes that you can connect to.

Thanks got it, but if I'm not mistaken both testnet and regtest use the same addresses' prefix? At least it is the case for legacy and P2SH addresses, and since I don't find any specific format for bech32 on the page I linked to I was also expecting Bitcoin Core will generate addresses beginning with tb1 on regtest.

They use different prefixes for bech32 addresses.

Ok, but then it means this page need to be updated https://en.bitcoin.it/wiki/List_of_address_prefixes
I created an account on Bitcoin Wiki and see how to do it myself, thanks for your help

I'd like to second that. At very least, please add that prefix to the wiki.

Another thing is that IMO giving regtest different addresses is unhelpful. It's not a big deal, but if I have a system built around communication with a bitcoin node, I'd expect not to have modify it, just to run some test scenarios in a controlled regtest setup.
From the perspective of a user either something is a "real-address" (mainnet), or not-a real one. And if it is not "real", then regtest vs testnet vs whatever else doesn't really matter. It is only making job of sw eng. integrating bitcoin a bit more complicated.


text:
are there Happy Hours?
after Genesis of Bitcoin, ie creating block#0, every wallet owner has an empty wallet, by the way there is nothing to mine. So how the block chain process can be initiated?
Are there Happy Hours and some lucky people are elected so that they can get free bitcoins? is it called premined bitcoins? In other words, where I can find description of the bitcoin blockchain bootstrap?
As an alternative question, is it possible that bootstrap process initiates on a credit/debt basis, ie ledger balance always nul?

Related: https://bitcoin.stackexchange.com/q/9773/516

after Genesis of Bitcoin, ie creating block#0, every wallet owner has an empty wallet, by the way there is nothing to mine. So how the block chain process can be initiated?

All you need in order to mine is a block to mine on top of. There don't need to be new transactions for mining to be possible. An empty block can be mined as easily as one with transactions in it. And, of course, there's always the transaction to pay the reward to the miner, at least until the block reward drops to zero.

Are there Happy Hours and some lucky people are elected so that they can get free bitcoins? is it called premined bitcoins? In other words, where I can find description of the bitcoin blockchain bootstrap?

No. The only way new bitcoins can be created is by mining.

As an alternative question, is it possible that bootstrap process initiates on a credit/debt basis, ie ledger balance always nul?

No. Bitcoins just exist and aren't an obligation or debt of anyone or anythinng else.
Thinking of bitcoin mining as analogous to gold mining may help. If you have an ounce of gold, nobody loaned it to you or owes it to you, you just have it. And all the gold that will ever exist is already somewhere, it's just not accessible yet. And when someone finds some gold, it transitions from being unowned to owned and the amount that is still left to be mined goes down.

Thanks. If the only way to create new bitcoins is by mining, in that case why is there a maximum limit to number of bitcoins? in consequence what happen when the blockchain reach end of life?

@daniel_exb Satoshi wanted there to be a limited supply, so he designed the reward curve to drop off to zero. At that point, the blockchain doesn't reach end of life, it just stops providing any mining reward beyond transaction fees. Whether or not mining will continue to work reliably when the only reward is transaction fees is a subject of some debate and you can ask a question about it if you like or search for existing discussions.


text:
Unconfirmed transaction simple advice
I am new to bitcoin and made a beginner mistake. I sent bitcoin from Mycelium wallet to coinbase wallet. Mycelium offered some rely small fees without warning, they only warned that if you pick 0 it might not happen. I picked a small fee as I considered that I am not in hurry. Now the Mycellium says transaction its confirmed and coinbase says its pending. If I understand Blockcypher correctly it says my BTC is received but no send. Is there anything I can do but hope that someone mines the rest of the block? If yes can you please tell me what in a simple way? amount is like 0.08... BTC so its relatively high for a student...

"If I understand Blockcypher correctly it says my BTC is received but no send." If you were to provide a transaction id or address, other peeople could check your assumption.

I wouldn't worry to much yet. These days Bitcoin transactions take their time to be confirmed on both sides. A transaction that would have previously been confirmed successfully in one hour, can these days take a day or more.
With the small fee you offered for the transaction you didn't exactly help in speeding up the process.


text:
How does a full-node index watch-only addresses?
I can import watch-only addresses into my full-node's wallet. I can start querying their utxos from that point onward.

Where are watch-only addresses stored and how does my node keep index of their balances / utxos?
If I want to backup and boot a new instance of my node will it retain the indexes associated with my watched addresses?
Is there a limit to how many addresses I can watch, will many make querying inefficient?

Where are watch-only addresses stored and how does my node keep index of their balances / utxos?

Usually the software creates a wallet file just like any other and stores information in that, except the wallet file will be missing private key information.

If I want to backup and boot a new instance of my node will it retain the indexes associated with my watched addresses?

Yes

Is there a limit to how many addresses I can watch, will many make querying inefficient?

Depends on your computer and the software used. There is no hard limit but the more there are the slower it'll be.


text:
What exactly happens when I import private keys to my wallet?
I can create addresses with private keys and import those keys into my wallet to receive their unspent outputs to later spend.
My question is split into two parts:

What exactly happens when you import a private key? Is that private key now stored and its corresponding address now tracked by your wallet?
A new transaction is signed with a private key. Therefore, if I have 1 BTC on one address and import its private key, and 1 BTC on another address and import that, how is it I can now spend 2 BTC in one transaction, which key was used to sign this new transaction?

Yes
Both. Each of the two keys is used to prove control over the corresponding UTXO of  the two UTXOs used as an input to the transaction


text:
Set bitcoin fee lower than minimum estimatesmartfee value
Currently when I broadcast transactions, I seem to be unable to do so with a fee below ~10^-4 bitcoin (~$2 at current exchange rate). Any 'conftarget' value between approximately 100 - 1000 yields the same ~10^-4 estimate. I would prefer to send some less urgent transactions with lower fees but it's not clear how to do so if when I set conftarget=1008 (which I believe is the bitcoin core max) for the transaction, I cannot access fees lower than described. Is this expected behaviour for Bitcoin Core?
On a related note, it is not completely clear to me how the estimatesmartfee 'estimate_mode' parameter functions. From the help, I can see that the options are 'ECONOMICAL' and 'CONSERVATIVE', which seem quite self-explanatory on a high level (former estimates lower fees than latter for same conftarget), but in practice - how does the estimation differ? So far I have used the default 'UNSET', which I understand defaults to 'CONSERVATIVE' - would this affect the value of the apparent minimum possible network fee described above?

Your post contains two questions, for the latter see https://bitcoin.stackexchange.com/questions/96489/how-does-bitcoin-core-estimate-the-transaction-fee/96491#96491 :)

Regarding your first question, a new fee_rate argument has been added to the sendtoaddress command in the upcoming release (v0.21.0, currently at the third release candidate) of Bitcoin-Core.
In addition, a new send RPC was integrated which allows you to set a specific feerate too.
Regarding your second question (meaning of CONSERVATIVE and ECONOMICAL), see How does Bitcoin Core estimate the transaction fee? .


text:
Help needed with PyWallet and wallet dump using MacOS
Could anyone please give me some guidance on how to perform a wallet dump using PyWallet on a MacBook (macOS 10.12 Sierra)? I’m not very savvy with this stuff at all. Have an old wallet.dat file from 2011 that I want to check all the keys from and was reading that doing a wallet dump would be an efficient way to do it without having to wait for the entire blockchain to sync on Bitcoin Core. Having a really hard time trying to figure out how to do it with almost no computer programming knowledge. So far I have Python 2.7 downloaded but am pretty stuck after that. Any help would be greatly appreciated. Thank you!

Install Xcode

Install MacPorts from https://www.macports.org/

Run these commands:
sudo port install python27 py27-twisted py27-pip py-bsddb python_select
sudo port select --set python python27
sudo easy_install ecdsa


text:
listed companies with significant bitcoin revenue
The currency flowing through listed companies on the main stock exchanges of the world is mainly of the standard, fiat kind.
Does anyone know if there are any listed companies out there on any major stock exchange for which a significant proportion of turnover, say more than 5% is in bitcoin or other cryptocurrency?

Take a look at the publicly listed bitcoin mining companies. I believe that Marathon Digital does hodl bitcoin (and they even raised money to PURCHASE bitcoin some weeks ago). You could also take a look at Coinbase and other exchanges but as far as I know they don't keep the transactions fees they take in bitcoin but trade them to this Dollar-Shitcoin.
Besides these options the only way to find such companies is to find companies that allow bitcoin payments and a significant amount of their users prefers this option. But the companies I know that do that are pretty small and not public...


text:
Is a 'seed phrase' independent of the type of wallet?
I have had a few things happen on my PC and for the moment can't directly call up my bitcoin in its old wallet. There are files from various wallets sitting in my home directory but before I try to get a wallet program to retrieve from them, will find a piece of paper where I wrote a seed phrase.
The question is, can this seed phrase be entered into any wallet, whether it is Armory, Electrum, Wasabi, Bither to get the bitcoin back, or must I be careful to install exactly the same wallet which gave me the seed phrase in the first place?

First of all, some software wallets imports are supporting only 12 word or 24 word combinations.
Some support different BIPs and thus path derivation schemes (32/44/84) by default, and some only single one of them.
Some have additional feature for a specific seed passphrase.
All of the differences you can check on https://walletsrecovery.org/
So to answer your question, you have to install the wallet that uses the same seed format and path derivation as the one you've originally created.

Ah dear is not exactly what I wanted to hear, sounds like there are about six families of wallet from the variables you describe. Hopefully it will work. I've only had about three kinds of bitcoin wallet that I've ever used so if necessary will try them one after the other.


text:
Is it safe to close a wallet and switch off the computer when there are only one or two confirmations?
This happens every time I have to send Bitcoin somewhere - a small clock symbol opens up in the electrum wallet, and the colour slowly changes from orange to friendlier shades of green as the number of confirmations of the transaction rises from 0 to 5.
Every time, I want to go somewhere, but feel obliged to plug in the computer and leave it switched on so that the 5 confirmations can happen in peace. I worry that otherwise possibly the bitcoin may disappear into the ether and I would lose it or otherwise that maybe I would not lose it, but the transaction would cancel itself half way and the recipient would never receive it.
This is an electrum wallet (4.0.9)
What is the truth of this? Can you close the wallet and switch of the moment you've clicked 'send' or should it be allowed to sit there switched on for forty minutes or whatever it takes to collect its 5 confirmations?

Can you close the wallet and switch [off] the moment you've clicked 'send'

Yes. Once the transaction is broadcast, the wallet has no further role in the processing of the transaction.
The exception would be, for example, if you use RBF and decide to instruct the wallet to up the fee. But this is a rare exception and isn't something a typical wallet would do without human intervention.

I worry that otherwise possibly the bitcoin may disappear into the ether ...

The bitcoin never conceptually "leave" your wallet until the transaction is confirmed.
In reality, the Bitcoins are not ever "in" any one specific wallet either. If they exist at all it is in the globally replicated transaction journal we call the blockchain. That persists even if your wallet is destroyed immediately after sending the proposed transaction.
Bitcoins are never in transit. Transactions may be.

... and I would lose it ...

No. If the transaction is never mined / confirmed, the money remains yours and can be spent later.

... or otherwise that maybe I would not lose it, but the transaction would cancel itself half way and the recipient would never receive it.

Bitcoin transactions cannot be cancelled.
The continuing activity of your wallet is not required.


text:
Can one consider that the interest of other actors/stakeholders would change something about the concept of "blockchain"?
I am new to the Bitcoin world and am trying to get an overview within a research project. I see that Bitcoin was born out of a certain motivation to decentralize money and that decentralization, open source, maybe security and verification are important. My question is, can one consider that the interest of other actors/stakeholders would change something about the concept of "blockchain"? For example, by the growing interest of large companies in smart contracts? Could block chain, for example, stand less and less for transparency and more for efficiency? Or does it not matter, because it is less about transparency and more about replacing trust?

The Bitcoin blockchain system is intended to be inefficient - it is based on proof of work. The security of the Bitcoin system depends on this deliberate inefficiency as well as blockchain's transparency. As you say, it is about avoiding the need for trusted third parties. That was paramount in the initial design.

So what do you mean with unefficiency? Do you want to say that nobody will be interested in blockchain without the interest on transparency because blockchain is inefficient? Banks are interested in blockchain although the inefficiency, because, as I red someehere here, the money transfer is faster, they want to reduce prices for transfers... But banks are not interested in transparency, or are they? They want the centralized system. If they are not and they are also working on blockchain, I am asking me if it would change blockchain. How could they adapt it to the current economic situation?

involves use of computing resources vastly greater than required for a blockchain not based on PoW. 2) No. 3) No because bank xfer is a few seconds here. Contactless payment instant 4) No they are not. 5) yes. 6) Not the Bitcoin blockchain. 7) You could but then it wouldn;t be the Bitcoin blockchain. 8) In millions of different ways, none relevant here.9) Comments are not for discussion - try [chat]


text:
Blockchain transaction change output
I'm very new to this.
It’s hard to know for sure, but what’s most likely the case with the below transaction:

Someone sent 25.99 bitcoin to another person/organization
Someone sent 1 bitcoin to another person/organization
Someone sent 26.99 bitcoin to another person/organization

You cannot say for sure.
The three options are potentially true.
However, many clients build transactions with the change output as the last output.
So, following this convention, I would say option 2 is the most likely.

In addition, the change output is most likely the output with the highest number of decimal digits.

Most modern clients randomize the change output index now. Really nice ones like Bitcoin Core will also match the change address to be of the same address type as the payment address

As a third party to the transaction, its hard to say what the most likely case is. You can guess, but there are a number of possibilities, and some wallet software will deliberately create transactions which confuse this sort of analysis.
To add to your list of possibilities:

Someone sent 25.99 bitcoin to another person/organization
Someone sent 1 bitcoin to another person/organization
Someone sent 26.99 bitcoin to another person/organization
Someone sent 26.99 bitcoin to themselves
Someone sent 25.99 bitcoin to some person/organization, and 1 bitcoin to some different person/organization

Some other more obscure(?) possibilities. These would perhaps be more probable if OP's post involved P2SH or P2MS addresses.

Two people shared ownership of the input, and each one of them now owns one of the outputs.
Numbers 1-5 again, but with 2+ people owning the input.
Numbers 1-7 again, but with 2+ people owning (each?) output.


text:
Blockchain transaction unspent
This is a bitcoin transaction as shown in a blockchain explorer. What does ‘2 confirmations’ mean here? Sorry for the picture quality.
Which one is the best answer?

2 confirmations by miners are required for this transaction to be accepted by the network
2 other blockchain nodes have confirmed this transaction
The transaction is included in one block (of the blockchain) whose hash is included in the previous block

2 confirmations means the transaction was included in a valid block and that block was continued by another valid block.
Option 3, although it should be next block (older than the one that contains the transaction) instead of previous block.

Thanks. So answer is 3 ?

yes, are you doing a bitcoin test?

Just learning stuff

So, someone sent 26.99 bitcoin to another person ?

Probably they sent 1 BTC to someone and ~26 BTC (minus transaction fee) back to themselves (what is called a change output). The fee of a bitcoin transaction is given by sum of input values minus sum of output values


text:
How Bitcoin nodes validate a new wallet
I have a cuple of questions about how wallet creation works. If I create a Bitcoin wallet offline, is there any way of like validate the new wallet, I mean, what if this wallet already exist? I know the posibilities are incredibly low.
And, if I create an address offline, how Bitcoin nodes would accept my address as valid (or this isn't needed?) I mean, in which moment, Bitcoin nodes accept my offline-created address.
I have create a script that creates bitcoin wallets, and I create one offline, then I search for that address on https://www.blockchain.com/explorer and it shows my current address, so my question is how this address appear in this web?

How Bitcoin nodes validate a new wallet

They don't
Bitcoin nodes validate blocks and they validate the transactions within those blocks
Other nodes don't have access to your wallet and can't validate it or anything in it.

I mean, what if this wallet already exist?

No one knows or cares if the private-key initially generated by your wallet already exists. Nodes don't check for this type of "collision".
If someone else's wallet has the same private key, either of you could spend each-other's money as well as your own.

if I create an address offline, how Bitcoin nodes would accept my address as valid (or this isn't needed?)

Any address is accepted so long as it looks like an address. A well-formed address has an acceptable length, initial bytes and checksum.

I mean, in which moment, Bitcoin nodes accept my offline-created address.

each node accepts it at different moments. In whatever moment they happen to come across the address and see that it is a well-formed address.

how this address appear in this web?

A correctly generated well-formed address that has never been used and consequently never appeared in the blockchain is nevertheless a valid address. I expect most blockchain explorers would simply display it and show that there are no transactions associated with it.

In summary, no one keeps track of wallets, private-keys and addresses that have been created and never used. All of these are just as valid as a wallet, private-key or address that gets used a thousand times a day every day of the year.
There's a vast ocean of numbers,  they are all valid. Some have been used, some not yet, almost all  will never be used.

See also

Can Large Bitcoin Collider break into the wallet which is created by new version of Electrum?

Addresses contain the network byte (hence old-style addresses start with 1 or 3) the 20-byte public key hash, and a checksum that doesn't let you lose funds if you mistype the recipient.
If the checksum is wrong, your wallet will warn you.
There's no way to prove that a public key hash was derived from a known public key. For example there's a corresponding private key to 1BitcoinEaterAddressDontSendf59kuE, but those burn addresses have their public key hash chosen, and no one will ever find their private keys.


text:
Is there any 'Metamask-like' app for Bitcoin?
9 months ago someone asked this same question: Metamask-like web3 inject for bitcoin but I was wondering if there had been be any changes since then.
I'm currently looking for a Chrome extension that allows you to validate Bitcoin users based on their wallets, It does not matter if it's not a Chrome extension, I just need some app that could accomplish this.
I'm working in a project using Metamask for login users, and I need to find out if there is a way of archieving this with Bitcoin (and other cryptocurrencies), so if you know something about the topic it would be great to hear you.

No, because Bitcoin doesn't have a (privacy-invading) standard web API like web3.js. No news in the last one year about that.

Bitcoin wallets are sets of addresses derived from master keys, while ethereum is account balance. As @MCCCS mentioned, bitcoin is also much more privacy-focused than ethereum.

Microsoft is apparently building a 'decentralized identity platform' which utilizes the bitcoin network. I haven't read much about it, I don't know if they have much code currently available,  but here is a link to their site: https://identity.foundation/


text:
Address generator error with python
I had created a script that creates a bitcoin private key, public key and address, for checking if all works fine I create one and check the private key on https://walletgenerator.net/, and it outputs a different address, every time I do that my script create a different addres that what walletgenerator returns.
Python script:
import secrets

import hashlib
import ecdsa
import codecs
import base64
class Address():
def init(self):
self.private_key = self.create_private_key()
self.public_key = self.private_key_to_public(self.private_key)
self.address = self.public_key_to_address(self.public_key)
@staticmethod
def create_private_key():
    bits = secrets.randbits(256)
    bits_hex = hex(bits)
    private_key = bits_hex[2:]
    return private_key

@staticmethod
def private_key_to_public(private_key):
    verify_key = ecdsa.SigningKey.from_string(codecs.decode(private_key, "hex"), curve=ecdsa.SECP256k1).verifying_key
    key_hex = codecs.encode(verify_key.to_string(), "hex")
    bitcoin_type = b'04'
    public_key = bitcoin_type + key_hex
    return public_key

@staticmethod
def public_key_to_address(public_key):
    public_key_bytes = codecs.decode(public_key, "hex")

    sha256_bpk = hashlib.sha256(public_key_bytes)
    sha256_bpk_digest = sha256_bpk.digest()

    ripemd160_bpk = hashlib.new("ripemd160")
    ripemd160_bpk.update(sha256_bpk_digest)
    ripemd160_bpk_digest = ripemd160_bpk.digest()
    ripemd160_bpk_hex = codecs.encode(ripemd160_bpk_digest, "hex")
    network_byte = b'00'
    network_bitcoin_public_key = network_byte + ripemd160_bpk_hex

    network_bitcoin_public_key_bytes = codecs.decode(network_bitcoin_public_key, 'hex')
    # Double SHA256 to get checksum
    sha256_nbpk = hashlib.sha256(network_bitcoin_public_key_bytes)
    sha256_nbpk_digest = sha256_nbpk.digest()
    sha256_2_nbpk = hashlib.sha256(sha256_nbpk_digest)
    sha256_2_nbpk_digest = sha256_2_nbpk.digest()
    sha256_2_hex = codecs.encode(sha256_2_nbpk_digest, "hex")
    checksum = sha256_2_hex[:8]

    address_hex = (network_bitcoin_public_key + checksum).decode('utf-8')
    return Address.base58(address_hex)

@staticmethod
def base58(address_hex):
    alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
    b58_string = ''
    # Get the number of leading zeros
    leading_zeros = len(address_hex) - len(address_hex.lstrip('0'))
    # Convert hex to decimal
    address_int = int(address_hex, 16)
    # Append digits to the start of string
    while address_int > 0:
        digit = address_int % 58
        digit_char = alphabet[digit]
        b58_string = digit_char + b58_string
        address_int //= 58
    # Add ‘1’ for each 2 leading zeros
    ones = leading_zeros // 2
    for _ in range(ones):
        b58_string = '1' + b58_string
    return b58_string

Doing
foo = Address()
print(foo.private_key, foo.public_key, foo.address)

returns
# 5598c164e8bcec667589267cdaf0f14a6b9399ae0b2a6b10972602a6feaf682d
# b'04cbeefab6ecfa84f5f120503de4574952f2d1fa5b11b8f6c80a13df02e6512090e6fede6dde3e65256c484162e38
# 39cf599c3d08a236432e8e307784b741ffca5' 18NFnELB9YpRiEbLMmRLKymYpvxC9yzkC2

And then, if I check the private key 5598c164e8bcec667589267cdaf0f14a6b9399ae0b2a6b10972602a6feaf682d on https://walletgenerator.net/, it returns:
Public address: 1LBLgjq3ntVdb8MqB41rHReWnrKgT41Lwv
Public address compressed: 1LBLgjq3ntVdb8MqB41rHReWnrKgT41Lwv

walletgenerator.net is probably a phishing site

Your python scripts generate uncompressed public keys, and they seem to calculate correctly.
When I use my own scripts, the results are:
Private key: ---------------------------------------
5598c164e8bcec667589267cdaf0f14a6b9399ae0b2a6b10972602a6feaf682d
Private WIF: ---------------------------------------
Kz66jawQ5eb7pQYJx3tTNmFQBS46x1rg92To2js3bY1SKrPxVWvL
Public key: ----------------------------------------
04cbeefab6ecfa84f5f120503de4574952f2d1fa5b11b8f6c80a13df02e6512090e6fede6dde3e65256c484162e3839cf599c3d08a236432e8e307784b741ffca5
pubkeyhash: ----------------------------------------
50cdf408e049ddab4bd8ebda8a6500e93831a633
BTC Address: ---------------------------------------
18NFnELB9YpRiEbLMmRLKymYpvxC9yzkC2

No difference to your results.
But there seems to be a bug in walletgenerator.net's calculation:
They claim that the uncompressed address was the same as the compressed address, which cannot be correct. Which tab did you use on their site, was it Wallet Details?
As a compressed bitcoin address, I get 1KJKsAzDeH1127x6w8e2xZyzRdvFkiLhme when I use my own scripts, and my Electrum client confirms that result (when I use the private key import feature).
All that does not match the results of walletgenerator.net, so my conclusion is that their site is buggy.

Thank you @citizenfu, yes, I tried to check the values on Wallet Details. It's a good thing hear from you that it is not my script what's wrong


text:
Withdraw from a BTC wallet Ucoincash 24hours is still pending?
I wanted to withdraw 0.62 Bitcoin back to my wallet and I did try to verify the receive wallet address as I submitted the request and it is still pending 24 hours later? On the blockchain, I see no transaction or received BTC? This request was sent Saturday Evening November 18th, 2017 at approximately 11 pm and it is 11 pm Sunday, November 19, 2017

I've voted to close this as a duplicate. If it turns out that the transaction hasn't been broadcast to the network by the wallet service, then you would need to raise that with the service (in that case, the question would be off-topic for the site).


text:
Where does the term HODL come from?
I know that HODL means you hold your crypto for the long run, whether the price goes up or down, but where does the term come from?
I have heard people say it means "Hold On for Dear Life" and other that it was a typo.

There term originated as a forum post in December 2013 as - what I can only assume to be a drunk day trader. That is holding his coins as the price is crashing.
I don't think it was intended to mean "Hold On for Dear Life" but it has definitely grown to mean that as OP explains that there are three people, the losers (inexperienced traders) and winners(experienced traders) and the group in the middle that buy and hold on for dear life. The forum post itself is an interesting read and I defz recommend that you check it out yourself: https://bitcointalk.org/index.php?topic=375643.0

It originated from this bitcointalk thread, posted in December 2013:
https://bitcointalk.org/index.php?topic=375643.0
It was a typo, but has since been given the alternative meaning you mentioned.


text:
Transfer incomplete and unspent
Im hoping i could get some assistance, im a newbie to cryptocurrency but will try my best to outline my Query,
I have transferred 0.06685156 BTC (incl. fees) from my Coinjar cash account to my Exodus Bitcoin cash Wallet 1HL3xwinsGfnNmTPsMrtzGgL3fud9pWDv1 on the 15th of November 2017.
It has now been 6 days and the funds have not yet come up on my Exodus Account.
I have checked on the blockchain but dont really understand what im looking for, i note this is showing up as  unspent, how can i fast track this particular transaction or what other options do i have.
Im happy to transfer a reasonable fee in BTC if someone can either clear this on my behalf  or provide a step by step guide for me to do it.
Transaction ID:
2d88911d1823c32ecd4dc951f87a830b680118f5b50c77fbb9b60fd02d22b83e
many thanks in advance

So you've sent a transaction from a Bitcoin address to a Bitcoin Cash address?  See this:  https://bitcoin.stackexchange.com/questions/57419/what-would-happen-if-you-send-bitcoin-btc-to-a-bitcoin-cash-bcc-address


text:
Please help me to solve unconfirmed transaction
I tried to send a bitcoin transfer and it is still unconfirmed and I have my block chain account set to "use recommended fee" by default. Can anyone help me get this confirmed or teach me how to get it confirm (or how to raised the tx fee to get it be confirmed faster? Many thanks for your kind support.
Here is the link:
https://blockchain.info/tx/c6816a387cb0ca8e33bb7b200372ce05919f6003034faaeecb1f72436827b32b

The fee is around 10 satoshi's per byte, which is quite low, it may take some time but it will almost certainly confirm eventually. I'd guess it will be within a few days, but that depends on the transaction load.

accelerated. will be confirmed very soon

Patience grasshopper!  According to 21's block confirmation estimator with your 10.21 sat/byte fee your tx will likely confirm in the next ~3-32 blocks.  For future reference though, if you would like to add a higher fee check into using recently added RBF (Replace By Fee) functionality that was recently added to bitcoin core and multiple wallets.  Here is a bitcointalk thread that discusses this at length for numerous wallet clients:
https://bitcointalk.org/index.php?topic=1802212.0

Also possible CPFP, it's usually more expensive than RBF but works even with transactions that you did not prepare to be replaced.


text:
Bitcoin calculator based on my machine
I tried to find an online tool that would allow me to calculate how many BTC (or portions of it) I might be able to mine with my computer, but I couldn't find an answer that is exhaustive.
Is there any such tool?

Your computer is worthless for Bitcoin mining.   All BTC mining is done with custom built ASIC rigs which are billions, if not trillions of times faster than the best home PC.

Thanks for your contribution. How do one knows it?
Imagine I'd like to calculate how many computers equals to the one I have I'll need to mine a bitcoin; how do I calculate that?

@Adriano Increasing the number of computers won't change anything because you are multiplying by zero. Computers are currently useless for bitcoin mining because the power they use costs more than the bitcoins they mine are worth -- many, many times more.

I might not have issues with power supply. I just want to understand, given my hardware, how long it will take to mine a bitcoin.
I am not concerned about the energy bill :)

Even though the comments were pretty clear about, "don't even try this", you seem insistent.
Mining Power is measured in Gh/s, or Giga-Hashes per second, which means how many Billion hashes can a computer try every second.
The mainstream ASIC processor, AntMiner S9, can do about 13 Th/s (13 Terra-hashes, or 13,000 Gh/s).
A good graphics card GPU can do about 1 Gh/s.
So you would need on the order of 13,000 graphics cards to come close to a single ASIC processor.
Since the S9 has a breakeven point around 1 year, it would take your PCs about 13,000 years to make enough money to buy a single S9, and the PCs would be far more expensive upfront, and use far more electricity along the way.
Bluntly put, if you really really focused with PC mining, you'd be extremely lucky to make about $3 a year.

References:
Is Gpu mining still an option?
https://bitmain-alliance.com/product/antminer-s9/?gclid=Cj0KCQiAuZXQBRDKARIsAMwpUeTtoNrXLyaRXqeHuVyaoEj4jeGUrx4zyJGeVYQpTUcvHllr41MKvb8aAj1iEALw_wcB
https://www.cryptocompare.com/mining/calculator/btc?HashingPower=4730&HashingUnit=GH%2Fs&PowerConsumption=1293&CostPerkWh=0.12
https://99bitcoins.com/2016-bitcoin-mining-hardware-comparison/


text:
How to upgrade Bitcoin Core from 0.18 to 0.20 on Ubuntu 18.04?
I've installed Bitcoin Core on Ubuntu 18.04 (CLI). Now, the version 0.20 of Bitcoin Core is released and I want to upgrade my server to it, but it seems the new version is not included in PPA yet. May you help me to upgrade my Bitcoin Core server to 0.20 in a safe and correct way please?

This is how I usually do it. Check the wget links in https://bitcoincore.org/bin
# Download Bitcoin Core packages for Ubuntu

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

# check the checksum and fingerprint //optional
wget https://bitcoincore.org/bin/bitcoin-core-0.20.0/SHA256SUMS.asc
wget https://bitcoin.org/laanwj-releases.asc
sha256sum --check SHA256SUMS.asc --ignore-missing
    >expected: xxx.tar.gz: OK
gpg --import ./laanwj-releases.asc
gpg --refresh-keys
gpg --verify SHA256SUMS.asc
    >expected: Good signature from "Wladimir J. van der Laan ..."

# extract, install and check versions of the binaries
tar -xvf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
sudo install -m 0755 -o root -t /usr/local/bin bitcoin-0.20.0/bin/*
bitcoind --version
    >expected: Bitcoin Core version x0.20.0

When I run sha256sum --check SHA256SUMS.asc --ignore-missing I receive bitcoin-0.20.0-x86_64-linux-gnu.tar.gz: OK and sha256sum: WARNING: 20 lines are improperly formatted

It's fine :) Formatting of 20 lines is improper to do sha256sum, from how I understand it, it's somewhat expected if you don't force the check sha256sum.

I'm getting different warnings while running your codes... gpg: WARNING: This key is not certified with a trusted signature! gpg:  There is no indication that the signature belongs to the owner. , gpg: no ultimately trusted keys found

I think it's because it's still a key you've just downloaded from the internet. The warning says it can't confirm that this key is certified (legit). I don't know more secure way of checking validity if you're not into building the package yourself. And the only way for it to be false is if both sources would be spoofed.

Here is extended explanation: https://bitcoin.stackexchange.com/questions/565/how-can-one-download-the-bitcoin-client-securely


text:
Why are there equal send transactions for each receive on Bitcoin Core?
I've lunched a new Bitcoin core wallet, and generated some addresses using it. Then I tried to receive some BTC to these address, and then, found out if I receive some BTC, there are equal send transactions too on the same address.
All incoming BTCs are in my wallet, and there is not any problem up to now. But I wonder to know what are that send transactions? I am paying fees for them automatically!
This is an example:
https://www.blockchain.com/btc/address/3PiCVEFLHPiexXf15UB7nw9yBMZTWjP73C

Is your balance not what you expect it to be? Are you making transactions after you have received Bitcoin? Have you shared your wallet.dat file with someone else or received your wallet.dat file from someone else? Seeing sends like this either means that your private keys have been compromised, or you are misunderstanding how Bitcoin works. Bitcoin Core does not randomly produce transactions.

@AndrewChow the balance is what I am expected, and I had transactions  after receiving BTCs. The strange thing is the same address which I had receives on, has the same amount that is send to somewhere else. Maybe I misunderstand the mechanism of Bitcoin core as a newbie in this platform.

You can only "send from" an address the amount that it has already received. So it is not unexpected that you see the same amount being sent elsewhere. If you are sending transactions, then you should not be surprised that Core is "sending from" addresses in your wallet.

Thank you @AndrewChow. Although, I did not say what address should be used to send BTC to other addresses and Bitcoin core seems managed this itself.


text:
Does restoring wallet.dat require the same paths and configs in servers?
I have a Bitcoin core server (Server 1) which is working well. Now I am testing backing up and restoring its wallet on a new server (Server 2).
Imagine that the server 1 has these configs:
blocksdir=/btc/blocks
datadir=/btc/data # wallet.dat file is here in  the wallets directory

Now, I want to move the backup file (wallet.dat) to the new server which its default paths are like this:
~/.bitcoin/wallet.dat
~/.bitcoin/blocks

Do I need to have the same paths in the server 2 for data and block directory as the server 1? Or can I move the backup file to the default path of wallet.dat in server 2?
Should I copy the download blockchain from the server 1 and move them to server 2 too?

A wallet.dat file contains no information specific to a particular install of Bitcoin Core, or its configured data and wallet directories.
You can freely copy just the wallet file to another instance, without having to copy the block data or other information such as peers, mempool, etc.

I did it @Raghav, but the balance information was 0 in the server 2 whereas it was not 0 in the server 1. I thought I might did something wrong. What's your idea?

Is your new server fully synced?

If you mean syncing with blockchain, no it was not sync fully when I tested the wallet.

A node always effectively treats the state of the ledger as it was at the point it's synchronized to. If you load a new wallet in a not-yet-synced node, the balance shown will be the one you had at that point in time.


text:
How can I generate preimage for lightning network invoice? Should I?
I'm developing API library for LND REST API.
Method POST /v1/invoices requires r_preimage parameter.
Should I generate it or LND can do it itself if I'll not specify it?
If I should do that - how to do it properly? General description would be enough.

As a rule of thumb it is probably best to let lnd generate the preimage for you.
If someone can guess your preimage they have the chance of steeling the payment. It is somewhat similar to guessing your Bitcoin private keys but probably not as bad as they can only get the current payment and technically even that might be tricky.
If you want to do it alone you should keep in mind three things :

The preimage should be truly random which for software is always hard to achieve
It should have a large enough size. Flipping a coin might be truely random but as there are only two possible outcomes one could guess / brute force those
It should be unique and never reused.

The third point is achieved in precise by following the first two points.
Also looking at BOLT 02 https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc you will see  that the preimage is 32 bytes of data which gives you even less flexibility than my second point suggested.


text:
How can I know that my transaction has been confirmed on the longer chain?
This question is more on the theory of bitcoin.  Let's say I receive a coin in a tx which has been confirmed with 6 blocks following the block that's been confirmed.  How can I be sure that there's no other place in cyberspace that has a longer chain  confirming a different transaction that transfers this coin to somebody else?

Building a chain longer than the best chain would require someone to have more Proof of Work hashpower than 51% or more of the total Bitcoin network hashpower.
The unlikelihood of this happening is the guarantee that the longest chain is the best chain.
To build a one block longer chain you'd have to assemble a block and find a nonce that produces a target less than or equal to the network target. Otherwise Bitcoin Core will discard your block as invalid. So to build a chain that is just 1 block longer than the current best chain you'd need massive amounts of hashpower, electricity, infrastructure and tens of millions of U$ investment. Again, all this for just one block.
The astronomic amount of work put into mining each block protects Bitcoin's consensus mechanism and assures everyone that the longest chain is correct.
If your TX was included in a block with depth 6 it means that for approximately one hour (~ 6 x 10 minute blocks) that chain where the block that holds your TX was included had the most work put into it all over the world.
There could be some other place where someone created an artificial chain with your TX in it but that chain will never be able to be longer than the main chain - unless they beat the network to find the next block. If they're unable to, then that chain will get ignored by everyone else in the network. That's how you know the TX you see on block explorers is in the longest/best chain.
For a more detailed reply you should read Antonopoulos' book (Mastering Bitcoin).

You can't be sure that there is not a longer chain somewhere else, since someone could work on another chain without telling anyone about it. It just becomes increasingly unlikely the more confirmations your transaction has.