text:
Using sendtoaddress is failing using json-rpc and I don't know why
The steps i followed are i first load the wallet in a different method which works, then i check the balance of the wallet in a different method which works, and then I call this sendbitcoin method(below).  I can see that the bitcoind server gets the message but it returns with a 500.
If i use bitcoin-cli it works however i need to add a -rpcwallet flag.  It's my understanding that since the wallet has been loaded i shouldn't need to use flag.  My wallets aren't encrypted so i don't believe i need to use a passphrase.
My bitcoin.conf file looks like this.
rpcuser=rpcuser
rpcpassword=rpcpassword
testnet=1
prune=550
server=1
dbcache=1000
[test]
debug=mempool
debug=rpc
dbcache=1000
rpcport=8332
rpcbind=0.0.0.0
rpcallowip=172.19.0.0/16
minconf=1
fallbackfee=0.00000001

And the method looks like.
func (w *Wallet) SendBitcoin(sendTo string, amount float64, coachID uint) (BitcoinTransaction, error) {

username := os.Getenv("RPC_USER")
password := os.Getenv("RPC_PASSWORD")
rpcURL := os.Getenv("BITCOIN_NODE_HOST")

if username == "" || password == "" || rpcURL == "" {
    log.Error("RPC_USER, RPC_PASSWORD, or BITCOIN_NODE_HOST environment variables are not set")
    return BitcoinTransaction{}, errors.New("RPC_USER, RPC_PASSWORD, or BITCOIN_NODE_HOST environment variables are not set")
}

// Prepare the RPC request payload
requestBody := map[string]interface{}{
    "jsonrpc": "1.0",
    "method":  "sendtoaddress",
    "params":  []interface{}{sendTo, amount},
    "id":      1,
}

logrus.Printf("request body : %v", requestBody)
logrus.Printf("Sending on wallet %v", w.Name)

jsonData, err := json.Marshal(requestBody)
if err != nil {
    log.Errorf("failed to marshal JSON request: %v", err)
    return BitcoinTransaction{}, fmt.Errorf("failed to marshal JSON request: %v", err)
}

logrus.Printf("JSON body : %v", jsonData)

client := &http.Client{}

req, err := http.NewRequest("POST", rpcURL, bytes.NewBuffer(jsonData))
if err != nil {
    log.Errorf("failed to create HTTP request: %v", err)
    return BitcoinTransaction{}, fmt.Errorf("failed to create HTTP request: %v", err)
}

req.SetBasicAuth(username, password)
req.Header.Set("Content-Type", "application/json")

// Send HTTP request
resp, err := client.Do(req)
if err != nil {
    log.Errorf("failed to send HTTP request: %v", err)
    return BitcoinTransaction{}, fmt.Errorf("failed to send HTTP request: %v", err)
}
//...

logs
[00] bitcoin      | 2024-02-22T22:36:59Z [rpc] ThreadRPCServer
 method=loadwallet user=rpcuser
[00] rest-server  | time="2024-02-22T22:36:59Z" level=info msg="balance
= 0.0003933699999999999, amount = 0.0001"
[00] bitcoin      | 2024-02-22T22:36:59Z Using SQLite Version 3.38.5
[00] bitcoin      | 2024-02-22T22:36:59Z Using wallet
 /home/bitcoin/.bitcoin/testnet3/wallets/111-20240221
[00] bitcoin      | 2024-02-22T22:36:59Z [rpc] ThreadRPCServer
method=sendtoaddress user=rpcuser
[00] rest-server  | time="2024-02-22T22:36:59Z" level=info msg="request
 body : map[id:1 jsonrpc:1.0 method:sendtoaddress params:
[tb1qljunwv4hv8nx3mwsrup4fse5zhahyjtmx0fwzl 0.0001 ]]"
[00] rest-server  | time="2024-02-22T22:37:00Z" level=info
msg="unexpected status code: 500"

Can you see the error message from the Bitcoin Core debug.log? Log file can be found in your Bitcoin datadir, for example in Linux the testnet logs are in ~/.bitcoin/testnet/debug.log

From the provided logs, it seems that your code is reaching the point where it sends the sendtoaddress RPC request to the Bitcoin node. However, the issue might be related to the response handling part of your code, which is not included in the snippet you provided.
You should continue the logs and inspect the response received from the Bitcoin node. Check the status code, and if it's not in the 2xx range, it could indicate an issue with the request. Additionally, parse and analyze the response body to get more information about the problem.
Here are a few steps to help you debug:
After resp, err := client.Do(req), check the HTTP status code:
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
log.Errorf("Non-successful HTTP response: %v", resp.Status)
// Handle the error appropriately
}
Read and parse the response body:
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Errorf("Failed to read response body: %v", err)
// Handle the error appropriately
}
log.Printf("Response Body: %s", body)
This should give you more information about what might be going wrong with the sendtoaddress RPC call. Keep an eye out for any error messages or additional details in the response body that can help diagnose the issue.


text:
Preparing a transaction with many outpts
What would be the exact command to prepare a transaction with multiple outputs, to a specific address?
I'm able to list all my outputs with lightning-cli listfunds, but I'm not sure how to include them all in a transaction with txprepare, so I can submit the transaction later.
If possible I would also like to set the fee as low as possible, i.e. 1 sat/b or lower.

Am I understanding right that you want to use multiple UTXOs in inputs and send to a single output?

That's exactly right. The help of lightning-cli suggests txprepare outputs [feerate] [minconf] [utxos] but I'm not completely sure how to specify several outputs. Also, the feerate will be per b or kw?

source: Stack Exchange

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

sort: votes


text:
Difference between createmultisig and addmultisigaddress on v 0.20.0?
What is difference between createmultisig and addmultisigaddress? I ran 2 methods for 2 same bitcoin address on bitcoin-cli but gives different addresses as multisig to me. the results are as follows:
>  bitcoin-cli -testnet createmultisig 2 "[\"03f47a5115cd9e5e21b94136db90e2e3d6ac7e40396d8e62f73df3fd3fcfb3f214\",\"0395ad430034c1761bbe9b4dfd784fb06229970d54016a7e090fc6ceb3814611b5\"]"
RESULT:
{
  "address": "**2Mt1jgrBoojAHbJS5zGJTZnx4TFktUCCNxu**",
  "redeemScript": "522103f47a5115cd9e5e21b94136db90e2e3d6ac7e40396d8e62f73df3fd3fcfb3f214210395ad430034c1761bbe9b4dfd784fb06229970d54016a7e090fc6ceb3814611b552ae",
  "descriptor": "sh(multi(2,03f47a5115cd9e5e21b94136db90e2e3d6ac7e40396d8e62f73df3fd3fcfb3f214,0395ad430034c1761bbe9b4dfd784fb06229970d54016a7e090fc6ceb3814611b5))#6nexfs8d"
} ```

> bitcoin-cli -testnet addmultisigaddress 2 "[\"2NEy9um4CpWerPeaEhPa3TckNYWnh58yDXN\",\"2Mxr2oaph8iapbnbL1MSEvfZH8EQaXYuhAy\"]"

RESULT:
 {
  "address": "**tb1qjyvx2kwl4kq2cypj5zawhw5gpwxmphxe487z3hxj9m36ux8tylpszpazsu**",
  "redeemScript": "522103f47a5115cd9e5e21b94136db90e2e3d6ac7e40396d8e62f73df3fd3fcfb3f214210395ad430034c1761bbe9b4dfd784fb06229970d54016a7e090fc6ceb3814611b552ae",
  "descriptor": "wsh(multi(2,[a025344d/0'/0'/0']03f47a5115cd9e5e21b94136db90e2e3d6ac7e40396d8e62f73df3fd3fcfb3f214,[a025344d/0'/0'/1']0395ad430034c1761bbe9b4dfd784fb06229970d54016a7e090fc6ceb3814611b5))#gmdd9d2p"
}

why those addresses is different?
thank you

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


text:
bitcoin-cli generatetoaddress <numberofblocks> <address> has 2 outputs
I have the following problem:
currently i am testing in my local regtest
I generated the following cb-tx for block at height 119: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03027700ffffffff0158bf122a010000001976a914a08da9e35ab58e957204703da9d48967ddd1703b88ac00000000
there are some tx in the mempool
for the other tx i take the txid from the getblocktemplate request
I reverse the byte order for all of those and for the txid of the cbtx aswell.
still, i get the following error: bad-txnmrklroot
when i generate a block using generatetoaddress in regtest, then use getblock and run my merkle function over the txids, the merkle root is correct which means it is a issue with the coinbase txid
i realized that the coinbase tx from the generatetoaddress rpc call has a second output with 0 satoshis.
is it possible to remove this second output so i can test further?
maybe someone had the same issue.
thanks in advance.

Not including the second output would result in a different failure, although it is likely that that check has not been performed yet. The inclusion of that output is necessary if your block contains segwit transactions. That output has an OP_RETURN script that contains the witness merkle root - a merkle root over the wtxids of all of the transactions in the block.
However the specific error bad-txnmrklroot refers to just the normal merkle root being incorrect. It suggests that your code for generating the merkle root is simply incorrect.

my merkle root is correct (following txids to merkle:)
"594965c2bee7f6c939a6169147e4ed4c34a2a0b0776d03264e9532d51692d4e6", "cbc45f050ec7f2b5f9b08c2c280046bbc9f7e2ac1e5e0a2f8d734a0f19d4f918", "dde614820003084cc76b039978ecf29b91fe0edc9f1f766ad229ed94f2358d51", "370e8307db3990b089269b40afcdc55597e49577a0ff5eee715f343cb11ea45a", "404c3ef9fcab48d3d6ec39f66c991d4554b34477eab2e68a8ef26a40c63caf8e", "0c821f76d1003204a2415fa8d0b75d5da97e04d60c5d759c10db8f66dc78edbb"
I got the correct merkle root (88657de90640e52883dc88f8cadef1da6cea08cb377787f537e47c821512918e), so my code seems to be correct

What makes you think that it is correct? Can you post the code that you used to generate it?

i generated the block with the generatetoaddress method since i wanted to compare txids and merkle root.
the above txids are from the block, as is the merkle root
I tested my merkle code with the txids and got the correct merkle root

Then you're probably calculating the txid of your coinbase incorrectly.

when i only have a coinbase tx in the block it submits, which means the coinbase txid is theoretically correct, right?

Yes. A block with just the coinbase has the merkle root as just the coinbase txid.


text:
bitcoin rpc submitblock merkle root + raw tx (bad-txnmrklroot)
I wanted to test the submitblock rpc call in regtest but I seem to have some issues with the transactions I try to submit.
I have the following raw transactions:
02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03016900ffffffff0158660c2a010000001976a914a08da9e35ab58e957204703da9d48967ddd1703b88ac00000000 (coinbase tx)
02000000000101bd04d336a75e3f4cbf2bf249f529afd9d7740e0836be8384d2a392ddca161ecc0100000000fdffffff0240420f0000000000160014bf67ccfbc8e589a2192a74d2e16bc074889b425bf00ed305000000001600149f5283153368455efcd8a24faa97acb1a2c7f616024730440220249d8bcb08b183c15db2a03bcf2abde3d3e09e0d08a6f029fde2725a800de2a202201902749176353383ea8a78afa1080a84dd311453c3ebd95601c09db721cc9c250121024b162d93981a3e60448bbe4efcf57721f1e443ef280933ae7d20e90e612f5d4468000000 (tx1)
020000000001010453faefcc8f26e4734e965e3619deab009f6e4faa2971c34be334e28c67f2650000000000fdffffff0240420f00000000001600141b08d84ee1d89a0b682020d619653613737cb64cf01fe32901000000160014fe841631fe5df0584d22bdc6580c6127d25d25b302473044022073a8008fdef43bc637675114f760689439c4b94a9e59a73fe53919a6f3d4c4a302201f787059a139a6b80eceb02c49ee70ac552d3ca5713ea2c33dcfdceb38cc2850012103c7df223ee6eb22b9f183e807fc0fa3b672f62e9fc2a6316b0ca8fca24d907c7f68000000 (tx2)
02000000000101d43c09b3878100668c3c0f9bac461b092378b47deb989c819dc3f1c0cca4095f0100000000fdffffff022818eb230100000016001420184bf7efc25f9a1ecf99a9c532f5e2c93cdd1340420f000000000016001454e45729918ad5a7fa1130b0be47e6b5cfab16e20247304402200d06ed77a7b20419988d62760ee1aa2bccda92a22ddfbdd16f96319cc7862695022022730ff785e033ecfc5ffb57b6258368aba7896d9414e66c6932e4841033de40012103656e09a3a63bf08aa0ab9177edff3f87d0dbc95dd2f76fbc9ebb5f2323e8036f11000000 (tx3)
I calculated the txids for all of these tx (byte order already reversed):
6c13bf0a4bf648312d82fa454b2f4ad9a4ead32a805009d5949f981c4cf3bd3b (coinbase txid)
0773014af32002fcf11a603aa2c19503e36cb9ca87c6a8c7a8b7c7a1b7a38b11 (txid 1)
143b545dd5809658cf082cd03cb1e9e7645d95afd54d79b71c93e3d4431c46e6 (txid 2)
85e8dfe954afa4139c893dfda796d57700b059595a7986bc906637167de49060 (txid 3)
when put in order, I get the following merkle root:
5e76726c3a221c7ef39bbbc6d0ca57dd85d320ac13dda01994c517b7c2fc1385
I submit the block via submitblock. from the merkle root on it looks like this:
5e76726c3a221c7ef39bbbc6d0ca57dd85d320ac13dda01994c517b7c2fc1385c03d2465ffff7f20020000000402000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03016900ffffffff0158660c2a010000001976a914a08da9e35ab58e957204703da9d48967ddd1703b88ac0000000002000000000101bd04d336a75e3f4cbf2bf249f529afd9d7740e0836be8384d2a392ddca161ecc0100000000fdffffff0240420f0000000000160014bf67ccfbc8e589a2192a74d2e16bc074889b425bf00ed305000000001600149f5283153368455efcd8a24faa97acb1a2c7f616024730440220249d8bcb08b183c15db2a03bcf2abde3d3e09e0d08a6f029fde2725a800de2a202201902749176353383ea8a78afa1080a84dd311453c3ebd95601c09db721cc9c250121024b162d93981a3e60448bbe4efcf57721f1e443ef280933ae7d20e90e612f5d4468000000020000000001010453faefcc8f26e4734e965e3619deab009f6e4faa2971c34be334e28c67f2650000000000fdffffff0240420f00000000001600141b08d84ee1d89a0b682020d619653613737cb64cf01fe32901000000160014fe841631fe5df0584d22bdc6580c6127d25d25b302473044022073a8008fdef43bc637675114f760689439c4b94a9e59a73fe53919a6f3d4c4a302201f787059a139a6b80eceb02c49ee70ac552d3ca5713ea2c33dcfdceb38cc2850012103c7df223ee6eb22b9f183e807fc0fa3b672f62e9fc2a6316b0ca8fca24d907c7f6800000002000000000101d43c09b3878100668c3c0f9bac461b092378b47deb989c819dc3f1c0cca4095f0100000000fdffffff022818eb230100000016001420184bf7efc25f9a1ecf99a9c532f5e2c93cdd1340420f000000000016001454e45729918ad5a7fa1130b0be47e6b5cfab16e20247304402200d06ed77a7b20419988d62760ee1aa2bccda92a22ddfbdd16f96319cc7862695022022730ff785e033ecfc5ffb57b6258368aba7896d9414e66c6932e4841033de40012103656e09a3a63bf08aa0ab9177edff3f87d0dbc95dd2f76fbc9ebb5f2323e8036f11000000
still, I get the following error: bad-txnmrklroot
do I miss something obvious here or is it a little more complicated?
thanks in advance

I have not verified your calculations, but you should know that you shouldn't do any byte-swapping at all, anywhere, except for display (human) purposes. At the protocol level, you take the 32 bytes that come out of (double) SHA256, concatenate those 32 bytes literally with another hash to provide the input for a Merkle hashing step, and the 32-byte result of those hashes is placed literally, without any swapping, into the 80-byte block header.

For each of your non-coinbase transactions, you have posted the byte order expected for the merkle computation. However you have the reverse byte order for your coinbase transaction. I believe you are incorrectly reversing that.
Additionally, the merkle root you have posted is also the reverse byte order of the actual merkle root. This should not be reversed.


text:
bitcoin block chain - database - how to request / how to get status of an object? [NOOB]
I wonder about the bitcoin and blockchain. I think I have understand the purpose of a blockchain. (security/decentralisation)
Ok we save transaction on blocks validate thanks to the proof of work.
But what I did not understand, how to get information from the blockChain. As for example to know "How mush Bitcoin Alice has ?"
Do we have to search all transactions of Alice saved on blocks and to calculate her balance ? Or is any other way (or something I have misandertood)
I know that there are tools to know the balance of an adress. But my question is how this tools works ? How they request the blockchain ?
Linking subject : What I understood is that we could save not only transaction in the bitcoin blockchain (or in the ethereum) There are dapps that use blockchain as ethereum to save there data. It is not a problem that to save many heterogeneous datas from differents dApps, mixing with transactions ?

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.

Do we have to search all transactions of Alice saved on blocks and to calculate her balance

Nobody other than Alice cares about her balance. That's because Bitcoin is cash, not a bank account. When you hand over a $10 banknote to a shopkeeper, they don't want to know how much total cash you have in your wallet, they just look at the $10 to see if it is genuine. Bitcoin does not keep track of balance per account holder - there are no accounts, no people, no balances in the Bitcoin network or blockchain.
Bitcoin works on the basis of keeping track of Unspent Transaction Outputs (UTXOs). A UTXO is roughly equivalent to a banknote or coin. When someone spends a UTXO, all other nodes check that the UTXO exists and hasn't been spent already.
You can create a list of UTXOs by reading the blockchain from the start once.
A Bitcoin wallet such as Bitcoin core may provide methods of looking at the data in its copy of the blockchain. For example Bitcoin core has an RPC API including functions such as getreceivedbyaddress - which normally only works on your own addresses, not other people's.

there are tools to know the balance of an adress. But my question is how this tools works ? How they request the blockchain?

They can use the Bitcoin network protocol to collect their own copy of the blockchain, index it and then perform their own analysis of that data.
The Bitcoin network protocols allow any new node, such as a wallet, to discover a few other nodes and to request from them copies of blockchain data, piece by piece.
Generally speaking, address balances are of no interest whatsoever. They play no part in the way Bitcoin operates. You might rummage through your  pockets and rainy-day coin-jar to write down the total amount of money you find but no one else really cares.


text:
What's the deal with "legacy" and "segwit" wallets?
I'm new to bitcoin, but I've already read about "legacy" and "segwit" wallets. At the beginning, I created a segwit wallet, given that it was described as a new standard. But then I found out that a market that I use can't send me bitcoin to this wallet because they use a legacy wallet. Later I read that it's impossible to transfer bitcoin between those two kinds of wallets. Is it true? If so, what's the idea? Because to me it doesn't make any sense. Especially that a new standard is probably created in order to obsolete the old standard and develop whole network using the new standard. Does it mean that my bitcoin in a legacy wallet in a certain point of time will be useless?
I tried this kind of transfer (legacy -> segwit) using Electrum and it didn't work. Does software matter?
When it comes to paper wallet created on bitaddress.org, which type is it? What kinds of problems with compatibility can it create?
Here it is said: "there is no general issue preventing a wallet from generating addresses of various output formats". But Electrum asks you what kind of wallet you want to use in the beginning, when you create the wallet. So... there must be some issue.

Later I read that it's impossible to transfer bitcoin between those two kinds of wallets. Is it true?

This is not true.
However a wallet needs to know about Segwit addresses in order to be able to send to them. Since it is a new address type (well new when it was introduced 3 years ago), software that hasn't implemented it yet won't know what to do with it.

I tried this kind of transfer (legacy -> segwit) using Electrum and it didn't work. Does software matter?

In what way did it not work? Electrum supports and uses segwit, so it should, unless you are using an older version of Electrum. Both the software and version of that software do matter.

Well, the market couldn't send me money on my segwit wallet. I wanted to try to send the money to my paper wallet, but then I was afraid there'd be only more problems and in 30 years, when I want to withdraw the money from the paper wallet, the standards will change once again and I'll never be able to withdraw it... Are my thoughts reasonable? Anyway, now I'll try sending some btc from legacy to segwit in order to confirm what you wrote.


text:
How can I convert my private key from bitaddress.org to WIF without putting the key into a website or a programme?
Rule number 1 says: don't put your private key into any website or programme, unless you're performing a transfer. This way you won't be robbed.
Then, I want to "sweep" my money off a paper wallet from bitaddress.org, but Electrum wants me to put the private key in WIF format ( https://bitcoinelectrum.com/sweeping-your-private-keys-into-electrum/ ). How can I convert my key to WIF without breaking the rule number 1?
By the way, what's the name of the format bitaddress.org returns private keys in? It is base58?

bitaddress.org already provides your private key in Wallet Import Format, which is encoded in base58check format.
In the example screenshot below, the base58check-encoded WIF private key is KzNKqwBPaVehsA2F94n9UJ5mrkM9NazBjqBBwsb2U9pAGLdc4md3
To address your "rule 1", the most secure way to handle this data is load Electrum onto an airgapped machine, enter the private key into that secure computer, and then use it to sign a transaction you build with an "online" machine that has access to the UTXO set and your wallet address.

Warning: Do not use the key or address in this example for any reason at all besides looking at it and learning! Pasting private keys on websites is always a terrible idea.

Hmm, OK, I wasn't exact enough. What I did on the website, after moving my mouse randomly etc., I clicked "paper wallet" and then chose "BIP38 encrypt" and put a password. And then I received a "Encrypted Private Key (Password required)" and it's not what Electrum is asking for... What should I do in order to have this key in WIF format?

OK, I've found it! Here: https://bitcoin.stackexchange.com/questions/92864/priv-key-with-58-characters-to-wif Thank you!


text:
missing turnover
I read what you wrote about missing turnover. I also got told this. They told me I just have to put a certain amount of BTC to my wallet because of the circulation. When I have this amount in my wallet, the hash could be completed and I could receive the money. Did anyone do this before? If I put BTC in my wallet, no one could take it out, so is this a try of scamming or not? Does anyone know about rules and regulation?

It's a scam,  100% certainly. They have access to the wallet that you don't know about. There's no need to keep posting the same question here. You are being tricked and should stop communicating with those people and discard that wallet.

Let me rephrase that… Someone is asking you to deposit money into a wallet which you didn't create under the dubious ruse of wanting to gift you money you didn't expect. Raises a few alarm bells, but that's just me.

Please read the answer on the linked question.


text:
Can somebody really tell how many BTC I have from a receive address?
I bought a small number of BTC in 2013.
Although it's not true, let's say for simplicity that I never moved them from my wallet.dat where I first received them.
Now, in 2020, I generate a new receive address in Bitcoin Core, loaded with that same wallet.dat.
Then I put this receive address in public.
Can anyone now somehow determine how many Bitcoin I own, based on that receive address?
Or is that receive address now as "opaque" and "pristine" as any receive address which has not received any coins yet?
I've been trying to understand exactly HOW Bitcoin is "not anonymous" for over a decade, but it's very difficult for me to grasp. For all practical purposes, it seems to be anonymous if actually used correctly. That is, never reuse receive addresses.
But I'm probably missing something.

Does this answer your question? How can there exist businesses that "specialize in blockchain analysis looking for patterns of usage that reveal how money is being used"?   See also answers to other questions about blockchain analysis

Can anyone now somehow determine how many Bitcoin I own, based on that receive address?

There is no way to look at an address on the blockchain (or a block explorer) and identify which other addresses were generated from the same wallet that generated that address. Obviously anyone can look at the blockchain and identify the number of Bitcoin held at a single address.

Or is that receive address now as "opaque" and "pristine" as any receive address which has not received any coins yet?

If the receive address hasn't received any Bitcoin it is as opaque and pristine as any other address that hasn't received any Bitcoin.

I've been trying to understand exactly HOW Bitcoin is "not anonymous" for over a decade, but it's very difficult for me to grasp. For all practical purposes, it seems to be anonymous if actually used correctly. That is, never reuse receive addresses.

Privacy (like security) is not boolean. It is a continuum. Bitcoin is pseudonymous rather than anonymous. The number of Bitcoin held at addresses is public but it is not obvious which individual owns a particular address. However, there are ways external to the blockchain where this information can leak in addition to address reuse. For example, if you buy a good from a merchant using the Bitcoin held at that address that merchant now knows you own that address and can track when you spend your funds in future.
Other altcoins like Monero, Zcash, Grin, Beam etc try to provide stronger anonymity guarantees than Bitcoin by not making transactions and effective balances held at addresses public. However they do that at the expense of weaker scalability, more experimental cryptography and/or greater computational burden. Alternatively Lightning (on top of Bitcoin) doesn't make transactions within a channel public but the opening and closing of the channel on the blockchain are still public.


text:
How do i debug a bitcoin transaction
My main problem is understanding how to convert the response from bitcoin-cli "decoderawtransaction" to the script format i am supposed to put in the debugginng tool. i.e my problem is understanding how to build the bitcoin script from the decoded transaction especially when trying to spend a segwit innput
For example how do i convert something like this
{
"txid": "159cdd5017ff7d2c4e1d5cd37793a125b8545b9bc99eb9cbec427978d11956c7",
"hash": "311d68d33ae87866a9d1e5482b8311bd2e9f9199f652747734b2515dc43bd835",
"version": 1,
"size": 222,
"vsize": 141,
"weight": 561,
"locktime": 0,
"vin": [
    {
        "txid": "d26bb78f9fa8b1e3f0b711af2861a3e02d579be61bc6efc3a84ed7bd82589466",
        "vout": 0,
        "scriptSig": {
            "asm": "",
            "hex": ""
        },
        "txinwitness": [
            "30440220711e2049f666f750f4b1816ca32c0db56de99e5f461fd454f209dae8e274e76f02206e5870f1f52ad70674a6a810218de0c15c45b153cb8b2a0ec2dc33a3f23dc14f01",
            "030713ff1cf6035cbaf5eb4a2f27d99214b72313f47276047cee2a7da5f35693b1"
        ],
        "sequence": 4294967295
    }
],
"vout": [
    {
        "value": 0.0005,
        "n": 0,
        "scriptPubKey": {
            "asm": "0 27b107c892a49b83f76c1e6c5d5860ba36d5da7f",
            "hex": "001427b107c892a49b83f76c1e6c5d5860ba36d5da7f",
            "reqSigs": 1,
            "type": "witness_v0_keyhash",
            "addresses": [
                "bc1qy7cs0jyj5jdc8amvrek96krqhgmdtknljra09w"
            ]
        }
    },
    {
        "value": 0.00019448,
        "n": 1,
        "scriptPubKey": {
            "asm": "0 2d5704072aa356ee73ce7dbcdcd77a56da29661f",
            "hex": "00142d5704072aa356ee73ce7dbcdcd77a56da29661f",
            "reqSigs": 1,
            "type": "witness_v0_keyhash",
            "addresses": [
                "bc1q94tsgpe25dtwuu7w0k7de4m62mdzjesle4zjex"
            ]
        }
    }
]

}
into something like this
    30450221009f61f453f44e807fdc538ca21710393d34005dd5709dabd8b6b9ccf09ea0b36a0220420d91a33f43d7b979471220e12cd1025975bd2e6c0bf2a14eb65ad89d578104
02de8f92034b9b3c956c1896d23a628537561e29faa772438aac2265c91ede6519
OP_DUP
OP_HASH160
393164d26cc8a065cb4915f46f6346d63ae26075
OP_EQUALVERIFY OP_CHECKSIG

Can someone please explain this or point me to a reading that explains this?

Does this answer your question? Decoding ScriptSig

To convert the response from bitcoin-cli decoderawtransaction to the script format you mention(scriptSig which unlocks scriptPubKey),
For segwit, you can get scriptSig part from txinwitness nested inside vin, which consists of signature 30440220711e2049f666f750f4b1816ca32c0db56de99e5f461fd454f209dae8e274e76f02206e5870f1f52ad70674a6a810218de0c15c45b153cb8b2a0ec2dc33a3f23dc14f01 and public key 030713ff1cf6035cbaf5eb4a2f27d99214b72313f47276047cee2a7da5f35693b1 here. If it's not segwit it would be located in scriptSig part.
To get scriptPubKey which is unlocked by vin, you should command decoderawtransaction again with other raw transaction hex, of which vout utxo matches vin, because scriptPubKey info is included inside vout only. You can get raw transaction hex by getrawtransaction with txid, which is d26bb78f9fa8b1e3f0b711af2861a3e02d579be61bc6efc3a84ed7bd82589466 here(you can find in vin).
For segwit V0, script pub key itself would be OP_0 OP_PUSHBYTES_20 <key-hash> or OP_0 OP_PUSHBYTES_32 <script-hash>. If key-hash(p2wpkh), script format you want would be OP_DUP OP_HASH160 <key-hash> OP_EQUALVERIFY OP_CHECKSIG, else if script-hash(p2wsh), OP_SHA256 <script-hash>.


text:
unrecognized output wallet when using Electrum to send bitcoin
help me understand this transaction - https://www.blockchain.com/ro/btc/tx/1318a3e54cff78fdd8f6b54e6fe5115072586091788c9bfa08ca82d83e4bc276 .
Never sent bitcoin from hardware / hot wallet before so I am new to this
So I tried a demo send from one wallet ****c276 to my crypto.com wallet **xmhue

so I understand that my wallet was converted to a new wallet ****qhev with the remaining amount

what I don't understand:

0.001 of my bitcoin got sent to the correct crypto.com wallet, but 0.001 of my bitcoin got sent to a unrecognized wallet - ***myAn - I don't understand what this is
I don't know how Electrum chose that wallet for sending the payment , is the choosing of the wallet automatic from Electrum ?


text:
How to calculate bitcoins in fees spent dailly? (Avg)
From https://bitcoinfees.earn.com/ I can see a list of bitcoin satoshi fees/byte
From https://thenextweb.com/hardfork/2018/07/12/bitcoin-block-size/ I can see that we can have block sizes of up to 2mb with segwit.
If I assume that segwit adoption increases in the next year, then I will base all calculations on the block size being ~2mb.
How do I back-of-envelope calculate total fees in bitcoin spent daily?
Assuming 6 blocks / hour, & with 24 hours in a day, is it:
~satoshiFee * 2m * 6 * 24
Which, assuming an average satoshi fee of 10 (using https://bitcoinfees.info/)
Gives:
10 * 2m * 6 * 24
And in BTC that's divided by 10^8, so we'd get:
20m * 144 / 10^8 = 28.8
Is that correct?

If you head to a place like this:
https://www.blockchain.com/explorer and click on one of the blocks you'll see a summary screen.
https://www.blockchain.com/btc/block/00000000000000000012ca146d2d1dc07d3157094b019ee59513e7a4caafc34e
Block reward is at the end of the summary.

Yes that look correct.
From https://bitcoinfees.info/, the current average fee rate listed at the bottom of the chart is 24 satoshis/byte. To calculate the total fees in a day you want fee rate * total bytes = total satoshis.
Assuming 2MB block size,
fee rate = 24 satoshis/byte
total bytes = 2MB * 6 * 24 = 288MB
total btc = total satoshis / 1e8
total btc = (24 * 288M) / 1e8 = 69.12 BTC


text:
Bitcoin payment delayed
I recently encountered a situation involving a Bitcoin transaction, and I'm seeking some clarification and advice. I provided someone with my Bitcoin address to receive payment, but I haven't received the funds yet. The sender claims to have sent the money, but it has been two days since the transaction was initiated.
To support their claim, the sender provided me with a screenshot showing a different Bitcoin address than the one I provided. They explained that the address can change during the transaction processing. I'm a bit confused and uncertain about whether this is true or not. Should the address remain the same as the one I initially provided?
Is there any way to verify the legitimacy of the transaction using the provided transaction ID or other means? What can I tell based on the given screenshot?
Thank you in advance for your assistance and guidance.

You mentioned a "support", what kind of support is it? Is it a legit exchange, or what happened?

No, it's just not an exchange but a guy I know.

They explained that the address can change during the transaction processing. I'm a bit confused and uncertain about whether this is true or not. Should the address remain the same as the one I initially provided?

Addresses do not change during transaction processing.
Modern wallets will create a new receiving address for each new transaction - so whenever you click the "Receive" button (or similar) in a wallet, your wallet generates a new address. However it still keeps track of all previously created addresses. Money sent to old addresses will still be received.
Again, this does not mean addresses change during a transaction. The receiving address you gave the other party is the address that will be used.
It is possible the sender's wallet may show the sender the sending address, not the receiving address.
As others have said, the best way to proceed is to check the transaction-identifier (TXID) at the bottom of the screenshot in any blockchain explorer - one of the "outputs" of the transaction should show your address (the one you gave the sender) and the expected amount in BTC. You will have to be careful when retyping the TXID from that image.
It is probable that the TXID shown is one in which the sender received some money and that they are not being truthful with you or are incompetent. They should tell you the TXID of the transaction that they created to send money to you. If they can't do this you should not accept that they have sent any money.

If you provided an address to someone (?) and they sent a transaction to a different address, then they didn't send it to you, it's that easy.
To verify the screenshot, just open any "Bitcoin explorer" webpage and search for your address. If there is an incoming transaction, you'll see there. You can also search for the provided txid, and check if the receiving address is yours.

How do I get the txtid?

Ask the sender or search for incoming transactions for your address. I can also see a long hex at the bottom of the screenshot, it can be the txid.

When the sender sends BTC to an address, they have transaction ID that can be used to verify the send operation.
So ask for this transaction ID and look up its details in a block explorer (blockchain.com/explorer will do). If you don't see your address as the recipient, then there's enough foundation to claim your sender not telling the truth.


text:
Bitcoin wallet carving
I've been file carving old drives and found several bitcoin Magic number headers. My question is does the wallet.dat file have a footer? Or how can I calculate the proper size of the Berkeley db file so I can cut and paste the hex into a new file.
Thanks,
Justin


text:
Moving the entire directory to new location for Bitcoin Core CLI
I use Bitcoin CLI and not the QT one, when syncing i used a external SSD to store blocksdata in SSD, obviously noob me didnt know of datadir function
Now my Chainstate, txindex are in roaming folder whereas blocks are in external SSD
1- If i copy chainstate, txindex and other files and paste them in same folder as blocksdata, change the .conf file in roaming folder and point datadir to SSD folder with the blocksdata in them, will it work if i run bitcoind from roaming
2- Do i also have to change the cookie path in .conf file with #rpccookiefile=
Any help is appreciated

Any help is appreciated, sorry for commenting again

If i copy chainstate, txindex and other files and paste them in same folder as blocksdata, change the .conf file in roaming folder and point datadir to SSD folder with the blocksdata in them, will it work if i run bitcoind from roaming

Yes. As long as you move everything, that will be fine. Note that you can only have one bitcoin.conf file, so any config options you want changed will have to be in the bitcoin.conf in the default data directory. But that can also have a datadir=<path> line to point to the location where all of the actual data will be stored.

Do i also have to change the cookie path in .conf file with #rpccookiefile=

No, that only matters if you want to have the rpc cookie stored somewhere outside of the expected data directory. Otherwise, it will be able to find it in the configured data directory.
Additionally, # at the beginning of the line means that the line is commented out, i.e. it is ignored. So changing that line wouldn't do anything anyways.

But my .conf file is located in C:\Users\ABC\Bitcoin, where the actual installation is
as well as weird enough i find the same .conf file in roaming folder too, although i never copied it there
also the CLI will auto fetch the directory details coz the applications are installed in
C:\Users\ABC\Bitcoin

Unless you've specifically configured it to read the conf file from a different location, Bitcoin Core will always use the conf file in the default datadir. It does not know nor care about the installation location. The details about the config options in use, including the location of the conf file in use, are logged into the debug.log file on every startup. Check in there if you are unsure. The conf file in your installation location may simply be the sample conf file.

Ok just saw the .conf file is fetched from appdata/roaming/bitcoin in debug file
am sorry for being such a noob
so now when i change the datadir=abc:\xyz
i have to copy the .conf file to abc:\xyz?
or leave it here and copy rest of the folders and files chainstate, indexes, wallets, .cookie, .lock, etc....

You have to leave the conf file there otherwise bitcoind won't know where to look for your data. Don't copy the conf file as the conf file in the new datadir location will be ignored as it will have already loaded the conf file from the default location.

User likely asking about Linux, but for Windows I found the location in the registry under Computer\HKEY_CURRENT_USER\SOFTWARE\Bitcoin\Bitcoin-Qt, named strDataDir


text:
Lightning Network on testnet - listchannels and listnodes returning empty values
I have setup a lightning node on testnet using c-lightning.
The lightning-cli getinfo command output:
{

"id" : "0315a5746114ab9f3e8f0a3f2f73153ef1e4a8fb58daa54fa97c9603dfab989a30",
   "alias" : "snjnode",
   "color" : "ff9900",
   "num_peers" : 0,
   "num_pending_channels" : 0,
   "num_active_channels" : 0,
   "num_inactive_channels" : 0,
   "address" : [
      {
         "type" : "ipv4",
         "address" : "103.72.61.18",
         "port" : 9735
      }
   ],
   "binding" : [],
   "version" : "v0.7.0-408-g0c189fe",
   "blockheight" : 1519822,
   "network" : "testnet",
   "msatoshi_fees_collected" : 0,
   "fees_collected_msat" : "0msat"
}

But lightning-cli listchannels and listnodes return empty values:
{
"nodes" : []
}

It should return the list of all nodes in the testnet network right? What is wrong?

In order for your node to be aware of all (public) nodes and channels on the network it need to download them first.
If you look at your output of getinfo you see that you don't have any peers. You should peer with at least one node for example with mine which you can find at https:ln.rene-pickhardt.de you do this via:
lightning-cli connect 03efccf2c383d7bf340da9a3f02e2c23104a0e4fe8ac1a880c8e2dc92fbdacd9df@144.76.235.20:9735
The gossip deamon of your node will then query my node for the network. Once the syncing is complete you will see all channels and nodes with the commands you mentioned.
Not that you will see some channels nodes right away as the output lists the nodes and channels it is already aware of

Okay,Thanks. I get what you are saying, but will it work if I connect to your node? Since my node is on testnet and your node is on mainnet.

Oh sorry overread that you are on testnet. No you need to connect to a testnet node for example htlc.me


text:
EstimateSmartFee returning same amount, regardless of conf_target
Running 18.0 on Testnet, fully synced at 1541869 blocks.
bitcoin-cli estimatesmartfee 10
{
  "feerate": 0.00001014,
  "blocks": 10
}

bitcoin-cli estimatesmartfee 50
{
  "feerate": 0.00001014,
  "blocks": 50
}

bitcoin-cli estimatesmartfee 1000
{
  "feerate": 0.00001012,
  "blocks": 1000
}

bitcoin-cli getblockchaininfo
  "verificationprogress": 0.9999922066691247,
  "initialblockdownload": false,
  "size_on_disk": 24450857625,

Any ideas? Thanks

What is the problem? Testnet has a bogus fee market; you should expect bogus estimates to come out.

This is expected behavior, especially on testnet. The fee estimator will often return the same fee rate estimate for confirmation targets after a certain value because there isn't enough or any data about transactions confirming at those confirmation targets. So it falls back to the highest confirmation target that it can estimate for and uses that for confirmation targets than that.
Also, you are on testnet which does not really have a fee market, and whatever fees it may have are probably bogus. Thus any fee estimates are also bogus.


text:
RPCPORT and --rpcport not working in Latest version: 0.18.0
We are using bitcoin core RPC Endpoint to broadcast transaction over network, It was working perfectly till version 0.17.0 but in latest version 0.18.0 RPCPORT and --rpcport is not working.
Please let us know is there any way to start RPC port on version 0.18.0

See the 0.18 release notes (https://bitcoin.org/en/release/v0.18.0#configuration-option-changes):

The rpcallowip option can no longer be used to automatically listen on all network interfaces. Instead, the rpcbind parameter must be used to specify the IP addresses to listen on. Listening for RPC commands over a public network connection is insecure and should be disabled, so a warning is now printed if a user selects such a configuration.


text:
Make a metadata transaction without transferring bitcoins
Is it possible to make a metadata-only transaction without transferring bitcoins? (I know you should always pay a fee, but is it essential to transfer bitcoins in a transaction?) Thanks and regards!

What sort of ‘metadata’ are you talking about? Just writing arbitrary data to the blockchain?

I'm talking about the metadata added with OP_RETURN opcode, I want to know if it is possible to create a voting system using OP_RETURN opcode to reflect the voter elections without having to make bitcoins transfers, just paying the transaction fee.

ah, got it. I'm curious, why implement a voting system on top of Bitcoin? I'm not sure I see the advantage that justifies the costs.

I'm just doing an analysis of different BlockChain platforms to implement an electronic voting system. The idea of using BlockChain is to achieve a more reliable and transparent system.

If that is your goal, I don't see how a blockchain is the ideal solution. Comments aren't a suitable place for discussion though, if you're interested, you can join the chat on this site to discuss further: https://chat.stackexchange.com/rooms/8089/mempool. Also, fwiw: https://xkcd.com/2030/


text:
What are the Advantages of Mainnet over Testnet?
In recent days most of the ICO's starting with test net then developing their own block with mainnet. I don't know why they are doing this. What are the reasons behind this starting with testnet and switching to mainnet?

Testnet coins do not have any value. So it can be used for extensive testing of vulnerabilities and bugs. If any bugs exists and coins are lost, they are just testnet coins without any value. If the same happens on mainnet, you actually lose monetary value.

@UgamKamat: That sounds like a great start of an answer.


text:
Exporting secure seed using bitcoin core
I am trying to secure my own bitcoin.
I want to generate a bunch of addresses from a HD Seed, however I am paranoid about the security of any seed generated from any website and so only trust in the bitcoin core client.
I have downloaded and compiled the bitcoin-core client, but am struggling to understand how to export the seed and or seed + my password.
Is this feature not available on bitcoin-core and if not is there something else people use to secure large amounts or bitcoin using a HD seed +  custom password.
My ultimate plan was to then get one of the addresses generated from this seed, plus 2 other addresses from other seeds on other remote machines to then create a multi sig address for securing my bitcoin.
Any help/input appreciated.

Bitcoin Core uses BIP32, but does not implement BIP39 - As such, you cannot export a set of seed words, since the seed to BIP32 master key conversions is one way only, and it is not possible to obtain seed words if you only have the master key.
You should simply back up the master key itself, and import it into another instance of bitcoin core when needed. The dumpwallet command will help you with that.


text:
Are there valid transactions which are impossible to mine?
Is it possible to have a bitcoin transaction T that is valid with a very generous transaction fee for which it is impossible for T to be included in the next block, or even in all subsequent blocks?
The block header contains a hash of the previous block header as well the hash of the merkle root of all transactions in the block. Can T exist such that including T in the block renders all possible nonce values for that block futile in solving the mining puzzle?
I'm guessing that the existence of such a transaction for any particular network configuration occurs with very low probability. Is there a proof which shows that such an event is unlikely or even impossible due to the cryptographic properties of the SHA256 hash function?

I think that the answer to your question is no, a transaction which makes every block it is included in invalid does not exist.
An important core property of a cryptographic hash function is that there is no discernable relationship between the input data, and output data. If such a relationship existed, then miners could 'cheat' by only creating blocks (input data) that would lead to a valid hash (output data) in the preferred range (lower than the difficulty target). In reality, we see that changing the input data slightly will drastically alter the output data, in a deterministic but unpredictable way.
And so I don't believe a transaction could exist, which would invalidate every block which it was attempted to be included in. Even if you create a block with just a coinbase transaction, and exhaust the nonce and extranonce space without finding a valid solution, the timestamp will still slowly increment, and each time it does you can search the entire nonce/extranonce space again. Probabilistically, since we expect an even, and random output value distribution from the hash function, after enough time, some combination of your transaction / the timestamp / the nonce and extranonce should lead to a valid block.
There is also lots of other data that can be included in a block, and altering any piece of it will affect the block hash as well. Murch's answer here tells us that lately there are ~2000 transactions in a block on average. For simplicity, lets assume that all transactions in the block are independent, so they could be included in any order. The number of permutations for the transaction ordering is thus 2000!, which is a huge number (~3.316 E +5735). For each of these combinations, the miner could exhaust the nonce space, the extranonce space, and then increment the timestamp and do it all again. This makes our number of possible arrangements even more enormous! Given enough time, and computational power, it becomes likely that a valid block hash will be found.
So, just from a probabilistic argument, I don't believe it is possible for the inclusion of some transaction to magically only create invalid blocks. Perhaps someone more well versed in the nitty-gritty details can offer a more thorough proof of this, but I think just the numbers alone, combined with the security properties of a cryptographic hash function, are reasonable enough proof.

Adding onto @chytrik answer, the "proof" that it's impossible to find such a hash is purely probabilistic; perhaps there is some transaction hash which by sheer mind-boggling coincidence would not be hashable with all the others or any nonce to find a block with the necessary difficulty.
If we supposed that this were the case, the next question would be how to find it. I think trying to actually find such a hash would have the difficulty of finding an arbitrary hash collision or harder, where finding a collision is already so difficult that for practical purposes it's considered impossible.
So if you had enough hash power to find the TX that would break the blockchain, you could already break the blockchain in numerous other ways.


text:
Can I send Bitcoin to my bank
Can I send my Bitcoin to my bank account I'm having trouble with idme verification


text:
Accessing my bitcoin
When I first invested $10;into Bitcoin it hadn't taken off yet,I forgot about it and then recently started receiving emails saying I needed to do something with my Bitcoin money but I have no idea what to do. I need help to get my Bitcoin into my wallet so I can receive the money that's been there for awhile.

Does this answer your question? Is it normal to be asked for an advance fee on a withdrawal?. Those emails are almost certainly fake, sent by conman who will trick you into sending fake release fees.


text:
What happened to my coins, balance account is zero ... hacked?
Yesterday I was surprised to seen that my wallet drop to zero by this transaction id : 504ebc5aa9c6dcdbfadfd97ccd47a289a309d829530e529e558b715563c4ec3b
It seems the adress : bc1q8yl5pq7p0cg6dtd85lz3hznj30rhe8k2s5kxhm
has picked all my BTC, plus others small transaction from somebody else are also availlable
Right now the transaction has been 36 times confirmed
and my balance show zero BTC.
Seems to be hacked ?
Did someone can help as I'm a newbie
Thx

What wallet/software/site are you using? Does your wallet still claim you have a balance?

7,5 hours ago your funds were moved in transaction d25efe9d5f1f2cc1fc253e4b32631fdb99870fb29b34d06fb48f43fb0de7ae92 to address 13fgTXgdyNVrq9qUxrkGzjoBVjQVZ9nKx4 which belongs very likely to bittrex.com . So the exchange might have information about the sender.
I'd report it to both the exchange and the police a.s.a.p.

Seems to be hacked?

If you are certain you did not make this transfer, then yes, it is very likely that you have been "hacked" in some way.

What happened to my coins

There is not enough information in the public blockchain to easily tell for certain. The recipient has not yet spent the money.

This is the sort of transaction that might occur if you were playing around with some new wallet software and tried out the "sweep key" function. If so, the money is in your new wallet not in the old.
It is also something that might happen if you had installed some software recently from a person or website you don't really know much about. In which case you might have installed some malware that, as well as doing what it promised, also installed some malicious features such as

a "backdoor" that gives a criminal access to your device.
a "keylogger" that captures the password to your wallet when you later use it.
something that searches for passwords, private-keys, recovery-phrases, wallet files etc and sends them to a criminal.

In any case, if the bc1q8yl5pq7p0cg6dtd85lz3hznj30rhe8k2s5kxhm address is not known to any wallet software you are using, it means that money has been stolen and it is almost certain you will not recover it. At the moment it doesn't seem you have enough evidence of a crime to report anything to your local police.


text:
Do most small miners join mining pools? Is "pay-per-share" the dominant approach?

Is it correctly understood that most individual/small miners join mining pools?

Is "pay-per-share" (or some variations thereof) the most popular mining pool approach, which means that the pool pays a miner a guaranteed payout depending on the hash rate provided by the miner? In other words, the pool absorbs all the risk from how much mining rewards the pool actually earns.

If 1-2 are true, then, for a given miner, the question whether to mine or not simply becomes a question of whether the cost of running the mining equipment and paying the pool fees is less than or greater than the current mining reward which depends on the current price of Bitcoin. Is that an accurate description?

I suspect this question is better answered by reading online resources such as https://www.investopedia.com/tech/how-do-mining-pools-work/ I'm not aware of any widespread survey of a statistically significant and representative sample of small miners worldwide. Without that, we can only speculate or offer opinion that is at best weakly substantiated.

I have looked at online resources such as the one you linked to. This is a question that practitioners can shed light on.


text:
is wallet vulnerable when unlocked for transactions?
is wallet vulnerable when unlocked for transactions?.I recovered a wallet some time ago and all is good.passphrase key all looks good.But a question came to my mind about the moment we make a transaction.I guess we must be connected to the net blockchain or however  you call it.Also we unlock the wallet for the transactions right or wrong? if yes,does that not make the wallet vulnereble for hacking even for a few minuites?help appreciated.


text:
Are the blocks produced by different nodes in the network comparable in terms of the order of transactions contained in them?
Having a transaction from person A to B and another transaction from person C to D that both took place in more or less the same time I assume that there might be a situation in which different nodes will receive these transactions in different order. Both transactions are valid but the order in which they will be included into the block will be different for mining nodes and therefore they will produce different hash / nonce / Proof of Work.
Is my assumption correct and if so then does it even matter? Or it is a natural thing that blocks produced by different nodes will be completely different in terms of order of the transactions (and maybe in terms of number of transactions contained in them) and the only thing that matters is correct nonce needed for proof of work (and if it's being found then the block will be accepted by other nodes).
I am happy to hear if answer to my question would be different in case of other projects (e.g. Ethereum or Cardano).

The order that two independent transactions appear in a block does not matter. It has an effect on the block hash, but so too do many other things. As a last resort, miners may choose to reorder the transactions in their block in order to achieve a different hash, but there are far easier things to do first.
However miners that use the block assembly algorithm implemented in Bitcoin Core are likely to result in blocks that have transactions in the same order. This algorithm does not take into account the time that a transaction was received as it's irrelevant. What it does account for are dependencies and fee rate (specifically ancestor set fee rate). Transactions with a higher ancestor fee rate will be included first, so two nodes constructing the same block will have a similar transaction order. That being said, there is still some randomness in the ordering when transactions have the same ancestor fee rate as the order at that point is not defined.

If A has 1 btc and B has 0 btc and A sends one btc to B with fee equal to x and then B sends this 1 btc back to A with fee 2x then I assume that this 2nd transaction couldn't be included first (even though it had higher fee). But maybe this case is covered by what you meant by "dependencies".

Yes. The 2nd is dependent on the 1st, and so it must come after. That's really the only consensus rule regarding sorting.

Two or more miners might produce a new block at the same time with different transactions or transactions in a different order.
There can only be one block accepted at any specific block height. Which means only one block with a specific parent (previous) block.
Every node independently chooses which of several competing blocks it accepts in its live blockchain. Since all nodes use the same rules, they all end up choosing the same block eventually.
This means that eventually, all nodes have identical blocks (though probably not stored in the same order on disk)


text:
Does checking for block validity involve checking for the validity of the whole blockchain?
In Ethereum Whitepaper there is a following description of Bitcoin's check for block validity:
The algorithm for checking if a block is valid, expressed in this paradigm, is as follows:

Check if the previous block referenced by the block exists and is valid.
[...]

Does this mean that in order to check block validity we have to recursively check all previous blocks within the blockchain? It sounds like it because if we would use the same algorithm for checking previous block validity then we would have to check validity of it's previous block as well and so on. Is that right?

The check can be done iteratively once and blocks marked as checked. Then we can check that a newly arrived block refers to a block we have previously checked as OK and we don't need to re-check any old blocks that have already been checked.


text:
How to fully uninstall Bitcoin Core on Macm2, and should I run a server as well as external HD
does anyone know how to fully uninstall Bitcoin Core from a mac m2?
Also, I have a 1tb external hard drive, should I get an AWS server to run Bitcoin Core? I am doing it locally and it is still eating up my memory. So I need to fully uninstall and reinstall on my external hard drive. I also need help deleting all system data from running it without my external HD.
very appreciative of any and all help

What is it that you actually want to do? It sounds like you might prefer moving your Bitcoin directory to the external wallet rather than completely uninstalling?

Remember to always backup your wallet and any important data.
The blockchain data is stored in a data directory. By default, it's located in ~/Library/Application Support/Bitcoin/. Delete this directory to remove all blockchain data. You can do this through the terminal or Finder.
rm -rf ~/Library/Application\ Support/Bitcoin/

Delete Configuration Files: Remove any remaining Bitcoin configuration files. These are usually in the home directory and can be hidden. Use the following command in the terminal to delete them:
rm -rf ~/.bitcoin/

After performing these steps, empty your Trash to permanently delete the application and associated files.


text:
Is it real BTC or fake
All,
I received some BTC to my coinbase wallet after someone asked me to setup custom network using the below setting. I received the BTC but I couldn't transfer to any other wallet and the says invalid BTC address. Am I scammed? Network name: Bitcoin RPC URL: https://testnet-rpc.satoshichain.io Chain ID: 5758 Currency Symbol: BTC Block Explorer URL: https://www.blockchain.com/explorer
Any help is much appreciated. The person who sent me this wants me to send money so he can validate the wallet address.
Is this true?
I'm not going to pay anymore but want to know if the BTC he moved to my wallet is real or fake. I read that any cypto sent using testnet doesn't have any real value. The guy used testnet-rep.satoshichain network so please tell me if this is fake or real BTC

Testnet BTC is worthless. You are being scammed.

Thanks for your reply, so I guess the URL he used is a testnet URL? it says testnet on there but just wanted to confirm. He is keep saying that the BTC he sent was real. He says there are many ways the BTC can be transferred that I don;t understand.

Does this answer your question? Is it normal to be asked for an advance fee on a withdrawal?

Excactly the same with you.
I received from someone BTC and gave me the same details..
Same name ,same rpc url ,same chain id,same currency symbol and same block explorer url..I can’t transfer BTC to any other wallet..he says that I must verification my wallet but I did already this..Maybe have the same scammer..


text:
Cannot Withdraw BTCpay Balance...Assistance Needed
I have tried to be as detailed as possible.
I setup a BTCpay store.  When setting up the wallet I used a xPub key, that I own the private keys to.  These private keys are attached to my blockchain.com wallet.  Previously, when I received payments through BTCpay the payments would appear in my blockchain.com wallet, because that is where the xPub key originated.
The problem:  The BTCpay payments are not appearing in my blockchain.com wallet, but only on the BTCpay wallet page.
The solution: I either need to be able to send my bitcoin out from BTCpay or access it via my private keys through a wallet, like Electrum.
When I try to send out the bitcoin from the BTCpay wallet it states that I am using the wrong derivation path, but I have tried the following-
•   m/84'/0'/0'
•   m/44'/0'/0'
•   m/44'/0'
I was told that the reason the payments don’t show in my blockchain.com wallet is because of a Gap Limit problem, basically my blockchain.com wallet stopped fetching the payments from BTCpay.  Blockchain.com wallets don’t allow changing the Gap Limit. Two wallets were suggested that allow the Gap Limit to be raised, Wasabi and Electrum.  When I entered my private keys into Wasabi, my balance showed zero and no transaction history.  When I entered my private keys into Electrum (native segwit) my balance is zero, but a transaction history shows up until May 2023.  In my blockchain.com wallet I do currently have a balance and many transactions since May 2023.  In my Electrum wallet I increased the Gap Limit to 500, but still shows zero balance.
Can anyone assist me with sending out my balance from BTCpay?

I appreciate that I'm not an expert in all the fields you cover but I see the question has been unanswered approaching a week, so here's how I'd approach it.
Your's seems to be a single problem: the private keys that started at blockchain.com no longer show activity there because of the site's gap limit, and while they do show activity with BTCpay, seem not to be usable for sending out.
I'd suggest getting those keys into a new Bitcoin Core instance, then moving those funds from there to a wallet you trust. This approach forces your device to rescan the blockchain and so avoids the gap limit issue.
VERY carefully review Husna QA's instructions here: while Core has never directly accepted seed phrases, it does seem a reasonable path from a creditable source to converting them. Also carefully review the follow-up discussion.

Thank you.  I am still dealing with this gap limit issue.  I will investigate your suggestion further.


text:
Bitcoin Core not displaying my account balance, can't do anything with it
Over a month ago on , I tried to send my balance from my Bitcoin Core wallet to another wallet on a different client, but I had accidentally set a really low transaction fee, leading to the transaction never going through. I expected after it was dropped from the Mem pool, the balance would show in the wallet, but Core isn't displaying it. Both Electrum and the Blockchain explorer are showing that the balance is in the wallet, but core won't update, and because it's a descriptor wallet, I haven't been able to move the wallet to another Client because I can't access the private keys. Any help on how to get this balance out?

Are you able to abandon the transaction? (abandontransaction RPC if you use the command-line, right click on the transaction and choose abandon in the GUI)?

No, abandon transaction is showing up unclickable, command line is saying that the transaction isn't eligible for abandonment


text:
Bitcoin message signing and other functions coded in C (not C++). Is there a good library that takes care of it all?
After searching for libraries that could do this, and/or code that could do this, all around the internet, and also AI code assistants failing me, I have managed to write C code (not C++, simple C) that generates a valid Bitcoin message signature! I used to code in C 30 years ago, so my code may not be the best, and I share it here in case one of you knows of a good library that does it all, as my next steps will be verifying a signature, preparing and posting transactions, etc. Here is what I have done:
Compile with (assuming you have all the libs in your path):
gcc btcsign.c -o btcsign -lsecp256k1 -lssl -lcrypto -lm

Execute with:
./btcsign "Private Key WIF" "Text message or SHA256 hash of a file"

For example:
./btcsign "5JkH4WGyg1XcUAzcfqLhKwpfs5A4v4Jdw6gWpgTLFhQW7wcnUMo" "Hello"

Generates this output:
Decoded Private Key: 7a97de76a46131c657bb9cc1ea2a19db73a4db1977c613ae2d6b1359466f0738
Uncompressed Public Key: 042a5d607f02bc50d6472eb1f098a6255cbdcf8ac181b43e52c15fc0abe0aa44bb9890417f2336f47e963e9892ef5f8ee6379a7aa9196324e4b11e550e921c7bce
Address: 136sTPvs2UWRUS7sLScmPqWiqCKveqnewL
Message Hash: c6e436f77154a548799e2b749f9a0687b4dc03a1c4b0d3ebf962f5e862ae1b6e
sig: bf2015fab095a0acc6e53245fc72de4de431008638069b49f20f8b1ad2457bba7db492187e42d70d38e7ace0d2f184ec156aabf8de5979ed1e5e877209518864
bitcoin_sig: 1cbf2015fab095a0acc6e53245fc72de4de431008638069b49f20f8b1ad2457bba7db492187e42d70d38e7ace0d2f184ec156aabf8de5979ed1e5e877209518864
signature_base64: HL8gFfqwlaCsxuUyRfxy3k3kMQCGOAabSfIPixrSRXu6fbSSGH5C1w0456zg0vGE7BVqq/jeWXntHl6HcglRiGQ=

Verify the signature (last string) using a public tool such as:
https://bitaps.com/signature

or
https://tools.qz.sg/

Here is the full code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/sha.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/evp.h>
#include <openssl/ripemd.h>
#include <secp256k1.h>
#include <secp256k1_recovery.h>

const char BASE58_CHARS[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

void base58c_encode(uint8_t *input, size_t input_len, char **output) {
    // Count leading zeros
    size_t leading_zeros = 0;
    while (leading_zeros < input_len && input[leading_zeros] == 0) {
        ++leading_zeros;
    }

    // Determine the size of the output buffer
    size_t output_size = (input_len - leading_zeros) * 138 / 100 + 1;
    uint8_t buffer[output_size];
    memset(buffer, 0, output_size);

    // Encode the input data
    for (size_t i = leading_zeros, j = output_size - 1; i < input_len; ++i, j = output_size - 1) {
        for (int carry = input[i]; j >= 0 || carry != 0; --j) {
            carry += 256 * buffer[j];
            buffer[j] = carry % 58;
            carry /= 58;

            if (j == 0) {
                break;
            }
        }
    }

    // Determine the start index of the encoded data
    size_t start_index = 0;
    while (start_index < output_size && buffer[start_index] == 0) {
        ++start_index;
    }

    // Allocate memory for the output string
    *output = malloc(leading_zeros + output_size - start_index + 1);
    if (*output == NULL) {
        fprintf(stderr, "Memory allocation failed\n");
        return;
    }

    // Add leading zeros to the output string
    memset(*output, '1', leading_zeros);

    // Copy the encoded data to the output string
    for (size_t i = start_index, j = leading_zeros; i < output_size; ++i, ++j) {
        (*output)[j] = BASE58_CHARS[buffer[i]];
    }
    (*output)[leading_zeros + output_size - start_index] = '\0';
}

// Base58 decoding
int base58_decode(const char *base58, unsigned char *output, int *out_len) {
    unsigned char buffer[50] = {0};
    int i, j, carry;

    for (i = 0; i < strlen(base58); i++) {
        const char *ptr = strchr(BASE58_CHARS, base58[i]);
        if (!ptr) return -1;

        carry = ptr - BASE58_CHARS;
        for (j = sizeof(buffer) - 1; j >= 0; j--) {
            carry += 58 * buffer[j];
            buffer[j] = carry & 0xff;
            carry >>= 8;
        }
    }

    // Find the starting non-zero position
    for (i = 0; i < sizeof(buffer) && buffer[i] == 0; i++);

    int leading_zeros = i;
    int size = sizeof(buffer) - leading_zeros;
    memcpy(output, buffer + leading_zeros, size);

    *out_len = size;
    return 0;
}

// Decode WIF private key to hex
int decode_wif_to_hex(const char *wif_key, unsigned char *hex_key) {
    unsigned char buffer[37];
    int out_len;
    if (base58_decode(wif_key, buffer, &out_len) != 0) {
        return -1;
    }

    // Validate checksum
    unsigned char checksum[SHA256_DIGEST_LENGTH];
    SHA256(buffer, out_len - 4, checksum);
    SHA256(checksum, SHA256_DIGEST_LENGTH, checksum);

    if (memcmp(checksum, buffer + out_len - 4, 4) != 0) {
        return -1;
    }

    // Extract private key (strip first and last byte)
    memcpy(hex_key, buffer + 1, 32);
    return 32;
}

// Base64 encoding
char *base64_encode(const unsigned char *input, int length) {
    BIO *bmem, *b64;
    BUF_MEM *bptr;
    char *buff;

    b64 = BIO_new(BIO_f_base64());
    BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
    bmem = BIO_new(BIO_s_mem());
    b64 = BIO_push(b64, bmem);
    BIO_write(b64, input, length);
    BIO_flush(b64);
    BIO_get_mem_ptr(b64, &bptr);

    buff = (char *)malloc(bptr->length + 1);
    memcpy(buff, bptr->data, bptr->length);
    buff[bptr->length] = '\0';

    BIO_free_all(b64);

    return buff;
}

// Helper function to convert a recovered ECDSA signature to Bitcoin format
int ecdsa_signature_to_bitcoin(const unsigned char *sig, unsigned int sig_len, int recid, unsigned char *output) {
    if (recid < 0 || recid > 3) return -1;

    output[0] = 27 + recid + (recid & 2 ? 4 : 0);
    memcpy(output + 1, sig, sig_len);

    return sig_len + 1;
}

// Function to print hexadecimal data
void print_hex(const char *label, const unsigned char *data, int len) {
    printf("%s: ", label);
    for (int i = 0; i < len; i++) {
        printf("%02x", data[i]);
    }
    printf("\n");
}

// Helper function to print the uncompressed public key
void print_uncompressed_pubkey(secp256k1_pubkey *pubkey, secp256k1_context *ctx) {
    unsigned char pubkey_serialized[65];
    size_t pubkey_len = 65;

    secp256k1_ec_pubkey_serialize(ctx, pubkey_serialized, &pubkey_len, pubkey, SECP256K1_EC_UNCOMPRESSED);
    print_hex("Uncompressed Public Key", pubkey_serialized, pubkey_len);
}

void double_sha256(const unsigned char *input, size_t length, unsigned char *output) {
    unsigned char hash[SHA256_DIGEST_LENGTH];
    SHA256(input, length, hash);
    SHA256(hash, SHA256_DIGEST_LENGTH, output);
}

int main(int argc, char *argv[]) {
    // Check if the correct number of arguments is provided
    if (argc != 3) {
        printf("Usage: %s \"wif_key\" \"message\"\n", argv[0]);
        return 1;
    }

    // Get the wif_key and message from command-line arguments
    const char *wif_key = argv[1];
    const char *message = argv[2];

    // const char *message = "Hello";
    const char *bitcoin_prefix = "\x18" "Bitcoin Signed Message:\n";
    unsigned char private_key_hex[32];

    // Decode WIF to private key hex
    if (decode_wif_to_hex(wif_key, private_key_hex) != 32) {
        printf("Invalid WIF key\n");
        return 1;
    }

    // Print the decoded private key
    print_hex("Decoded Private Key", private_key_hex, 32);

    // Initialize libsecp256k1
    secp256k1_context *secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);

    // Load the private key
    secp256k1_ecdsa_recoverable_signature recoverable_sig;
    secp256k1_pubkey pubkey;
    if (!secp256k1_ec_pubkey_create(secp256k1_ctx, &pubkey, private_key_hex)) {
        printf("Error creating public key\n");
        return 1;
    }

    // Print the uncompressed public key
    print_uncompressed_pubkey(&pubkey, secp256k1_ctx);

    // Generate un_Bitcoin address from public key
    unsigned char un_serialized_pubkey[65];  // Increase the buffer size to 65 bytes
    size_t un_serialized_pubkey_len = 65;
    secp256k1_ec_pubkey_serialize(secp256k1_ctx, un_serialized_pubkey, &un_serialized_pubkey_len, &pubkey, SECP256K1_EC_UNCOMPRESSED);
    const unsigned char *d = un_serialized_pubkey;
    uint8_t un_sha256_hash[32];
    uint8_t un_pubkey_hash[20];
    SHA256(un_serialized_pubkey, sizeof(un_serialized_pubkey), un_sha256_hash);
    RIPEMD160(un_sha256_hash, sizeof(un_sha256_hash), un_pubkey_hash);
    uint8_t un_address_payload[21];
    un_address_payload[0] = 0x00; // Main net version byte
    memcpy(un_address_payload + 1, un_pubkey_hash, 20);
    uint8_t un_address_checksum[4];
    uint8_t un_address_hash[32];
    SHA256(un_address_payload, 21, un_address_hash);
    SHA256(un_address_hash, 32, un_address_hash);
    memcpy(un_address_checksum, un_address_hash, 4);
    uint8_t un_address_pre_base58[25];
    memcpy(un_address_pre_base58, un_address_payload, 21);
    memcpy(un_address_pre_base58 + 21, un_address_checksum, 4);
    size_t un_address_base58_len = 25;
    char* un_base58_address = malloc(34 * sizeof(char));
    if (un_base58_address == NULL) {
        exit(EXIT_FAILURE);
    }
    base58c_encode(un_address_pre_base58, un_address_base58_len, &un_base58_address);

    // Print the Address
    printf("Address: %s\n", un_base58_address);
    free(un_base58_address);

    // Create the prefixed message
    unsigned char prefixed_message[256];
    size_t prefix_len = strlen(bitcoin_prefix);
    size_t msg_len = strlen(message);
    prefixed_message[0] = (unsigned char)msg_len;
    memcpy(prefixed_message + 1, message, msg_len);
    unsigned char full_prefixed_msg[256];
    size_t full_prefixed_len = prefix_len + msg_len + 1;
    memcpy(full_prefixed_msg, bitcoin_prefix, prefix_len);
    memcpy(full_prefixed_msg + prefix_len, prefixed_message, msg_len + 1);

    // Hash the prefixed message using SHA256 twice
    unsigned char hash2[SHA256_DIGEST_LENGTH];
    double_sha256(full_prefixed_msg, full_prefixed_len, hash2);

    // Print the message hash
    print_hex("Message Hash", hash2, SHA256_DIGEST_LENGTH);

    // Sign the message hash
    if (!secp256k1_ecdsa_sign_recoverable(secp256k1_ctx, &recoverable_sig, hash2, private_key_hex, NULL, NULL)) {
        printf("Error signing the message\n");
        return 1;
    }

    // Serialize the recoverable signature
    unsigned char sig[64];
    int recid;
    secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_ctx, sig, &recid, &recoverable_sig);

    printf("sig: ");
    for (int i = 0; i < 64; i++) {
        printf("%02x", sig[i]);
    }
    printf("\n");

    // Convert to Bitcoin format
    unsigned char bitcoin_sig[65];
    int bitcoin_sig_len = ecdsa_signature_to_bitcoin(sig, sizeof(sig), recid, bitcoin_sig);

    printf("bitcoin_sig: ");
    for (int i = 0; i < 65; i++) {
        printf("%02x", bitcoin_sig[i]);
    }
    printf("\n");

    // Encode the signature in base64
    char *signature_base64 = base64_encode(bitcoin_sig, bitcoin_sig_len);
    printf("signature_base64: %s\n", signature_base64);

    // Clean up
    free(signature_base64);
    secp256k1_context_destroy(secp256k1_ctx);

    return 0;
}


text:
Can a Trezor accept/use a private key created independently offline?
Can I create a private key using bitaddress.org offline and then use that private key in a trezor wallet? Also will the trezor use that private key to produce a mnemonic phrase?

You cannot import individual private keys into a Trezor. However you can generate your own mnemonic offline and import that into a Trezor.

awesome thanks...how do you gnereate your own mnemonic?

Own mnemonic can be generated using the Seed Tool: https://bitcoiner.guide/seed/


text:
How do I find out if I have bitcoins I purchased
I remember when they used to call people and sell Bitcoin over the phone I remember purchasing some and either 2008 or 2009 I ended up getting five of them with an actual coin sent to me how do I find out if they kept track of that

In 2008 or 2009

The first Bitcoin was mined on or after 3rd January 2009, so you can't have bought any in 2008
Mike Caldwell created the first Bitcoin physical coin in 2011. So you can't have bought any physical coin-like Bitcoin token in 2009.
It must have been 2011 or later.

how do I find out if they kept track of that

By contacting them directly.
However, I doubt any of the businesses that sold physical coins in 2009 (were there any that early?) are still trading.
Even if they still exist, they may not be able to help. As an example see https://www.casascius.com/TandC.aspx

Company warrants and represents that [...] all digital copies securely destroyed.
[...]
Coins that are destroyed or stolen are permanently unrecoverable. If your Casascius Coin is lost, stolen or damaged, they cannot be replaced or re-issued.

Useful sources

https://en.bitcoin.it/wiki/Casascius_physical_bitcoins
What is a physical bitcoin token?


text:
Where is my btc?
Hi My friend bought BTC in 2017 on an exchange. He just recently went back into it and saw he had some btc in there. After taking a look we saw he bought some then sent some, problem is he doesnt remember where he would have sent it, is there any way to find out to jog his memory?
11/12/2017
To address 3BPixQAKAXXu34UVmNHVNg5zAU6ZBqbsNQ -
Sent 0.003643-
Tx id d0e02f3946c0c01bf31b4e035490c34a
5/12/2017
To 38tJkbhhgYxx7JjptZFsrynd4PcZWqKd7z -
Sent 0.010564-
Txid 052bac1e036ce1f76e2dbb34e880b085

is there any way to find out to jog his memory?

No.
As you know, Bitcoin transactions are recorded in the Bitcoin blockchain. This is public information, replicated by all Bitcoin nodes.   However Bitcoin is pseudo-anonymous, there is no simple way to identify recipients. In Bitcoin, control over money is associated with numbers that are indistinguishable from random numbers.
Your friend should look into old email messages etc.


text:
(Mac user) Found old Multibit.key file and have installed Classic. I have imported the key and it is now syncing... what next?
From searching around I have managed to install MultiBit classic and amended the java file so it would work.
Imported the key and I think entered the password correctly, it now says:
importing private keys...completed successfully
And the wallet is now synchronising. I imagine this could take a few days?
After this, do I need to install Multibit HD? What is the process from here?
Thank you!

What is the process from here?

According to https://github.com/Multibit-Legacy/multibit

Videos that demonstrate how to move your wallet to Electrum are available on YouTube.

But, like Multibit itself, the links are defunct, so
See
MultiBit with multiple addresses to Electrum and answers to other questions about Multibit and Electrum

Those videos no longer work

@Zaq answer updated

Multibit classic has a lot of bugs and is now outdated and discontinued. It will be better and much more safe to import your private keys into electrum wallet


text:
Impact of Future Blocks on Bitcoin
The Bitcoin protocol limits the timestamp of future blocks to be at most 2 hours greater than the current time. If this time limit were increased, let's say to 8 hours, what impact would it have on the Bitcoin network?

Does this answer your question? From where does the 2 hours limitation on bitcoin time stamp come?

tl;dr: Greater difficulty in calculating difficulty?

So far as I know, generally speaking, relaxing rules results in a hard fork of the network. This is because older nodes regard such blocks as invalid and discard them while newer nodes accept them. It is difficult to introduce such changes without forking the blockchain and forking the network. You would likely need an extraordinary exceptionally strong and compelling benefit to justify this to others.
It might help miners a tiny bit, but I suspect that would be insignificant.
The blockchain seen by new nodes would see a greater number of blocks that are out of apparent chronological order.  It might more often cause temporal confusion among human observers of blockchain explorers etc.
It could complicate the calculation of network difficulty significantly. This is probably the most significant effect (other than the hard fork issue)

Hi RedGrittyBrick, If the entire network has reached a consensus and the future time limit has been extended to 8 hours, does the risk of attack increase for the entire Bitcoin network?

I don't know of any other way it could increase risk of attack. But my lack of knowledge may not be a good basis for any specific conclusion.


text:
How to create coinbase? How to use witness?
BIP141 adds a new rule called "witness commitment". The document says: "The commitment is recorded in a scriptPubKey of the coinbase transaction." I didn't quite understand what that meant, Therefore, I directly placed the 'default_witness_commitment' provided by the block template in the scriptPubKey location when creating coinbase. Here's my code：
def makeCoinbase()->None:
    global coinbase,tmpl
    version=pack('<L',1)
    inputCount=unhexlify('01')
    txHash=unhexlify('0000000000000000000000000000000000000000000000000000000000000000')
    preSequence=unhexlify('ffffffff')
    eh=encodeHeight(tmpl['height'])  #Don't worry about this function, it handles height
    msg=eh+b'my message'
    msgSize=pack('B',len(msg))
    sequence=unhexlify('ffffffff')
    outCount=unhexlify('01')
    amount=pack('<Q',tmpl['coinbasevalue'])
    script=unhexlify(tmpl['default_witness_commitment'])
    scriptSize=pack('B',len(script))
    lockTime=unhexlify('00000000')
    coinbase=version+inputCount+txHash+preSequence+msgSize+msg+\
        sequence+outCount+amount+scriptSize+script+lockTime
    tmpl['transactions'].insert(0,{
        'data':coinbase.hex(),
        'txid':dblsha(coinbase)[::-1].hex()
    })

The variable tmpl is the template obtained using the "getblocktemplate" command.I'm testing my code in regtest. When I submit a block, Bitcoin Core does create a new block. And my balance did go up.
However, when I checked coinbases in the newly generated block, the result was as follows:
{
    'txid': '9cb794f3292d1ece3af6c1d3055cf6fb26cf2126ff48b39b229bfec5ec651ec4',
    'hash': 'de081b2a9552ac559d3501ed0669f675530fe9890e27d263c1aff65e678ddc4e',
    'version': 1,
    'size': 153,
    'vsize': 126,
    'weight': 504,
    'locktime': 0,
    'vin': [{
        'coinbase': '016c54686520477265617420476f642050616e',
        'txinwitness': ['0000000000000000000000000000000000000000000000000000000000000000'],
        'sequence': 4294967295}],
    'vout': [{
        'value': Decimal('50.00063100'),
        'n': 0,
        'scriptPubKey': {
            'asm': 'OP_RETURN aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c',
            'desc': 'raw(6a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c)#psf60z3m',
            'hex': '6a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c',
            'type': 'nulldata'
        }
    }],
    'hex': '010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff13016c54686520477265617420476f642050616effffffff017ce8062a01000000266a24aa21a9edb14717ddf39dacad0babfff4d8d951c076e95d11d2b1f328632c32f98c015d2c0120000000000000000000000000000000000000000000000000000000000000000000000000'
}

As you can see, it contains only one vout. And that vout does not contain address. But I look at coinbase for blocks in the main network, and it always contains more than one vout, and the vout contains the address.My question is am I building coinbase the right way? If not, how do I fix it? Although the Bitcoin core did not report errors, I always suspected that I had lost the miner's address.

I always suspected that I had lost the miner's address.

True, you have the BIP-141 witness commitment (an OP_RETURN) but you do not have an output that pays the miner.
Currently it looks to me like you are burning the BTC 50 you assigned to the OP_RETURN vout. I think you should instead assign that value to a second vout that pays the miner through an appropriate locking script (scriptPubKey).
So I guess you want outCount=unhexlify('02') and when you construct coinbase= ... append a second set of  +amount2+scriptSize2+script2 before +lockTime

I changed the code later， and as you said, I set two vouts. But I put reward in the first vout and witness in the second vout，like this:
vout1=reward+scriptsize+script
vout2=0+size(default_witness_commitment)+default_witness_commitment
is this correct?

And I also encountered another problem, I get the pukey and scriptpubkey of my address using the "getaddressinfo" command.
address='bcrt1q95h0le6kknpnjp4c29cau03gvdyxd35zug30yr'
pubKey='022847e92a4202b75e5799ed13d1a529dcfcafc5d594bdf1e2c2a14f462683aeb8'
scriptPubKey='00142d2effe756b4c33906b85171de3e28634866c682'
I found that by putting scriptpubkey into vout1 without any opcode, submitting the block and reviewing it, I could see the correct address. But if I add the opcode, the address in the generated new block is wrong, or there is no address. So I'm not sure if I should add an opcode

(1) So far as I can see, BIP-141 doesn't specify a particular output index for the commitment. (2) In your scriptPubKey, 00 is OP_ZERO and 14 is OP_PUSHBYTES_20 (or similar, it doesn't have a standard name). So there are opcodes and adding more will just make the transaction nonstandard (and probably waste money).  This is a standard P2WPKH locking script as you can see in answers to this question

Thanks for your patience. I get it


text:
How to set the output script of coinbase transaction
I found that the "getaddressinfo" command in RPC can get pubkey and scriptpubkey. My address pubkey scriptpubkey are:
address='bcrt1q95h0le6kknpnjp4c29cau03gvdyxd35zug30yr'
pubKey='022847e92a4202b75e5799ed13d1a529dcfcafc5d594bdf1e2c2a14f462683aeb8'
scriptPubKey='00142d2effe756b4c33906b85171de3e28634866c682'

I tried to put the scriptpubkey into output script of coinbase transaction, and it correctly generated new blocks. And the block also shows the correct address. But that's without adding any opcodes. If I add opcode, it can generate a new block, but the block shows the wrong address, or no address. So should I add opcodes or not? If should, what opcodes?

The scriptPubKey (as you give in hex above) already contains all the opcodes it needs. If you add more, it won't be the same script, and it generally won't have a corresponding address. There is no reason to do that, though it is legal.

thanks, I think so too, but not very sure

Bitcoin addresses are standardized human-readable notations for certain classes of specific scriptPubKeys. While there is nothing invalid about scripts outside of these standard forms, there is generally very little reason to, and it is uncommon. These forms (as of december 2023) are:

P2PKH addresses (1...): 25-byte hex 76a914...88ac, encoding script OP_DUP OP_HASH160 <...> OP_EQUALVERIFY OP_CHECKSIG, present since the first Bitcoin software release.
P2SH addresses (3...): 23-byte hex a914...87, encoding script OP_HASH160 <...> OP_EQUAL. The address format is defined in BIP13, while the softfork that gave meaning to this script is in BIP16.
P2WPKH addresses (42-character bc1q...): 22-byte hex 0014..., encoding script OP_0 <...>. The address format is in BIP173 while the softfork is in BIP141.
P2WSH addresses (62-character bc1q...): 34-byte hex 0020..., encoding script OP_0 <...>. Like P2WPKH, the relevant bips are BIP173 and BIP141.
P2TR addresses (62-character bc1p...): 34-byte hex 5120..., encoding script OP_1 <...>. The address format is defined in BIP350 and the softfork is in BIP341.

The address you gave above is a P2WPKH address (its prefix and length don't exactly match the table above due to it being for regtest), and the hexadecimal scriptPubKey is the correct corresponding script. If you add more opcodes, it won't match the address anymore (and almost certainly not do what you want).

thanks for your answer

I have one more question. I set up two vouts in coinbase. The first vout stores the reward and scriptpubkey for miners. The second vout stores the defalult_witness_commitment. This value comes from the "getblocktemplate" command. Is this setting correct? like this: vout1=reward+size(scriptpubkey)+scriptpubkey    vout2=0+size(defalult_witness_commitment)+defalult_witness_commitment

Now I understand completely


text:
How to calculate Merkle Root? Need to reverse?
I downloaded the necessary information and made the coinbase. Then I calculated the merkle root... But I always get an error message when I submit a block: "bad-txnmerkleroot". Tere is my code:
def dblsha(d)->bytes:

    return hashlib.sha256(hashlib.sha256(d).digest()).digest()

def makeMerkleRoot()->None:

    global merkleroot,txnlist
    txnlist=[coinbase]+[unhexlify(a['data']) for a in tmpl['transactions']]
    merklehashes=[dblsha(t)[::-1] for t in txnlist]
    while len(merklehashes)>1:
        if len(merklehashes)%2:
            merklehashes.append(merklehashes[-1])
        merklehashes=[dblsha(merklehashes[i]+merklehashes[i+1]) for i in range(0,len(merklehashes),2)]
    merkleroot=merklehashes[0][::-1]

I reversed the data of all transactions(include coinbase)
I calculated the hashes(bytes)
I calculated the merkleroot(bytes)
I reversed the merkleroot
I converted the merkleroot(bytes) to hex
But always get an error: 'bad-txnmerkleroot', regardless of whether I inverted it or not, or how many times. Do I really need to reverse the data during the calculation? By the way, I tested the code in regtest. Should I test the code on the main network? Are there other reasons for the 'bad-txnmerkle' error? Like the wrong coinbase. I'm really at my wits' end.

You should not need to reverse anything; hashes are never reversed in Bitcoin, except for human display purposes. So if you start from txids you get from an explorer or RPC output, then you should reverse those (to unreverse them), but other than that, none are used.

About stealing comments and posting them as answers

I tried to cancel all inversions, but still got the error "ProcessNewBlock: AcceptBlock FAILED (bad-txnmrklroot, hashMerkleRoot mismatch)". I'm getting crazy with this question.

Can update your question to reflect your updated code, specifically how are you submitting the result to bitcoind?

Don't know if you stll need this info, but:
If you get tx.ids from the RPC (node) than you have to reverse those.
When you create the coinbase and double sha256 it you MUST NOT reverse it.
So, when you have the hash256 (double sha256) of the coinbase and you reversed the tx.ids you get from RPC, you can calculate the merkle root.
Same result is done by creating merkle branches: when you reversed the tx.ids got from the node with RPC, you can create merkle branches (aka steps in some sources) and put the coinbase hash256 as the first input when calculate the merkle root (in some sources this the function is called "with_first(coinbase, steps)"). This will recreate the same merkle root as it would be generated by starting with leaves (TXIDs hash256).


text:
get exact time of a transaction in the past (not in mempool)
I am trying to build a python program, that returns details of a transaction, such as inputs, outputs, time, amount, etc. I have already loaded bitcoind -txindex, yet, when I decode a raw transaction, I do not get the time field. I have already read that decoderawtransaction does not contain the time of the transaction, but I am curious of the way btc explorers get those data?
The only time fields that I have found are in getblock command and in getrawmempool/getmempoolentry (although I do not focus on unconfirmed transaction). Can i get any info from them?
Thank you for your time.

pretty sure that doesn't really exist... block explorers probably write the time to an external DB the moment they receive a transaction on their node(s)

As you have found, there are no time fields in transaction data.
Blocks have a timestamp but that can be up to 2 hours out.
Nodes can of course choose to record the time at which they first saw a transaction, this might be during relaying of transactions before the transaction is confirmed by being added to a block by a miner.


text:
Lost Bitcoin from 2011 or 2012
So I wanted to look at some pornography on the internet in either 2011 or 2012 I purchased $50 worth of Bitcoin proceeded to purchase the 29.99 internet porn but there was like $18 left over and I was very naive at the time about Bitcoin and tried and tried to get that back into my bank account not knowing that you have to sell it back so I just chalked it up as $18 gone well I was informed that Bitcoin is almost $50,000 per coin now and I know at the time they were less than a dollar a coin so I've got 18 to 20 Bitcoin out there somewhere how do I go about finding it? I remember the bank account it came from I remember using PayPal to do the transaction what do I need to do and how do I do it?

Does I have lost my wallet, what can I do? answer your question?

Did you just sent the $50 bitcoin into the wallet the site provided to you ? Or you had it purchased into your personal wallet before you transferred to the wallet or scan page the pornography site gave you ..
If you did sent it directly to the pornography site my friend the rest of it is gone into the site
And you you did sent it to your personal wallet before you sent the $29.99 to the site look your wallet up it’s in there


text:
Difference between cryptography in cryptocurrency hardware wallet and 2FA hardware security key
What's the general overview of difference between the way how cryptocurrency hardware wallet works and how hardware security key (used for 2FA) works?


text:
If only one Bitcoin miner gets the block reward, is it worth mining only for the transaction fees as a (not-so-competitive) solo miner?
I have heard (but not that knowledgeable) about mining-pools. If a weak system joins the pool, it has a chance to get a portion of the block reward, but I assume that not all of the miners are joined to a mining pool.
If I use my average PC for Bitcoin mining, it is a very low probability that I will be the first to solve the hash problem, thus, I won't earn the block reward most probably. I will only be rewarded with the fees with respect to the calculations I have made. So my question has two parts;

I assume that the numbers showing the average revenue generated from mining includes both the transaction fees and block rewards, is that correct?
If that is the case, then shouldn't the weak miners consider a lower average revenue, until they earn the block reward with such low probabilities?

Please correct any points that I might have been wrong about. Thanks in advance.

I will only be rewarded with the fees with respect to the calculations I have made.

That's not correct. If you don't mine a complete block, you get nothing at all.
Joining a pool will let you get a proportional share of the income (from both the block subsidy and the fees), changing the game from a lottery to a more predictable payout based on your contributed hashing power.


text:
When increase transaction fee three times in few minutes - transaction had an attempted double-spent?
I make transaction from my wallet - send BTC.
After I send, I increase transaction fee three times, in a few minutes.
Now I see - Status: conflicted with a transaction with 21 confirmations
I use Bitcoin Core version v0.18.1 (64-bit)
In block explorer I see that this transaction had an attempted double-spent.
What can do in my case?

The double spend attempt is your fee increase. It is impossible to modify a transaction after it has been broadcast. So to increase the fee, your wallet intentionally creates a double spend of it that has a higher transaction fee.
However it isn't just a pure double spend; there are additional conditions the original transaction and its double spend must meet before nodes will replace the original. When you increase the transaction fee, the wallet checks that the original transaction met certain rules, then it creates the double spend to meet the replacement rules.
The wallet should recognize that the original transaction has been replaced, but if it does not, you should be able to force it to. Because the replacement confirmed, you should be able to right click on the original transaction entry and choose the "abandon transaction" option to keep it out of balance calculations other things. It will remain in your transaction history, but have no effect on anything.

Increasing the transaction fee is literally trying to replace the transaction. Some sites will detect that as an "attempted double spend" - it literally is, but in this case it is desirable.


text:
Retrieving an addresses' public key from Pkscript/sigscript/witness
Let's use this transaction as an example. In the transcation, address 3GGoy8NoCF62TCAPGidWMU3u1ZrgwmasFt has a pkscript, a sigscript and a witness. It is possible to use any one of these, or some combination of them to retrieve that address' public key?

The output script (typically referred to as the scriptPubKey, but for some reason blockchain.com is calling it pkscript) tells you where to find the public key(s). It depends on the output script used. The public key(s) could be found in any of the three places.
In your example, the output script is a Pay to Script Hash (P2SH) script. This tells us that the script that is actually being executed is found in the input script (typically referred to as the scriptSIg, but for some reason blockchain.com is calling it sigscript). P2SH stipulates that the first item in the scriptSig is another script. In this example, there is only one item in the scriptSig, and that item is a script. This script is a Pay to Witness Pubkey Hash script (P2WPKH). This tells us that in the witness for this input, we should find a signature, followed by the public key. If you look at the witness section, you will see two items, the first is the signature, the second is the public key.
So in your example, the public key is found in the witness. However this is not always the case. It all depends on the various script types. If the output script were a Pay to Pubkey (P2PK) script, then the public key would be found in the output script. If it were a Pay to Public Key Hash (P2PKH) script, it would be found scriptSig. The address could also refer to a more complicated script that has multiple public keys, or no public keys at all. It all depends on the scripts.

Thank you. How can you tell which script type are the output and the input scripts? And where in the witness can the public key be found?

There are a set of standard script templates so you can just match the scripts against the templates to determine the script type. Most of these templates also match to an address type. For example, addresses beginning with a 3 correspond to P2SH output scripts. In your example, the public key is 03ac7d8d505d09082033ec04ce1e6dd5ff3e1bf4c2788f6588da38f39460772210. It's the second thing listed in the witness section.