text:
BIP 32 Public Parent Key -> Public Child Key
Reading the BIP 32 section of how to generate Public child key from Public parent key, I got stuck in the following:

The returned child key Ki is point(parse256(IL)) + Kpar.

As I could understand point(p) is the Elliptical Curve multiplication which will output X and Y coords, so how can I add them with Kpar? Also, it should return me a Compressed public key right?

A public key is an elliptic curve point. So K_par is also an elliptic curve point. You can then just do a EC point add to add the point given by point(p) with K_par to get a new point, which is also a public key.

So if I have K_par as compressed I need to recover Y value using ModPow(a, (p+1)/4, p) ?

@AllanRomanato Yes, converting a compressed serialization of a point to a point requires recovering the Y coordinate (and negating if necessary, to make the oddness match up).

The addition operation in that context refers to the Elliptic Curve group operation ("point addition").
The child key returned is a point, not a serialization. So the question of whether it's compressed or not is not technically relevant. In practice, every time a serialization of a point is used in BIP32, it is compressed though.


text:
Hexadecimal Bitcoin Transactions
Suppose I have a random transaction which I recovered from blockchain blk****.dat file.
How can I calculate the number of confirmations of this transaction? I dont want to use the RPC call getrawtrasaction.

You can't without knowing which block the transaction was in.

Why do you not want to use the getrawtransaction command?

Because I want to parse my own way

@Allan Parsing cannot help you because the number of confirmations is not contained in the transaction. It depends on the number of blocks built on top.

Ok, so how I can get the number of the block which is built on? With that, I can calculate. Actualblock - BlockWhichTransactionIsIn = NumberOfConfs

source: Stack Exchange

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

sort: votes


text:
How to monitor Bitcoin address for new transactions?
I have some generated Bitcoin addresses which I want to monitor for newly received transactions, I have a full node but I don't want to import those addresses to the node's wallet. I don't want to use any external service API like block.io or blockchain.com, I am working on my own code.
I want to keep this list of addresses in an external DB (MySql or Mongo) and I want to keep track of them until they receive let's say n confirmations.
I know I can user -blocknotify to receive information of newly mined blocks and with this new block I can scrape the transactions and look for the addresses I monitor. But how can I guarantee I will have all the UTXOs?
If the address is newly generated with the last block I can create my local DB with addresses information. But what should I do if I import (on my database, not Bitcoin Core wallet) an old address which had already been used, how can I check for UTXOs?
Also, how can I check if any of these monitored addresses have unconfirmed transactions?

It's possible to do this externally, but it's tricky to get right and might cause of loss of funds if you don't.

You need to correctly identify transactions you can spend. This is relatively trivial with P2PKH addresses, but a little more involved if using more exotic script types. You need to understand rules like transaction maturity before considering a UTXO to be spendable.

You need to correctly handle reorganizations if a transaction changes its confirmation state or is invalidated by a change in its confirmation state and an alternative is included.

You need to manually walk every single block to find old transactions, or use the UTXO scanning feature to find ones which may be unspent. This is very time consuming and requires full retention of all blocks since genesis (or at the very least, the birthdate of the wallet). Repeating this if you want to monitor a new address with potentially old entries.

You need confidence that your code is correctly accounting, which is only something you can ensure.

It's easier to use the built in wallet which handles all of this correctly, really.

That is the problem, I cannot use a built-in wallet, I am creating a wallet system to my application.

Why can't you use the built in wallet? There's tools like watch only keys which be used for almost any application, if you don't want the wallet itself managing funds, it can at least handle UTXO identification and reoragnisations.

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


text:
Is it fraud? Would banks ask for fees through bitcoin?

So a man came to me on Instagram saying that he wanted to buy old money specifically from Hong Kong for a museum in Philadelphia, and that he would pay me good money for my old coins and bills, then he said he transferred the money through Bank of America but the money would only transfer into my Hong Kong bank account if I pay a verification fee to his bank through bitcoin atm with a QR code he gave me, he said the QR code belonged to the bank but I couldn’t check, it was very fishy so I started agitating him to test him and he sent this CERTIFICATION that he claims is from Bank of America. He also kept rushing the process And his English was strange and he never really answered my questions directly, he called the fees clearance fees, activation fees and verification fee on different occasions and now I’m so confused. I don’t use Bitcoin so I have no idea is this fraud or not. Please help!

This is definitely a scam.
Even if an activation fee was a legitimate thing, they would just charge that amount out of the amount you were going to receive - if you were to receive $1000 and the fee was $5, they'd just give you $995. Beyond that, no bank I'm aware of charges fees in cryptocurrencies.
Don't send any money to these people.

There are also numerous errors in this "certification" that make it very obvious that it's a low quality fake created by someone who doesn't speak English well.

Yes definitely a scam. Don't proceed further.


text:
Syncing bitcoin node with multiple cores
I'm syncing my node on 32 CPUs, and it's super slow.
Obviously, syncing doesn't go in parallel. I wonder if there is any fundamental obstacle for "divide and conquer" way of doing it.
So let's say we have 62 blocks, and 2 CPUs. We divide it by half, and the first CPY syncs 1-32 blocks, and 2nd cpu syncs 33-64 blocks, after both tasks are completed, we are checking that 32 and 33 blocks match.
Am I missing something? This feature seems so simple to me but somehow not implemented.

What makes you think that this isn't implemented?
Block download is already multithreaded and blocks are downloaded out of order. Everything that can be verified in a block without requiring other blocks (such as the PoW matching the PoW stated in the block header, merkle root, etc.) are verified when the block is received. This all happens in separate threads.
But the bulk of verification is checking that the transactions within the blocks are valid. This cannot be done without having verified all of the blocks previous to the one being verified, so this is unfortunately a serial operation that cannot be parallelized.
The crux of the issue has to do with the UTXO set. Suppose block 2 has a transaction that spends an output created in a transaction that is in block 1. If you receive block 2 and start verifying transactions before you have block 1, then you will be unable to verify the transaction whose parent(s) are in block 1. Thus you must wait for block 1 to be received and verified before you can verify block 2.
Of course you can still check the other things in block 2 and write it to disk first, then proceed to download more blocks. These just need to be queued for the actual transaction verification.
The transaction verification involves adding and removing items from the UTXO database. This database needs to be written to disk which means that there will be a lot of disk I/O which is generally slow. The database is cached in memory but is flushed to disk when the in memory cache becomes full. You can make this faster by increasing this cache. In your bitcoin.conf, add a line dbcache=<n> where <n> is the amount of RAM in MiB that you want to dedicate to the cache.
The default dbcache is 450 MiB, so setting a dbcache value larger than 450 will speed up syncing as more of the database is cached and thus less disk I/O is needed. A dbcache of 8000 is large enough that the entire database will fit in memory and thus only be written to disk once. If you have enough RAM for this, then setting dbcache=8000 will allow for the fastest sync time.

Thanks Andrew for such a good answer. Now it's clear why it's implemented in the current way. Increasing cache didn't improve the speed too much(visually), also it makes abrupt shutdowns of the machine more critical, as the cache hasn't been saved on the disk, and the bitcoind will have to do "Rolling forward" for all already downloaded and verified blocks.

dbcache=8000 increased my progress increase per hour from 0.6-2.0% to ~5%, A great improvement for me considering I have bitcoin-core running from an external drive.


text:
Save state to the disk at abrupt bitcoind shutdowns
I have a bitcoind running, and after new blocks being synced, sometimes I kill it(without stop command).
Next time, when I start it, it goes through already synced blocks.
Is there any way to force bitcoind keep the state on a hard drive after accepting each new block?

I think bicoind save the state of the last block because it can access to DB and read the last block stored into DB.
also, I have noted when running bitcoind, it runs some previous bock (I don't know the motive)
This is the log of the bitcoind
2019-08-22T10:51:33Z init message: Rewinding blocks...
2019-08-22T10:51:36Z init message: Verifying blocks...
2019-08-22T10:51:36Z Verifying last 6 blocks at level 3

ps: If you kill the process bitcoind without stop command you can corrupt some file blk and inside it, the client bitcoin can store trash data


text:
How to transfer hash power from one pool to another
Is it possible to transfer hash power from one pool to another? If yes, how?

If you want to move all your computational power (hash power) suppose you could just disconnect from your current pool and connect to the other one
If you want to divide between different pool I suppose you could just connect to them then use a tactic of process priority to choose how much power you want to devote to each pool depending on its process, for Ubuntu you could have a look at a thread like this one: https://askubuntu.com/questions/656771/process-niceness-vs-priority but it depend on your operating system


text:
How to get total transactions on the network with RPC
I have seen no concrete answer to this question anywhere.
I assume it is possible to get the total number of successful transactions on the bitcoin network using bitcoin-cli command because most explorers provide this information.
How can i get this information from a fully synced node?

I'm reasonably sure this is not exposed by the RPC API.
You could parse debug.log and look for lines like:
2019-08-20T12:17:58Z UpdateTip: new best=0000000000000000000e6c402b311740e21f79a42ed84ecf69a3ae4fe88ce882 height=590956 version=0x20000000 log2_work=90.9855 tx=446914655 date='2019-08-20T12:17:55Z' progress=1.000000 cache=277.1MiB(321228txo)

Where tx=num gives the total transaction count. I reckon that most explorers maintain a separate database of the transactions, and simply run a query against that instead of pulling data like this from a node or log.

Another possibility is to use the getblockstats command to get the number of transactions (not including the coinbase transaction) for a specific block (by height/hash). E.g.
$ getblockstats 500000 '["txs"]'

{
  "txs": 2701
}

Then, iterate through all of the blocks to get the total for all blocks.


text:
Bitcoin Transaction Signing
I wrote a couple of algorithms that perform the ECDSA and also the verification. So I used my algorithm and the RPC call for signing and I got a couple of questions.

Since we have the ephemeral private key which has to be random how can I sign two times the same transaction and get the same signature as Bitcoin RPC does.
What is the hash that should be signed, the whole transaction without the signature, do I have to exclude any fields?

Since we have the ephemeral private key which has to be random how can I sign two times the same transaction and get the same signature as Bitcoin RPC does.

This "ephemeral private key" is known as a nonce. Bitcoin Core, and most other wallet software, use a technique called Deterministic Nonces. Specifically, they use the algorithm defined in RFC 6979 to produce the nonce deterministically. It essentially hashes together the message and the private key being used and uses that hash as the nonce. If you sign the same message with the same private key multiple times, the same nonce will be used and thus you always get the same signature.

What is the hash that should be signed, the whole transaction without the signature, do I have to exclude any fields?

For non-segwit inputs, the message that is signed is the entire transaction with all other input scripts empty. For the particular input being signed, the scriptPubKey or the redeemScript if there is one, is put in the input script. Then the sighash type is appended to the end. This is hashed twice and that hash is then signed.
For segwit, the message is a bit more complicated and described in BIP 143.

If I have more than 1 input I have to sign more than one time?
Also, If I use a different nonce, it will generate a diff R and S, will it still be valid?

Yes. Each input will have its own message and require its own signatures. An input can have multiple signatures, in which case you will have the same message signed by multiple keys. With the nonces, any nonce can be used to produce a valid signature. It's why it can also be random. There is no single "correct" nonce or signature for a given message and private key.

So if each input needs a signature, i will have to use the scriptPubKey for each in each signing iteration, and the others inputs empty, after all I insert each signature in the right place correct? Also if I have for example 3 inputs and 2 outputs or 1 input and 3 outputs, which scriptPubKey should I use?

Please don’t write software handling money if this is the sum total of your understanding of the cryptography.

You use the scriptPubKey of the output that is being spent. Each input refers to a specific output, you use the scriptPubKey of that output. Not the scriptPubkeys of the outputs that are created by the transaction.


text:
Elliptic Curve Point at Infinity
Let's take into account the Bitcoin curve. My questions are:

What exactly is the "point at infinity"?
Is there more than one "point at infinity"
How can I identify if my EC generated x and y are the "point of infinity"?
Is there a way to calculate the "point of infinity"?

check out this chapter from a great book called Programming Bitcoin by Jimmy Song. The very last part talks about the point of infinity you're interested in. https://github.com/jimmysong/programmingbitcoin/blob/master/ch02.asciidoc

What exactly is the "point at infinity"?

It's a point that is added to the points on the curve. Together they form a group. It has the following properties:

(x,y) + (x,-y) = infinity
(x,y) + infinity = (x,y)
infinity + (x,y) = (x y)

In other words, the point at infinity is the identity element of the addition in the group. Therefore some people write the point at infinity as "0".

Is there more than one "point at infinity"

Just one.

How can I identify if my EC generated x and y are the "point of infinity"?

The point at infinity is not on the curve, so it does not have x or y coordinates. It appears whenever a point is added to its own negation (for which the normal addition rule has no answer).

Is there a way to calculate the "point of infinity"?

It simply is "the point at infinity", there is nothing to be calculated about it.

But when I am deriving child public keys from a parent public key there is a step which is if Ki is the point at infinity the resulting key is invalid, I still miss how to figure it out.

Ki is the sum of point(...) and Kpar. I've given the rules above: if those two have identical coordinates, except the y coordinate is negated, the result is the point at infinity.

I got it, so if x of Ki = x of point(...)+Kpar and y of Ki = -y of point(...)+Kpar so it is the point at infinity... Greattt

The point of infinity DOES have coordinates because IT IS on the curve. It is when the point on the curve is on y=0. To know x just do the math. It is called the point of infinity because at this point, the tangent is a totally vertical line which means it has an "infinite" slop.

@OscarSerna That's nonsense, sorry. The point is on the curve if you're using projective or Jacobian coordinates, but in affine coordinates there is no (x,y) that corresponds to it.

@OscarSerna For example on the (very small) curve y^2 = x^3 + 8 over GF(97), there is a point on the curve with coordinates (27, 0). It is however not the point at infinity.


text:
Calculate Transaction Confirmations
I am writing an API for one of my systems which can verify if a monitored address is receiving Bitcoin, I can already check if the address is on the newly received block, save it to a database for future use as UTXO, it is being managed pretty well.
I am just running into an issue. Since raw blocks do not hold the height information, how can I calculate (without using any external API) my database stored transaction confirmations? It does not make any sense also in my architecture RPC calls for that.

For this task, it's better to run a full-node with the transaction indexing txindex=1. Then you can get the number of confirmations from the txid of a transaction by calling:
bitcoin-cli getrawtransaction "txid" true and checking under the field confirmations. If you have jq installed you can call for example bitcoin-cli getrawtransaction 64749d0a6ab7292ed7445609e1adb8df8d67b29e344d752971699ca75bbda78e true | jq '.confirmations' and you get your answer.
In case you are not running your node with the txindex=1 option, you need to loop through the blocks to find your transaction and the number of confirmations is obtained by subtracting the block height of the transaction from the block count. You could check if the transaction is in a block like this:
bitcoin-cli getblock $(bitcoin-cli getblockhash 610321) | jq '.tx' | grep 210d8e526f4d3f72f7cdc9014ef057aa4654f64a7b1bd059f2d8dea7fcce79cd

If the command above returns anything, the transaction is in that block.

I am trying to minimize the number of calls to my RPC server since ZMQ is already notifying me when a new block arrives(along with its contents). Instead of querying the full node would I keep local storage of block hashes to check transaction confirmation?

If you want to know the number of confirmations of a future transaction you can look for the txid of the transaction in the contents of that block, if it's present, then it got one confirmation. Then add one for every new block.


text:
Signing a Segwit Multisig Transaction
I am creating some test code which can create transactions and sign then, I already could do it with NON-Segwit multisig address, they were signed using my code and broadcasted.
But when I tried with Segwit multisig, I got problems, it was not signing it right.
Can someone walk me through the steps of creating and signing a multisig segwit transaction?

Can you post how you were trying to sign segwit multisig?

I was trying to sign the same way as I was signing the traditional multisig wallet, I have the private key and the redeem script.

It sounds like you are using the non-segwit sighash algorithm. This is not correct. Segwit uses a different sighash algorithm as defined in BIP 143.


text:
Segwit with Multisig
I was analyzing a Bitcoin transaction that works both with Segwit and non-Segwit for multisig Scripts.
Here is the transaction: https://www.blockchain.com/en/btc/tx/80975cddebaa93aa21a6477c0d050685d6820fa1068a2731db0f39b535cbd369
Note that on indexes 0, 1 and 2 we have the unlocking script in the scriptsig filed and on index 3 it is using witness program. No problems until now.
What is bugging me is why when I get the redeem script from indexes 0, 1 and 2 and execute the ripemd60, sha256, create checksum and encode to base58 it generates the Public address as we can see in the screen of blockchain.com. But when I do the very same thing using the redeem script which is in the witness section, it returns to me a completely different address, why is that happening?
Also, what is the scriptSig on the index 3? How it is generated?
Example:
Redeem Script of index 0:
522102194e1b5671daff4edc82ce01589e7179a874f63d6e5157fa0def116acd2c3a522103a043861e123bc67ddcfcd887b167e7ff9d00702d1466524157cf3b28c7aca71b2102a49a62a9470a31ee51824f0ee859b0534a4f555c0e2d7a9d9915d6986bfc200453ae

The address generated from index 0 using my script:
3JUJgXbB1WpDEJprE8wP8vEXtba36dAYbk

It is the same as the transaction.
Redeem Script of index 3 (Segwit):
5221021e6617e06bb90f621c3800e8c37ab081a445ae5527f6c5f68a022e7133f9b5fe2103bea1a8ce6369435bb74ff1584a136a7efeebfe4bc320b4d59113c92acd869f38210280631b27700baf7d472483fadfe1c4a7340a458f28bf6bae5d3234312d684c6553ae

The address generated from index 3 using my script:
36aKiVksQRLKwByBYVz3KwquFcvHZkwroP

Address from the transaction recovered from blockchain.com
3CYkk3x1XUvdXCdHtRFdjMjp17PuJ8eR8z

You are computing just the P2SH address for the segwit script. However it is not just P2SH, it is a Segwit script wrapped inside of a P2SH. You actually have to first take the witnessScript (the multisig script or segwit redeemScript) and make a P2WSH output script with it. Then this script becomes the redeemScript for the P2SH script.
So given
5221021e6617e06bb90f621c3800e8c37ab081a445ae5527f6c5f68a022e7133f9b5fe2103bea1a8ce6369435bb74ff1584a136a7efeebfe4bc320b4d59113c92acd869f38210280631b27700baf7d472483fadfe1c4a7340a458f28bf6bae5d3234312d684c6553ae

as the witnessScript, you produce
002044c55c1da36a576217259c3bc21b0c3943f7eb3ff4e3c381d9fd3502434b9e87

as the redeemScript. This is a P2WSH output script. This is then hashed to create the hash in the P2SH script:
a914771962306e72e479245d48e879dd2a1862225b4c87

which has an address of
3CYkk3x1XUvdXCdHtRFdjMjp17PuJ8eR8z

Is there any BIP that defines it?

BIP 141.

So for us to generate the redeemScript from witnessScript we need to ripemd160 them?

No. You have to SHA256 the witnessScript. Then put that into a p2wsh script. Then hash160 that script for the p2sh address.

For native Segwit we don't need this right? Since we won't have the sigScript field anymore.

For native segwit you still need to hash the witnessScript. But there is no need to make another script and hash that. Native segwit also has a different address type.


text:
Segwit Bitcoin Transaction Signing
As I could understand, we can recover the R and the S values from any transaction following the ScriptSig where we have DER serialization.

Segwit transactions, where the signature will be in the witness section, recovering R and S follow the same steps?
If I use the compressed public key (starting with 0x02 or 0x03) how can I verify the signature, since I don't have the Y coordinate of the public key?
For multi-sig transactions using P2SH as I understand we need to sign with the first key, then get the output transaction with the first signature and sign it with the other key, but using the signature math we use the hash of the message which is the txId, but on segwit the txid will not change after signing since the witness is not counting as part of the hash for txid?

Any other thing that I should look when signing a transaction?

In any transaction you'll have the signature inside scriptsig using a push OP to indicate its length and in a SegWit tx you'll have it as a witness item with a CompactInt to indicate its length. After extracting the signature it is only a matter of decoding DER.
To get the full (x,y) coordinates you have to use the elliptic curve equation (y^2 = x^3 + ax + b) to compute y by only having x. ECDSA x,y coordinate validity verification doesn't seem to work
To sign a transaction, a modified serialization is always used as the data to be hashed and then signed not the original transaction (in other words the resulting hash will be different from txid). This is true for all standard scripts such as P2PK, P2PKH, P2SH, P2WPKH, P2WSH,... The only difference is the modification and serialization. In legacy ones (the first 3) the procedure is described in OP_CheckSig on bitcoin wiki and the SegWit ones are defined in BIP-143.

Using this equation is just simple math like y = sqrt(xˆ3+0+7)?

Not exactly. sqrt is modular square root not a normal square root. A fast way to compute it for bitcoin curve is to find the result of ModPow(a, (p+1)/4, p)

So it is a normal square root that I have to use right?

What is the meaning of this equation ModPow(a, (p+1)/4, p)

It means find the result of (a ^ ((p+1)/4)) % p where a is the result of the right side of the equation (y_squared) or xˆ3+7. Usually BigInteger classes in different languages have ModPow methods, in .Net it is BigInteger.ModPow, in python it is pow(val, val, val) that takes 3 values.

Yes
Most of crypto-libraries have the verify method. You can pass the compressed public key as an input. BTW, it is possible to recover Y part from compressed public key
No. For multisig P2SH (and any other type) we (a)calculate the digest, (b)sign this digest with private keys and (c)create the final transaction from all parts. We do not need to use any signatures on step (b) as a source for calculations

Any other thing that I should look when signing a transaction?

How to redeem a basic Tx?

On 2. I am not using any libraries, how can I recover the Y part using just the compressed key?
On 3, what would be this digest?


text:
how can i coding wallet to build exchange to client withdraw
i want to build a cryptocurrency exchange so my question how is best way and secure way to depositing and withdrawing clients ?
should i use api like https://cryptoapis.io or https://www.blockcypher.com/ ?
and this api dont support tether too !!?

If you are looking for tether on bitcoin (omni-layer), here is the API: https://api.omniexplorer.info/

The most secure way is running your own full nodes per Blockchain.
Using third-party services such as blockcypher will put you & your business at high risk because of:

You're giving the keys to your home & revealing the password of your bank account to someone else! Because in order to use such services, they are the one who make the public & corresponding private keys for you. Even though particularly Blockcypher claims that they will never store your keys, relying on it (I'm not blaming them!) is a risky approach by design!
You won't be able to participate in verifying transactions on your own & maybe you're part of some attack (e.g. 51% attack even though its very unlikely).
You're centralizing the technology that has come into existence for the sake of decentralization!

If there was high costs or too steep learning curve on running your own full nodes & connecting to, Maybe using provided interfaces (e.g. JSON/RPC for bitcoincore) was a reasonable way to start with, & switch to your own nodes during next steps, But as there is no such barrier, you'd better launching your own nodes.


text:
Do I need to download whole blockchain?
Im using bitcoin core debian linux to process payments on my shop using RPC API calls.
Now im switching wallet server, do I need to download whole block chain in order to process transactions on my shop? like create addresses for customers, see balance for customers,,,etc

What does it mean "Now I'm switching wallet server") if you change the machine server you can copy the .bitcoin dir in the new server if I understand well

Important to note the new server will still need to resync and reverify which takes a considerable amount of time even if you already have downloaded all the blocks.


text:
JavaScript Mining System Design
How do I verify a unconfirmed transaction using JavaScript ?

To verify any transaction, you must be running a full node. Since you mention JavaScript, you might be interested in bcoin: https://github.com/bcoin-org/bcoin

@pinhead Please share some demo codes.

There’s more docs and guides at https://bcoin.io if you can’t find what you need there, join our slack or chat with us on IRC #bcoin

It is not possible to verify just a single transaction, without knowing the state of the network. To know the state of the network, you must verify all of it's historical transactions (aka, run a full node).
So this means it is not possible to just take a single transaction alone, and verify it using some bit of code. Rather, you will need the entire history of transactions, so that you can determine whether the transaction is valid in relation to the current state of the network (ie, does the person who is attempting to spend some coins rightfully own them?).
There are various implementations of a bitcoin node available, written in various languages. You'll want to find one that you can interact with programmatically using javascript.
EDIT: I now see you seem to be asking about building some mining software. My answer above still holds true (you'll need a full node to determine the network state and create block templates), but otherwise I think your question (build mining software) is overly broad.


text:
Is it safe to say that all bitcoin that is mined is staying in the bitcoin adresses that is generated between 2^0 and 2^256?
We know that bitcoin adresses are generated with a 256 bit number(the amount of multiplication  that is used on secp256k1 curve). So there can be 2^256 addresses at most where all the bitcoin sits on. Can we say that if one can somehow get all the bitcoin addresses(I know it is not doable), you get all the bitcoins that is generated/mined ?

First of all, since a single key can be represented by tons of different address types, let's assume what you meant to ask is about private keys. As @dave_thompson_085 points out, most addresses are actually limited to a 2^160 space by a RIPEMD hash. So that number may be closer to the actual amount of keys you'd need to sweep "all" the bitcoin.
But you are basically correct, the security of ECDSA is based on really big, really random numbers that are so big and so random no one will ever generate the same number as you.
A few details though, from my understanding:
The order of the curve is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
ref 1
ref 2
So there is a slightly lower number of possible private keys than just 2^256
Also, not all Bitcoin outputs require a single key for spending. There are multisig scripts and more complicated spending policies. Assuming you had "all" the private keys and could look them up in a practical way, I suppose you could assemble multisigs where necessary. But that's not all - plenty of transactions are HTLCs which require the pre-image to a hash in addition to a valid signature to spend.
Another thing is that some Bitcoin addresses really are black holes (burn addresses). If an address represents a point that is not on the secp256k1 curve, then there is literally no private key.
Some Bitcoin may also have been sent to unrecoverable scripts like OP_RETURN or scripts that require finding a hash collision.

Privatekeys are slightly under 2^256, but addresses (for txn types that use them, as you note), are 2^160. Which is still more than can be stored in the universe.

Good point. Will add


text:
Why are there not mnemonic-seed words in Turkish especially considering the increasing rate of bitcoin adoption in the country?
How come bitcoin doesn't have Turkish words as wallet seeds especially considering the increasing rate of bitcoin adoption in the country ?

Because no one has stepped up to do the work or hire someone to do it for them. That's how open source works : )
This repository contains the mnemonic list in different languages (Currently just 8). There are also wordlists in other languages that are stuck in limbo. However if you find it to be worth it, you might want to prepare a list and submit it to the repository as a pull request, and one day it might get merged.

Will do for sure.

@EfeCini And that's the open source spirit! I'm sure it'll prove useful and be incorporated in a wallet software one day. You may also try submitting it to other repositories such as Trezor's here: https://github.com/trezor/python-mnemonic/tree/master/mnemonic/wordlist

Yes open source rocksbut earning shitty fiat by working on bitcoin would be great too tbh. Should I also submit it to other wallets like ledger,coldcard too?

Of course. And I wish you luck, some might not be able to accept because they wouldn't know any speakers of that language to review your wordlist. In that case, you may ask them if instead you could ask for a review in the BitcoinTalk forums. It has a Turkish section if I recall correctly. Then you could address the points raised and they should be able to accept.

All these people (https://github.com/orgs/bitcoin/people) can accept changes. The main maintainer (The BIP Editor) is luke-jr, so maybe you could ping him and ask him if there is anything in your changes that he finds doubtful.


text:
lightningd wont work: SQLITE version mismatch: compiled 3036000, now 3032003
I installed bitcoind and trying to run lightningd through this guide: https://github.com/ElementsProject/lightning/blob/master/doc/INSTALL.md#to-build-on-macos.
I did everything it says. Bitcoin node is running, blokcs are up to date but when I do  "./lightningd/lightningd", it throws a message: "SQLITE version mismatch: compiled 3036000, now 3032003".
How do I fix this and run a lightning node?

Since losing the database could lead to loss of funds, C-lightning is a bit conservative and will only accept to start against a SQLite runtime dependency of the same version it was compiled with.
To solve this issue, just recompile lightningd.

Can you tell me which step is this on the link? Because I might have just done that. Os is Macos. Link: https://github.com/ElementsProject/lightning/blob/master/doc/INSTALL.md#to-build-on-macos

Did you update your system in-between the time you compiled lightningd and the time you tried to run it?

Yes I might have. I tried so many thing so I'm not sure.

Then just re-compile lightningd as suggested in the answer..

I did recompile still the same :(


text:
Is a private key that is created with an additional passphrase included in the existing 24 worded private key basket?
We know that there are finite number of private keys out there that are derived from 24 words. If I create a wallet with an additional 25th word passphrase (which is not in the existing 2048 seed words), is that private key included in the existing private keys that are derived from 24 words or is it an entire new private key which is out of the existing 24 worded private key basket?

tl;dr: Every key is in every basket, given enough time.
I believe the following to be true:

Sequences of keys generated from seeds are indistinguishable from random sequences (except at extremely large scales).
Seeds with the tiniest difference produce completely different sequences.
The sequences are infinite in length.
The elements of the sequences are members of a finite set.

The consequences should be clear.
A longer, meandering and unsatisfyingly-unquantified answer might be:
If you add (or omit) a passphrase, does it generate the same private key sometime?
The most popular definition for 24-word seed phrases, which are also called recovery phrases sometimes, is BIP-39
This allows for an optional additional passphrase to be used together with the seed phrase when calculating the private keys. The passphrase adds an extra layer of security and different passphrases will cause different private keys to be generated.
This system is invariably used with BIP-32 Hierarchical Deterministic (HD) wallets. These wallets generate, not just one, but a whole series of private keys from the seed data.
The consequence is, if you lose your wallet and forget your passphrase, you can't recover control over your money only using the seed phrase.

Note that some wallets also use a password or passphrase to encrypt some or all of their wallet data. This is a different passphrase from the one used with the seed phrase when creating a new wallet or recovering a lost wallet. It is easy to get confused by this. Don't get them mixed up.

Addendum
Lets say you create wallet A and wallet B as follows

Wallet
seed phrase
pass phrase

A
boss rural month arm exit elegant eight grain palace biology pistol control outside album slab top boil absorb tree mean street giggle head frozen
Alex

B
boss rural month arm exit elegant eight grain palace biology pistol control outside album slab top boil absorb tree mean street giggle head frozen
Axle

Because Alex is not Axle, Wallets A and B will each generate a different sequence of private keys. Lets call these sequences baskets A and B.
Lets say you are a very busy person, perhaps you buy Amazon, eBay and Alibaba and make every transaction worldwide, pay to a new private key in one of your wallets, alternating them.
In the very short term (the first million years say), Perhaps baskets A and B will be disjoint sets.
However
Every key is in every basket, given enough time.
Every key is in every basket an infinite number of times, given infinite time.
See Bitcoin collider
Of course, the Earth will be be swallowed by the Sun in the forseeable future, so there may not be enough time. You'd have to ask a statistician and base an estimate on a prediction of future computing power and how that may be bounded by the amount of matter in the accessible universe and various other physical constraints.

Maybe I did not ask it clearly. Lets say that I have a private key generated from a 24 seed word(wallet_1). This wallet_1 belongs to a pile of all private keys which can be generated from those 2048 words(all_wallets_generated_from2048words). When I add a 25th word(a passphrase) to that, it creates a whole different private key, hence a different wallet(wallet_2). Does that wallet_2 belong to that all_wallets_generated_from2048words pile or not? Can that same private key which is generated with a passphrase be populated with different 24 words without a passphrase?

See addendum above.

With 24 words and without a passphrase we will have 2048²³ different wallets/private keys(24th word is checksum). If I create a wallet with any passphrase, does that belong to those 2048²³ ?

With any 24 words, you will eventually have all private keys. with or without passphrase. AFAIK, using 24 words instead of, say, 12 doesn't increase the used entropy because of the data types used for seed numbers etc generated from those words.

So if my wallet's seed words are ABCDEFGHIJKLMNOP + passphrase. That means that someone still -in theory- guess the "actual" word combinations without the passphrase, let's say AHGKDHSNCOM and reach to the funds. Am I correct?

They don't need to guess anything. They just put in any words they like and wait.

Let us continue this discussion in chat.


text:
How can I get the bitcoin amount of an bitcoin address which doesn't belong to my wallet?
I am trying to make a query about a bitcoin address's btc amount. As I've read, getreceivedbyaddress rpc command can only be used for the addresses of a wallet that one owns and that command is awallet command. I want to make a query about any bitcoin addresses btc amount. Is it possible? If yes, how do I do it?

You can use the new scantxoutset method to check for UTXOs matching a given script, address, or key descriptor.
For example, to scan an address, you can use:
bitcoin-cli scantxoutset start "[\"addr(1....)\"]"

Does it scan all the txs in the bitcoin db to find that specific tx which that specific adress is in the utxo set of that tx?

It only scans the txs in the utxo set - any outputs that have already been spent will not be considered

When I run that comment, it takes 1-2 min but when I do the query on blockchain.info, it happens in seconds. Why? Can it be that they downloaded the bitcoin database and tweaked it so it computes very fast? I am asking because I need fast results too if possible. Do you have an idea?

@EfeCini Explorers extract all this information into a separate database optimized for their query patterns. You will not be able to match that speed using just Bitcoin Core, and should consider running a service such as Insight or ElectrumX on top of it


text:
Which LN implementation is better for developing Lightning apps in python(django framework)?
May be a noob question but I want to develop lapps in python(django framework for the web part)? Does the implementation make a difference? If yes, how?

All implementations have APIs against which you can easily program with any modern language. So I'd say it doesn't really matter.
However c-lightning ships with a python client called pyln or pylightning which also gives access to their low level plugin API which might be an additional reason for a python developer to select c-lightning


text:
How is someone not able to steal my bitcoin with Dumpprivkey command?
In an online course the instructor told us that anyone can find the private key of a wallet by using dumpprivkey(address), address being the address that is created from the key (which is public in a transaction on the bitcoin chain).He said that this command returns a WIF object. I assume that is not true because then anyone would steal anyone's bitcoin by looking up the addresses in tx's on the cahin and running the command. Can someone enlighten me about this dumpprivkey command please ?

I hope he meant that they can get the private key for any address in their wallet. Obviously, the software cannot dump a key it does not have.

So, this command needs wallet and the address to operate right. Correct?

The wallet needs to be unlocked, the key needs to be in the wallet, and you need to specify the address whose key you want.


text:
What can be bitcoin's secret can be at most and at least?
We know that: S(Secret-Scalar) x G(Generater Point-Point(X,Y)) = Public Key
In bitcoin, what is the range of that secret can be? What can it be at most and at least? Is there a limit to it like 2^256? If yes what is the logic behind that too?

The maximum and minimum private key possible is defined by ECDSA and the curve being used. In ECDSA, the private key is an integer between 1 and n - 1, where n is the order of the generator point G. Bitcoin uses the secp256k1 curve whose generator has an order n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141, which is almost 2^256.
This means that the minimum value for a private key is 1 and the maximum is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140. If you use an integer outside of this range, taking the modulo n of that integer will give you a value that is in the valid range (except for multiples of n for which the modulo is zero).

Pedantic nit: if you use an integer that is a multiple of n, taking the modulus with n will not give you a valid value (but any other integer will work).


text:
How to know where number of inputs field ends in a transaction if it is not a fixedsize field?
I know that we parse a transaction in bytes. So there are 2 quesions that I search for the answers of:
1- Can VarInt field -that gives the number of inputs in a transaction- be more than 2 hex digits(2 Hex = 8 bits = 1 byte)? I am asking this to be sure that it is not fixed size. We know that 2^8 = max 256 and I am pretty sure that there can be more than 256 inputs in a tx.
2- If it is not a fixed size field how do we know where number of inputs field ends or prevTx field starts?

Does this answer your question? Or this code?

A Varint is a Variable Length Integer, and can be up to 9 bytes in total
It is usually only one byte, which can represent numbers 0-252. 253-255 (0xFD-0xFF) are used as markers for the next three lengths.
Marker    Payload
None      1 byte of integer data
0xFD      0xFD followed by two bytes of integer data
0xFE      0xFE followed by four bytes of integer data
0xFF      0xFF followed by eight byes of integer data

Each marker indicates how to interpret the upcoming bytes.

So to have a better understanding: At most this field can be: FFFFFFFFFFFFFFFFFF, which represents 1.844674407371E+19
many inputs in the transaction, right? (first byte for representation and others for the input count)

@EfeCini That's right - you will hit the block's SIGOPS and size limits far before you hit a encoding limit for the number of inputs

Similarly PUSHDATA4 as an opcode is impossible to use.

Except on legacy transactions.


text:
Error: non-mandatory-script-verify-flag (unknown error) (code 64) with OP_CHECKSEQUENCEVERIFY (OP_CSV)
I am trying to implement a relative time lock on a regtest network using OP_CSV and keep getting this error when I try to consume the locked BTC.
I am creating a UTXO with the scriptPubKey as 10 OP_CHECKSEQUENCEVERIFY OP_DROP which would allow anyone to consume it after 10 blocks have been added to the chain since this transaction.
For unlocking (consuming) this UTXO, scriptSig should be OP_TRUE for successful script verification. (Signature is not required as there is no OP_CHECKSIG)
Also in the unlocking transaction I'm setting nSequence = 10 for this input where 10 is the number of blocks it was locked for. Is this correct?
Where am I going wrong with this?
I am implementing this using the following steps:
Bitcoin Core Daemon version v0.18.0.0-g2472733a24a9364e4c6233ccd04166a26a68cc65

Block count: 503

UTXO being locked:
 {
    "txid": "19136e437bd506d688ced7abbb1e5e17bebb7f0aeb76c179ffd1a6feedd1adf7",
    "vout": 1,
    "address": "mkdCEMwvG7tmRLrpgVyKn2gVy6keGwkpWV",
    "label": "",
    "scriptPubKey": "76a9143806c21703f0e59cff6659b05fbd9c7b18de257b88ac",
    "amount": 124.00000000,
    "confirmations": 1,
    "spendable": true,
    "solvable": true,
    "desc": "pkh([4f42f41a/0'/0'/1']02bc24fa178154b7db3443b6b10454d21551efde08113ff3fe42004cd78100eb74)#0etyma69",
    "safe": true
}

Locking raw transaction (Signed and sent):
Hex: 0200000001f7add1edfea6d1ff79c176eb0a7fbbbe175e1ebbabd7ce88d606d57b436e1319010000006a47304402203c59eb369d8d4f1a14a1e8b3a298cf548cb83408fd8f1557169b006078fd738002206a8b1868f361644f2ff8e29c211443116e7afd62913d9c432555c555637551bd012102bc24fa178154b7db3443b6b10454d21551efde08113ff3fe42004cd78100eb74ffffffff01f0d418e30200000006030a0000b27500000000
Decoded:
{
  "txid": "f0df2904c0f7f806e5992a72ddccfe5873f50ac7da45397f1544b8ff72c791ee",
  "hash": "f0df2904c0f7f806e5992a72ddccfe5873f50ac7da45397f1544b8ff72c791ee",
  "version": 2,
  "size": 172,
  "vsize": 172,
  "weight": 688,
  "locktime": 0,
  "vin": [
    {
      "txid": "19136e437bd506d688ced7abbb1e5e17bebb7f0aeb76c179ffd1a6feedd1adf7",
      "vout": 1,
      "scriptSig": {
        "asm": "304402203c59eb369d8d4f1a14a1e8b3a298cf548cb83408fd8f1557169b006078fd738002206a8b1868f361644f2ff8e29c211443116e7afd62913d9c432555c555637551bd[ALL] 02bc24fa178154b7db3443b6b10454d21551efde08113ff3fe42004cd78100eb74",
        "hex": "47304402203c59eb369d8d4f1a14a1e8b3a298cf548cb83408fd8f1557169b006078fd738002206a8b1868f361644f2ff8e29c211443116e7afd62913d9c432555c555637551bd012102bc24fa178154b7db3443b6b10454d21551efde08113ff3fe42004cd78100eb74"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 123.99990000,
      "n": 0,
      "scriptPubKey": {
        "asm": "10 OP_CHECKSEQUENCEVERIFY OP_DROP",
        "hex": "030a0000b275",
        "type": "nonstandard"
      }
    }
  ]
}

Block count: 504

Unlocking raw transaction:
Hex: 0200000001ee91c772ffb844157f3945dac70af57358feccdd722a99e506f8f7c00429dff00000000001510a00000001c0b909e3020000001976a914b849d945ca598e6b3ea0a062ce41e5006cc5108588ac00000000
Decoded:
{
  "txid": "4c41b8f007aba1b4e76f94e63017620d1ed09460a9cf18fb5f345848a48b0ead",
  "hash": "4c41b8f007aba1b4e76f94e63017620d1ed09460a9cf18fb5f345848a48b0ead",
  "version": 2,
  "size": 86,
  "vsize": 86,
  "weight": 344,
  "locktime": 0,
  "vin": [
    {
      "txid": "f0df2904c0f7f806e5992a72ddccfe5873f50ac7da45397f1544b8ff72c791ee",
      "vout": 0,
      "scriptSig": {
        "asm": "1",
        "hex": "51"
      },
      "sequence": 10
    }
  ],
  "vout": [
    {
      "value": 123.99000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 b849d945ca598e6b3ea0a062ce41e5006cc51085 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914b849d945ca598e6b3ea0a062ce41e5006cc5108588ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "mxKP6T3nHhYj7eiq1wHf7pvtJeM7WmuFiE"
        ]
      }
    }
  ]
}

When I try to broadcast this transaction (using sendrawtransaction) it returns the error:
non-BIP68-final (code 64)

Which is what I expected since 10 blocks have not been mined since the creation of the UTXO.
Generation 10 blocks...

Block count: 514

When I try to broadcast now it gives me:
non-mandatory-script-verify-flag (unknown error) (code 64)

Thanks in advance.
P.S. I'm very new to bitcoin development, so apologies if this is an obvious question.

The error gets resolved when I use OP_10 instead of 030a0000 to push the number 10 on the stack.
It appears that the bitcoin optimizes the size of the scripts. So to push any number from 2 to 16, OP_2 - OP_16 should be used and for numbers greater than 16 we should give minimum required bytes in the script.
E.g.
OP_10 (5a) -> Correct
01 0a -> non-mandatory-script-verify-flag (Data push larger than necessary)
02 0a00 -> non-mandatory-script-verify-flag (unknown error)

Thank you for taking the time to update and answer your own question - people doing that have been invaluable in my own learning.

That error is popped up to ensure that the transaction relayed by your node is standard. Since your transaction output that you are spending is not standard you see the non-mandatory-script-verify-flag error. Currently P2PKH, P2SH, P2WPKH, P2WSH, P2PK, bare multisig and null data are standard outputs. This avoids downstream users splitting the network between upgraded and non-upgraded nodes and the upgraded ones banning the non-upgraded ones for relaying a non-standard transaction. You can find the code that pops the error here.

It's not the scriptSig that is nonstandard; it's the output being spent that is.

@PieterWuille ah right! thanks for correcting. I have edited the answer.

@UgamKamat I had tried a similar non-standard transaction with hash locks and it works. Also, the error string is (unkown-error) which I believe is being generated in the catch block of  the EvalScript method.


text:
Relation between bitcoin address/private keys size and number of characters?
Bitcoin address is 25 bytes long, address = [Version Byte (1)][Hash 160 (20)][Checksum (4)]  whereas number of characters in this string are 34.
Same with private key:  32-byte have almost 52 characters.
I want to know how can I map number of characters to the size(Bytes) of the bitcoin address(P2PKH)?

As its name implies the ripemd160 function will always output 20 bytes (160 bits). The P2PKH address will always be 25 bytes long.

That’s not correct. Leading null bytes are sequestered, encoding to addresses down to 26 characters long.

when you start to code then only you know. Number of characters depends on how the variable is declared, is it byte, hex or character.  For example, if you may think you declare privKey="1223a34fdcb...." in hex format but the program may interpret it as ascii character 1,2,2 etc. So, you have to double checked.

There are many types of Bitcoin addresses. Your example specifies (legacy) pay-to-pubkey-hash (P2PKH) address defined by Base58 check encoding and Wallet Import Format (WIF) which is also specified by base58 check
Base58 encoding treats the entire input payload as a big-endian big integer. Consider these alternate examples:
Input value: bc in ASCII: 0x62 0x63 (2 bytes) interpreted as a 2-byte int and encoded without leading zeros...
base 2: 110001001100011 (15 characters)
base 10: 25187 (5 characters)
base 16: 6263 (4 characters)
base 58: 8VG (3 characters)
So going forwards we know that for this example it took 3 base58 characters to encode two bytes. Lets run it backwards and try minimum and maximum values:
base 58, maximum value with 3 characters zzz encodes three byte value: 0x02fa27
base 58, minimum value with 3 characters 211 encodes two byte value: 0x0d24
Conclusion:
From this example alone we discover that we can not determine the length in bytes of the original value based just on the length in characters of the encoded string.
Bonus:
Modern addresses are now encoded with bech32 and represent Segregated Witness programs. The bech32 spec is defined in BIP173 and look like this: bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
bech32 encoding does not use interpretation as big integers and instead maps input bytes more directly to output characters:

The data-part values:

1 byte: the witness version
A conversion of the 2-to-40-byte witness program (as defined by BIP141) to base32:

Start with the bits of the witness program, most significant bit per byte first.
Re-arrange those bits into groups of 5, and pad with zeroes at the end if needed.
Translate those bits to characters using the table above.

As a result of the previous rules, addresses are always between 14 and
74 characters long, and their length modulo 8 cannot be 0, 3, or 5.
Version 0 witness addresses are always 42 or 62 characters, but
implementations MUST allow the use of any version.

So in summary, with a bech32 address you can determine the length in bytes of the input value based on the length in characters of the encoded string:
In bech32, each character represents 5 bits


text:
How accurate is 'estimatesmartfee' in bitcoin-core?
Method of estimatesmartfee is very simple and easy to use and understand. But I want to know how accurate this function really is? It would be great help if you can provide a link to article or Research paper.

I have found this article https://bitcointechtalk.com/an-introduction-to-bitcoin-core-fee-estimation-27920880ad0 which give you a pretty good summary of this bitcoin function.
Notice that estimatesmartfee return is based on the data of what happened in the past in the blockchain, it is not trying to predict what will happen in the future but what should happen based on what happened before, maybe you will find a better algorithm if you think that there will be something new that will disturb the market.
From the article:

A more sophisticated algorithm may attempt to be more forward-looking.
However, the more complex the algorithm, the more difficult it becomes
to describe its operation and results, and the more difficult it is to
argue that the algorithm is safe against manipulation.


text:
Why do I have to update my node version if I am up to date?
So a few months ago I unplugged my bitcoin node when it was running perfectly. So when I connected it again this week I had to let it sync to the blockchain again. Now you can see it's synced but I have several issues.
It tells me to update the version when v0.19.0.1 is totally up to date. And if I need to update, how do I do it?
Secondly I don't know but it says that my node is unreachable (I cropped out the IP address). How can I fix it?
Thanks

Your node is not up to date: the latest release of Bitcoin Core is 0.19.1 which is a newer release than 0.19.0.1.
You appear to be using a RaspiBolt. The RaspiBolt project's FAQ addresses your question here: How to upgrade Bitcoin Core?.
Regarding the reachability, your best bet is likely to raise an issue on the project's GitHub page (which it appears that you have done already).
There are some issues asking about nodes being unreachable on the project's github page, but I don't know more about that.

Thanks for the tip on updating. The unreachable issue I think it's because of port forwarding


text:
having trouble installing electrum, can't find libsecp256k1
I'm having trouble running electrum from source.
Seems I need to install libsecp256k1 (but I have bitcoin core v.18 installed so i thought i already had it). Electrum has docs about this: https://github.com/spesmilo/electrum-docs/blob/master/libsecp256k1-linux.rst#1-using-package-manager. But this command doesn't find anything on linux mint???
Traceback (most recent call last):
  File "run_electrum", line 80, in <module>
    from electrum.logging import get_logger, configure_logging
  File "/home/zach/electrum/electrum/electrum/__init__.py", line 3, in <module>
    from .wallet import Wallet
  File "/home/zach/electrum/electrum/electrum/wallet.py", line 50, in <module>
    from .simple_config import get_config
  File "/home/zach/electrum/electrum/electrum/simple_config.py", line 13, in <module>
    from . import constants
  File "/home/zach/electrum/electrum/electrum/constants.py", line 30, in <module>
    from . import bitcoin
  File "/home/zach/electrum/electrum/electrum/bitcoin.py", line 34, in <module>
    from . import ecc
  File "/home/zach/electrum/electrum/electrum/ecc.py", line 45, in <module>
    do_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1()
  File "/home/zach/electrum/electrum/electrum/ecc_fast.py", line 189, in do_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1
    raise Exception('libsecp256k1 library not available. '
Exception: libsecp256k1 library not available. Verifying Lightning channels is too computationally expensive without libsecp256k1, aborting.`

Bitcoin Core does not install libsecp256k1. It is packaged into the binary itself so it is not installed into the system. If libsecp256k1 is not available in your system's package managers (which it probably shouldn't because it isn't officially distributed AFAIK), you can install it from source. The instructions for that are directly in the README.

This link was provided concerning this issue on github:
https://github.com/spesmilo/electrum-docs/blob/master/libsecp256k1-linux.rst


text:
I have two accounts and can't fin my original one
I'm new to Bitcoin. I opened an account to transfer cash from an online betting site. After doing so, my computer crashed I lost all connections and info except my Bitcoin address. I opened a new Bitcoin account and now when I log in, it takes me to the new account. I can't get logged in to my original account and find my money.
Thanks, Brian

A bitcoin address is not sufficient information to recover a wallet. We'll need more info to help you. Which wallet did you use? Did you make any backups of it in any way?

Do you use the wallet bitcoin core?

From what you wrote, it looks like instead of downloading wallet software you opened an account at some business who controls money on your behalf instead of you directly controlling your own money. If so, you need to contact that specific business. See Types of wallet - Custodial


text:
Where can I download bitcoin core version 0.16.0
I changed my passphrase around march 2018 and now I can't use my new passphrase on the new bitcoin core version. When I put the back up wallet.dat into the new versions of bitcoin core, it tells something about my wallet not being compatible? So where can I download the older versions of bitcoin core, especially version 0.16.0 because it was around that time that I changed my passphrase and back up my wallet.dat. I have tried bitcoin core versions 15.1 and 16.1, but they don't work, so I think 16.0 will work because this was the time with the segwit wallet issue. Or if there is another possible solution, please let me know.
Thanks ahead of time.

What is the exact error? Different versions within the same major version (i.e. 0.16.0 and 0.16.1) will not have major changes to the wallet that make them incompatible or anything like that. If 0.16.1 can't open the wallet, then 0.16.0 won't be able to either.

So the problem really is that, I can't unlock my wallet with my correct password. I know it is the correct password because I had changed the password to a common one that I use a lot I even showed it to my wife telling her just incase she needs to access the wallet However several months afterwards,I was active with the wallet, transferring and receiving some little bits of bitcoin and then I just left the wallet for over a year and now I can't get into my wallet with my password.I am thinking that my situation is similar to this guy here,  https://github.com/bitcoin/bitcoin/issues/14461

As you've explicitly asked for Bitcoin-core 0.16.0 download link, Just went through the links for version 0.16.0 under bitcoin.org & bitcoincore.org & yes, links are broken!
So, even though I agree with Andrew that you may use other minor versions (e.g. 0.16.1, 0.16.3) without any loss, but when it comes to merely helping you to download your desired version, you've got a couple of choices:

Download the source files & Build the client on your own
Use the Docker container here & you will be up & running in minutes.

Thanks, but I am not that advance in building the client on my own. How do you do it? if it's not too hard.

With the second option (Docker container), you don't have to build the client on your own @Light, even though building a client isn't that hard, but may seem tricky to some users. So keep up with the docker option. Good luck!


text:
Possible to run a Lightning node on same computer as Bitcoin Core node?
I have a Windows 10 laptop that is running a full Bitcoin node using Bitcoin Core. Is it possible to also run a Lightning node on the same laptop simultaneously with the Bitcoin node?

Yes but some lightning implementations are not running on windows. Lightning needs hardly any hardware but requires to talk to a Bitcoin node (local or remote) anyway.

Thanks Rene - is there a website or instructions online that you know of that would walk me through exactly what I need to do to get the Lightning node running? I don't want anything I do to mess up my Bitcoin node.

I think lnd runs on windows their installation guide says exactly how to download, compile, install lnd and fire it up with bitcoind as its backend. you might have to open a communication channel via bitcoin.conf but that is also described on their site: https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md

Actually, at least the three big implementations do all run fine on Windows. OP might want to consult this guide for a very simple installation of bitcoind and lnd with nice UI on Windows: https://medium.com/lightning-power-users/windows-macos-lightning-network-284bd5034340


text:
How to sign an Altcoin transaction manually with 2 inputs and 2 outputs
So i'm working with the altcoin denarius which has the following raw TX structure. This is a transaction I am try to sign:
Original:
01000000a73a7b5d01068ee1e392668191ce0ae4337074e7a384be3c5d72bd45b7f7ce6fa2006258110100000000ffffffff0208c29400000000001976a914ebb93cbd9952b3941e0415509b301dfd1cb84b0388ac90d00300000000001976a914b1acab9b97a1d9f35898b9d74fe11619e636ac3d88ac00000000

VERSION: 01000000
TIME: a73a7b5d

INPUT COUNT: 01
INPUT [0] PREV TXID: 068ee1e392668191ce0ae4337074e7a384be3c5d72bd45b7f7ce6fa200625811
INPUT [0] PREV OUTPUT INDEX: 01000000
INPUT [0] SCRIPT LENGTH: 00
INPUT [0] SEQUENCE NUMBER: ffffffff

NUMBER OF OUTPUTS:02
OUTPUT [0] VALUE: 08c2940000000000
OUTPUT [0] PUBLIC KEY SCRIPT LENGTH: 19 (25 in decimal)
OUTPUT [0] PUBLIC KEY SCRIPT:
  76 (OP_DUP)
  a9 (OP_HASH160)
  14 (bytes to push)
  SCRIPT HASH: ebb93cbd9952b3941e0415509b301dfd1cb84b03 (pubkey hash)
  88 (OP_EQUALVERIFY)
  ac (OP_CHECKSIG)

OUTPUT [1] VALUE: 90d0030000000000
OUTPUT [1] PUBLIC KEY SCRIPT LENGTH: 19 (25 in decimal)
OUTPUT [1] PUBLIC KEY SCRIPT:
  76 (OP_DUP)
  a9 (OP_HASH160)
  14 (bytes to push)
  SCRIPT HASH: b1acab9b97a1d9f35898b9d74fe11619e636ac3d (pubkey hash)
  88 (OP_EQUALVERIFY)
  ac (OP_CHECKSIG)

LOCKTIME: 00000000

I have various methods to convert bytes to hex strings and a few others:
    public static String hex2smallEndian(String hex){
        String[] dat = split(hex, 2);
        String swapped = "";
        for(int i = dat.length - 1; i >= 0; i--){
            swapped += dat[i];
        }

        return swapped;
    }

    public static String[] split(String str, int count){
        String[] dat = new String[str.length() / count];
        for(int i = 0; i < str.length(); i+=count){
            dat[i / count] = str.substring(i, i + count);
        }

        return dat;
    }
    private static byte[] hex2bytes(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }

    public static String bytes2hex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 2];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = HEX_ARRAY[v >>> 4];
            hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
        }
        return new String(hexChars);
    }

Here is my RawTransactionBuilder class:
import java.math.BigDecimal;
import java.security.Signature;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.util.ArrayList;

import static com.xemplarsoft.Vars.TX_FEE;
import static com.xemplarsoft.libs.crypto.KeyManager.bytes2hex;
import static com.xemplarsoft.libs.crypto.KeyManager.getPubFromPriv;
import static com.xemplarsoft.libs.util.Sha256.hex2bytes;

public class RawTransactionBuilder {
    public static final String VERSION = "01000000";
    public static final String SEQUENCE_NUMBER = "ffffffff";
    public static final String LOCKTIME = "00000000";

    public final int inputCount, outputCount;
    public final RawOutput[] outputs;
    public final RawInput[] inputs;
    public RawTransactionBuilder(ArrayList<UTXO> utxos, String from, String to, BigDecimal amount){
        inputCount = utxos.size();
        outputCount = 2;
        outputs = new RawOutput[outputCount];
        inputs = new RawInput[inputCount];

        BigDecimal total = new BigDecimal(0);
        for(int i = 0; i < utxos.size(); i++){
            UTXO u = utxos.get(i);

            total = total.add(u.getAmount());
            inputs[i] = new RawInput(u.getTxId(), u.getScriptPubKey(), u.getVout());
        }

        BigDecimal change = total.subtract(amount).subtract(TX_FEE);
        outputs[1] = new RawOutput(from, change);
        outputs[0] = new RawOutput(to, amount);
    }

    public String buildUnsignedRawTX(){
        long mills = System.currentTimeMillis();
        String ret = VERSION; // VERSION

        ret += hex2smallEndian(String.format("%1$08x", mills / 1000L)); // TIME
        ret += hex2smallEndian(String.format("%1$02x", inputCount)); // INPUT COUNT

        for(int i = 0; i < inputCount; i++){
            RawInput in = inputs[i];
            ret += in.getPrevTXHexLE(); // INPUT[i] PREV TXID
            ret += in.getPrevOutIndexLE(); //INPUT[i] PREV OUTPUT INDEX
            ret += "00"; //INPUT[i] SCRIPT LENGTH
            ret += SEQUENCE_NUMBER; //INPUT[i] SEQUENCE NUMBER
        }

        ret += hex2smallEndian(String.format("%1$02x", outputCount)); // OUTPUT COUNT

        for(int i = 0; i < outputCount; i++){
            RawOutput out = outputs[i];
            ret += out.getValueHexLE(); // OUTPUT[i] VALUE
            ret += out.getScriptLengthHexLE(); //OUTPUT[i] PUBLIC KEY SCRIPT LENGTH
            ret += out.getScriptPubKey(); //OUTPUT[i] PUBLIC KEY SCRIPT
        }

        return ret += LOCKTIME;
    }

    private String buildSignedRawTX(){
        long mills = System.currentTimeMillis();
        String ret = VERSION; // VERSION

        ret += hex2smallEndian(String.format("%1$08x", mills / 1000L)); // TIME
        ret += hex2smallEndian(String.format("%1$02x", inputCount)); // INPUT COUNT

        for(int i = 0; i < inputCount; i++){
            RawInput in = inputs[i];
            ret += in.getPrevTXHexLE(); // INPUT[i] PREV TXID
            ret += in.getPrevOutIndexLE(); //INPUT[i] PREV OUTPUT INDEX
            ret += in.getScriptSigLength(); //INPUT[i] SCRIPT LENGTH
            ret += in.getScriptSig(); //INPUT[i] SCRIPT SIG
            ret += SEQUENCE_NUMBER; //INPUT[i] SEQUENCE NUMBER
        }

        ret += hex2smallEndian(String.format("%1$02x", outputCount)); // OUTPUT COUNT

        for(int i = 0; i < outputCount; i++){
            RawOutput out = outputs[i];
            ret += out.getValueHexLE(); // OUTPUT[i] VALUE
            ret += out.getScriptLengthHexLE(); //OUTPUT[i] PUBLIC KEY SCRIPT LENGTH
            ret += out.getScriptPubKey(); //OUTPUT[i] PUBLIC KEY SCRIPT
        }

        return ret += LOCKTIME;
    }

    public String buildUnsignedRawTXForSiging(int inputIndex){
        long mills = System.currentTimeMillis();
        String ret = VERSION; // VERSION

        ret += hex2smallEndian(String.format("%1$08x", mills / 1000L)); // TIME
        ret += hex2smallEndian(String.format("%1$02x", inputCount)); // INPUT COUNT

        for(int i = 0; i < inputCount; i++){
            RawInput in = inputs[i];
            ret += in.getPrevTXHexLE(); // INPUT[i] PREV TXID
            ret += in.getPrevOutIndexLE(); //INPUT[i] PREV OUTPUT INDEX
            if(i == inputIndex){
                ret += in.getScriptPubKeyLength(); //INPUT[i] SCRIPT LENGTH
                ret += in.getScriptPubKey(); //INPUT[i] TEMP SCRIPT SIG
            } else {
                ret += "00"; //INPUT[i] SCRIPT LENGTH
            }
            ret += SEQUENCE_NUMBER; //INPUT[i] SEQUENCE NUMBER
        }

        ret += hex2smallEndian(String.format("%1$02x", outputCount)); // OUTPUT COUNT

        for(int i = 0; i < outputCount; i++){
            RawOutput out = outputs[i];
            ret += out.getValueHexLE(); // OUTPUT[i] VALUE
            ret += out.getScriptLengthHexLE(); //OUTPUT[i] PUBLIC KEY SCRIPT LENGTH
            ret += out.getScriptPubKey(); //OUTPUT[i] PUBLIC KEY SCRIPT
        }

        ret += LOCKTIME;
        ret += "01000000";

        return ret;
    }

    public String signTX(ECPrivateKey priv){
        Signature sig = null;
        ECPublicKey pub = null;
        try{
            pub = getPubFromPriv(priv);
            for(int i = 0; i < inputs.length; i++) {
                sig = Signature.getInstance("SHA256withECDSA");
                sig.initSign(priv);
                String hash = hex2smallEndian(bytes2hex(Sha256.getHash(Sha256.getHash(buildUnsignedRawTXForSiging(i)))));
                sig.update(hex2bytes(hash));
                inputs[i].setScriptSig(sig.sign(), pub);
            }
        } catch (Exception e){
            e.printStackTrace();
            return null;
        }

        return buildSignedRawTX();
    }

My RawInput class:
public class RawInput {
    private final String prevTXID, scriptPubKey;
    private final long prevOutIndex;

    private String scriptSig;

    public RawInput(String prevTX, String scriptPubKey, long prevOutIndex){
        this.prevTXID = prevTX;
        this.prevOutIndex = prevOutIndex;
        this.scriptPubKey = scriptPubKey;
    }

    public String getPrevTXHexLE(){
        return hex2smallEndian(prevTXID);
    }

    public String getPrevOutIndexLE(){
        return hex2smallEndian(String.format("%1$08x", prevOutIndex));
    }

    public String getScriptPubKey(){
        System.out.println("Script Pub Key: " + scriptPubKey);
        return scriptPubKey;
    }

    public String getScriptPubKeyLength(){
        return String.format("%1$02x", scriptPubKey.length() / 2);
    }

    public void setScriptSig(byte[] sig, ECPublicKey pub){
        String signature = bytes2hex(sig) + "01";

        ECPoint pt = pub.getW();
        String sx = adjustTo64(pt.getAffineX().toString(16));
        String sy = adjustTo64(pt.getAffineY().toString(16));

        String pubkey = "1E" + sx + sy;

        String sigLength = String.format("%1$02x", signature.length() / 2);
        String pubLength = String.format("%1$02x", pubkey.length() / 2);

        System.out.println("PUBKEY: " + convertPubToAddress(pubkey));

        this.scriptSig = sigLength + signature + pubLength + pubkey;
    }

    public String getScriptSigLength(){
        return String.format("%1$02x", scriptSig.length() / 2);
    }

    public String getScriptSig(){
        return scriptSig;
    }
}

And my payment method group that is called when a payment is requested:
//Payment Method Group
    private String to, from, narration;
    private BigDecimal amt, total;
    public void makePayment(String to, BigDecimal amount, String narration, String from){
        this.to = to;
        this.from = from;
        this.amt = amount;
        this.total = amount.add(TX_FEE);
        this.narration = narration;

        cli.createRawTXList(from);
    }
    private void makePayment(ArrayList<UTXO> utxos){
        if(utxos == null){
            this.to = null;
            this.from = null;
            this.amt = null;
            this.total = null;
            this.narration = null;
            return;
        }

        ArrayList<UTXO> required = new ArrayList<>();
        ArrayList<UTXOverview> requiredOverview = new ArrayList<>();
        BigDecimal soFar = new BigDecimal(0);
        boolean needsMore = true;
        int index = 0;

        while(needsMore){
            UTXO current = utxos.get(index);
            soFar = soFar.add(current.getAmount());
            required.add(current);
            requiredOverview.add(current.asOverview());

            if(soFar.compareTo(total) >= 0){
                needsMore = false;
            }
            index++;

            if(index >= utxos.size()) needsMore = false;
        }

        String WIF = "EXAMPLE_PRIV_KEY";
        ECPrivateKey priv = convertWIFtoECPrivateKey(WIF);
        System.out.println("WIF: " + convertPrivToWIF(adjustTo64(priv.getS().toString(16)).toUpperCase()));

        RawTransactionBuilder raw = new RawTransactionBuilder(required, from, to, amt);
        System.out.println("RAWTXBUILDER unsigned: " + raw.buildUnsignedRawTX());
        System.out.println("RAWTXBUILDER txid: " + bytes2hex(Sha256.getHash(Sha256.getHash(raw.buildUnsignedRawTX()))));
        try {
            System.out.println("RAWTXBUILDER signed: " + raw.signTX(priv));
        } catch (Exception e){
            e.printStackTrace();
        }
        this.to = null;
        this.amt = null;
        this.total = null;
        this.narration = null;
    }

My problem is that whenever I run the above code, with sendrawtransaction I get TX rejected (code -22) which poins to an error of some sort. I've tried flipping the transaction hash to little endian, and leaving it as it generates. Signing the hash as a raw hex string and as raw bytes. I know that my convert functions work as I have verified that the proper WIF and Address are recreated. I'm not sure where my issue is.

Just to be clear, I do not want to use BitcoinJ. I've followed a tutorial from https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required


text:
Bitcoin consensus and server of miners
I know consensus is what 51% thinking.My questions is where miners communicated?On what server,what port??Where??The must push own api (copy of blocks) for thinking of consensus.So where BTC miners pushing api,for where blockchain explorer used it,where?

The Bitcoin Network is a P2P network made up of independently operating nodes from all over the world. Miners will connect to this network in order to maintain a view of the network's state, which is crucial to their participation as a miner.
By connecting to the network, a node (and/or miner) will receive and relay information from its peers, about new transactions and blocks. Nodes communicate using TCP, and the standard port is 8333. For a deeper dive into the specifics of the gossip protocol, see this question.

Thanx.That's help me,because i dont understand P2P network,for comunicate they must have some server,some http or https address where they can use info(broadcast),and where they can push info to other nodes/miners.

The must push own api (copy of blocks) for thinking of consensus

If I understand your question correctly, you are looking for an API specifically for managing consensus.
I believe consensus is a kind of emergent property that arises naturally from the ordinary communication between Bitcoin nodes, the sharing of blocks of data.
It is intentional that consensus arise but so far as I know, there is not a specific separate consensus protocol whose job is only to create consensus.
Consensus means that virtually all Bitcoin nodes have the same data, the same view of which blocks are valid. This arises because they all apply the same rules concerning block validity and they all actively share information about blocks they know of.
There is no API for consensus specifically. The API needed for obtaining new blocks in order to find out receipt of payments etc is also sufficient for a node to compare its own copy of the blockchain with another's (or to compare several other nodes' copies with each other). The node can then apply standard rules about which blocks to save and which to discard.
It probably does require some careful thought to design a data sharing protocol in which the accumulation of data at nodes acts in a convergent rather than divergent fashion. It evidently does not need a separate "consensus" API.


text:
Electrum address syncronization
I need to periodically check the balance of a number of bitcoin addresses (a few tens or hundreds addresses).
I noticed that Electrum may syncronize a thousand or more imported addresses in a matter of a few seconds. But I failed to realise how it is done searching through Electrum source code.
Which methods it uses? Does it really import all these addresses into currently connected remote node and then calls listunspent no matter how many addresses I insert into the wallet?
Can you please point me to a code snippet that implements such funtionality

Electrum wallet requires a special Electrum compatible server where it can query the data needed.
There are now several implementations eg:

https://github.com/spesmilo/electrum-server
https://github.com/chris-belcher/electrum-personal-server
https://github.com/kyuupichan/electrumx

...code snippet that implements such funtionality

https://github.com/spesmilo/electrum-server/blob/ce1b11d7f5f7a70a3b6cc7ec1d3e552436e54ffe/src/storage.py#L286

I just wonder if I can connect to one of those electrumx from my app, in other words to simulate electrum client in order to synchronise addresses?

Should be possible, yes.  Just study the API.

@vistore Does this answer your question?  If so, please accept the answer.


text:
Learning to trade iOS user friendly crypto wallet safety when stored in and transfer for trading or use to purchase or get cashed
iPhone users best crypto wallet in bitcoin currency trading and transfer for easy access to use and keep safe deposit and profits as a new and first time trading experience  to the trading crypto currency and forex markets and stock exchange

I’m trying to get my money back from a brokerage account which I used my debit card to purchase bitcoin for first deposit to open my trading account, and then I was told to buy as much bitcoin as I can and I wanna understand how I can buy bitcoin currency with bitcoin currency and because it’s a brokerage company does that mean I have a wallet already or not? Because they want me to get a wallet so they can return my money back in bitcoin currency and then close my account.  What should I do with this situation please help me

Choose a wallet program/app from a reputable list such as https://bitcoin.org/en/choose-your-wallet
Install that wallet program/app on a secure clean PC or phone (as appropriate)
Get the wallet to give you a receive address (nowadays wallets issue a different address each time)
Get your brokerage to transfer money to that address
Get them to tell you the transaction-ID and check that in a bitcoin explorer

I was told to buy as much bitcoin as I can

That's a bit of a red flag.

I wanna understand how I can buy bitcoin currency with bitcoin currency

That doesn't make sense. Its like buying dollars with dollars. No one does that. Unless some of those dollars are fake dollars or hot dollars. See Fungibility
You can transfer money from one wallet to another. In your case that might be transferring money from your broker's wallet to your wallet.
It can be confusing because some exchanges/brokers etc label an account a "wallet" when it isn't (a wallet holds a private key that only you know, this isn't the way most exchange/broker accounts work, they hold the keys not you)

first time trading experience to the trading crypto currency and forex markets and stock exchange

Just remember you are jumping into a pool of very hungry, very experienced, well equipped sharks. Don't "invest" any money you would not be happy to lose.


text:
Withdrawal process
My broker asked Me to pay verification fee which is $670 and provide my  ID I wanna ask is it legit to do that ? I invested 350 and earned $12000k

This sounds like a scam

How precisely do you know that you earned that amount? Be as precise as you can. Did you independently confirm that your trades were profitable? Are you taking the broker's word for it?

Who said you earned 12000k from 350 ? if it is just written on a website maybe it is fake, also there is no need for verification fee and ID in the bitcoin network, if you send him coins using bitcoin, you no longer own them, and there is no support service to retrieve them for you, be careful of scam.


text:
How to implement getrawmempool?
I’m trying to get all transaction ids in the memory pool as json array. I just finish downloading bitcoin core and do now know where to begin. Any help would be appreciated!!

You can use the command bitcoin-cli getrawmempool to get a JSON array of all transactions that are stored locally in your mempool.
Since v0.9 release you can also pass a verbose boolean to get more info related to the transactions in your mempool like size, fees, or ancestor/dependent transaction within the mempool.
Do note that there is no one global copy of the mempool. The mempool is node dependent and stores valid transactions that your node has seen but has not yet been confirmed in the block. Since you have just downloaded and spun up your Bitcoin Core node, your mempool information might be limited when you compare it to nodes that have been running for days.

How to get asm instruction for a transaction in mempool? Because getrawmempool doesn't include it, even with verbose.


text:
bitcoind rpc interface, generate method deprecated in version 0.19.0 (latest)
How to generate a block in the new version of bitcoind.

bitcoin-cli -regtest generate 1

The above command no longer works with the latest bitcoind package
I want to confirm a transaction I have executed under the regtest mode for bitcoind, hence generating a block to confirm the tx.

generate was deprecated and removed in favor of generatetoaddress.


text:
Wallet Recovery with Bip39 Seed
From having a list of bip39 seeds, is there any way of recovering a wallet?  In particular, I have a list of ~100 seeds--one of which is mine--and need an automate way of figuring out which is valid and has my funds.
Thanks

There are a few things to consider here.
First, do you know the path of the HD wallet? You can find out what type of path structure your wallet is using, and if the address with the unspent transactions was the very first one, then it would be account 0, for example.
See this on BIP44 paths...
If you know the path structure, and you know the exact address you are looking for at a given path, then you could do something like this using bitcoinjs-lib:
const bip39 = require("bip39")
const bitcoin = require("bitcoinjs-lib")

const network = bitcoin.networks.bitcoin

for (const phrase of phrases) {
    const seed = await bip39.mnemonicToSeed(phrase)
    const root = bitcoin.bip32.fromSeed(seed, network)
    const path = "m/44'/0'/0'/0"
    const child = root.derivePath(path)
    const { address } = bitcoin.payments.p2sh({
        redeem: bitcoin.payments.p2wpkh({
            pubkey: child.publicKey,
            network
        }),
        network
    })

    if (address === '3...') {
        //this is yours
    }
}

Note that this example is for P2WPKH wrapped addresses (3 prefix). You would need to change this a bit depending on the type of address you are trying to match.

Hi Michael, unfortunately I do not have the path of the HD wallet.  I have a list of seeds (and thus can derive the master public key) and was thinking of scanning the blockchain (blockchain.com) using the master public key to see the funds in the wallet.  I do know how many bitcoins I have in that account.  Do you have any other suggestions on how to do this without the path? I can always derive addresses but that will take very long.

@SameerLal indeed! You can obtain the xpubs from the list of seeds you have by looping through them as I have shown above, and then check on https://www.blockchain.com/btc/xpub/<xpub_address> to see if you've found your match.

thank you!  This works well.  Sorry for so many questions, but do you happen to know of a python module or any code that'll allow me to derive the xpub address from bip39 seed without having to do any heavy lifting? just trying to save time.

Sure no problem. Is python your preference? The snippet I posted above uses bitcoinjs-lib which is pretty well maintained and easy to use, but if node/JavaScript isn’t your thing I can help you achieve this with a python library as well.

Yeah I'd prefer python because I already have a (fairly long) script I wrote in python for other parts.  If you do not know of any other alternatives, no worries, I can spend some time trying to pythonify the code you wrote.

This looks promising: https://github.com/ranaroussi/pywallet/blob/master/README.rst except in your case you’ll want to provide your mnemonics from a list rather than using the generate() method.

this looks interesting, except I think in the readme it is creating a wallet derived from the phrase.  the xpub key in the json is different than the one I see on Ian's site: https://iancoleman.io/bip39/.  I'm actually not sure why this is the case, any ideas?

I am thinking of something like this:
`for seed in checksum_candidates:
w = wallet.create_wallet(network="BTC", seed=seed)

xpubkey = w['xpublic_key']

url = f'https://blockchain.info/multiaddr?active={xpubkey}'

time.sleep(1)

r = requests.get(url = url, verify=False)

response_dict = json.loads(r.text)

print(response_dict['wallet']['final_balance']) `

but am worried this method might not work for some reason since i'm getting a balance of 0 for all of my candidate seeds (false negatives?)

It seems the python lib uses the path m/44'/0'/0'/ while Ian’s site uses m/44'/0'/0/ without the last ’. But the path would only affect the derived addresses, not the root xpub. Are you using the root xpub to query the transaction histories?


text:
find bip32 seed from transaction
Based on my bip32 word list, I have a list of about 100k seed phrases that pass checksum and am trying to figure out my actual seed.
Earlier, I was derivign the xpub key and searching the blockchain for the final balance, but now, i have a transaction address.  I was wondering if there's an easier way for me to determine my actual seed using this new information.

What exactly do you have and where did you get it? Are you missing one or two words from a wallet seed? Or you forgot what order they go in? The question is a little ambiguous. Typically there is no way "find a seed". It is generated once and must be kept safe.

@pinhead Essentially, I have the 24 word list but about 6 words are written really sloppily and it's hard to decipher.  So I have a program which tests out combinations for each missing word, so in total there are approx ~100k seeds and then ~9k that pass checksum.  I need to know how do you check the balance of a seed if you have a wallet address from a previous transaction

Yikes. Well brute force may be your only hope. Derive addresses from each possible seed and check the Blockchain. We wouldn't want it to work any other way, that'd be a security failure.

@pinhead yes, but like I'm not exactly sure if the address that I derive wil lbe the same as the transaction I have a log of?  I guess I'm not sure if the python packages I'm using will guarantee that I find it, provided the correct seed is amongst my list

yeah this is an issue with bip39 in general. You also need to know which wallet generated the seed and which bip32 path was used to generate the addresses you received bitcoins at.

You first need to think back and try to remember what wallet you used to generate this seed phrase with. It may not even be a BIP39 mnemonic even though it uses the same wordlist.

it's on a nano ledger s

is there no way to derive the xpub key from the seed and search the blockchain using that??


text:
How to display Recipient Address, Change Address & Transaction Amount
I have made A software in which i can Signed Transaction (From Electrum Un-Signed Transaction HEX), i just want to display the following thing to USER in Readable Mode :
1. Recipient Address
2. Change Address
3. Transaction Amount
How can i show this to USER to readable form so that user verify the Transaction before going broadcast.
Thanks,
Amish Sharma

This is not possible. Just a raw transaction does not contain this information.

Just go to BTC explorer any search in google
example:
https://www.blockchain.com/explorer
type your wallet adress or transaction ID
And check.

I am developing a Desktop App, so need to calculate by my own / by hand /by code....

Do we have any procedure to get all of these value ?


text:
How to withdraw or transfer to bank account
I have bitcoin and i want to sell or withdraw to get the amount to Indian bank or Paypal. Is there any way to get the equal amount for bitcoin. If yes and how?

Bitcoin is not tied to bank accounts but instead lives on a distributed ledger known as a blockchain. This ledger is verified and stored by thousands of nodes across the world. Selling and buying bitcoin is not part of the protocol for Bitcoin, and instead is bought and sold on Exchange services such as Coinbase, Kraken, Gemini, etc. or Peer-to-Peer/Face-to-Face. Bitcoin is exchanged for fiat, not converted. When you sell bitcoin, someone is buying that bitcoin for fiat.
You will need to research and find an exchange that will allow you to sell bitcoin for your native country's fiat currency. Then you can withdraw said fiat into your bank account.

I tried with the coinbase. when i click on link account. I cant link the account. https://imgur.com/a/ZR2IWJ1

@atek Your issue is related to Coinbase and their banking services. This may be due to your region or some other factor prohibiting Coinbase - the company - from providing service to you. You may also experience problems due to your browser, in which case try clearing the cache, disabling cookie/tracking blockers, or using a VPN. Check the terms of service of the exchange, of course.

i tried with the android app also same result

Are you aware of or have you tried the distributed exchange called Bisq?
Odds are high you can make a connection with somebody there and work out an
arrangement for either scenario you expressed an interest in.


text:
Implementation of BIP39, I want to generate a BIP39 512-bits seed from 12 mnemonics but failed
I have a question.
I used the website (https://www.mobilefish.com/download/ethereum/bip39.html) to generate a 12-words mnemonic(English word list) without password and got below:
"organ rate senior panel first task siren room deer excite bachelor project"
And the 512-bits seed is like:
"53329c51c9416d4d2fe46ecd8edab1c9a5289b3366c98bb6ee843e7bd4242ee46b6be686aef697d23278062d8c033cf2788df96cc4f24375682f36eb9a66996d"
However, I tried to generate 512-bits seed by myself but failed.
I used online PBKDF2 SHA-512 Hashes: https://stuff.birkenstab.de/pbkdf2/
And entered like below but got wrong result.
Message: organrateseniorpanelfirsttasksirenroomdeerexcitebachelorproject
Salt: mnemonic
Iterations: 2048
Key length: 64
What I got is: 559c3427c333595e3ef78cc19d7f412452a763a09b66c8c7da2b49ecf12cd5d51ae7cb9bffe9d33ca358a421e984b626053192eea36ba909d307df0fa9ceda60
Please help to answer it....
Thanks!

I see your question was answered and you got it working, but for those who may see this question later on I would like to point out that the Message in the PBKDF2 function is the Mnemonic Words separated by spaces, not concatenated one after the other.

Just as a side note: What you get from 12 words is a seed of 512 bit length because it was stretched with PBKDF2. The entropy is only 128 bit with 12 words (each word represents 11 bits of information ~= 132 bit with 4 bit checksum).
If you look at a library like https://github.com/bitcoinjs/bip39/blob/master/src/index.js for example, you see that the spaces between the words aren't removed. If you paste the original words into the PBKDF2 tool you get the correct seed.

Thanks for your reply!
However, I don't think you have answered my question.
In BIP32:
To create a binary seed from the mnemonic, we use the PBKDF2 function with a mnemonic sentence (in UTF-8 NFKD) used as the password and the string "mnemonic" + passphrase (again in UTF-8 NFKD) used as the salt. The iteration count is set to 2048 and HMAC-SHA512 is used as the pseudo-random function. The length of the derived key is 512 bits (= 64 bytes).
It indicates that using mnemonic sentense as the password and string "mnemonic" + passphrase as the salt.

In point 3, I still can't generate the right 512-bits seed out with "9c76470ecfc577bc325ddf3949d844d6".

Sorry, you are right. What I described was BIP32 (which does use HMAC-SHA512). I forgot that BIP39 also does key stretching already. I edited my answer.


text:
Receiving transactions in prune mode
I am new to Bitcoin.  I have downloaded the whole blockchain but I still can't access my wallets because I get a popup telling me to use prune mode.  My question is: I know that I have received transactions that I have not yet seen in my wallet.  If I run prune mode, will I lose those deposits since they are not yet in my wallet?

I am new to Bitcoin.

Welcome !

I have downloaded the whole blockchain but I still can't access my wallets because I get a popup telling me to use prune mode.

You might not have enough disk space (hence why you're not able to see your funds).

If I run prune mode, will I lose those deposits since they are not yet in my wallet?

No, not at all.
By using prune mode you'll be able to fully sync to the tip (current last block of the chain) and thus see your funds, which you apparently cannot without prune mode because of your disk space.


text:
How do I find the wallet that Bitcoin was sent to?
How do I find the wallet that Bitcoin was sent to?  I was new to Bitcoin and created at wallets in at least 2 places (Armory and Coinbase) but all are showing zero.

Why do you think bitcoin was sent to a wallet exactly? What information do you have?

You need to know one of two things

the sending address, or
the transaction id

You can put either of these into any blockchain explorer and find out the receiving addresses.
Once you know the receiving addresses you can open each of your wallets, ask the wallet to display all the receiving addresses it has previously generated. Don't ask the wallet to generate a new receiving address - that will just make it create a new address. There will be a less obvious option in a menu that will show all addresses used so far.
Once you have the list of addresses in each wallet you can find if any of them match any of the receiving addresses from the transaction shown in the blockchain explorer.

There is no way for anyone else to find out which non-custodial wallets (the best sort) contain an address - that information is not public.
If you have a custodial wallet - you can ask the custodian for help. For example, if you have a coinbase account, you could ask coinbase customer support for help.

If you know the public address that it came from, you can check the block explorer for the most recent transaction.


text:
How do miners communicate in Bitcoin/ Decentralized Network?
1.)If there is no central authority maintaining database how miners differentiate among other miners.
2.)Do they have there own database which have details(Mac/IP address) of neighbouring miners .
3.)Decentralized system feels absurd when i was trying to create blueprint where i was thinking to create a downloadable executable program ( socket programming for intercommunication) but i got struck how would communication take place b/w miners,user.
4.)Can you give me a little insight that if i want to run any consensus program on 10 computers connected to internet how would it work .

Bitcoin is a gossiping network. There is no hierarchy among the nodes, each node operates at equal privilege level. Bitcoin has an established protocol defining how nodes communicate with each other, and some stepping stones to find the first peers (although they could easily be replaced by other on-boarding mechanisms).
Whenever a node learns new data on the Bitcoin network, it gossips to its peers about that data. As every node connects to multiple peers, the information will generally reach every participant eventually.
Block data has special propagation guarantees: the blockchain ensures that the whole network converges on a shared ground-truth regarding the network state and new blocks are relayed with priority.
Some nodes that are otherwise indistinguishable from other participants use the transaction data they collected from the gossip network to author new blocks. Some of the so-called "miners" run additional communication protocols to expedite communication between each other, but this is not required.

If a new miner enters the blockchain what steps would he take to find neighbouring nodes .Can you  name all protocols chronologically . Thanks in advance .

@SiddharthTeli I think you mean "new miners enter the 'network'". You can look at this well written answer to see how Bitcoin full nodes find each other. In a nutshell they use past peer history, DNS seeds or hard coded IP addresses. Miners also use an additional communication network called FIBRE to relay blocks between one another at a really fast speed.