text:
Why Entropie is divided by 32 (Seed to MNEMONICS)
I want to create a Seed-Phrase (mnemonics) from entropy. One aspect of BIP39  is to create the checksum and describes it as follows (Link BIP39):

The mnemonic must encode entropy in a multiple of 32 bits. With more
  entropy, security is improved but the sentence length increases. We
  refer to the initial entropy length as ENT. The allowed size of ENT is
  128-256 bits First, an initial entropy of ENT bits is generated. A
  checksum is generated by taking the first  ENT / 32

This thread describes a lot of details but not why divider 32 (or I don't understand it).
I am not a cryptographer and I did not find any detailed description why the divider 32 has been chosen. My guess is entropy. But why exactly?

BIP39 uses a dictionary of 2048 words. Each word is indexable with 11 bits (2^11).
The combined entropy and checksum is represented as a sequence of words from the dictionary, and therefore must have a length which is evenly divisible by 11.
If you take any integer N where N mod 32 = 0, then (N + N/32) mod 11 = 0.
So ENT/32 simply provides the number of bits which must be used for the checksum.


text:
Access my wallet using a 16 digit passphrase
I had a wallet years ago on a PC I sold. I mined bitcoin on it and what not. Recently I found a 16 digit passphrase I wrote down for my wallet. That is all I have and probably all I needed. If I only wrote down the 16 digit passphrase that means that's all I probably needed to access it anytime. I'm 99 percent sure I was using bitcoin core but I'm not too sure. What I do know for sure is that I have my 16 digit passphrase. My question is how can I access my wallet with my 16 digit passphrase I got?

Unfortunately, that 16-digit passphrase is likely the password to decrypt your bitcoin core wallet.dat file. So you'll need to have that file in order to access your wallet.
It could also be a BIP-38 protected paper wallet, but it doesn't sound like you have one of those.
Your best bet may be to search every email inbox, dropbox account, backup hard drive, or whatever else you may have, for either a backup of your wallet.dat file, or evidence of an account with an online wallet service.

source: Stack Exchange

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

sort: votes


text:
Keep Wallet Safe While Entering United States
I'll be traveling to the United States soon, and I've read that civil asset forfeiture laws may allow customs agents to take/keep crypto currencies.  Is there an easy way to keep my wallet safe from confiscation? I have a Trezor, but I'm not sure how best to travel with it. Should I keep coins on an exchange while traveling? Move them to a paper wallet or my laptop?

Great question. I wouldn't temporarily use an exchange. Use trezor's multiple hidden wallet method and don't forget to check out the pro-tip. Probably another Trezor user knows what I'm talking about and can write a decent answer

The Trezor (and other hardware wallets) use the BIP 39 specification for the recovery mnemonic. If your device is confiscated, you can use the recovery mnemonic to restore your wallet to another Trezor, hardware wallet, or software wallet. From there you can access your Bitcoin.

Ah, that's reassuring. I need to look up how to recover my wallet to another device and make sure I understand the steps and have everything before its needed. My Trezor is holding a couple different types of coins, each with amounts across a few addresses. If I do recover, will I need to restore each individual coin & address?

The recovery mnemonic encodes all of the information necessary to generate all of the private keys and addresses that your Trezor will ever use. By using that, you can restore all of your addresses and all other coins which use BIP 39 and BIP 32 (BIP 32 is the derivation method that generates all private keys and addresses).

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


text:
How do I implement bitcoin-seeder for an altcoin?
I am creating an altcoin, following a tutorial. The tutor skipped explaining setting up the DNS seeder.
How can I implement this code https://github.com/sipa/bitcoin-seeder ? Currently when I run ./mycoind (on my local machine) I get connection refused when trying to connect to the seeder defined in strMainNetDNSSeed
When I run ./dnsseed (on my vps) it does not run on port 8333 (actually 9333, I am using https://github.com/pooler/litecoin-seeder/ , a fork of the bitcoin seeder). Can anyone help?

There are many steps to setting up a DNS seed, so it is next to impossible to determine why your attempt failed without having more knowledge of your setup.
But if you are trying to set up a DNS seed for an alt coin, then I would strongly suggest you use the generic-seeder to prevent having to muck around in the source code.
The generic-seeder is a clone of the original bitcoin-seeder app that aims to make it easy to run a seeder for virtually any blockchain network. The bitcoin-seeder was developed specifically for the bitcoin network only, and configuring it to work with a different blockchain network can be time-consuming and tedious at best. The generic-seeder overcomes this limitation by utilizing a configuration file that holds the data used to connect to a given blockchain, without having to edit the source code, and adds new features and a full setup tutorial as well.
Github repo: https://github.com/team-exor/generic-seeder
Step-by-step setup guide: https://github.com/team-exor/generic-seeder/blob/master/SETUP.md
Full disclosure: I am the author of the generic-seeder.

DNS seeder runs on port 53 It crawls on p2p port of your coind which in your case is 9333.
Click this link for further instruction.

Welcome to Bitcoin.SE! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

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


text:
How can I find all bitcoin addresses with transaction history over (cumulative) 10 million?
Title says all. Any help is appreciated, thanks.

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


text:
Error "bad-txns-inputs-duplicate". Very weird
Recently I had an error, which I could never reproduce again. I don't want this error to occur in production, but I don't know how to fix this either or what could even be the reason for it.
First, here is what I did, in short:

My backend generated a new address.
I sent some funds to the address.
Backend waited, until the funds appear in the address (by polling mempool.space API).
Backend took the array of UTXOs of this address, iterated through this array only once, adding UTXOs to transaction inputs, until the necessary sending amount is covered.
Backend submitted TX Hex of this transaction to mempool.space.

This resulted in the "code": -26, "bad-txns-inputs-duplicate" error.
Google says it occurs, when a UTXO is spent multiple times in one transaction. I reviewed the code thoroughly, it is impossible that a UTXO was added into tx inputs multiple times.
Also, it was the first transaction of the wallet, so there was no previous transaction, that could spend a UTXO.
Any ideas regarding what could happen there?

Did you keep a copy of the raw transaction? What does it look like when you look at it in detail?

@Murch yeah, this is a very good question, unfortunately no.

The error indicates that the same input was spent twice in the same transaction.
Since you cannot reproduce it, it’ll be hard to fully track down what the issue was, but my guess would be that there was a concurrency issue where the way you were polling the data source was executing twice in parallel and added the same UTXO twice to your UTXO pool.
If there was any chance of asynchronicity or concurrency in your implementation, you might want to guard against this issue by deduplicating your UTXO pool before selecting inputs. You might also want to implement some sort of logging in case of errors.

The issue you're facing, marked by the error code "-26, bad-txns-inputs-duplicate," suggests a problem with duplicate UTXO (Unspent Transaction Output) usage. This error occurs when the same UTXO is inadvertently used more than once in a single transaction, which Bitcoin's protocol doesn't allow.
Based on your process:

Polling the UTXO set: There might be a race condition. If you're polling too quickly or if the mempool hasn't fully updated, the same UTXO could be perceived as available, even though it was already committed to a transaction.

Solution:

Implement a delay between polling UTXOs and submitting the transaction to ensure the mempool is fully updated.
Alternatively, use a more robust mechanism for tracking spent UTXOs, such as checking the transaction's status in the blockchain rather than solely relying on mempool status.

First transaction issue: Although it's the first transaction for this wallet, a UTXO might be getting erroneously referenced multiple times due to how the inputs are selected. Double-check how your code iterates through and selects UTXOs. Ensure no UTXO is mistakenly added more than once to the input array.

These tweaks should prevent the error from reoccurring.


text:
After mining a block and getting a hash. What do i do next?
I am pretty new to bitcoin.Suppose I mined it with a mining software. Now what do i do to earn a reward? How do i see the transactions? How do know what the block is? Most importantly, where do i submit the hash? Please help me. I am very grateful.

No. I have understood what bitcoin mining is. I want to know what to do once i get the hash.

Transmit the new block to your peers (a small number of other nodes you are in contact with). Wait 100 blocks, Optional - spend the money in the coinbase transaction.

As a miner you first pick a set of transactions that you want to include in a block. Then you calculate the block header fields, add some randomness, and check whether that block candidate passes the difficulty requirement. If it does not, you create a new block candidate and try again.
When a block candidate fulfills the difficulty requirement, you have found a valid block. Your node then announces the block to its peers.
As the transaction set is picked as an input to the mining process, the block's content is already known. The block reward is paid out by the miner to themselves: the first transaction in the block, called the coinbase-transaction, pays the transaction fees and block subsidy to the miner. Each miner includes their own address in their block candidate's coinbase transaction, so whoever finds a valid block gets paid. Outputs of coinbase transactions can only be spent 100 blocks later, so only blocks that become part of the best-chain get paid.


text:
Download blocks in blk00000.dat format from a specific period
For study purposes, I would like to download blocks from a specific period, i.e. January 2017 - June 2017, in blk.dat format (blk00000.dat, blk*.dat).
I downloaded blockchain.core but it makes me download the whole blockchain - correct me if I'm wrong.
Also I tried with blockchain.info but the problem is that I can only get one block at a time and just in Json or Hex format - don't need those.
So, do you know how could I do and with which program or API to use?
I'm a beginner, so please the more details you can give the better it is, even if they seems obvious.
For this work I'm coding in python.

Bitcoin Core is the only software that saves the blocks in the blk*.dat format. This format is not standardized and internal (i.e. not exposed to users). The contents of, for example, blk2342.dat can differ between multiple instances of Bitcoin Core.
The only option is to run Bitcoin Core yourself, or to find somebody who runs Bitcoin Core and can provide you with these files.


text:
Taxes when selling products/services in bitcoin
If I sell products/services in bitcoins, do I need to convert them to dollar (or the local currency) always? Or it's ok to charge in Bitcoin and fill the invoice in BTC (and/or with the conversion to local currency) but keep the payment in BTC?
Or we need to always convert them to local currency and leave the registry of that transaction in some bank of our company etc?
// Sorry if it's duplicate because I think this must be a common question but I'm not finding the answers.

There is no 'correct answer' to this question, it is just a matter of accounting, preference, and perhaps adherence to local regulation/taxation on business practices. If you are concerned about taxes with respect to bitcoin, then you need to talk to an accountant or lawyer that operates in your jurisdiction, not random people on the internet.

I want to know the different alternatives, I can create the company in any country. Besides that I think is a very general question, most of the countries will probably fit in 3 or 4 different scenarios


text:
Software to predict price
First please don't downvote or close, I have read this:
How to predict value of bitcoin?
My question is not the same, I know is imposible to predict this. But I see there are a lot of strategies with chart candles for example, different candle patters etc, so my question is how reliable are those things?
Because if they work, why there isn't any software doing all the operations automatically following the patterns?
And if they don't work, why they exist?
In any case, is there any software out there with "predictions" based on these different strategies or patterns?
will be much easier if some software just tell us "here is X pattern so price will be up/down on next transactions" then we could decide what to do, but at least we don't need to burn our eyes searching for thos patterns.

"how reliable are those things?" / "And if they don't work, why they exist?" software and strategies to predict the price exists but it works very restricted. there is a normal price fluctuation which you sometimes can successfully predict with software and sometimes not. the problem is, that no software can predict "political events". news and headlines like "bad news from china again", "bitcoins were stolen from a south korean exchange. was the bitcoin-network hacked?", "some people are selling all their thousands bitcoins", "scaling problem solved: lightning is now implemented" are influencing the bitcoinprice more essential than things which can be predicted by a software.
"why there isn't any software doing all the operations automatically following the patterns?" even if this would work not everybody would have acces to this software (because if this software would be good, it would rarely be cheap) and not everybody would have the technical knowledge and the volition to use it.

so that means all the strategies and analysis are useless, this is just intuition and lucky...

yes - throwing shells might be the right explanation, but surrounded by a lot of buzz words and marketing bla, including expensive consulting, it becomes suddenly an economical topic with a layer of expert knowledge :-)

@Enrique No. You are assuming that the only use of a strategy is to predict the price. This is incorrect. Another, and very important, use of a strategy is to provide a desired risk/reward tradeoff.


text:
Is there a difference in buying coins with bitcoin or etherum?
So today I decided to throw my hat into the ring and bought some stellar lumen coins.  Since bittrex is not currently accepting new accounts I decided to go with poloniex.
Poloniex doesnt offer lumen in their etherum market so I had to buy it with bitcoin, is there a difference when buying (any currency/token) with bitcoin or etherum?
I am still very new to the Cryptocurrency scene so any information would be greatful

..is there a difference when buying (any currency/token) with bitcoin or etherum?

Not insofar as the outcome is concerned: you'll own whatever crypto you traded for. Whether you traded btc, eth, or your old socks for the stellar lumens, the result is the same: you now own stellar lumens.
Of course, as you've discovered, owning a certain coin may give you more access to people willing to trade for other coins. In this case, there is a difference between eth and btc, in that you cannot trade eth for stellar lumens on Poloniex (and if you wanted to trade your old socks, it would probably be even more difficult to find a counterparty to your trade).

The only difference could be with rounding depending on precision of coins with relation to value to each other. I think most exchanges are governed by law to not steal fractions of pennies but it's always an uncertain point sometimes and so I can not say you aren't in some cases losing fractions of coins.
Also some times on inefficient markets crypto currencies may differ in prices across different currencies. This is an opportunity for arbitrage and typically doesn't exist. This may be caused by sudden changes in the market and usually temporary barriers. Like for example etc goes up rapidly, and LTC had been struggling, there may be a shortage of LTC and so there might be a temporary profit margin through LTC to etc then to btc. But usually the market players will balance things out quickly. It basically the speed of crypto currencies type thing like a ripple in a pond and probably a better topic for forex trading on economics or finance se.
from a math point of view crypto currencies maybe analyzed with linear algebra where your portfolio is a coordinates of vector and basis is the currency to base currency exchange rate. Then redistributing the portfolio amounts to a linear transformation.

Also an example with most economic models for self generating wealth portfolios, a basic assumption is that there is no arbitrage or that markets are perfectly efficient. This is for various reasons, some for the linear algebra to work out and transformations to be invertible, others based on typical real marketss were there is really no arbitrage. But basically these models use more complex levels of arbitrage like with options and Delta neutral hedging. So it is through completely different securities and derivatives, not directly through exchange rates.

Also typically short term arbitrage strategies under perform long term growth. (Short term usually utilizes margin trading/leveraged capital (which can be risky practice and heavily regulated in u.s. after lessons learned from pre great depression era)). Example refer to LTCM from late 90s and Russian bond default.


text:
Plan to decrease the fees
Is there a future plan to make the fees lower ? Will BTC block size increase after the 5G being rolled out in the world ? We could really use a Little bigger block while also developing lighting network . Please don't close this and let's have a conversation.

related: https://bitcoin.stackexchange.com/q/36085/5406, https://bitcoin.stackexchange.com/q/63375/5406

5G bandwidth only addresses one part of the issue with larger blocks. The CPU workload involved in verifying signatures is another bottleneck that is perhaps more pertinent looking forward.


text:
What is needed to generate a bech32 address?
So I wrote a vanity address generator in c# with the NBitcoin lib. When I use the private key used to generate the address and input it in Mycelium it outputs a different address. This does not occur when working with legacy addresses, so I'm guessing I need something more than just a private key in order to generate a segwit address. Was it a redeem script or something? How can I make sure I get the same address in a wallet when I input the privkey?

For a typical single key segwit address (P2WPKH), it is just a key. How are you creating the address? Can you give an example of the key you use, the address Mycelium creates, and the address that you create?

My program outputs: Address: bc1q00dnht0ymgkxp8cxlcg5e7mty0w3w9mnvt49vkn75hc809t7nmrq5g9djj
Private Key: KyaVpeyGfVRgWUtY2t9HYa7rssFkEcWeE53rNudbEAVRdg3EPpQs                  while Mycelium outputs bc1qa59kdryyyh43gyekxswjj3dwsrzs273rs97puv                                        how do I make new lines without submitting the comment?

You can edit your question with the additional information.

Thanks everyone for the explanation. So yes, only a private key can be enough to generate a bech32 address. The issue in my case seems to be that I was using
var addr = key1.ScriptPubKey.GetWitScriptAddress(net);
Instead of
Key key1 = new Key();
var secret = new BitcoinSecret(key1, net);
var addr = secret.GetAddress(ScriptPubKeyType.Segwit);
Now the output addresses of mycelium and my program match.


text:
What am I missing about this "guaranteed" money-making scheme that I didn't hear from anyone but just popped up in my head?
Let's suppose that I have already set up an account at Exchange A and Exchange B, loaded each up with a small buffer of BTC (much less than 1 BTC), and am able to make API requests to buy/sell from these.
Now, I start pulling down sell/buy offers from both exchanges, automatically, every minute, all the time.
My script then picks the most affordable (for me) "sell" offer, regardless of the amount, and takes the offer (buys the coins).
Instantly afterwards, it takes the most profitable (for me) "buy" offer on the other change (sells the coins).
It doesn't do these actions unless it calculates that the "rest sum" is over zero.
Is this not guaranteed to make me money each time this is done? And since it's automated, I only need to set it up once and then lean back and watch guaranteed money stream into my accounts, taking some of them out every now and then?
It sounds way too good to be true, so I must be missing something. Otherwise, I'm sure that this would be done by millions of people, around the clock, and it would quickly stop working. I feel as if this is probably very well known and long since "patched".
But in terms of my understanding of how marketplaces/exchanges work, this seems like it would work. Unless there is some kind of random delay or other uncertainty which makes it impossible?
Of course, those exchanges/marketplaces all require photo id to be scanned and sent to them, so I'm unable to try this out "live", but I still want to know why this wouldn't work.

Hi Poor Coin, I think your question is similar to this one: https://bitcoin.stackexchange.com/q/12670/5406

What you are describing is called Arbitrage and is done by many traders for a variety of different assets, not just cryptocurrencies. This is only guaranteed to make you money so long as there is a price difference between exchanges. The end result of many people doing arbitrage is that the exchanges all settle onto the same price.
The main difficulty in performing arbitrage is the time it takes to move assets from one exchange to another. Ideally you would buy the asset, immediately transfer it to another exchange, and then sell it. However because of physics and protocol limitations, it is not possible to immediately move Bitcoin (and most cryptocurrencies). In the time that it took to move the Bitcoin, the price may have moved to be unfavorably to you, so you may lose money, or at least, not make any.
There are ways around it such as having balances on multiple exchanges so buying on one exchange triggers a sell on another. It's not strictly the same asset, but your balance of that asset does not change. However this requires upfront capital to setup those balances.
There are efforts to make it easier to perform arbitrage by decreasing the transfer time. Layer 2 protocols such as the Lightning Network or Blockstream's Liquid network allow for fast and nearly instant transfers of Bitcoin, so they can be utilized by traders to transfer Bitcoin between exchanges to perform arbitrage.

Bitcoin is not the biggest issue. Usually, it's especially the fiat that is hard to move from one jurisdiction to another.

As Andrew Chow pointed out your idea is already in place. But less for making money, rather for stabilizing prices.
Plus make sure you are not missing a detail, the fees. At least one Bank actually lost money that way back in the days when computer trading was introduced in stock exchanges.


text:
Creating a Locking Script
What will be the script like for a situation like this:
Lets say Alice and Bob are 2 parties. Alice has a password which Bob wants. Alice will only give Bob the password if Bob pays 5BTC to Alice. How can we ensure Alice can consume the money only if she gives the right password to Bob. Else Bob gets the money back.
I was thinking along the lines of Bip199. Please let me know if anything else can be done as BIP199 faces a flaw. I was recommended to use OTP but how to incorporate that in a Locking Script.

First of all we need to answer this: how does Bob know he received the right password? And is it possible to test this in a stateless manner (e.g. if Bob knows the hash of the correct password beforehand, it's easy; if he needs to try to log in to a site with it, this is not possible).

Yes, so can we make a locking script such that only when BOB gets the right password can Alice consume the UTXO

Yes, but how do you define "right" password? Please answer this: when Bob receives a password, how does he verify it's the correct one?

So for example password is for a mail- then all BOB can do is try and see, if not valid then not let Alice consume.  I was suggested to think in terms of One time Password(OTP), any suggestions?

I don't understand what you're asking. What does "password for a mail" mean? How does Bob verify he has the right password?

Lets say Alice has an email account and a password for that account. Bob wants to use that email and for that will have to ask Alice for its password

Ah, that's simply not possible. There has to be a stateless way (not "try to login") for Bob to verify he received the right password if you want some form of atomic swap of money for the password.


text:
Why is trading behaviour so similar across all (mainstream) exchanges?
I don't know much about stocks and investing, but lately I have been keeping a close eye on crypto exchanges and I noticed something I can't explain.
No matter what news is announced good or bad, or what ripple effect whales cause when they buy or sell, all exchanges behave nearly identically in real time. I would have expected at least some delays between exchange spot rates changes. Or perhaps geologically based differences, like Chinese people sleeping affecting exchanges based in China. Instead the trading graphs all move together.
What causes the exchanges to mirror each other so much?

You, as in the collective you that makes up the trading market.
Whenever the price differs enough between two exchanges, a trader who has an account (and funds) on both can profit by selling on the cheaper one, selling on the more expensive one, and then possibly transferring fiat/BTC to compensate. Of course, there are trading/withdrawal/transfer fees involved in all of these, but if the rates differ enough, it will at some point inevitably be worth it. This is called arbitrage.
Sophisticated traders likely keep funds specifically spread across exchanges to take advantage of this, and may have automated trading bots that trigger buy/sell orders whenever arbitrage opportunities arise.
The result of people exploiting arbitrage is that the price starts to balance out across exchanges.


text:
Can a 'free' Bitcoin 'marketing' ad be checked in any way
Total Bitcoin newbie here. I have no bitc, nor a wallet, nor am I sure I want one. I've been intrigued for a while, but security is a big passion of mine...
Today just now youtube pointed me to an interesting lecture by Bill Gates and others. [1] Apparently it was at the SF, CA exploratorium in the 'morning', but that would not fit with the current timezone if it is live. (That part just came up at the end of the Bill Gates section a few minutes ago.)
This video is supposedly by Microsoft Europe - but the author has only this video.
There was a big picture on the screen while Mr. Gates was speaking at the "Village Global" event. It advertised free bitcoin if you send in bitcoin, eg they will send you back 10x what you send in from 0.1 to 20 Bitcoins.
The address per "Microsoft admin" in chat is: 1w1AQvpK4ixo9YQ3KHFYi4BgKHuDqg1hR
Online I looked that up [2] and found this:
Total Sent
0.00000000 BTC

I believe that indicates the ad is definitely a scam.
Did I get it right???
Are there other ways to check for scammers that I may not know?
Thank you so much!
[1] Bill Gates about Microsoft Future, Quantum Power, Bitcoin Evolution - YouTube: https://www.youtube.com/watch?v=oKzuP-Pljpw
[2] Blockchain Explorer - Search the Blockchain | BTC | ETH | BCH: https://www.blockchain.com/btc/address/1w1AQvpK4ixo9YQ3KHFYi4BgKHuDqg1hR

I found one more thing I can read: Secure Trading - Bitcoin Wiki: https://en.bitcoin.it/wiki/Secure_Trading

The Village Global event with Gates seems to have taken place some time ago, perhaps June 2019 or November 2018.  It certainly couldn't be happening live in San Francisco right now, as that city is under a shelter-in-place order due to coronavirus.  There is no way that YouTube account has anything to do with the Microsoft corporation.

Their address currently has had 8 transactions sent to it.  On the one hand, this may unfortunately mean that 8 people have fallen for the scam.  On the other hand, it proves that their chat window, which has "people" posting every few seconds about how they got money from the scheme, is just fake bots.

Yes, this is very obviously a scam.
For some reason, some people seem to lose common sense when Bitcoin (or cryptocurrency in general) is involved. So here is a really quick way to check if an offer sounds legit: Consider the same situation, but using $USD (or your local currency of choice).
For example:
It advertised free dollars if you send in dollars, eg they will send you back 10x what you send in from $500 to $100,000!
Does this sound believable? What about:
It advertised free bitcoin if you send in bitcoin, eg they will send you back 10x what you send in from 0.1 to 20 Bitcoins.
(At the time of writing, 1 BTC is worth approximately $5K USD).

Ask yourself: what business would do well to give away $100K USD worth of anything to random people on the internet?
If it sounds too good to be true it probably is.


text:
Transaction Status: 0 / not confirmed, not in mempool
Trying to send BTC, but fail. The transaction is not in mempool.
What to do with these and how to solve the problem?
I already returned BTC canceled the transaction

Is the software you're using Bitcoin Core?
Then you need to make your software forget your unconfirmed transaction that is not in the mempool, so that you can make it again with a higher fee.
When launching your Bitcoin Core, run it with -zapwallettxes. This'll make your wallet forget the unconfirmed transactions relevant to your wallet. You can learn how to add that on Andrew Chow's blog.
Then the balance in your wallet should become the balance before you made the payment.
I've learned this from here, but the other two methods aren't applicable as you need to change your transaction to increase the fee.


text:
How do I get new unconfirmed transaction from mempool?
I know there is a function that allows me to see all transactions that are in mempool, but is there a way to see every new transaction that enters mempool? Like log to file whenever new unconfirmed transaction enter mempool.

Hi, what are you trying to achieve ?

I'm trying to achieve live list of transactions in mempool. Whenever new transaction enters mempool, I want to receive like push notification to my php that updates transactions in mempool live


text:
Raspberry Pi 3 / Bitcoin Node / No space left on device / Link Database to External Hard drive /
I was following @meeDamian Bitcoin node guide on a Raspberry Pi 3 and could get almost everything to work except that it stores the Blockchain on my USB Harddrive. Its mounted and I have disk space but it puts everything in my root folder.
Where and how can I specify that it gets stored on my USB Drive and can I just the delete the files in folder "blocks"
Thanks for your help
IMG: Node Logfile + Filesystem

You have /dev/sda1 mounted at /mnt/hdd. Maybe you should mount it at ~/.bitcoin instead. ALternatively you could make ~/.bitcoin a symbolic link to a directory under /mnt/hdd. It will be necessary to backup (e.g. tar or rename) the existing contents of ~/.bitcoin before making either change and restore afterwards.

Hi thanks, It now works. I had to copy the .bitcoin folder onto my USB drive first and than delete the original .bitcoin. After that the symbolic link worked fine. Before that the symbolic link always created a subfolder as if its not allowed to change the folder type from regular folder to symbolic link.

You can tell the Raspberry Pi to use your usb drive as your root file system (rootfs). That would fix the problem.
I am also running a full node on RPi 4 and a 1TB SSD, and what I did was to flash Rasbian in the SSD as well as in the SD card. Then, after booting for the first time the RPi with the SD card and with the SSD unplugged, I told the RPi to boot from the SSD like this:

Connect your USB Hard drive to the RPi.
Change the id of the drive to something different so the RPi can differentiate the SD card from the drive. Let's set the id to 0xd34db33f by doing this:

sudo fdisk /dev/sda

Enter the next values to the options that are going to pop up next:
Command (m for help): p
Command (m for help): x
Expert command (m for help): i
Enter the new disk identifier: 0xd34db33f
Expert command (m for help): r
Command (m for help): w

Check that the PARTUUID of the SD card and the drive are different now by using the following command:

sudo blkid

the "/dev/mmcblk0p1" and "/dev/mmcblk0p1" are referencing the SD card, and the "/dev/sda1" and "/dev/sda2" are referencing the drive. So the PARTUUID of the sda1 and sda2 must be the one that we just setup (d34db33f) followed by a dash and the number of the partition.

Modify the cmdline.txt file to tell the RPi to boot from your drive like this:

sudo cp /boot/cmdline.txt /boot/cmdline.txt.bak
sudo nano /boot/cmdline.txt

Once in the file, find the variable root=PARTUUID=#######-02 and change it to the one that we just set. The line should look like this:
 console=serial0,115200 console=tty1 root=PARTUUID=d34db33f-02 rootfstype=ext4....
Exit by pressing CTRL + X, Then "Y" to save changes, and then ENTER to confirm.

Reboot the RPi:

sudo reboot

Make sure the RPi is booting from the drive:

findmnt -n -o SOURCE /

if it shows dev/sda2 then your good. If not, just recover your cmdline.txt file by using the backup we saved, and start over.

Finally, we will tell the RPi to mount automatically the drive and use it as the file system by modifying the fstab file:

sudo nano /etc/fstab

Once in the file editor, modify the second PARTUUID to the id we setup earlier. The file should look like this after modification:

proc            /proc           proc    defaults          0       0
PARTUUID=########-01  /boot           vfat    defaults          0       2
PARTUUID=d34db33f-02  /               ext4    defaults,noatime  0       1

CTRL + X, Y, and ENTER to save changes.

Reboot the RPi again, and That's it!

I had to resize my SSD after this, but I am not sure if you will have to. If you do, or if you need more details, this is the tutorial I followed:
https://jamesachambers.com/raspberry-pi-4-usb-boot-config-guide-for-ssd-flash-drives/
All credits for the guy of the tutorial.


text:
Bitcoin core has been stuck syncing to the network
This keeps repeating in the log file:
2020-04-16T23:59:53Z ERROR: AcceptBlockHeader: block 0000000000000000000fb8b3828b04c17205ffcdedddc8be1d400d132d336460 is marked invalid

The only answer I could come up with myself was to "unprune" the blockchain to force it to redownload. I then reactivated the "prune" feature and restarted the blockchain download. I think the block was corrupted - we'll see.


text:
How does a bitcoin wallet incorporate UTXOs for payment?
How does the wallet choose the UTXOs it will use?Retrieve one by one until the number meets the number to be paid?

Early versions of Bitcoin used a simple knapsack solver to optimize for the least number of inputs possible given the available UTXOs in the wallet.
Modern versions have much more complicated selection logic, additionally attempting to not combine change from many unrelated transactions for the sake of privacy.
Other wallets have different selection criteria with differing payoffs. Historically many simple wallets attempted to just add the largest possible outputs until they satisfied the amount, however this optimized for low fees and transaction sizes at the expense of maximizing the amount of small dust UTXOs produced. These all have different trade offs, but the simple ones tend to be horrifically inefficient or lacking in even basic privacy.

Thank you. Your answer is very helpful to me


text:
JSON with price AND daily change?
May be someone could point me towards a public API with Bitcoin price AND 24h change? Like $7'602 +2.3%?
All APIs I've found (like coindesk's) only contain price, not change :(

You can calculate the change yourself. The coinbase API (not a recommendation, just an example) has and endpoint for 24-hour stats (https://api.pro.coinbase.com/products/BTC-USD/stats)
{
open: "7674.24000000",
high: "7810.99000000",
low: "7490.00000000",
volume: "14477.94427039",
last: "7694.56000000",
volume_30day: "479763.13996598"
}

Last price minus the open price equals the 24 hour gain. Divide the gain by the open to get the decimal percentage.

Oh, thanks, didn't know about this url.

This url is probably even better: https://api.coindesk.com/v1/bpi/historical/close.json?for=yesterday


text:
Payout query in Mining
If a miner account is in active , possible to get payout in halving automatically? Bcoz my mining account is active, but cannot access. Possible to get my profit in halving ? My wallet is fused with mining. Please give details. Thanking you.

What do you mean by 'miner account is active', and 'wallet is fused with mining'? Do you own and run ASIC hardware? Based on what you've written, it sounds like you may be victim of a common 'mining scam'.

Hi sir, thanku for kind answer. I don't know ASIC Hardware. Mining machine is also not my own.i done a small investment near 75$ in my wallet. To my fb friend. Now he says 20000$ in my account.

Ah, I'm sorry to say it sounds like you are the victim of a scam. That isn't how mining works at all. Did the 'fb friend' ever ask to have access to your wallet login, or tell you to import a watch-only bitcoin address to the wallet? For examples of other users falling for this scam, see: https://bitcoin.stackexchange.com/questions/74362/how-can-i-get-a-private-key-for-this-address/74384#74384

Does this answer your question? How can I get a private key for this address


text:
Is it "safe" to mine with your cpu on a laptop for a long time?
I am currently trying to use the CPUMINER program on a Chromebook (using Linux) with its CPU for educational purposes. The Chromebook has four cpu cores.
I would like to know if it is safe for the computer to be mining Bitcoins for a long time (ex: a whole day) using all four cores. Would the CPU be damaged? Should I only use some of the four?

Unless it overheats there's no problem with nonstop mining. I'd suggest installing something like CoreTemp to view internal temperatures. You should adjust its number of cores used until all of the temperatures can be considered low enough. How low? 70°C should be fine. 100°C isn't very nice I think. There's no exact limit, but you can search online.
Overclocking? I can't comment if mining nonstop on an overclocked CPU is healthy for your computer. You might need to reduce the temperature by even more.


text:
How to find my transaction from root of Merkle Tree
How could I verify my transaction from the root of Merkle Tree.

You can't with just the root of the tree. You need both the root and the path to have a proof.

@vrnvav97 the tx that you want verify is on mainnet or testnet? If yes could you post the tx id so we can show a complete working example?

@darosior ok so i need a path also to verify my tx.

@aqquadro its nowhere, i was clearing my doubts. But can u show any other working example?

First of all, you need to use gettxoutproof
$ bitcoin-cli help gettxoutproof
gettxoutproof ["txid",...] ( "blockhash" )

Returns a hex-encoded proof that "txid" was included in a block.
...

you receive data including your transaction id with another txids (privacy purpose).
then you need create empty merkle tree and place txids inside leafs, check this link to know how you can do it. You need to work even with little and big endian
After that you have to concat leafs and do SHA256 twice until the merkle root.


text:
How would you store a very large amount of crypto currency
I have Litecoin, Bitcoin, Ethereum and NEM. In recent times, I've become a very lucky boy indeed!
I usually download and install the "official" wallets that download the entire blockchain but this is getting impossible now, especially for Ethereum Mist wallet which just plays up all the time causing me to delete chain data and force a so-called "fast sync".
If you were in my position, having this very large amount of coins, how would you go about storing/protecting them? For each of the above which wallets would you use and how would you split things so as to not put everything in one basket?
Many thanks

I am very happy with my Trezor, less so with my Ledger (because I find the interface annoyingly clunky).  The Trezor is extremely easy (and, I believe, extremely safe as long as you don't leave your PIN number or recovery phrase lying around).  It works fine for Litecoin and Bitcoin, and a bit more annoyingly for Ethereum (where it outsources the wallet to another provider).  I don't believe it will hold NEM.  I'm not sure if the Ledger will hold NEM, but it should be easy to look up on their website.  I hold only Ripple in my Ledger, because (among the coins I hold), this is the only one the Trezor won't handle.

Your Bitcoin is safe on the blockchain so long as your private keys are safe. I imagine that the same is true for the other currency that you hold. Using the official wallet is a good answer provided there are no security bugs in the installed software version AND provided your computer is secure. This is where Trezor and Ledger come in where theoretically your private keys are never exposed.
Personally, I am comfortable that I can setup a secure enough computer. As an added security measure a computer can be kept completely offline except when necessary to transfer to a hot wallet or, you can use a cold wallet that allows offline signing. I used to recommend Armory for Bitcoin but have not checked up on it recently.


text:
Unconfirmed transaction for 6 days now. Please help
I have an unconfirmed transaction that has been sitting there for 6 days now. Any assistance would be greatly appreciated.  Thanks.
https://blockchain.info/tx/98d4fee15e8eab8b78237a7b2eda8c62aa7c43a2e157b09ed4ee5b944092da6d
Cheers
Hoowee

Hi there, the difference here is that I withdrew my coins through an exchange.  Their support is terrible and hence I was hoping I can get some assistance here.

You can probably use CPFP to add a massive fee and get it mined.  Essentially, you spend the unconfirmed transaction in another transaction (to yourself for example) and just use a really big fee.  Eventually a miner will want to mine both to get the fees.

It seems the fee used is 61sat/B, but now the regular fee is 301sat/B and priority is 317sat/B. So you have to wait until a miner takes your transaction and confirm. I have faced this issue many times and waited for days and weeks to get a single confirmation.
If you are in a hurry then try any tx-accelerator like viaBTC or pushtx.
Also, you can check the mempool to see how long it may take to confirm your transaction.
Mempool state by fee level

Blockchain.info
BTC.com

Manu, can I use tx-accelerators if the transfer was done via an exchange not my own wallet?

You only need a transaction ID. But use free accelerators, I would recommend you to wait for few more days. Be patient!!, it will be confirmed soon :)

Lol I've been waiting for 6 days. But ok I will take your advice and wait a couple more days.  Thank you Manu.


text:
How do I Transfer Bitcoins If I have a watch-only account with the Private Key
How do I transfer bitcoins over from a watch only electrum account if I have the private key and its address?

Does this answer your question? Can't spend Watch-Only coins, have I been scammed?

Transfer control to a new Electrum wallet
If you have the private key you can, in principle, either import the key into a new wallet or sweep it into a new wallet.
Electrum supports sweeping and doesn't encourage importing.
Importing doesn't involve a transaction or transaction fees but is more vulnerable to subsequent loss. The recovery-words also known as recovery-phrase or seed-phrase, cannot be used to recover control over money associated with an imported key. You'd need to make regular backups and test recovery from backup.
Sweeping involves a transaction but is regarded as safer.

Transferring Bitcoins
Note that you are not really moving bitcoins. The record of who controls what money is recorded in the public Blockchain which every full-node wallet has a copy of.
A watch-only wallet lets you observe transactions relating to money controlled by other people (or by other wallets). So there's no sense in which your bitcoins are in a watch-only wallet. You could as well say that everyones bitcoins are in every full-node wallet.

Electrum account
Electrum is a wallet, not an account. Your money is not stored by, managed by or controlled by Electrum.org. You control your money using software you install on your own computer.

Watch-only
Watch-only wallets are a useful feature if you keep your private-keys in cold-storage - such as in a hardware wallet.
They are also a favourite method by which scammers trick people out of money.

+1 but I think the last part is the only relevant part.

I have one address in my wallet and one private key in a WIF format. Do I need multiple keys to have my regular spending wallet?, cause I only have one address.

You only need the key that corresponds to that address.

My Private Key is in a WIF Format, when I put it in it doesn't want to go with my address. Its 51 characters long. Is there a converter from WIF to a regular private key?

See the last sentence of my answer and the comments by MCCCS.

Based on some of your comments:

My Private Key is in a WIF Format, when I put it in it doesn't want to
  go with my address.

It sounds as though your wallet could be importing the wrong address type (ie legacy vs p2sh-segwit vs bech32).
With Electrum you can import your WIF and specify the address type.
Electrum can import private keys using the console and the importprivkey() command.
If you want to import p2sh segwit (address starts with a 3):
importprivkey('p2wpkh-p2sh:L5eaxGKPZZMnanjxDzBd82VaxnHAE6MmBojiEFAVTM9mWZEhMMqG')
Import as native(bech32) segwit (address starts with bc1):
importprivkey('p2wpkh:L5eaxGKPZZMnanjxDzBd82VaxnHAE6MmBojiEFAVTM9mWZEhMMqG')
Import as legacy p2pkh (address starts with a 1):
importprivkey('p2pkh:L5eaxGKPZZMnanjxDzBd82VaxnHAE6MmBojiEFAVTM9mWZEhMMqG')


text:
How can I seamlessly extend disk for bitcoin-core full node?
I'm running a bitcoin-core full node and serve customers wallet service (e.g. creating a wallet, sending tx). I set the chain data disk size to 400GB when first setting the node up and the disk is almost full now.
I'd like to increase the disk size without halting or stopping wallet service. Can I get advice or tips for doing it?
I'm using a cloud service for running the node and it's highly likely to stop bitcoind process if I increase disk size on the cloud console. (I don't think bitcoind can write to disk while the cloud service working on the disk)
Any help would be appreciated. Thanks!

This sounds like a question for your hosting provider; you should ask if they support online disk resizing. It has nothing to do with Bitcoin Core.

I understand what you mean. My question was more about finding workaround while disk is not read/write-able. I think I'm gonna spin up another instance and export wallet to the new node.

This is a question for general system administration, and is not Bitcoin-specific.


text:
Unspent bitcoin transaction
So about two weeks ago i sent bitcoin to a friend, and it was confirmed but in the summary it was listed unspent, he claimed not to have received. I was really confused since then, now this morning i check again and i noticed the status has changed to ‘spent’. Now i am more confused. Does that mean he has finally recieved it? *i tried contacting blockchain support but i didnt get a response

You need to look to your chat history and see if the address coins were sent to is the address your friend gave to you. If so, they are trying to make you send again to scam you.

Does this answer your question? Bitcoin sent, recipient claiming not received


text:
Recover the bitcoin using my bank account transaction details
I lost my wallet and i purchased using my internet banking and Is there possible way to recover my bitcoin using my bank account transaction.

Bitcoin has no relation to the banking network - if you're lucky, you might have purchased BTC on a custodial platform (one which keeps the private keys for you) and your bank account's transaction history can help you identify which platform you had sent funds to. You should then be able to contact their support to regain access to your account.
If you moved the BTC to a wallet where you maintain the private keys and have lost access to that, you are out of luck unless you made a backup.
If someone asked you to transfer them fiat through the banking system, promising Bitcoin or high investment returns in exchange, you may have been scammed.

i have purchased very long back at that time i spent 1 coin = 1 Indian rupees but due to the job movement to different location i forgot my wallet

Bitcoin price has never been 1 BTC = 1 INR at any point where India actually had exchanges you could transfer to - you've likely been scammed if that's actually what happened


text:
How to search for an address in last block?
I want to check in bitcoin-core and see if there is any of my watching addresses in last block.
So my question is how can I know a specific address is included in last block or not?
I can search with getblock <hash> 2 but it returns only addresses in vout and I need the ones are in vin too.

Are you using the Bitcoin Core wallet as your watching only wallet?

If you have txindex enabled and are using a Linux, debian-based machine, install jq: sudo apt install jq
and save this script somewhere as "any-name.sh":
#!/bin/bash

BLOCK_HASH=$(bitcoin-cli getbestblockhash)
BLOCK_TEMPFILE=bestblock.json
VIN_TXNS_TEMPFILE=vin_txns.temp
VIN_N_TEMPFILE=vin_n.temp

# Check if all temp files and addresses file exists, and delete them if they do before recreating them.
if [ -f "${VIN_TXNS_TEMPFILE}" ]; then
  rm ${VIN_TXNS_TEMPFILE}
fi

if [ -f "${VIN_N_TEMPFILE}" ]; then
  rm ${VIN_N_TEMPFILE}
fi

if [ -f "${BLOCK_TEMPFILE}" ]; then
  rm ${BLOCK_TEMPFILE}
fi

# Get the block information in JSON format
bitcoin-cli getblock ${BLOCK_HASH} 2 > ${BLOCK_TEMPFILE}

# Get the block height for use in address file name
BLOCK_HEIGHT=$(jq ".height" ${BLOCK_TEMPFILE})

# Check if the address file exists. If so, we do not need to run the script again.
ADDRESSES_FILE="Block_${BLOCK_HEIGHT}_Addresses.txt"
if [ -f "${ADDRESSES_FILE}" ]; then
  rm ${BLOCK_TEMPFILE}
  exit 0
fi
touch ${ADDRESSES_FILE}
touch ${VIN_TXNS_TEMPFILE}
touch ${VIN_N_TEMPFILE}
touch ${BLOCK_TEMPFILE}

# Get the block transaction ID's, excluding the first transaction (coinbase)
jq ".tx[].vin[].txid" ${BLOCK_TEMPFILE} > ${VIN_TXNS_TEMPFILE}
tail -n +2 "${VIN_TXNS_TEMPFILE}" > "${VIN_TXNS_TEMPFILE}.temp" && mv "${VIN_TXNS_TEMPFILE}.temp" "${VIN_TXNS_TEMPFILE}"
sed -i 's/"//g' ${VIN_TXNS_TEMPFILE}

# Get the block transaction n's, excluding the first transaction (coinbase)
jq ".tx[].vin[].vout" ${BLOCK_TEMPFILE} > ${VIN_N_TEMPFILE}
tail -n +2 "${VIN_N_TEMPFILE}" > "${VIN_N_TEMPFILE}.temp" && mv "${VIN_N_TEMPFILE}.temp" "${VIN_N_TEMPFILE}"
readarray -t n_vals < ${VIN_N_TEMPFILE}

# Delete the vin n tempfile
rm ${VIN_N_TEMPFILE}

# Get the block txout addresses
jq ".tx[].vout[].scriptPubKey.addresses | .[]?" ${BLOCK_TEMPFILE} > ${ADDRESSES_FILE}

# Delete the block tempfile
rm ${BLOCK_TEMPFILE}

# Get each transaction's vout addresses
i=0
while read line; do
  val=${n_vals[${i}]}
  echo $(bitcoin-cli getrawtransaction "$line" true) | jq ".vout[${val}].scriptPubKey.addresses | .[]?" >> ${ADDRESSES_FILE}
  let "i=i+1"
done < ${VIN_TXNS_TEMPFILE}

# Delete transaction IDs tempfile
rm ${VIN_TXNS_TEMPFILE}

sed -i 's/"//g' ${ADDRESSES_FILE}
awk '!a[$0]++' ${ADDRESSES_FILE} > "${ADDRESSES_FILE}.temp" && mv "${ADDRESSES_FILE}.temp" "${ADDRESSES_FILE}"

Make the script executable: chmod +x any-name.sh
then you can run the script with ./any-name.sh . Keep in mind that this script takes several minutes to complete. I run a node on a raspberry pi 3b, and this script takes ~4 minutes to complete.
Script explanation:
The vins from the most recent block contain a transaction ID as well as the vout index from that transaction that's being spent. We can use the command bitcoin-cli getrawtransaction <transactionhash> true to print JSON information from the transaction as long as we have txindex enabled. This information includes, most importantly for us, the address that is being spent (and "null" if the address being spent is not a standard address type). So for each vin in the block, we find the relevant transaction, and get the address at the specified vout index.

I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.
Here is the github link:
https://github.com/ORP967/Bitcoin_Core_RPC_par_address
Let me know what you think or if you have any improvements you might have.


text:
Mining pools repayment in a coinbase tx
Is it possible to add more outputs than one to the coinbase transaction? And if it is, can miners use them to repay users for renting hash to the pool?
I think in this case they know who to pay and this could prevent blocks from being found almost instantly and empty.

Yes it's possible to add more outputs in coinbase transaction.
https://bitcoin.stackexchange.com/a/103612

Welcome to Bitcoin! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Or flag the question as a duplicate, once you have enough reputation.


text:
How can be proven that a signature is valid with it's public key
If someone wants to make a transaction, they need to sign the transaction data with their private key. For example Sign(transactionData, privateKey) creates the signature. What is exactly this Sign function and what happens inside this function? And how can be verified that a signature is valid with a public key? For example Verify(signature, publicKey), what happens inside this function?

You should ask this on https://crypto.stackexchange.com.

When signing the transaction, a sha256 hash of the transaction data is taken, and a ECDSA signature of this hash is generated using the private key.
When validating the signature, we first generate the sha256 hash of the transaction data the same way, then we validate the signature using the ECDSA algorithm by passing in the signature, the public key, and the transaction hash.


text:
Why does the txn_count field exists in a block?
I was wondering why the txn_count field in a block exists. The count of transactions could be determined by parsing the txns field in tx format, right? Same for 'tx_in count' and 'tx_out count' in a transaction. The tx_in and tx_out can be just parsed and the count can be determined based on that, right? Is this true? And if it's true, why do the txn_count, tx_in count and tx_out count fields exist?

I was wondering why the txn_count field in a block exists. The count of transactions could be determined by parsing the txns field in tx format, right?

Yes, it could, but it isn't. Ultimately serialization formats are a convention, and Satoshi picked one when he created the initial software which has persisted in the protocol. It could be changed, but why bother?

The tx_in and tx_out can be just parsed and the count can be determined based on that, right?

That's not quite true - you need some way of conveying at least where the inputs end and the outputs begin (which in the existing protocol is served by the txin count). When deserializing a list of transactions (like in a block message), you also need to know where each transaction ends and the next one begins (which in the existing protocol is served by the txout count).

Is it also used so you can reserve a certain amount of memory before parsing the transactions you think?

You could, but that actually isn't done (at least in Bitcoin Core). The problem is what if you receive a block that claims to contain a billion transactions? Instead, it will allocate buffer space in increments of at most a few MB, so an attacker would need to actually send megabytes of data to get you to allocate that much.

Thanks for the clear explanation!

Serialization is certainly not my area of expertise, but I'd guess: one challenge with serialized data is to know how much data to read. Explicitly providing the count of objects (and their length) you're about to parse is likely simpler and safer than having multiple levels of terminators in a hierarchical data structure and may actually require less data overall.

Thanks! Is it also used so you can reserve a certain amount of memory before parsing the transactions you think?


text:
How is the balance of a Bitcoin address quickly calculated?
For what I understand, the balance of a Bitcoin address is the total sum of UTXOs of that address in the entire blockchain.
The current size of the blockchain is around 350GB. How is the total sum of UTXOs for a specific address calculated quickly? I imagine looping over every transaction in the entire blockchain and comparing the UTXO with the given address takes a lot of time. Does the calculation of the balance of a Bitcoin address work like that? And do miners repeat this process for every transaction to check if the available balance of that address enough?

At the protocol level, Bitcoin has no concept of "balances" or "addresses", and their common interpretation isn't relevant during verification.
Every transaction spends "coins" and reforges them into new "coins" (called UTXOs). Every UTXO has a value (in number of satoshis) and an locking script. UTXOs are always spent in their entirety. If you only have a 1 BTC UTXO and want to send 0.1 BTC to someone, your wallet will under the hood create a transaction that has one input (your 1 BTC UTXO) and two outputs (one 0.1 BTC UTXO with an locking script created from the receiver's address, and one 0.9 BTC UTXO with an locking script you can unlock yourself). From a protocol perspective, there is nothing special about this UTXO that goes back to yourself (called a "change output") - it's just another UTXO.
Transaction explicitly identify which previous coins they're spending, based on the txid that created them, not based on the locking script. So it doesn't matter what the sum of the values of UTXOs with a particular locking script is; coins are spent when they're mentioned as an input in another transaction. That means the only thing that matters is:

Do the input UTXOs exist?
Is the sum of the input UTXO values (whether they have the same locking script or not) not less than the sum of the values of the newly created UTXOs.

Now, sites like blockexplorers do show balances. They're a higher-level - and misleading - abstraction. They do this by simply maintaining an index per address of all transactions that have the script corresponding to that address as locking script, and all transactions that spends such outputs.
Wallets for privacy reasons construct new addresses all the time (typically one per incoming transaction), as there is no cost to creating more addresses. Looking at it from a per-address perspective is therefore misleading, and has caused people to lose money (when they think "X is my address, I only need its private key" - you need the keys to all addresses, even change addresses, your wallet uses).

Thanks, very clear explanation! The only thing I still don't get is how do miners check (quick) if an input UTXO exists?

All full nodes maintain a database with all unspent outputs.

Stumbled a bit on the "not less". Maybe "equal or more" would read a bit smoother.

@PieterWuille - does a full node maintains database of all unspent outputs of all addresses in the block or just my node's wallet address?

@Sripaul A full node validates all transactions fully; that is not possible without actually having access to the outputs being spent by those transactions. As a result, it needs some way of getting that information. Common full node implementations due that with a database of UTXOs, or a database of all transactions ever. Just your own wallet data isn't sufficient to validate transactions.


text:
Is there any way to trade without photo id before Bisq introduces its API?
I know that the Bisq developers are "working on it", but v1.5 was just released today and still not a sign of it. I'm growing ever more impatient.
While I like Bisq, and understand that it takes time to develop sensitive things like this, it would still feel better if there were at least one alternative. But there isn't, as far as I know. I don't mean "fake-decentralized" websites which are fully centralized. I mean decentralized applications for trading Bitcoin, supporting automation.
I'd like to try (with a very small amount of BTC) to trade it against other crypto currencies in an automated manner. Sadly, all exchanges require photo id BS, so they cannot be used.
What happens if Bisq is shut down? I depend entirely on it; there's literally no other way for me to get Bitcoin. If it goes down, I go down.
And no, the fact that it's a decentralized application doesn't stop somebody from nuking their official, centralized, clearnet website, or the GitHub repository. Obviously, they wouldn't rely on these if they had a practical choice, but nobody uses these "alternative Internet" projects.
It's weird to me that Bisq appears to be one-of-a-kind rather than one out of many different decentralized exchanges. How can that be?


text:
What is the maximum channel capacity allowed on the Bitcoin testnet?
Using Electrum desktop wallet connected to the testnet, when trying to open a channel  with the amount exceeding 0.16777215 BTC I get the following:

Could not open channel. Exception('Requested channel capacity is over protocol allowed maximum')

Is 0.16777215 BTC hardcoded in Electrum or is it determined by the testnet itself?
I noticed that on the mainnet the maximum capacity is siginificatly higher as some exchanges allow LN withdrawals of 0.5 BTC.

Is 0.16777215 BTC hardcoded in Electrum or is it determined by the testnet itself?

There's no such hard coded value in Electrum. The limit is imposed by the Lightning protocol:

for channels with chain_hash identifying the Bitcoin blockchain, if the four most significant bytes of amount_msat are not 0:
MUST fail the channel.


text:
Why didn't this atomic swap go through?
I attempted swapping 0.01 of testnet BTC for stagenet XMR and BTC that
was meant to be swapped for XMR was refunded to me. When I executed
swap buy-xmr --testnet --change-address tb1qf9p5mrl2mf4ulae257ewj2rns6hsu2y4p8j0q2 --receive-address 78Qb9HKw6CQGfLdnWQtBNXUkyeGvz3XeMHc59hs8CGe8TrMfUnsYqsLdHGng8Xs896TuCUxoKPwjP4DZ1Vebfm7WCMALwKF --seller /dnsaddr/unstoppableswap.net/p2p/12D3KooWLHbHtkK53WoBA82Yht3PCCx6KXYxoJ6QqgXg1rSNtWhR
I got the following output from swap:
Connected to Alice at /dnsaddr/unstoppableswap.net/p2p/12D3KooWLHbHtkK53WoBA82Yht3PCCx6KXYxoJ6QqgXg1rSNtWhR
Received quote price=0.00605939 BTC minimum_amount=0.00010000 BTC maximum_amount=0.10000000 BTC
Waiting for Bitcoin deposit deposit_address=tb1q369qkpa6pxmg79qp6zatfnexka723z8hezv2ne max_giveable=0.00000000 BTC minimum_amount=0.00010000 BTC maximum_amount=0.10000000 BTC
Received Bitcoin new_balance=0.01000000 BTC max_giveable=0.00999875 BTC
Starting new swap amount=0.00999875 BTC fees=0.00000125 BTC swap_id=93b2db62-7032-4bd6-812a-7288db37e737
Estimated fee of 138.23298630 is smaller than the min relay fee, defaulting to min relay fee 1000
Estimated fee of 150.34098510 is smaller than the min relay fee, defaulting to min relay fee 1000
Published Bitcoin transaction txid=6ae82a171e25d85a317516078d6c4a25d34f7f4eee910bf247d7924400ba7a63 kind=lock
Waiting for Alice to lock Monero
Alice locked Monero txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5
Waiting for Monero transaction finality txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 target_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=1 needed_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=2 needed_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=3 needed_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=5 needed_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=6 needed_confirmations=10
Received new confirmation for Monero lock tx txid=4b01a1e785ffb09090b336b76979f404f1f97a3995b7aeb6e356491ac84899c5 seen_confirmations=7 needed_confirmations=10
Published Bitcoin transaction txid=94f18b0d37641e20ee57a679890437fbeeb6ee8dd9d66e97fdbf91ddb8c4d552 kind=refund
Waiting for Bitcoin transaction finality txid=94f18b0d37641e20ee57a679890437fbeeb6ee8dd9d66e97fdbf91ddb8c4d552 required_confirmation=2
Waiting for Bitcoin transaction finality txid=94f18b0d37641e20ee57a679890437fbeeb6ee8dd9d66e97fdbf91ddb8c4d552 seen_confirmations=1 needed_confirmations=2
Waiting for Bitcoin transaction finality txid=94f18b0d37641e20ee57a679890437fbeeb6ee8dd9d66e97fdbf91ddb8c4d552 seen_confirmations=3 needed_confirmations=2

The amount of BTC that
I've sent in both cases was within the accepted by the seller range, i.e.
0.00010000 - 0.10000000 BTC and the seller seemed to be online all the time.
history subcommand clearly shows that the swaps have not succeded:
+--------------------------------------+-------------------+
| SWAP ID                              | STATE             |
+==========================================================+
| 93b2db62-7032-4bd6-812a-7288db37e737 | Done: BtcRefunded |
|--------------------------------------+-------------------|
| ba633b45-5b09-4dcd-bc3a-71986d003893 | Done: BtcRefunded |
+--------------------------------------+-------------------+

This is the transaction that initiated the swap. I've no clue why my swaps have not succeded.
Am I missing anything?


text:
Does electrum wallet "sit on top of" bitcoin-cli?
Does electrum wallet "sit on top of" bitcoin-cli? Or is it an abstraction of some other software?
I have already learned that Electrum's gui is not
a wrap around their cli and there are some things that you can do in its gui, like bumping fees, that you cannot from their cli.
Does their core library utilize bitcoin-cli under the hood?


text:
Does `autoclean-once` without vacuuming lightningd.sqlite3 slow down the future growth of size lightningd.sqlite3?
I ran
lightning-cli autoclean-once failedforwards 600
lightning-cli autoclean-once succeededforwards 600
lightning-cli autoclean-once failedpays 600
lightning-cli autoclean-once succeededpays 600
lightning-cli autoclean-once expiredinvoices 600
lightning-cli autoclean-once paidinvoices 600

on my Core Lignitning node to remove hundreds of items that are older than 10 minutes. Despite than the size of lightningd.sqlite3 remained the same. From what I gathered this is how sqlite3 works:

When content is deleted from an SQLite database, the content is not usually erased but rather the space used to hold the content is marked as being available for reuse.

1. Does autoclean-once without vacuuming slow down the future growth of the database (due to reuse)?
2. Would it be safe to use vacuum after shutting the node down?
3. What is the forensic aspect of vacuuming.

No, SQLite doesn't automatically reuse freed space after deleting rows. Instead, it marks the space as free but doesn't immediately reclaim it. This can lead to fragmentation over time, where the database file becomes larger than necessary. The VACUUM command is used to reclaim this unused space. It rebuilds the entire database, reorganizing the data and removing the free space. This can significantly reduce the database file size and improve performance. That being said sqlite3 implements an auto-vacuum, that will reclaim space, just the timing is not user-controlled.

Vacuuming is safe, as it compacts the data as is, and doesn't perform any user-visible changes (the data is reorganized, but it doesn't change as such). Yes.

None that I am aware of. Potentially you could recover some deleted rows I guess, however CLN is careful to never delete important information, until we're absolutely certain it won't be needed anymore. For longer term archival you can use a backup plugin which replicates changes to a plugin.

Many thanks for your response. sqlite3 implements an auto-vacuum I would like to know how frequently might one expect auto-vacuum to be executed on a CLN node that is run 24/7.

Good question, as far as I understand the sqlite3 code it tracks how dirty and fragmented the blocks are and will trigger an auto-vacuum when the effective data dips below a percentage. So the auto-vacuum interval depends on the DB use, and therefore on both the nodes activity as well as the operator behavior. As such there is no answer that works for everybody.


text:
Is the balance of the channel safe if I set unilateraltimeout to 0 and go offline when mutually closing the channel?
I run a core lighning node with a couple of private, single-founded channels.
Because of my circumstances my node is usually online for a couple of hours every three days or so.
I want to mutually close one of my lightning channels, and
am thinking of running:
lightning-cli -k "id=${scid}" unilateraltimeout=10800 feerange=[2000, normal]

where scid is the short_channel_id of the channel to be closed. I
set unilateraltimeout to 10800 seconds, i.e. 3 hours.
I consider also setting the parameter to 0 or skipping it (it then defaults to 48 hours)
Is it safe to set unilateraltimeout to 0 and go offline when mutually closing the channel?


text:
Why this alternative method to mining will fail?
From what I understand, we need mining to validate the block, we need the proof of work to limit the number of miners can add a block, and we need the block interval to give time to the new block to spread across the chain.
And usually it's said mining is like a lottery, and hence the alternative idea:
Instead of proof of work, we choose randomly some of the miners registered on the network, only that miner can validate and add the next block, and it has let's say 2min to do it, if not another miner is chosen randomly.
In this way we don't need to waste a lot of energy to solve the hash problem.
What is the problem with this solution?
(I know it has a problem, but I can't see it and I think knowing this will help me to understand better why we need the proof of work)

Instead of proof of work, we choose randomly some of the miners registered on the network... Who is "we"?

Instead of proof of work, we choose randomly some of the miners registered on the network... Who controls the registration process?

@NateEldredge, good point, but maybe there is a way to solve that, like using a random function with seed extracted from previous block hash, it's random and neutral and everybody can check if the node trying to add the block is allowed to do it by the random value. "We" is the software, if we all are using the same software (and that must be case always) then everybody can validate the random node, and nobody can control that random number. I'm still mising something?

@PieterWuille is not that already known? I don't know the details about it, but I guess the Bitcoin network already knows where are the other nodes right? I mean if not what happens when I send a transaction from my wallet? It must send that to some node, and how does it know that node exist and where it is? aren't they registered somewhere?

@Enrique: there is no complete, shared list of all nodes active on the P2P network at any one instant. Each node just has itself a set of peers it is working with, and this set will change as nodes join, disappear, or mis-behave and get dropped.

Peter wrote DNS Seeder, a crawler which builds & maintains a list of nodes available for connection (so new nodes can quickly find peers), but AFAIK this list is not guaranteed complete in any sense. The P2P network is organic, dynamic and ever-changing. Trying to find all active nodes reminds me of the Hamiltonian Path Problem.

Of course, not all nodes are miners, which somewhat simplifies any potential implementation of your idea. Suppose a complete, dynamic registry of miners could be maintained, and a truly random, consensual system to choose the "next" annointed miner from this registry is implemented. Then why hash at all? just grant the subsidy to that miner. Perhaps so the miner can prove it is still active (and not be removed from the list) and allow for the inter-block time interval to ellapse ?

@Enrique The problem the mining process is solving is exactly guaranteeing that every node (evetually) agrees on the same state. Your solution assuming a consistent state across nodes already exists (in order to be able to pick one from them at random and have everyone agree about who that is). If it were possible to do that, you wouldn't need a blockchain anymore. No, there is no consistent list of nodes, or miners, in the network. You either need a central registry of all nodes (in which case, you could also let this registry just decide which chain wins), or you could use a blockchain..

@PieterWuille I can't see why, I mean we have already a lot of information that everybody must validate, every miner could just add itself to the blockchain, as a miner, the same way we can check the balance for some address, or like states in smart contracts. There is a registry for miners but is in the blockchain not a central registry. We just change the way we choose who can add the block, instead of a complex calculation, is just pure random (sorry if I'm asking something stupid but I really can't see it)

There is a big difference between information we validate and information everyone agrees on. In Bitcoin, there is no guarantee at any point in time that two nodes have the same state. They may not agree on what the currenr best block is (forks). The only thing we have is an economic incentive that results in nodes growing more likely to agree on the past. No, there is absolutely no registry for miners. You can start mining without asking anyone for permission even, without any identifier. Just start creating blocks and broadcast them.

Both things will be solved implementing the list of miners then, will be just like a state in smart contracts.

This is actually a good idea in principle. The reason why this method will not work in the Bitcoin setting is that it is not Sybil-resilient. In particular, Bitcoin solves the problem in the anonymous setting, meaning that the parties participating do not know who else is on the network and more specifically do not know how many others are on the network.
If we imagined this idea implemented naively in Bitcoin, one could create a construction as follows: First, somehow maintain a list of all the nodes in the network (while from a network engineering point of view this is difficult, I will argue that, even if it were easy, the method remains insufficient), perhaps by IP. When nodes exit and enter the network, update that list. Every desired interval of time, say every 10 minutes, elect one peer from the network as "leader" in a globally consistent manner such that every node agrees on who is leader. The leader is allowed to produce a block within 10 minutes; regardless of whether they manage to produce a block within this timeframe, a new leader is elected for the next block generation afterwards.
Now let's think what the problem with this construction is: Because IPs are not authenticated and their allocation is somewhat centralized, you could imagine an adversary allocating multiple IP addresses and using one computer to connect to the network from multiple addresses. This increases their probability of being elected leader. An adversary who controls more than 51% of the IPs on the network would then be able to perform 51% attacks. While this might seem implausible, we actually know ways of doing it using, for example, BGP attacks. The critical observation is that such a mechanism would require an assumption of honest majority by IP address, not honest majority by computational power. This is a much stronger assumption than the honest majority by computational power assumption that Bitcoin makes today. Bitcoin's assumption makes it resilient to Sybil attacks because computational power cannot be faked in the same manner that IP address can be.
Lastly, let me say that there exist protocols which use your idea. However, they do not pick a network participant at random by IP address, but use other means for selection. One such example is the Ouroboros BFT protocol in which participants are chosen sequentially to produce blocks -- in this case the population is fixed and does not evolve. Another example is the Ouroboros protocol in which participants are chosen exactly as you describe, but with a weight which is proportional to the amount of money they own in the system -- here the population is evolving as money is changing hands (note that other flavours of Ouroboros, such as Ouroboros Praos or Ouroboros Genesis, do not work in this manner). Another line of work in similar directions is Algorand.
There are many subtle details on how to implement such protocols which are covered in these papers: How to do the random selection efficiently; how to do the random selection in an unbiased manner (or mostly unbiased manner); how to make sure all participants agree about who is elected leader; how to deal with people entering and leaving the network; how to deal with prediction of this randomness to harm the network; and so on.


text:
Why is so expensive to buy Bitcoin with Credit Card?
There are many sites accepting credit cards to buy Bitcoin, but they charges a huge fee, sometimes is more than 10% (and I think never less than 5%).
Why is that? what is the problem with buying Bitcoin with CC? because usually buying via bank transfer has no extra cost.
I think could be related to some chargeback protection, but if this is the case, is not possible for example to block the "withdraw" of BTC from the seller account for a few days (or whatever is safe to avoid chargebacks)?
Sorry if it's duplicate but I couldn't find the answer neiter here nor google :(

It is about the blockchain. A transaction goes in to a block and gets stacked on the blockchain. This process takes a lot of cryptographic processing power, which is done by miners. This process becomes practically irreversible as more block go up the chain.
So the power of bitcoin is its guarantee a transaction is becoming irreversible and definitive as the blockchain grows. This means, you buy Bitcoin it is yours. Yes, if it is still in the exchange they hold the private key to respend your BTC, but they won't hold the lock forever.
Chargeback is one thing. A stolen credit card another. Credit card fraud is at large scales currently. All this is putting a big administrative overhead on the exchanges. Users will have to do all sorts off verification to prove the credit card is really theirs. So, that 10% is the administration fee for all that, plus risk mitigation. Also I believe, that withdrawal is restricted anyway, regardless of this fee.

If I go to a currency exchange shop and use my credit card to buy Euro banknotes I don't pay a 10% admin fee even though the chargeback or stolen-card risk is the same as you describe.

Where I'm from, you identify with a passport to the exchange and you sign the exchange receipt. In case you issue charge-back, the exchange will submit this as evidence it was actually you doing the buy and not some fraud. Probably they even have surveillance camera's. This is more difficult to prove when the exchange is online.


text:
Why is my Bitcoin private key so much shorter than my PGP private key?
My PGP key takes up a huge, multi-line block of text, but my Bitcoin private key is just a small string. Yet both are considered extremely secure. Why is my PGP private key so long?

GPG keys are usually RSA keys.
RSA keys are based on the difficulty of the factorization. Keys are usually 2048 or 4098 bits.
Bitcoin uses ECDSA (Elliptic Curve Digital Signature Algorithm), where keys are usually smaller. Bitcoin uses the curve secp256k1 where keys are 256bits.
Roughly, an RSA key with 2048 bits offer similar security then a 256 bit ECDSA key.
Both offer more or less 128bit of "symmetric" security.
With newer versions of GPG you can also generate and use EC keys (nist-P, ed25519 or secp256k1)

PGP keys can also be DSA/ElGamal which are about the same size as RSA. In addition a PGP 'secret' (private) key packet actually includes both the private and public key values, with the private part encrypted which adds some overhead, plus metadata: at least one userid and usually at least one signature and sometimes other attributes. And a PGP key block (either public or secret=private) usually includes not just one keypair but a 'master' key and one or sometimes more subkey(s). OTOH PGP uses base64 while bitcoin uses base58 which is a tiny bit less space-efficient.

Thanks for the help, both of you...The part about a PGP key block containing a bunch of extra data makes a lot of sense. I have some follow-ups though if that's okay:

Why does an RSA key need to be 2048 bits to offer similar security compared to a 256-bit ECDSA key?
Does the fact that Bitcoin keys are only used for signing whereas a PGP key is used for both signing and encrypting have anything to do with this?

I propose, that this is a good question for another crypto forum? Bitcoin doesn't use RSA...


text:
I sent money from my BTC (Blockchain) to BCC (coinbase) by accident. Any help to recover the funds? Both accounts are owned by me
I sent money from my BTC (Blockchain) to BCC (coinbase) by accident. Any help to recover the funds?
I need help as I know transactions cannot be refunded but I have read a few forums where people have recovered it.


text:
If I send BTC from Jaxx will it give me both BTC and BCC
Just want to know if Bittrex supports both blockchains, Bitcoin and Bitcoin cash, when importing from a Wallet like Jaxx

not exactly clear, what you mean by importing... Usually BitTRex provides an address, and you can send funds to this address. It works for BTC and BCC, I have tried them both in the past. There are many others as well. But importing? I don't think so, there is no link between your JAXX adress and the addresses/keys at BitTRex. Do you want to avoid the tx fees?

By importing I mean sending BTC to Bitrex from Jaxx.

Bitcoin and bitcoin cash are two separate networks, if you send a tx on one network, it will not affect what happens on the other network. If you are using Jaxx, your wallet will show separate btc and bch balances in the app.
To deposit both btc and bch to Bittrex, you will not to get a btc deposit address from Bittrex and send btc to it. And then get a bch deposit address from Bittrex and send bch to it.
That said, I am unsure if Bittrex supports bch right now. If they do support it, the above will work. If they do not support bch, then obviously you cannot deposit a coin they do not support.

Thanks...I will look on Jaxx...The help  files on Bittrex says it supports the fork.

Chytrik is right: be careful not to mix btc/bcc. Only send bitcoin to bitcoin addresses, and bcc to bcc addresses. You cannot send across chains. This will make you lose your funds. Even if Jax supports both. And yes, bittrex supports both as well.


text:
Can Coinbase Bitcoin network fee really be 50%
Ive just bough £47.81 of bitcoin.  After fees i'm left with 0.00375837 BTC.
I want to buy another cryptocurrency but the network fee is 0.00186539 so i'm left with only £24.41.
Can this fee be correct?  Thats close to 50%.  Is it the sum im trying to trade?

Transaction fees are calculated based upon the size of the tx in bytes, not the amount being transferred. Right now the network is very congested, so fees are higher than normal. In this case Coinbase is initiating the tx, so you are at their mercy to dictate the fee (that said, setting a lower fee may mean your tx does not confirm). If you trade within the coinbase exchange (not sending coins to another exchange), you should not be charged network tx fees.
Once the backlog of txs clears out, it will be cheaper to transact again.


text:
BTC received in BECH32 (P2WPKH) format address not exist in Electrum
I sent some BTC to a BECH32 (P2WPKH) format address. (details of the transaction)
I imported the private key(wif) in Electrum, but I can't find the income?
I am sure I sent to the right address and imported the right wif. How can I get the incomes?
Thanks a lot!

did you prefix p2wpkh: to the wif when importing? do you see the address under the addresses tab? view menu > show addresses if it's not there.


text:
When did Bitcoin start to allow more than 2 transaction outputs?
The original Bitcoin paper specifies that:

Combining and Splitting Value

(...) Normally there will be either a single input from a larger
previous transaction or multiple inputs combining smaller amounts,
and at most two outputs: one for the payment, and one returning the change, if any, back to the sender.

As I understand, there is currently no limit on the number of transaction outputs. Was Bitcoin ever implemented in a way that allowed no more than 2 outputs? If so, when did it change, and were there any opposing arguments in the community/from Satoshi for keeping the maximum number of outputs at 2?


text:
How are we so sure that the bitcoin network is connected?
I am only beginning to understand the bitcoin's p2p network protocol but so far I know (and correct me if I am wrong) that a new node in the network attempts to connect to a "few" other nodes that already in the network to become a part of the network. I suppose that this makes a bitcoin network a random graph of some sort where we can make no hard guarantees about the topology and structure of the network and the best we can do is calculate estimates. In such a scenario my question is that how do we ascertain that the bitcoin network obtained (by randomly linking nodes with each other) is one connected graph and not split up into multiple connected components? Is it guaranteed to be connected or is it probabilistically so? If it is probabilistic what role does the maxconnections limit (125) has here?
I understand that there are some hard-coded seeds in the bitcoin client (and DNS) to which a new node can connect to and be a part of the already connected network thus evading this problem. Even if this is correct that problem still remains that the entire network may end up splitting up into multiple components if a few of these nodes end up disconnecting from the network. How do we guarantee that the network always remains fully connected when nodes can randomly disconnect and re-connect into the network?

how do we ascertain that the bitcoin network [...] is one connected graph

Problems paying people.

The senders and recipients in transactions are people who make contact using non-bitcoin protocols - for example HTTP websites, SMTP email, chat, in-person, by phone.
Therefore if the Bitcoin network were fragmented we should expect that pretty soon a person whose wallet is in one fragment would experience difficulty paying someone whose wallet was in a different fragment.
This would occur because different fragments would have different head blocks in their blockchain and pretty soon miners in one fragment would not be able to process transactions whose inputs were from a block they don't have.
I would expect Bitcoin discussion fora would gradually become filled with the wailings and gnashings of a horde of frustrated, angry and bewildered Bitcoin users.
I mean, more than the fora normally are :-)
After this became known, I would expect at least one or two whales to succumb to the temptation to double-spend massively. If so it seems superficially it would be a huge crisis for Bitcoin.
In practice, since this has not happened yet, I guess it would take some massive splitting of the Internet (e.g. Putin turns on his Russian Internet isolation switch for sufficiently long).
When there is a hard-fork (e.g. BCH) something a little similar happens, people who own n BTC before the split now own n BTC + n BCH. In the case of Bitcoin network fragmentation, someone who owned n BTC before would now own n BTC in fragment A and n BTC in fragment B. Although this might make them happy, potential recipients would worry about the consequences in an eventual remerger of those fragments.

In practice, since this has not happened yet
That is the part I wanted to be addressed. Why has it not happened yet (not purposefully but just out of randomness)? Is it impossible or improbable? Further how does the network maintain its connectivity when a few nodes leave?

@Sarthak123: Your question's title is "How are we sure the Bitcoin network is connected". If you want to ask "Why has the Bitcoin network not fragmented" you should probably ask that as a new question - adding a link back to this question if you feel that would help people understand what you are asking. See also Node/peer discovery


text:
How to sign a PSBT transaction?
I have a PSBT (in Base64 format) which I need to sign using GoLang, but I can't figure out which steps I need to do that. I found this but I'm not really confident with Bitcoin and Python, so I didn't fully understood the Signer Algorithm. What should I do?

I haven't used this particular feature, but btcsuite/btcutil (written in Go) has a psbt package that should allow you to do that: https://godoc.org/github.com/btcsuite/btcutil/psbt

I saw it, but no example and I'm not enough confident with BTC to fully understand what I have to do

As I commented, with the psbt package from btcsuite/btcutil it is possible.
I have created an example of how to use it. I don't know if this is the best/most efficient way of doing it. But I hope this gives you a template and example to work with. But it is relatively low-level and without some deeper technical understanding of Bitcoin it may be difficult to follow.
It spends the second (0-indexed) output from this transaction on Testnet.
package main

import (
    "bytes"
    "encoding/hex"
    "fmt"

    "github.com/btcsuite/btcd/chaincfg"
    "github.com/btcsuite/btcd/chaincfg/chainhash"
    "github.com/btcsuite/btcd/txscript"
    "github.com/btcsuite/btcd/wire"
    "github.com/btcsuite/btcutil"
    "github.com/btcsuite/btcutil/hdkeychain"
    "github.com/btcsuite/btcutil/psbt"
)

const (
    // Provided PSBT with one P2PKH input. Created in part 1 below.
    psbtBase64 = "cHNidP8BAFIBAAAAAX7Mj1abZbFtfUYFYBIFRKxCOxs8wfMRu3NhVBHTbnFfAQAAAAAAAAAAAayEAQAAAAAAFgAU8yFPpRndMpAJ7aO+RtRN4Nh3mbYAAAAAAAEBH6CGAQAAAAAAFgAUJw/E3xSMUU+8VVGHXk7Dc4vGNjkiBgOoVLKI2rj2DMlswSDkSf0KR7jQHULLPOWS/x3q8b3MqQyj8e/WAAAAAAMAAAAAAA=="

    // Extended Private Key.
    extPrivateKeyStr = "vprv9GpFMh8VMAXKgdZVFGXFvsexjr25MHKvtCY7vKHbRr8A6xCm4bQYbQrJmLz6h3F9MGf5edwxQuZR7DCLFVvjMxgfJ9so9mcN2SHGR3QFr3S"
)

// Part 1: Creating the PSBT (will be returned as base64)
func part1() string {
    // The extended private key was generated with Electrum and we derive the
    // specific key used.
    // `keyC` contains the private key that _contains_ the coins to be spend.
    keyC, _ := hdkeychain.NewKeyFromString(extPrivateKeyStr)
    fingerprint := keyC.ParentFingerprint()
    keyC, _ = keyC.Child(0)
    keyC, _ = keyC.Child(3) // Electrum derivation of the 4th address.
    pubKeyC, _ := keyC.ECPubKey()

    // Create a brand new PSBT spending the following outpoint.
    txhash, _ := chainhash.NewHashFromStr("5f716ed311546173bb11f3c13c1b3b42ac4405126005467d6db1659b568fcc7e")
    outpoint := wire.NewOutPoint(txhash, 1)
    inputs := []*wire.OutPoint{outpoint}
    pubkeyScript, _ := hex.DecodeString("0014270fc4df148c514fbc5551875e4ec3738bc63639")
    spendTxOut := wire.NewTxOut(100000, pubkeyScript)

    // The address and amount to send funds to.
    outAddress, err := btcutil.DecodeAddress("tb1q7vs5lfgem5efqz0d5wlyd4zdurv80xdkfkf3cn", &chaincfg.TestNet3Params)
    // The witnessScript consists of a `0x00`, followed by the size of the
    // pubkey-hash `0x20` and the pubkey-hash itself.
    witnessScript := append([]byte{0, 20}, outAddress.ScriptAddress()...)
    outputs := []*wire.TxOut{wire.NewTxOut(99500, witnessScript)}

    // Create the psbt instance.
    pC, err := psbt.New(inputs, outputs, wire.TxVersion, 0, []uint32{0}) // Note: typically the sequence is `0xffffffff`!
    if err != nil {
        panic(err)
    }

    // Use the Updater to add information to the input.
    u, err := psbt.NewUpdater(pC)
    if err != nil {
        panic(err)
    }

    u.AddInBip32Derivation(fingerprint, []uint32{0, 3}, pubKeyC.SerializeCompressed(), 0)
    u.AddInWitnessUtxo(spendTxOut, 0)
    u.AddInSighashType(0, 0)

    // Show the base64 encoding of the unsigned PSBT.
    b64, _ := pC.B64Encode()
    return b64

}

// Part 2: Sign the PSBT in base64 encoding and return it.
func part2(psbtBase64 string) string {
    // Reader for the PSBT.
    psbtBytes := []byte(psbtBase64)
    r := bytes.NewReader(psbtBytes)

    // Create instance of a PSBT.
    p, err := psbt.NewFromRawBytes(r, true)
    if err != nil {
        panic(err)
    }

    // Load the extended private key.
    bip32Key, err := hdkeychain.NewKeyFromString(extPrivateKeyStr)
    if err != nil {
        panic(err)
    }

    // Derivation path should be read from PSBT.
    // Note: We ignore checking the fingerprint, etc.
    path := p.Inputs[0].Bip32Derivation[0]
    for _, d := range path.Bip32Path {
        bip32Key, _ = bip32Key.Child(d)
    }

    pubKey, err := bip32Key.ECPubKey()
    if err != nil {
        panic(err)
    }

    privKey, err := bip32Key.ECPrivKey()
    if err != nil {
        panic(err)
    }

    // Manually creating the signature.
    sigHashes := txscript.NewTxSigHashes(p.UnsignedTx)
    sig, err := txscript.RawTxInWitnessSignature(p.UnsignedTx, sigHashes, 0,
        p.Inputs[0].WitnessUtxo.Value, p.Inputs[0].WitnessUtxo.PkScript,
        txscript.SigHashAll, privKey)

    // Use the Updater to add the signature to the input.
    u, err := psbt.NewUpdater(p)
    if err != nil {
        panic(err)
    }
    sucess, err := u.Sign(0, sig, pubKey.SerializeCompressed(), nil, nil)
    if err != nil {
        panic(err)
    }
    if sucess != psbt.SignSuccesful {
        panic("could not sucessfully sign for some reason")
    }

    // Finalize PSBT.
    err = psbt.Finalize(p, 0)
    tx, err := psbt.Extract(p)

    var buf bytes.Buffer
    tx.Serialize(&buf)
    return hex.EncodeToString(buf.Bytes())
}

func main() {
    fmt.Println("Base64 PSBT: ", part1())

    fmt.Println("Signed tx: ", part2(psbtBase64))
}

I understood you code, but I found out it seems to be working only for transactions with only one input. What about multiple input transactions?

The Inputs field of the psbt structure is a slice of inputs that can be indexed, as is done with the example code by simply using index 0.


text:
Update wallet to multi tokens
I don't know if here, I have to ask, but if not, please direct me.
How can I make a wallet accept more coins.
More exactly: I have a wallet BEP2, native currecncies is BNB (Binance). What needs to be done for this wallet to accept other BEP2 tokens.
I didn't try anything because I don't know where to start.
Thank you.

I suggest that you buy a hardware wallet, such as ledger or trezor.
Those wallets are compatible with a wide range of cryptocurrencies. If they do not provide support to a coin, that coin is not worth buying.

Thank you for your answer.. My problem is: money is already in this wallet, but it is not supported for that token. equivalent 7000 usd

Do you have the wallet private key? or the seed (12 words?)
In Ethereum blockchain you can add any token manually using token contract address, I don't know how binance chain works, but probably the same way.
I just google about it and found guard wallet. I don't know that wallet, but you have few options because you are using a not common blockchain
https://guarda.com/blog/bep-2-wallet/