text:
bitcoin-cli listtransactions fee amount is way off, why?
I am using the default signet network, my txid is 3923927eb3b6213bab5d0bee8364a87eafe357cb4d42ce6c587f0372735c7ff0.
bitcoin-cli listtransactions shows a fee of 0.00596777 when in reality the fee is 0.00000282. Why such a huge discrepancy?
Here is a link to the tx on mempool.space
And here is the output from listtransactions:
{
            abandoned = 0;
            address = tb1q9fnletvwwup855vyqttuya0evaypg0njqdjsv4;
            amount = "-5e-05";
            "bip125-replaceable" = no;
            blockhash = 00000012d461cd4e35b5b41ba81decb75b76bdcf7d84844fc91917f47d760a9f;
            blockheight = 195521;
            blockindex = 440;
            blocktime = 1715698392;
            category = send;
            confirmations = 4991;
            fee = "0.00596777";
            label = "";
            time = 1715696690;
            timereceived = 1715696690;
            txid = 3923927eb3b6213bab5d0bee8364a87eafe357cb4d42ce6c587f0372735c7ff0;
            vout = 3;
            walletconflicts =             (
            );
            wtxid = d4e19c5eb0e51ebe05db73587bf2b52afebafdcc36480befd95e190f01fef9e0;
        }

EDIT:
As requested please see output direct from bitcoin-cli. FWIW this is a payjoin tx.
{
    "address": "tb1q9fnletvwwup855vyqttuya0evaypg0njqdjsv4",
    "category": "send",
    "amount": -0.00005000,
    "label": "",
    "vout": 3,
    "fee": 0.00596777,
    "confirmations": 5180,
    "blockhash": "00000012d461cd4e35b5b41ba81decb75b76bdcf7d84844fc91917f47d760a9f",
    "blockheight": 195521,
    "blockindex": 440,
    "blocktime": 1715698392,
    "txid": "3923927eb3b6213bab5d0bee8364a87eafe357cb4d42ce6c587f0372735c7ff0",
    "wtxid": "d4e19c5eb0e51ebe05db73587bf2b52afebafdcc36480befd95e190f01fef9e0",
    "walletconflicts": [
    ],
    "time": 1715696690,
    "timereceived": 1715696690,
    "bip125-replaceable": "no",
    "abandoned": false
  }

Where did you get the output from? It doesn't look like the JSONRPC returned by bitcoin-cli. Could you paste the output from bitcoin-cli?

Yeah, e.g. the fields appear to be sorted alphabetically instead of in the order that bitcoin-cli would output them, and I don’t think that Bitcoin Core would ever output scientific notation. Any chance that this output was post-processed by another program to reach this state?

I am formatting the returned value into pretty printed json. Sure, I will respond asap with the direct value from bitcoin-cli.

Have added the unformatted output as an edit above.

This occurs when one of the inputs is unknown to the wallet, for example when participating in a multiparty transaction like a CoinJoin.
What happens is that the wallet checks to see how much value in the inputs it knows about, and if it is nonzero, computes the fee by subtracting the outputs value from it and then negating. The base assumption in this calculation is that all inputs in the transaction belong to the wallet - if any input is known, then the calculated input value will be nonzero, but all inputs must be known for this calculation to be correct.
So what's happened here is that your transaction has two inputs, one of which is known, one not. The known one appears to be the second input of 0.003. Taking that as the "input value", the calculated fee as -(0.003 - 0.00896777) =  -(-0.00596777) = 0.00596777.
One thing to notice here is that the fee is given as a positive number, however the wallet is supposed to be reporting it as a negative number. This is an indicator of this particular issue.

Interesting, yeah, that checks out: 596777+282 = 597059 which is exactly the first input’s amount. Perhaps we’d be able to discover based on a positive fee that the wallet doesn’t have the entire information and prevent the fee from being displayed.

Ah that may be on my end with regards to the negative value being positive, I am formatting the returned value from bitcoin-cli programmatically. Is there any scenario where it would not make sense to total the input values and output values and subtract them to get the fee?

The wallet really shouldn't be returning the fee here since it can't accurately determine it.


text:
Why are bip32_derivs included in psbt outputs?
I do not want to share my output bip32_derivs as it seems to leak unnecessary info to other participants in collaborative transactions.
Why are bip32_derivs included in psbt outputs?
EDIT: I should have mentioned that I expected walletprocesspsbt to remove all bip32_derivs when setting bip32derivs to false. I wonder if this is a bug or intentional behavior?

The BIP32 derivation field in PSBT outputs is useful to be able to re-derive the address used in the corresponding transaction output. For instance it is useful for a signing device to verify the change address.

source: Stack Exchange

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

sort: votes


text:
Can I restore an additional address of Bitcoin Core
Once in Bitcoin Core I created an address to receive some payments from a faucet. After years I reopened the Bitcoin Core and started to synchronize it. After a while there was a crash, and I decided to remove the previous Bitcoin Core folder (it appeared to be in a USB hard drive and didn't get to Recycle Bin - when I decided to restore the removed files it was too late).
Then I reinstalled the Bitcoin Core, put there a wallet.dat from backup and successfully synchronized the blockchain. But I discovered - there's no address for the faucet, which I needed and there's no satoshi I expected. Apparently I created it before the backup (some previous history was there - so the wallet was restored - but without the latest address). So, should I consider the value on this address lost?
I tried to create the dump (dumpwallet "dump.txt") and to find the master private key there to restore the private key of this address somehow. The dump file contains some # extended private masterkey (starts with xprv). Also I know the address, which I set to the faucet (1J2ia2JZVoN8fqdvGYjkVaaX3A2C5BZzwj). So I thought I can use this data in "Mnemonic Code Converter" (https://iancoleman.io/bip39/) (extended private masterkey to BIP32 Root Key input and selected the Bitcoin Core presets everywhere). Surprisingly enough the first generated entry contained my first default address, but I couldn't find neither of the other addresses from the dump file. The address from the faucet doesn't exist in the dump either. What do I do wrong?
Here is the address I'm talking about: https://www.blockchain.com/btc/address/1J2ia2JZVoN8fqdvGYjkVaaX3A2C5BZzwj

Try it in Electrum. Do extended private masterkey import:

Create a standard wallet.
Choose "User a master key".
Paste the xprv… address at the top from the dumpwallet file.

@HannahVernon See my edits. I hope it helps.

Awesome, thanks!

New receive addresses are always generated in the same sequence for the same wallet. That is why if you have old wallet.dat you always can regenerate receive addresses even if they are created after the time you backuped your wallet.dat.
I mean you can, put your wallet.dat into bitcoin core and create new address to receive payments like you did before receiving payment years ago - newly generated address will be the same as before (1J2ia2JZVoN8fqdvGYjkVaaX3A2C5BZzwj). Now you have your lost private key regenerated.
If bitcoin core is already syncronized with blockchain, then your balance will be still incorrect and will not take into accont coins belonging to 1J2ia2JZVoN8fqdvGYjkVaaX3A2C5BZzwj. You should rescan your local copy to correct this:
According to btcscan.org address 1J2ia2JZVoN8fqdvGYjkVaaX3A2C5BZzwj received coins at block 657133. Press Ctrl+T to open bitcoin core consle (if you are using GUI) and do the following command to rescan near missing block:
rescanblockchain 657132 657134
Now your balance is correct and you are able to spend it.

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


text:
nLocketime error PUSH TRANSACTION ERROR: 64: NON-FINAL
Created nlocktime with electrum and used the time date feature which is using unix time instead of block height number for the locktime.
SO when pushing the raw tx before its time I get code 26 message non final which is fine as the time in the unix clock has not been reached.
Once the time arrived, I tried again and this time I get  non-final (code 64)  Why? And yes the btc from wallet being sent was confirmed at least with 1 confirmation. Here is the raw tx code. Any help would be appreciated as this is driving me crazy.
020000000156ab1d690e27b9d6dc3764233fa73a9749253472443e7d4efd86c7532eb58a64000000006a47304402205531d1b6808572a77bf649d480cb2f4676ead7035ed39bdb1bb1e928d5441a9102205710edaf122ec991ccab08a6945a1a728d08eecae5dbafb1e72c8481e1672f9d012102cbf41593c5fdb8caaf1942e0c4f2256de0a174c85b2d05252a9053dfc08de65afdffffff01a26900000000000017a91432d423f7e7722ed3ab0c87786e877b5f220148708795980460
{
"txid": "5b0b8137b86986fe65b2d07346d7dde9cc94ac9cd20671f5161b3bc76012a995",
"hash": "5b0b8137b86986fe65b2d07346d7dde9cc94ac9cd20671f5161b3bc76012a995",
"version": 2,
"size": 189,
"vsize": 189,
"weight": 756,
"locktime": 1610914221,
"vin": [
{
"txid": "648ab52e53c786fd4e7d3e4472342549973aa73f236437dcd6b9270e691dab56",
"vout": 0,
"scriptSig": {
"asm": "304402203a3c80d8cb01c28558269fdda6faaa7b1b963030b8867d9c0a933b9813c192c802202770970cdb704416c8fe504a9ed518537e983d2cce534fafa02046aa2181bf7a[ALL] 02cbf41593c5fdb8caaf1942e0c4f2256de0a174c85b2d05252a9053dfc08de65a",
"hex": "47304402203a3c80d8cb01c28558269fdda6faaa7b1b963030b8867d9c0a933b9813c192c802202770970cdb704416c8fe504a9ed518537e983d2cce534fafa02046aa2181bf7a012102cbf41593c5fdb8caaf1942e0c4f2256de0a174c85b2d05252a9053dfc08de65a"
},
"sequence": 4294967293
}
],
"vout": [
{
"value": 0.00026092,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 32d423f7e7722ed3ab0c87786e877b5f22014870 OP_EQUAL",
"hex": "a91432d423f7e7722ed3ab0c87786e877b5f2201487087",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"36Kmqv4k5cxigNvgV6Geejn7Cvc7MR3oPt"
]
}
}
]
}
It finally broadcast at 443 pm!  BUT WHY DID I HAVE TO WAIT!!!
    https://blockchair.com/bitcoin/transaction/71b27932fa35bc3fbf8343ea81e497b73b11cad7cda87485484a7e52f542c414

It's most likely because nLocktime is based on the "mediantime" of the previous block... not "exact" unix time.
Due to delays in finding a new block, it is not unusual for "mediantime" and "current time" to end up out of sync by quite a significant amount (1+ hr).
If you don't have access to a Bitcoin Node to check the getblockchaininfo command, then you can use this online API: https://chainquery.com/bitcoin-cli/getblockchaininfo
Check the "mediantime" value and compare with your "nLocktime". Once "mediantime" > "nLocktime", you should be able to broadcast without error.

HCP....Thankyou so much...thats it! As always you have come thru. Appreciate it!


text:
Random 'The operation has timed out' errors in JSON-RPC
I run Bitcoin Core QT and ASP.NET website on the same webserver. My website communicates with Bitcoin Core QT via JSON-RPC. There are hundreds of requests behind the scenes. Sometimes a request finishes with The operation has timed out exception. What is wrong with it? This unstable behavior is really annoys me.
My bitcoin.conf is:
rpcuser = XXXXXXXX
rpcpassword = XXXXXXXX
server=1
rpcallowip=xx.xx.xx.xx
rpcallowip=127.0.0.1
rpcport=xxxx
rpcthreads=1200

UPDATE: I use heavily edited https://github.com/GeorgeKimionis/BitcoinLib, which in its turn internally is based on HttpWebRequest. RpcRequestTimeoutInSeconds is set to 60 seconds. Is it not enough to get balance and account list?

What kind of RPC calls are you issuing?

@PieterWuille, I updated my question.

Some operation might take longer then your RPC clients timeout is set to. This could be either due to system workload or due to loading bigger sets of data over RPC (example: a wallet with 100'000 wallet transactions).
Try to debug which commands take long/longer and consider checking your RPC clients http timeout.

As I see timeout can occur literally in any RPC call. More often in 'ListAccounts', then in 'GetAccountAddress', sometimes even in 'Move' and 'SendRawTransaction'.

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


text:
Guessing nonce - nonce pools/domains
Blockchain miners calculate the hash of (block data + nonce value). They actually guess (are looking for) nonce in order to get hash staring with a defined number zeroes. (The number of required starting zeros in hash value define the difficulty of finding a nonce that fits - proof of work).
My question is do all miners guess/try nonces from the same pool or range (this way they actually non-efficiently test the same guesses many times) or they somehow split the pool of possible nonces among themselves in order not to try the same nonces multiple times?

The nonce value is indeed "guessed" by the miner.
The miner can also choose a part of the coinbase transaction (what the stratum protocol calls the ExtraNonce2). Another part of the coinbase transaction is imposed by the pool: this is the ExtraNonce1, in terms of the stratum protocol.
Pools are supposed to assign distinct ExtraNonce1 to all miners, to prevent duplication of work.

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


text:
I can't start bitcoind on Raspberry Pi. Why do I need settings.json.tmp when I didn't need it before?
I've reset my raspberry pi because after configuring Samba, bitcoind started downloading the blockchain much slower. Removing Samba didn't return it to the original speeds so I figured starting with a fresh Raspian SD card might speed things up again.
I am following the same instructions to install bitcoin-cli but this time I get this error
Error: Failed saving settings file:
- Error: Unable to open settings file /mnt/bitcoin/Coins/Blockchain/settings.json.tmp for writing

The full instructions I'm following are here. I've used the same drive mounted at the same place as before. I don't have a file settings.json.tmp. I do have settings.json and I naively cloned it and named it settings.json.tmp, but it didn't help.
This is how I'm installing it:
tar xvf bitcoin-0.21.1-arm-linux-gnueabihf.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.21.1/bin/*

And this is how I'm trying to start it:
bitcoind -daemon --datadir=/mnt/bitcoin/Coins/Blockchain

I guessed maybe that the problem was that this time I was installing version 21.1 whereas before I was using version 21.0, I still had the old .tar.gz file so I tried installing the previous version, but got the same error.
Then I tried creating a new blockchain folder at /mnt/bitcoin/Coins/Blockchain2/ but I get the same error. If that's a fresh folder, why would it try to read any files?
Does anyone know what the problem is here? Googling the error returns absolutely nothing.
I would appreciate any help.
EDIT: Extra info
I've just tried creating a new folder in the home directory instead of the hard drive and it worked. So why not on the hard drive? When I try to sudo rm settings.json.tmp I get rm: cannot remove 'settings.json.tmp': No such file or directory. Why is it trying to read a file that's not even there?
EDIT 2: ls -l /mnt/bitcoin/Coins/Blockchain/
Here is the output of ls -l /mnt/bitcoin/Coins/Blockchain/:
total 16896
-rwxr-xr-x 1 root root       37 Jun 18 17:19 anchors.3386
-rwxr-xr-x 1 root root       37 Apr 23 11:42 banlist.dat
-rwxr-xr-x 1 root root        5 Jun 12 20:40 bitcoind.pid
drwxr-xr-x 3 root root   262144 Jun 18 14:41 blocks
drwxr-xr-x 2 root root   262144 Jun 18 08:43 chainstate
-rwxr-xr-x 1 root root 12969496 Jun 18 17:19 debug.log
-rwxr-xr-x 1 root root   247985 May 19 15:27 fee_estimates.dat
-rwxr-xr-x 1 root root       18 May 19 15:27 mempool.dat
-rwxr-xr-x 1 root root  2623946 Jun 18 17:19 peers.dat
-rwxr-xr-x 1 root root        7 Jun 12 20:40 settings.json
drwxr-xr-x 2 root root   131072 Apr 23 11:42 wallets

Is settings.json.tmp perhaps a symlink to a non-existing file? What does ls -l /mnt/bitcoin/Coins/Blockchain2/ tell you?

@PieterWuille I added the output as an edit to the post because trying to format it in a comment wasn't working. As you can see, the .tmp isn't there. I wondered if it's causing the issue because of permissions, but I believe I didn't have to change any permissions when it worked before I reset. And the permissions look good here anyway I think (user has read and write, that's good yes?).

Well it's failing to open the settings.json.tmp file for writing. This may indicate that you don't have write permissions. Are you running Bitcoin Core as root?

@PieterWuille Yep, haha, that was it. I did sudo bitcoind -daemon --datadir=/mnt/bitcoin/Coins/Blockchain and it's working. I just kept the same alias that I used before. I don't get why it didn't need root before.
Thanks so much for your help.

I wasn't running it as root. Once I ran it with sudo bitcoind -daemon --datadir=/mnt/bitcoin/Coins/Blockchain, it worked as expected.

This solution doesn't seem to work for bitcoin-core installed as a snap.


text:
How can I generate SegWit addresses from a mnemonic using python?
So, I have written a script that generates BIP39 mnemonics. I now want to generate N native SegWit public keys from this mnemonic.
I have found this, but it generates legacy addresses. It uses the module bip32utils.
def bip39(mnemonic_words):
    mobj = mnemonic.Mnemonic("english")
    seed = mobj.to_seed(mnemonic_words)

    bip32_root_key_obj = bip32utils.BIP32Key.fromEntropy(seed)
    bip32_child_key_obj = bip32_root_key_obj.ChildKey(
        44 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(
        0 + bip32utils.BIP32_HARDEN
    ).ChildKey(0).ChildKey(0)

    return {
        'mnemonic_words': mnemonic_words,
        'addr': bip32_child_key_obj.Address(),
        'publickey': binascii.hexlify(bip32_child_key_obj.PublicKey()).decode(),
        'privatekey': bip32_child_key_obj.WalletImportFormat(),
        'coin': 'BTC'
    }

if __name__ == '__main__':
    seed = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'
    pprint.pprint(bip39(seed))

I assume I need bip44utils or something, but it doesn't exists. I have tried looking at bip-utils but I can't work out how to convert my mnemonic to an address.
Does anyone know how I can convert a mnemonic to a SegWit address (in a way that I can change the derivation path to get multiple addresses)?
EDIT (SOLVED):
I found bitcoinlib can do this.
from bitcoinlib.wallets import Wallet

passphrase = 'input display smile visa surround learn solar hero vacuum parrot cigar devote'

w = Wallet.create("Wallet1", witness_type='segwit', keys=passphrase, network='bitcoin')
WalletKeys = (w.get_keys(number_of_keys=10))

for k in WalletKeys:
    print(k.address)

And now it works just as I wanted it to.

If you just need a command line, you can try pip3 install btc-address-dump.
Here is an example:
$ btc_address_dump "olympic wine chicken argue unaware bundle tunnel grid spider slot spell need"
mnemonic = olympic wine chicken argue unaware bundle tunnel grid spider slot spell need
private key (hex) = c7ac679b56f50bfd54dd924fe45a8dca7a1c2dced254b03dac22afc03adb9127
private key (WIF) = 5KLDyKtrScLYsKMJzVCt8Mf6Nn9DEV7V3fg8njfSZnqe7ZEMqzK
private key (WIF compressed) = L3urFcPsE2yHf5zeQjVSfUB8j8FEzX5cnmhjNsJfqjKgowPP4tmg
public key (uncompressed) = 044cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1087190d91e26af594e3f8ecd3f4d3596c03c45d3b235da916903c930c6593cc4
public key (compressed) = 024cd0aaeca3b636078583408e75edd77307b5190ca7a48bb9fbc1f2576c17dff1
legacy address (p2pkh uncompressed) = 1Q5RqZctfcNkTPad2tuJSREByd2gB8xs63
legacy address (p2pkh compressed) = 12W36tm2jnreFiYdrzfE6cvRaKRbicEpnA
p2sh-segwit address (p2sh p2wpkh) = 3AzXxVUqdzvzEqVmdtmeVqRwc98uqwyh76
bech32 address (p2wpkh) = bc1qzp6lz6zy9p7k68r0a7lzfpkdxvj3yapynzuatt

This looks great thanks. I got errors though when I run import btc_address_dump. This should work with python3.8.5 right?

how can I implement the btc_adress_dump in a good way, dou you have a complete python code for this.
Would be very great.

Hi JOjo, the project appears to be developed on this github reposity under an MIT license. This may present a good starting point for any amendments you wish to make.—I’m gonna delete your answer post since it’s not answering the question that started this topic. Please start a new topic if you have another question.


text:
Changing settings of Bitcoin-Qt on Mac
I am using Bitcoin-Qt on my Mac under Mac OS 10.8.3. Everything is working fine but when I want to change any settings in the settings menu, it will never remember my new settings. Is there any solution to this?

I'm not able to reproduce this. You should perhaps report it on the issue tracker.

I will try to re-install it, maybe it will solve the problem.


text:
How do you calculate fees with bitcoind?
Here is the transaction id as an example, please help me calculate using bitcoind: 10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd

Possible duplicate of Calculation of transaction fee for transaction

My question specifically pertains to using bitcoind, the other question is a little more broad.

Fees are the difference between the total inputs and the total outputs.
To retrieve the total out: Let’s make a getrawtransaction request with this transaction id, and add all the "vout" values together to get the total.
The request will look like this (use "1" at the end to return JSON):

bitcoin-cli getrawtransaction
  10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd 1

In this example there is only 1 output:
  "vout": [
    {
      "value": 3.60555045,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 ccc497f13cf4c598201e4b12353649be44172b01 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914ccc497f13cf4c598201e4b12353649be44172b0188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1KfiMh5SDTYBGrDDHfSegrHkkWZQ2mSXtP"
        ]
      }
    }   ], ...

To retrieve the total input: We need make an additional request for each input to get the input values. So in this example there is one input:
  "vin": [
    {
      "txid": "b13b4765e46228f3239858c9f18e766b72bed24a56c52b9692e7f021c376e7ce",
      "vout": 1,
      "scriptSig": {
        "asm": "3044022044ca9b69f8c14eccd400be62a5320c8938aee176033c91f4cb17f57b14a20de402206e520a6398b01467772395557415bde2b7879e0e554eb6306718aa81fae5247d[ALL] 0373b9e8c6bd75e3029c00d629baff141895a4444d55894d48f0426842608d8e4d",
        "hex": "473044022044ca9b69f8c14eccd400be62a5320c8938aee176033c91f4cb17f57b14a20de402206e520a6398b01467772395557415bde2b7879e0e554eb6306718aa81fae5247d01210373b9e8c6bd75e3029c00d629baff141895a4444d55894d48f0426842608d8e4d"
      },
      "sequence": 4294967295
    }
  ],
...

We are interested in the "txid" and "vout". We need to make an additional getrawtransaction request for this id, and look at the value of the 2nd ouput (since vout is 1). That output is here:
{
  "value": 3.61007045,
  "n": 1,
  "scriptPubKey": {
    "asm": "OP_DUP OP_HASH160 02952d768c840f30a49e20af5bd4219210a14d24 OP_EQUALVERIFY OP_CHECKSIG",
    "hex": "76a91402952d768c840f30a49e20af5bd4219210a14d2488ac",
    "reqSigs": 1,
    "type": "pubkeyhash",
    "addresses": [
      "1Ef4RcUBZfrFyoVxZeU7tH5dRd9SXcJHN"
    ]
  }
}

Now we can subtract the total inputs from the total outputs to get the fees: 3.61007045 - 3.60555045 = 0.00452 in fees


text:
how generate <sig> part of scriptSig in bitcoin transactions
I studied many links about bitcoin trxs and about generating scriptSig.
Finally I couldn't understand how to make this part.
for example I read this links:
What is relation between scriptSig and scriptPubKey?
https://bitcoin.org/en/developer-guide#transactions
How do you create a scriptsig for a new raw tx?
How to redeem a basic Tx?
How to create the <sig> <PubK> part in "scriptSig"?
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
https://en.bitcoin.it/wiki/Protocol_documentation#tx
https://en.bitcoin.it/wiki/Transaction
I found that I must sign a thing but whats that thing ?
exactly and step by step What should I put together and then sign it?
specially if I had more than 1 input how make sigscript ?
I have a library that does the sign operation for me. however, I don't know what structure I need to use for the message that is going to be signed especially when there are multiple outputs.

The data to be signed is called Hash Preimage. Then you sign the double SHA256 of hash preimage, which is 256-bits long. Before hashing, the data must be formed as shown in this answer. If you're signing a SegWit transaction, the contents of the preimage changes, as defined in BIP 143.
Then you can use the formulae here, Eq. 2:
(x1, y1) = k × G(x, y) mod p
r = x1 mod n

k is a random number, G is the generator, p is the prime modulo, etc.
Then,
s = (k^-1 (h(m) + d * r)) mod n

d is the private key, h(m) is the double SHA256 result. Now, you can use r, s to create the DER-encoded signature.

I read this but this solution was for only a transaction with one output. if my outputs becomes 2 or 3 now how must make scriptsig?

Here's an example with multiple outputs. Here's the specification for outputs in BIP143, scroll down to hashOutputs.

I read this link But it's not explained at all about how the script signature section was created !!

After you formed the data in the examples, you double sha256 it and use the equations above. Do you want to learn how to do that using libsecp256k1?

no. I have a library that do the sign operation for me. I only want to know exactly which parts of the transaction do I need to put together, and what order should I use before sign operation with more than one input and one output ?


text:
Missing input returned from sendrawtransaction on P2SH multisig?
I'm playing around on regtest to build a flow for P2SH multisig. I'm getting "missing inputs" back from the sendrawtransaction RPC call, but I see inputs when I put it in a decoder. They each have a parent txid along with the index of the transaction they're trying to spend. Also the sigscript is two of the three sigs required, with the redeem script after.
It's a transaction that signs two multisigs and sends the coins to two addresses.
I get the feeling there's something I've misunderstood or added in the wrong place. Particularly the OP_0 which I understood to be a baked in bug from way back seems to appear in my script but not in other's.
Also I'm unclear about what the signature script needs to contain? I read that you need the original redeem script preceeded by the signatures. But mine seems to be a lot longer than examples I've found.
Here's a sample HEX of my transaction:
0100000002c7aa6e8710e39a51633e8a7dd76b9e8f6781753b99c26f2c3cc4193d4bdd6bae00000000fdfd0000483045022100e5837a236b445e9c93252aada919af04ec3c0242a69b9596a9a6e3998a874a4c02201d5075a35698230584a5ba3e71ef65f457c2ae98be130d9c79447c13d068e2e60147304402204afbb74994287fb09384836aef0b48b254f3ae595c7353ef3ba9b72625506d97022046d99158aad1198b70d04a0195e8e65b0115218ee529061e35b66090c0d82a65014c695221037e57f9f2a4b858ceeecb7b8c443dba0c8a15a01fa2f0ff67101a89aa38bb240d21037e722d46da6fabaf28ec4d52eeb52b4589ed6aa71838eb52bcb3293caf310d3921038d1924d2e0e895b198c653861f78c0f65709961b1c6fee5498a337f952bf9e0353aeffffffff326a67f8668570fb0a60af8ebcf2ab0793dd4ba272ff6c7c3cf4eb2b62c19d6201000000fdfd000047304402201efed43a1a9bc3286745628adc829ee75716a3cc9e5d96bbace2e77cd61c210602205dd6e1e903b0186538978a327f7c206b1107d575b0fc8db201bf0bae2535882401483045022100dce634a29da4cf08e3b6b16b3ca7c8abf8900d1e8976f3b14a120d8b85e6034402205b11fd15cfa7d29681a59408bf67540a48c32fca7ebe3b24c7a2d695e5ea3765014c6952210233ca1ca0da0e46decd7a89d7c37ec30d60850a96c2ccf0a7c58dd9c016f1bf9c21025b7f36a085d039a5a394ec9948418ffb16438d2463a8a3647c58e0b4e42bd7ed2103001fb69eedda91acf8cc93895334616523370f629ec864a0da9b2d3e8a2fa3ca53aeffffffff0200e1f5050000000017a914f71e30b65d23124daf513943a07b6f9f54f0c9cd870065cd1d0000000017a91484fdbb3c611311033208cb3aacb8d60392095f558700000000

And here's what Bitcoind thinks it decodes to:
{
    txid=531157efd4cbb1561e13aa1f39b31cae87f463f7f84ba04373b794a73784dc23,
    hash=531157efd4cbb1561e13aa1f39b31cae87f463f7f84ba04373b794a73784dc23,
    version=1,
    size=666,
    vsize=666,
    weight=2664,
    locktime=0,
    vin=
    [
        {
            txid=ae6bdd4b3d19c43c2c6fc2993b7581678f9e6bd77d8a3e63519ae310876eaac7,
            vout=0,
            scriptSig=
            {
                asm=0 3045022100e5837a236b445e9c93252aada919af04ec3c0242a69b9596a9a6e3998a874a4c02201d5075a35698230584a5ba3e71ef65f457c2ae98be130d9c79447c13d068e2e6[ALL] 304402204afbb74994287fb09384836aef0b48b254f3ae595c7353ef3ba9b72625506d97022046d99158aad1198b70d04a0195e8e65b0115218ee529061e35b66090c0d82a65[ALL] 5221037e57f9f2a4b858ceeecb7b8c443dba0c8a15a01fa2f0ff67101a89aa38bb240d21037e722d46da6fabaf28ec4d52eeb52b4589ed6aa71838eb52bcb3293caf310d3921038d1924d2e0e895b198c653861f78c0f65709961b1c6fee5498a337f952bf9e0353ae,
                hex=00483045022100e5837a236b445e9c93252aada919af04ec3c0242a69b9596a9a6e3998a874a4c02201d5075a35698230584a5ba3e71ef65f457c2ae98be130d9c79447c13d068e2e60147304402204afbb74994287fb09384836aef0b48b254f3ae595c7353ef3ba9b72625506d97022046d99158aad1198b70d04a0195e8e65b0115218ee529061e35b66090c0d82a65014c695221037e57f9f2a4b858ceeecb7b8c443dba0c8a15a01fa2f0ff67101a89aa38bb240d21037e722d46da6fabaf28ec4d52eeb52b4589ed6aa71838eb52bcb3293caf310d3921038d1924d2e0e895b198c653861f78c0f65709961b1c6fee5498a337f952bf9e0353a
            },
            sequence=4294967295
        },
        {
            txid=629dc1622bebf43c7c6cff72a24bdd9307abf2bc8eaf600afb708566f8676a32,
            vout=1,
            scriptSig=
            {
                asm=0 304402201efed43a1a9bc3286745628adc829ee75716a3cc9e5d96bbace2e77cd61c210602205dd6e1e903b0186538978a327f7c206b1107d575b0fc8db201bf0bae25358824[ALL] 3045022100dce634a29da4cf08e3b6b16b3ca7c8abf8900d1e8976f3b14a120d8b85e6034402205b11fd15cfa7d29681a59408bf67540a48c32fca7ebe3b24c7a2d695e5ea3765[ALL] 52210233ca1ca0da0e46decd7a89d7c37ec30d60850a96c2ccf0a7c58dd9c016f1bf9c21025b7f36a085d039a5a394ec9948418ffb16438d2463a8a3647c58e0b4e42bd7ed2103001fb69eedda91acf8cc93895334616523370f629ec864a0da9b2d3e8a2fa3ca53ae,
                hex=0047304402201efed43a1a9bc3286745628adc829ee75716a3cc9e5d96bbace2e77cd61c210602205dd6e1e903b0186538978a327f7c206b1107d575b0fc8db201bf0bae2535882401483045022100dce634a29da4cf08e3b6b16b3ca7c8abf8900d1e8976f3b14a120d8b85e6034402205b11fd15cfa7d29681a59408bf67540a48c32fca7ebe3b24c7a2d695e5ea3765014c6952210233ca1ca0da0e46decd7a89d7c37ec30d60850a96c2ccf0a7c58dd9c016f1bf9c21025b7f36a085d039a5a394ec9948418ffb16438d2463a8a3647c58e0b4e42bd7ed2103001fb69eedda91acf8cc93895334616523370f629ec864a0da9b2d3e8a2fa3ca53ae
            },
            sequence=4294967295
        }
    ],
    vout=
    [
        {
            value=1.00000000,
            n=0,
            scriptPubKey=
            {
                asm=OP_HASH160 f71e30b65d23124daf513943a07b6f9f54f0c9cd OP_EQUAL,
                hex=a914f71e30b65d23124daf513943a07b6f9f54f0c9cd87,
                reqSigs=1,
                type=scripthash,
                addresses=[2NFms4Kj7Jqa3ozPffoHg2NVzuYvH7sAGTN]
            }
        },
        {
            value=5.00000000,
            n=1,
            scriptPubKey=
            {
                asm=OP_HASH160 84fdbb3c611311033208cb3aacb8d60392095f55 OP_EQUAL,
                hex=a91484fdbb3c611311033208cb3aacb8d60392095f5587,
                reqSigs=1,
                type=scripthash,
                addresses=[2N5NR9Aua54wSwHbdmRhjPwPtqc1v1zYyze]
            }
        }
    ]
}

Here's what Bitcoinj thought it was sending:
SpendObj aftr sigs:
[
    Transaction
    {
        531157efd4cbb1561e13aa1f39b31cae87f463f7f84ba04373b794a73784dc23
        purpose: UNKNOWN
        in   0[] PUSHDATA(72)[3045022100e5837a236b445e9c93252aada919af04ec3c0242a69b9596a9a6e3998a874a4c02201d5075a35698230584a5ba3e71ef65f457c2ae98be130d9c79447c13d068e2e601] PUSHDATA(71)[304402204afbb74994287fb09384836aef0b48b254f3ae595c7353ef3ba9b72625506d97022046d99158aad1198b70d04a0195e8e65b0115218ee529061e35b66090c0d82a6501] PUSHDATA1[5221037e57f9f2a4b858ceeecb7b8c443dba0c8a15a01fa2f0ff67101a89aa38bb240d21037e722d46da6fabaf28ec4d52eeb52b4589ed6aa71838eb52bcb3293caf310d3921038d1924d2e0e895b198c653861f78c0f65709961b1c6fee5498a337f952bf9e0353ae]
            unconnected  outpoint:ae6bdd4b3d19c43c2c6fc2993b7581678f9e6bd77d8a3e63519ae310876eaac7:0
        in   0[] PUSHDATA(71)[304402201efed43a1a9bc3286745628adc829ee75716a3cc9e5d96bbace2e77cd61c210602205dd6e1e903b0186538978a327f7c206b1107d575b0fc8db201bf0bae2535882401] PUSHDATA(72)[3045022100dce634a29da4cf08e3b6b16b3ca7c8abf8900d1e8976f3b14a120d8b85e6034402205b11fd15cfa7d29681a59408bf67540a48c32fca7ebe3b24c7a2d695e5ea376501] PUSHDATA1[52210233ca1ca0da0e46decd7a89d7c37ec30d60850a96c2ccf0a7c58dd9c016f1bf9c21025b7f36a085d039a5a394ec9948418ffb16438d2463a8a3647c58e0b4e42bd7ed2103001fb69eedda91acf8cc93895334616523370f629ec864a0da9b2d3e8a2fa3ca53ae]
            unconnected  outpoint:629dc1622bebf43c7c6cff72a24bdd9307abf2bc8eaf600afb708566f8676a32:1
        out  HASH160 PUSHDATA(20)[f71e30b65d23124daf513943a07b6f9f54f0c9cd] EQUAL  1.00 BTC
            P2SH addr:2NFms4Kj7Jqa3ozPffoHg2NVzuYvH7sAGTN
        out  HASH160 PUSHDATA(20)[84fdbb3c611311033208cb3aacb8d60392095f55] EQUAL  5.00 BTC
            P2SH addr:2N5NR9Aua54wSwHbdmRhjPwPtqc1v1zYyze
    }
]

The example to compare to is here:
https://blockchain.info/rawtx/ca1884b8f2e0ba88249a86ec5ddca04f937f12d4fac299af41a9b51643302077
It is spent by this:
https://blockchain.info/rawtx/19f589be5fda5a97b5a26158abd1fa02e68a15e5a6a4d83791935f882dbe0492

Seems to me  that the transaction outputs referenced in the inputs cannot be found

They're on regtest on my local machine. I've called the RPC client to print them out and I see them.

Can you say whether the scripts are correctly formed?

I checked the first input script and it is correctly formed. You use a clean unlocking script, including the OP_0 at the beginning and correctly pushing 2 signatures and the redeem script onto the stack. The redeem script is a valid 2-of-3 multisig script.

Your second input script is also a correctly formed 2-of-3 multisig script.

The UTXO referenced in input 0 has the locking script 14 727712707247cd8b2846fe5290072e8843dacb35 87?
The UTXO referenced in input 1 has the locking script 14 10205b6f1a5df6d95fe4a06ac10490008f8b322f 87?

I think I figured it out. I've swapped some sigs around. That's why it looks correctly formed, but is invalid.


text:
How do you commit to the previous output's amount when signing a segwit input with rust-bitcoin?
I'm trying to sign a segwit transaction in rust-bitcoin. To start with, my transaction setup looks as follows:
let previous_output = OutPoint::new(Txid::from_hex("991ab2b13f6bc6c13002d79d5e9775626a5e7328e14cd16837d50d1cc637dc6a").unwrap(), 0);
let tx_input = TxIn {
    previous_output,
    script_sig: Default::default(),
    sequence: 0xffffffff,
    witness: Default::default()
};

let tx_output = TxOut {
    value: 4999995000,
    script_pubkey: output_details.script_pubkey() // don't worry about this
};

let mut transaction = Transaction {
    version: 2,
    lock_time: 0,
    input: vec![tx_input],
    output: vec![tx_output]
};

In order to sign the transaction (using Schnorr, by the way), I extract the sighash as follows:
let signature_hash = transaction.signature_hash(0, &output_details.script_pubkey(), 0); // is that really the most idiomatic way of passing a sighash flag in rust-bitcoin?
let message = Message::from_slice(&signature_hash.to_vec()).unwrap();

When I print the hex-serialized message, I get the following value: fa42b9b0f54972b31712b2efbc86db1bf78aa833bc9c969ea7860ef38a25fbaf.
However, in order to sign a segwit transaction, the previous output's amount must also be committed to, and I'm not seeing a way to do that. As far as I can tell, the sighash I should be signing is in fact 61746ec9baa14bbe82586c7f149926b1492871c67dc7fe21e7cfe2f2260a1405.
Finally, though less relevantly, if things were to work fine, here's how my signature process would conlude:
let signature = private_key.sign_schnorr(message);
let signature_vec = signature.as_ref().to_vec();
transaction.input[0].witness = Witness::from_vec(vec![signature_vec]);

Thanks in advance for helping me figure this out!

There is a bitcoin::util::sighash module which has all of the sighashing stuff. I'm not certain that it is the correct way, but it is definitely a way to get the result that you want.
It looks like you have to create a SighashCache object, which you can then use to get all different kinds of sighashes for the transaction.
In your case, this code might make it work:
let previous_output_as_tx_out = TxOut {
    value: 50_0000_0000,
    script_pubkey: output_details.script_pubkey()
};
let prevouts = vec![previous_output_as_tx_out];

let mut sighash_cache = bitcoin::util::sighash::SighashCache::new(&transaction);
let input_index = 0;

// taproot_key_spend_signature_hash is the crucial part
let signature_hash = sighash_cache.taproot_key_spend_signature_hash(input_index, &Prevouts::All(&prevouts), SchnorrSighashType::Default).unwrap();
let message = Message::from_slice(&signature_hash.to_vec()).unwrap();

This is the correct way. I apologize for the misleading Transaction::signature_hash name, which should probably be renamed to Transaction::legacy_signature_hash and/or deprecated in favor of the SighashCache object.
To arik, the reason for the weird SighashCache API is that from segwit v0 onward, the signature hashes for different inputs in a transaction share a significant amount of computational work, which saves time when saving a whole transaction.

Thanks for the response! There doesn't appear to be much documentation or really anything in terms of examples on how to use the taproot_key_spend_signature_hash method, in particular its prevouts parameters. But I should hopefully figure it out within a couple minutes.

All right, got it. Feel free to update your answer with the code I used :)


text:
How do I fix my check-multisig if-else output script?
I'm trying to create a custom script with if/else and a multisig operation in one branch. Currently, my script looks thus:
OP_IF
    <pub1>
    OP_CHECKSIG
OP_ELSE
    OP_2
    <pub2>
    <pub3>
    <pub4>
    OP_3
    OP_CHECKMULTISIG
OP_ENDIF

I have calculated a testnet address (2NF3yXy2MambEnJuY7eStLNcX92WSxytLvC) from this example script and sent testcoin there. Then, I tried spending the money with the following sig script:
OP_0 <sig2> <sig3> <redeemScript>

However, when trying to broadcast the transaction, I get an error:

PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED
  (SIGNATURE MUST BE ZERO FOR FAILED CHECK(MULTI)SIG OPERATION)

For reference, here's my raw transaction:
0100000001a492c575e44450a9be9ec4520ea365c53ea6f2018130d682ebf97bdf1b1a15ca01000000fd230100483045022100f502ecfd2b7bbb3e7092b320c568abe0d68dd7e613ab3efcb9e479b2641a73a502202b416bb86bce3d242084f8e24cbed76e5a2c5a0795a5bbd7f3366bf6d086ae4f0147304402201022c7548b55f3fbe3ddf427ad2ae5c6a776e2a63ee25376dca123d53d0f940f022041aa7967208ee8aee1811f02d6c7db0ad2872304133d46dbdd117e9bc09d8c97014c8f632102bc050e51811c2c454bf3487129b19d60b87f7a51fb434e6073def19dc55cf4b3ac67522102a906b96ea2df77aff1f84cc9949550f8d6b8f3db5acd625d12d70b6da4b94b1e2102046e854e69a49dd210dbf554f1e420893935b47123667a1834def9fe5d44358a210325db22e2aef6f143026500522431d4f348f911562316350852e6382da6a048a753ae68ffffffff01403fcb000000000017a91429b5c822f40f80cce593460927095ea6d8d720bc8700000000

Its sig script is this:
00483045022100f502ecfd2b7bbb3e7092b320c568abe0d68dd7e613ab3efcb9e479b2641a73a502202b416bb86bce3d242084f8e24cbed76e5a2c5a0795a5bbd7f3366bf6d086ae4f0147304402201022c7548b55f3fbe3ddf427ad2ae5c6a776e2a63ee25376dca123d53d0f940f022041aa7967208ee8aee1811f02d6c7db0ad2872304133d46dbdd117e9bc09d8c97014c8f632102bc050e51811c2c454bf3487129b19d60b87f7a51fb434e6073def19dc55cf4b3ac67522102a906b96ea2df77aff1f84cc9949550f8d6b8f3db5acd625d12d70b6da4b94b1e2102046e854e69a49dd210dbf554f1e420893935b47123667a1834def9fe5d44358a210325db22e2aef6f143026500522431d4f348f911562316350852e6382da6a048a753ae68

Which decodes to

0
  3045022100f502ecfd2b7bbb3e7092b320c568abe0d68dd7e613ab3efcb9e479b2641a73a502202b416bb86bce3d242084f8e24cbed76e5a2c5a0795a5bbd7f3366bf6d086ae4f[ALL]
  304402201022c7548b55f3fbe3ddf427ad2ae5c6a776e2a63ee25376dca123d53d0f940f022041aa7967208ee8aee1811f02d6c7db0ad2872304133d46dbdd117e9bc09d8c97[ALL]
  632102bc050e51811c2c454bf3487129b19d60b87f7a51fb434e6073def19dc55cf4b3ac67522102a906b96ea2df77aff1f84cc9949550f8d6b8f3db5acd625d12d70b6da4b94b1e2102046e854e69a49dd210dbf554f1e420893935b47123667a1834def9fe5d44358a210325db22e2aef6f143026500522431d4f348f911562316350852e6382da6a048a753ae68

The last line is clearly visible as the redeem script, which in turn decodes to this:

OP_IF
  02bc050e51811c2c454bf3487129b19d60b87f7a51fb434e6073def19dc55cf4b3
  OP_CHECKSIG OP_ELSE 2
  02a906b96ea2df77aff1f84cc9949550f8d6b8f3db5acd625d12d70b6da4b94b1e
  02046e854e69a49dd210dbf554f1e420893935b47123667a1834def9fe5d44358a
  0325db22e2aef6f143026500522431d4f348f911562316350852e6382da6a048a7 3
  OP_CHECKMULTISIG OP_ENDIF

Is my sig script incorrect? Is the output script invalid? How can I fix this and make it work?
Thank you very much in advance!
EDIT: After taking into consideration Pieter's comment but placing the extra OP_0 right after the two signatures in the sig script, it worked. Here's the new decoded sig script:

0
  3045022100f502ecfd2b7bbb3e7092b320c568abe0d68dd7e613ab3efcb9e479b2641a73a502202b416bb86bce3d242084f8e24cbed76e5a2c5a0795a5bbd7f3366bf6d086ae4f[ALL]
  304402201022c7548b55f3fbe3ddf427ad2ae5c6a776e2a63ee25376dca123d53d0f940f022041aa7967208ee8aee1811f02d6c7db0ad2872304133d46dbdd117e9bc09d8c97[ALL]
  0
  632102bc050e51811c2c454bf3487129b19d60b87f7a51fb434e6073def19dc55cf4b3ac67522102a906b96ea2df77aff1f84cc9949550f8d6b8f3db5acd625d12d70b6da4b94b1e2102046e854e69a49dd210dbf554f1e420893935b47123667a1834def9fe5d44358a210325db22e2aef6f143026500522431d4f348f911562316350852e6382da6a048a753ae68

And here's the link to the transaction: https://testnet.smartbit.com.au/tx/1894cb91fde60432e59d60f30de503e8b6fbe5d1756bbf0ef7302b57bf31d195

I believe you may need two OP_0's at the start: one to be consumed by OP_IF, and one which is popped off by OP_CHECKMULTISIG. I'll turn this into a full answer once I've identified the issue.

Thanks for your response! I just tried it, and I'm still getting the same error: PUSH TRANSACTION ERROR: 16: MANDATORY-SCRIPT-VERIFY-FLAG-FAILED (SIGNATURE MUST BE ZERO FOR FAILED CHECK(MULTI)SIG OPERATION)

~30min in the Video Andreas explains the „IF“ handling of script. There must be a value before the IF statement. Either 1 for the If-branch or a 0 for the else branch. https://m.youtube.com/watch?v=yU3Sr07Qnxg

@pebwindkraft: that should be an answer. ;)

@murch: not chasing for credits anymore :-) Pieter and you have provided the answers, and this is just "a little bit" additional explanation, which might help the users to better understand the previous comments.

@pebwindkraft: Fair enough. However, it's not only about the reputation, it's also that comments shouldn't be used to answer questions. ;)

OP_IF consumes a number from the top of the stack.
The OP_IF will evaluate to true if the number is not 0, and to false if the number is 0.
 H/T for this answer by David Schwartz, and  to Pieter Wuille for getting me on the right track.


text:
Are multibit HD (or other no web wallet) and Blockchain.info wallet words compatible?
Well the title says it. I tried to enter blockchain.info seed words into multibit, but it doesn't seem to be working.
So what I'm trying to do is to have multibit (or other) alternative of my blockchain.info wallet so I can send bitcoins when blockchain.info is down.

I think you are asking two different questions: 1) How can a Blockchain.info wallet be imported to a desktop wallet? 2) How can I use a wallet in parallel on blockchain.info and a desktop wallet. The two questions don't necessarily have to have the same answer, but your question is loaded because you postulate that they do.

As far you don't create new addresses it is one question, because I'm asking to send bitcoins and nothing more. The problem is obvious and real, because blockchain.info was down recently several times and this is easy solution how to recover your bitcoins. Of course you need to backup private key every time you add new address. If you do both wallets will show all transactions and correct balance, so you can use them in parallel.

The wallet Blockchain.info offers to users is not an deterministic wallet, as such the mnemonic they present is not compatible with any other piece of software other than their own. If you have your wallet.aes.json file downloaded it can be opened with a very old version of MultiBit Classic, other than that you will have to wait for the centralized wallet to be available again before you can send money.

Thank you for correct answer, however I solved my problem using electrum wallet. I imported the private keys of my blockchain.info wallet, and that worked.

Good to know. Just keep in mind that you will not be able to recover this custom wallet setup using the seed, so keep your wallet file safe.


text:
test net block time wrong
I can see http://tbtc.blockr.io/ time of block are showing "right now". When I click "all blocks" the time is two hours ahead of "now". I don't think it's blockr time zone problem, because
1) when I submit transaction, it will show correct time
2) my bitcoinj wallet also showing future time against
System.currentTimeMillis();

which is UTC time. (I use ntp and it happens on two different computers)
Anybody have an idea why this is happening?

It might be that any times in the future get converted to right now. It might be good to put a screenshot, though, so that you can still see the issue even if the problem gets fixed.

well the screenshot shows last 11 blocks, considering they go faster in testnet, the last one should be half hour old

The timestamps on those blocks are indeed quite varied so I think that blockr.io is not using the timestamp field in the block as sole timing information, instead using something like min(relayed time, block timestamp) so that blocks that have a future timestamp are shown as "right now" because they use the relayed time. They probably are not only using the relayed time since in that case they'd be misdating all blocks after downtime.
TL;DR: do not trust the timestamp field in the block, it can be manipulated.

the question is more why there are future timestamps in test net ? Are you sure that even main net does not check the block time ?

Yes, it is not possible to synchronize clocks in a distributed system, so Bitcoin limits the checking to a rather large range of [-2 hours:+2 hours], which is what you're observing. From an observer the cases of the block creator putting a timestamp in the future and the observer's clock lagging is indistinguishable.


text:
How to do paper backup and restore for bitcoin core
Since bitcoin core is HD wallet, it should be possible to make "seed" like backup for it and there should be way to restore the wallet from it as well. I know there is dumpprivkey, but it needs to be done after every transaction to be safe. Other wallets have nice seed backup and restore methods, I suppose core should have one as well.
There is xprv method mentioned in comments, but I'm still missing restore method. Also I would like to do it from console only, since my wallet is on remote server without graphics.
I'm interested in "string" backup mainly because I want to store it in trezor hardware password manager, which does not support files

Core doesn't create seed mnemonics. Best you can do is backup the xprv. See here: https://bitcoin.stackexchange.com/a/56428/5273

xprv method could be good enough, but the answer does not tell how to restore hd wallet from it, I'm changing the question

Bitcoin Core does not allow you to restore from a given seed or master private key (xprv). There is currently no mechanism for importing seeds or master private keys and no mechanism for exporting seeds (and a convoluted workaround for exporting master private keys).
Note that you can import individual private keys, not just seeds, mnemonics, or master private keys. These can be imported with importmulti or importprivkey and can be exported with dumpprivkey.

that's too bad to hear, anyway seems as correct answer so far

Has there been any recent changes to Bitcoin Core that enable backing up to paper wallet or is it still the same?

@M.K.Safi No, there has not.

@AndrewChow What if I start a new wallet and use sethdseed with a fresh keypool. Then to restore the wallet, I would set the same HD seed again, and do a blockchain rescan. Would that not be sufficient?

@M.K.Safi Yes, I believe that would be sufficient to recover your private keys. However you need to be careful that the wallet you restore to is blank so that there is not already an existing seed and keypool. Otherwise you may be using keys that you did not backup.

@AndrewChow Thank you! But how does the wallet know which addresses to scan for? What if, hypothetically speaking, I generate 10,000 addresses that I don't use and then end up using the address 10,001. Would Bitcoin Core be able to know that addresses from 1 to 10,000 are empty but 10,001 has balance?

@M.K.Safi No, it would not.

there should be setting to look ahead number of addresses, I think it's 1000 by default

Is this answer still correct? bitcoin-cli dumpwallet ~/my_test_wallet.txt will dump the wallet with the hdseed in it. You can then create a blank wallet and sethdseed


text:
Using Bitcoin with MEAN stack
I want to make a web app that accepts and uses Bitcoin, complete with user accounts, bitcoin storage per user, etc.  How would I go about hooking this up using MEAN?  Is there a reference for setting up a bitcoin user account database RDBMS model or a SQL/noSQL reference that you can suggest?

I don't think it would be particularly different from LAMP. You'd use different libraries, sure, but you've got the same problems to solve: creating addresses, detecting payments, secure key storage, etc.


text:
Bitcoin raw transaction hash signing
I was just wondering when you're at the double hashing part of making a transaction do you need to specify the scriptpubsig like:
01000000
01
1c615595ac93432de87bcc519f2ddffce1a5f88bd4ec3e586c56e05b35e13767
01000000
00
ffffffff
02
6400000000000000
19
76a9143b65057d8846147349a816f41a6c5cc1e706a02b88ac
a086010000000000
19
76a914f323ec06f263e6ba625de2cf27f1495294065b8088ac
00000000
01000000

or does it need to be like:
01000000
01
eccf7e3034189b851985d871f91384b8ee357cd47c3024736e5676eb2debb3f2
01000000
19
76a914010966776006953d5567439e5e39f86a0d273bee88ac
ffffffff
01
605af40500000000
19
76a914097072524438d003d23a2f23edb65aae1bb3e46988ac
00000000
01000000

main differences:
example 1:
 1c615595ac93432de87bcc519f2ddffce1a5f88bd4ec3e586c56e05b35e13767 //tx of input
 01000000
 00 //script len
 //no script
 ffffffff //requence

example 2
eccf7e3034189b851985d871f91384b8ee357cd47c3024736e5676eb2debb3f2  //tx of input
01000000
19 //script len
76a914010966776006953d5567439e5e39f86a0d273bee88ac   //script
ffffffff //sequence

You want the scriptsig there. You can find out all you need and more here: http://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required

the thing that got me was the  result of step 14.. i presumed that it would be equal to createrawtransaction output.... thanks


text:
Is there any way to buy bitcoins online without a fee?
I'm new to bitcoins, and my experience is from something like E*Trade buying on the NASDAQ, so that's my frame of reference. I paid a small broker fee for every buy or sell, and I trusted the exchange and the software 100%.
But I thought the big advantage of bitcoin was no middle man. Hence I assumed no fees.
But perhaps contrary to that first assumption, in my second assumption I thought there would be this big trusted website where you go and buy / sell anonymously without having to trust the other party. You would just need to trust the exchange itself.
Can I buy bitcoins anywhere without a fee?
Can I buy bitcoins anywhere with 0 risk of getting ripped off, as in a flea market?
Can I get both positive things in one place (ideal)?
Thanks.
EDIT
Coinbase Pro allows me to do limit buys for free. The trick there is to set the limit price to the current price and keep changing the price if necessary to get the desired quantity purchased.
Coinbase had been charging me 1% on large buys. So for small buys ok; large buys, it adds up!
CEX.IO on the other hand, gave me large limits and they charge a flat fee of $10. So for a buy of $3000 this is only .33 percent; much better!
Also, something I need to watch out for is the buy price. The exchanges mess with that to make extra margin I think. So I need to shop for best price before committing to buy. Compare the total price including fee based on buy price.

"But I thought the big advantage of bitcoin was no middle man. Hence I assumed no fees." For payments there is no middle man. But you're trying to trade, not pay.

Well you could use something like bisq that gets rid of the middle man

@DavidSchwartz for a secure payment you'd also want a middleman since you can't trade at exactly the same time. It's just that the middlemen don't have to be bankers.

Of course you may trade bitcoins with just anyone without having to pay fees to a centralized exchange.
I think Bisq (formerly BitSquare) may be the best answer to the question; decentralized, free for some definitions of "free", and very low risk due to the escrow system - but not completely without fees, indeed as of 2017 one may end up paying quite much higher fees on Bisq than on some of the centralized exchanges.  Well, let's walk through this ...
Fees and costs
You probably won't get away completely without fees:

There is the bitcoin transaction fee, a fee for getting the transaction included in the network.  Basically, you can't withdraw your funds from the exchange or move it from one wallet to another without paying a network fee (though internal transfers i.e. on an exchange may be for free).  As of 2017 it has become significant (i.e. 0.001 BTC, but can vary a lot), though not that bad if you want to turn over significant amounts of money (i.e. 1 BTC).  According to the protocol the fee is not mandatory, but a regular transaction without a fee paid is very unlikely to be included in the blockchain.
With many exchanges, one pays the exchange a withdrawal fee instead of paying the network fee.  The withdrawal fee is usually constant, and usually higher than the average network fee paid by the exchange.
Fees to the exchange ... any commercial centralized market place do eventually have costs and hopes to get investments recovered; I would be vary of a site claiming to be for free - though, some exchanges takes in most of the profits on margin traders.  Sometimes market makers pays less fee than market takers - sometimes it's opposite (on Localbitcoins market makers pay the full fee).
Arbitrator fee - on peer-to-peer-platforms (Bisq) where arbitration may be needed, one may have to pay a fee for that.
Spread - on any exchange there will be a difference between the bid and the offer.  If you need to buy bitcoins instantly, you will have to cover the spread.  If you have the time, then place a bid/offer just marginally better than the competition and wait for the other party to take your offer and cover the spread.  On the exchanges with highest volume, the spread will anyway be insignificant compared to the volatility.
Banking fees, for converting fiat to/from exchanges and/or other peers selling bitcoins.
Currency converting costs.  YMMV, but for me this is a relatively significant and a somewhat hidden cost of sending fiat to an exchange.  The exchange typically don't do trades in my local currency, and my bank gives me a pretty bad exchange rate when I send money to the exchange.
Even meeting up with other people to trade cash may be costly wrg of transportation costs and time taken.
Time is money - spend hours searching for the cheapest offers, and how many dimes did you save on it? (And how much did the bitcoin market value rise while you were searching for it?)

Risks
No method are without risks.

Bankruptcy - as for the centralized exchanges this is probably the biggest risk - one day you send money to the exchange, the next day the exchange is gone.  It does happen from time to time.
Funds on a centralized exchange being frozen for other reasons.  Your funds may be frozen for a variety of reasons - it does happen from time to time.
Bitcoin transactions getting stuck.  Not so much an issue when transferring from the bigger exchanges, but due to the block size issue a transaction may stay pending for arbitrary long if it appears the transaction fee was too low.  I have personally experienced twice that a transaction from an honest seller using "wrong" wallet software was timing out after 72 hours.  This became less of an issue in late 2017, as the default timeout has been increased to two weeks and because there is more often periods with idle capacity in the blockchain.
Money lost or stalled due to other technical issues - seldom an issue, but if using a "shitty" exchange it may happen.
Simple scams (mostly an issue if buying or selling bitcoins to random strangers without a proper escrow system in place).  Some payment methods are also reversible (particularly credit card payments and paypal payments) or easy to fraud.
Fake exchange scams (mostly an issue when selling btc); there exists several sites looking like legit exchanges, except they will just eat up your bitcoin if you transfer btc there.  It has also happened that an attacker has managed to highjack the DNS entry and get a valid SSL certificate for the exchange (openledger.info).
Money laundring; lots of the money in circulation comes from criminal sources, and you may become suspected of money laundry.  This may cause your funds to get frozen on centralized exchanges.  This may cause troubles with law enforcement if trading peer-to-peer.  Laws may vary between different jurisdictions, unless it ought to be obvious that the money comes from criminal sources you generally should be on the right side of the law, but having to spend time answering questions from the police is still within my definition of "trouble".  Some banks may even decide to freeze your account just because you're sending money to the exchanges.
Third party scams; mostly an issue when selling bitcoins (anonymous money) for bank deposits (trackable money), not so much when buying bitcoins - a fraudster tricks a victim (or gains unauthorized access to the bank) into sending money to the bitcoin seller, and tricks the bitcoin seller into sending bitcoins to the fraudster.  The victim gets angry with the bitcoin seller i.e. because he's expecting the bitcoin seller to send him an iPhone.
Outright robbery - may be a risk if doing cash trades (I've encountered some attempts on robbery myself when doing cash trades), especially when appointing meetings with random strangers in dark alleys, or if counting bigger amounts of cash on a public place with the wrong person watching.  If you expose that you have a lot of bitcoins i.e. through Localbitcoins and your identity and address can be found out, you may also receive threats ("pay one bitcoin to address 1... or else something bad may happen to your family" - I've experienced that, too).
Software bugs and malicious software; can you trust the wallet software, etc?  How to tell that i.e. Bisq does it's job, without any severe bugs causing bitcoins to be lost?

Other answers here are focusing on the best or cheapest exchanges.  I'll skip that and try to make an overview of alternative market places:
Bisq (formerly Bitsquare)
Bitsquare is a free and decentralized market place, it comes with a good escrow protection.  It does have some drawbacks though:

I managed to buy bitcoins through a "same bank"-offer, using my local domestic bank account.  However, I did need to know the SWIFT-code for my bank, and I did need to know how to convert an IBAN to a local account number.  YMMV, but I think this is a bit too difficult for quite a lot of people wanting to buy bitcoins.
It's an application, not a web site - meaning you need to install special software to access it.  Also, it's a graphical monolithic application that is supposed to be running 24/7, difficult to use on/from laptops and mobile devices.
You can't buy bitcoins without already owning bitcoins - you will need to seed the application wallet with enough bitcoins to cover transaction fees and escrow deposit
As far as I can see, there is no way to do free-text communication with the seller there.
There is a max limit for how much can be transferred in a single trade
Beware of the potential chain split in November - the maintainer has promised to follow the 1X-chain, so if SegWit2X should be successful, one may end up at the wrong side of a chain split.

Bisq supports bank payments (including local currencies and local banks) and convertions to/from altcoins, as far as I can see cash is not an option there.
You will eventually need to cover banking fees, and the bitcoin transaction fees will be higher than normal due to the complexity of the escrow transactions.
(Note: the author haven't tried Bisq for quite some time, the information above may be out-of-date).
IRC
The IRC channel #bitcoin-otc on freenode is also place where it's possible to trade coins with no middleman taking commissions.  I've never tried it though.
Mycellium
The mycellium wallet (android) has a cash-transaction built-in marketplace which is (as for now) without any fees - but if it ever becomes popular, the Mycellium team may decide to slap a fee on it.  During the last year, I've gotten close to 0 trades through the Mycellium platform, so I've given it up.
LocalBitcoins
With a 1% fee (paid by the advertiser), LocalBitcoins.Com (LBC) is an unlikely candidate on this list - but still, the fee is not mandatory to pay, one can "sneak" away from it, without violating the ToS.
If you search for offers on LBC, you will most likely find that there is a relatively big gap between the offers and bids.  If you don't need to buy bitcoins immediately, you can "turn the table" and put out your own "i buy bitcoin"-ad.
Telegram
On the telegram chat service there is a bot BTC_CHANGE_BOT.  I haven't tested it though, don't even know if it has fee structures.

Using Zelle on Bisq ended up being about 2% total fees (not including the 20% deposit). This ended up being almost exactly what coinbase charges.

How much did you buy for?  I think most of the fees on Bisq (formerly BitSquare) are transaction fees, which are static - meaning that they will be high when buying small amounts, but low if buying big amounts.  Though, long time since I used it (missing the server-client model, it's difficult for me to have a graphical application up and running and be available on it all the time - and I've been concerned to end up on the wrong chain wrg of UASF and 2X)

I didn't buy, but my calculation was upon the max you can buy with Zelle, which I think is 0.5 BTC. I'm going to try calculating the effective rate for something like moneygram on LBC, which has no preset size limit. And I still need to check out OKPay on bisq. I think it's funny bisq uses tor, then sends you right under the federal reserve's nose with zelle, which is practically the only option. hehe

Some Chinese exchanges don't charge a fee.
Any site that has possession of your bitcoins or dollars means there is at least some risk of getting ripped off.
So unfortunately, what you ask for doesn't exist.

It didn't exist back in 2015, but it does exist today - BitSquare.

There is no middle man for using Bitcoin. If all your income and expenses were in Bitcoin, the transfers would have negligible overhead. But what you are looking for is a service that will take your government currency and give you bitcoins. Of course such a service has costs involved.
There are several big exchanges where you only need to trust the exchange itself rather than your counterparty (Bitstamp, Bitfinex, Kraken etc.). However:

They are generally not anonymous. Currency exchange is a highly regulated business, and if you want to trade large amounts you will be expected to identify yourself.
You will pay a fee for using them. They are providing a service for which they have costs, there is no free lunch. There is also slippage involved.
You can never have 0 risk. Nothing is ever certain. That's true for everything, not just Bitcoin. But you can minimize your risk if you act prudently.

Alternatively, you can try your luck finding someone who wishes to sell, and buy directly from him without any fees involved. But in all likelihood, that's not worth your time.
Note that the overhead is caused primarily by the government currency side of the equation. In essence, if you were to trade one cryptocurrency for another, that could be done with much less risk and costs (using atomic trades etc.).

Edit July 2018: These sites, even all this thread could be outdated. My opinion some years later has changed.
Fee is the way the exchanges win money, so if you trust some exchange without fee...

The exchange is no charging fees due to an temporary offer, and this thread will be outdated very soon.
The exchange will win money with other services, so on long-term you will pay, maybe for withdrawal fees or something similar
Maybe because is a scam... and you won't recover your money (or partially)

The fees are relatively cheap from 0.1% (one per thousand) to 1.5% so, the best way is to know other fees like withdrawal fees (from 'free' to 1.5%). Ask yourself what is more important, warranty vs free-charge.
Remember, these exchanges are your 'middle man'. You deposit there your Bitcoin or $, then risk always exists.
[Some outdated webs have been deleted]

So there's no risk if you don't deposit? I.e. you could buy BTC with creditcard and have the BTC transferred to your own address. The exchange never holds your money, the worst they can do is overcharge your CC or send your BTC to the wrong address, both can be insured against.

If you buy cryptocurrencies, you deposit FIAT, and you can buy BTC. But fiat and btc are inside the marketplace until you withadraw your money.

I heard whaleclub is a scam. (1) https://www.whaleclub-scam.com/,  (2) https://bitcointalk.org/index.php?topic=2317823.0. There is even a site dedicated to it.

@TylerS.Loeper I think you mean whaleclub [dot] io but I think it is not the same site. Despite of all, this post was answered more than two years ago, and this is too much for quality information in cryptocurrencies. Some of these sites are outdated or closed (due to China laws)

@Rutrus, true. I was just updating your answer with the information I had heard since I was myself browsing this question and answer recently. But I am not asking you to update your answer, since it was from a different time.

Don't worry. I want to leave my answers updated. I think it is a good habit. People sometimes don't look at dates.

In my opinion, your BANK should offer sending money to your designated bitcoin wallet - and grab the 1% fee while no-one else have. At least we all trust our banks, don't we? Yet for some reason they're not interested.

This is more of an opinion than an answer. Should probably convert this into a comment. BTW, the untrustworthiness of banks was the reason why bitcoin was created.

authors: امجدعبدالحر يونس شمخي ابو نور


text:
How to recover access to funds with blockchain.info passphrase
Now at blockchain.info wallet I did backup my pass phrase. But I have no idea what my private key(s) are. There is no export that I can find. I understand there used to be.

If blockchain.info goes out of business, can I use my pass phrase to gain access to my funds from another wallet?

Can you clarify the part where you say there's no export option? (Screenshot, ideally)

@WizardOfOzzie, done. personal info cut out. There is no export functionality any more in blockchain.info

Oh of course. I'd forgotten the v2 wallet was the default.

The answer is yes, I can access my funds using only my pass phrase.
Mycelium, for example, when installed, comes up and asks if I want to restore a wallet from a 12-word passphrase, which is what blockchain.info created.
It then found my funds and will allow me to send / receive.
I have since learned that the pass phrase is just used to generate the private key using the SHA-256 hash algorithm.

The passphrase is actually used as the salt in hmac-sha512 (BIP39)

@WizardOfOzzie, I'll research that and correct my answer. Thanks!


text:
How to build a Java trade bot
So my friend is interested in cryptocurrency and I decided to give him a hand, since he wants to start buying and selling coins for profit. I thought I could accomplish this, so I will point out my plan:

I will look into GDAX, which from what I understand will be better for us since we will be making several low price transactions.
Since GDAX can access Coinbase, I can just use my wallet from there to pull in funds.
Once I have registered on both sites, I will start creating the actual Java application.
I was thinking of using this API: https://github.com/robevansuk/gdax-java Even though it is a bit confusing for me, I think I can figure out how to do these functions: get market data (to figure out when to sell or buy), get account (obviously), deposit and withdraw from Coinbase, place a new order (for trading)

Now I wanted to ask you a few things on this plan.
1) Do you know of any examples of implementations of this API: https://github.com/robevansuk/gdax-java
2) I am using GDAX for the purpose of security and lower fees, but will withdrawing and depositing for Coinbase cost a fee?
3) I am probably a little blinded, due to my lack of knowledge in the subject. Before I get in this, could you point me into the best way of approaching this plan?

So you want to limit your bot strictly to gdax? There are some libs providing abstraction layers from a specific exchange. One example is
https://github.com/timmolter/XChange
This becomes very helpful once you want to make trades on more than 1 exchange.

for examples of uses of this codebase, it might be worth looking at the 'forkers' of the code base and what they're doing with it: https://github.com/irufus/gdax-java/network/members. Also join the gitter channel, theres a growing number of people looking at using the codebase for mostly crypto bots.
withdrawing/depositing to GDAX is a 0% fee transaction - its all done within their systems as far as I'm aware so shouldn't cost anything as you're not transacting on the bitcoin network.
Join the gitter channel. Link in the README here: https://github.com/irufus/gdax-java/ - this is the origin for the codebase. There's a bunch of us now trying to do stuff with this codebase.


text:
Am I being hacked, can I prevent it?
I have just sent bitcoins from one account of mine to another, and after I sent it I checked on blockchain.info to get updated about confirmation.
There, I noticed something peculiar, it said that I made two transactions at the same time, when I made only one. The first transaction was to the correct address and the correct amount.
But the second transaction was not one that I made. The second thing I noticed is the SUM of both transactions, together they form the exact amount I last received to this account a few days ago.
This looks to me like a hack. At this moment these transactions have net yet been confirmed, can I do anything about it?
Can a transaction be created fraudulently and accepted by the miners?
How can a hack like this be accomplished (if it is a hack).

Did you create the transaction yourself or did simply send bitcoin wuth the help of a wallet?

I am running a full node, so I guess I created it myself

You are not being hacked.  These are not two separate transactions; it is one transaction with two outputs.  The second output was automatically created by your wallet client and sends back to a new address which also belongs to you.  This is a normal and necessary feature of how Bitcoin works, called "change". See How does change work in a bitcoin transaction?
If this transaction were malicious, it would mean that someone had access to your private key; if so, they would also have stolen your earlier transaction.  Moreover, they would  have stolen the coins as soon as they obtained the key; they wouldn't have waited for you to make your own transaction.

Thank You Nate Eldredge for your response, I had no idea about this feature, and because the change address is not written in the bitcoin client, that idea couldn't of crossed my mind.
After googling I found that when using bitcoin-qt it is possible to enter the command "listaddressgroupings" in the debug console, to see all addresses including change addresses.
https://bitcoin.stackexchange.com/questions/9077/how-to-get-all-addresses-including-the-change-addresses-from-bitcoind.

@AdamShem-Tov: Yeah, I think the Bitcoin Core developers took the view that this is a technical detail that end users don't need to be bothered with.  But of course when you look "under the hood" with a block explorer like blockchain.info, you see the details, and they can be confusing when they don't appear to match the high-level view presented by the client.


text:
Mining a transaction with a 0 BTC output
It is possible to mine tx that has a 0 BTC output?
In theory it is non-standard but valid, so it is not relayed but it can be mined.
How to mine it in practice? Are there nodes that accept it? I tried Eligius' 192.3.11.20 but it rejects it.
EDIT: i want to do p2pkh transaction

Do you want to create p2pkh output and send zero satoshies on it? Such output is non-standard (dust) and will not be relayed and mined (but it is possible)
Or may be you want to create nulldummy (OP_RETURN) output? This is possible
BTW, sometimes miners confirm non-standard transactions, for example https://blockchain.info/tx/b4ea693a9d2d7e32b66777964fce13da302bed024bd9fd4651919da650fb1c40 (it is p2pk output)


text:
Detecting Mixed transactions/addresses in Bitcoin
I would like to know how I can detect bitcoin transactions that are mixed by Mixers' services?
Is there any sample code or sample set or any applicable example in this regard?
Thank you

Thank you for the answer. Is there any reference for the mentioned addresses?

Hello, I am still looking for a way to detect mixer-created transactions in bitcoin. Can you please share an algorithm or sample with me? Thank you


text:
How can I find Miners' Wallet addresses?
Is there any way to find miners' wallet addresses in Bitcoin Blockchain?
I would like to find transactions that are related to the miners themselves.
Thank you in advance.

The first transaction in every block is the coinbase transaction which is created by the miner of that block and which typically pays them the mining reward and transaction fees.
There is a high probability that the receiving addresses of coinbase transactions are addresses controlled by miners.
Pools may complicate this.

Thank you. Got the point. I have difficulty in realizing the first transaction in the block since all have the same blocktime and blockheight. I am not sure how I can pick the first one.

Also the coinbase transaction probably has 0 fees, and 0 inputs (or inputs with 0 BTC) depending on what tools you use to look at it.


text:
How I can detect transactions submitted on bitcoin from L2 Lightening network?
I want to identify transactions submitted from L2 on the Bitcoin blockchain. How I can find these transactions?
For example, in the Lightening network, do transactions wait in Mempool? If not, how the lightning is connected to the Bitcoin blockchain?
Thank you

how the lightning is connected to the Bitcoin blockchain?

When a Lightning channel is opened or closed, there is a corresponding transaction on the Bitcoin Blockchain. From what I've read, the opening transaction involves a 2 of 2 multisig output. It can't be distinguished from similar outputs created for reasons other than opening lightning channels.
In between those events there would typically be a large number of lightning transactions, using Lightning channels, that leave no trace in the Bitcoin Blockchain.

Useful References

https://voltage.cloud/blog/lightning-network-faq/what-do-open-channel-transactions-look-like-on-chain/

Thanks for the answer. My question is how I can identify opened and closed transactions confirmed in Bitcoin blockchain?

The channel opening and channel closing transactions will be among those involving 2 of 2 multisig.


text:
Reasons Behind Finding an IP addresses of Miners
I am wondering if Finding IP addresses of each miner, can help the transactions to be processed by them without waiting time in mempool or not?
I do not understand clearly why people are looking for IP addresses of the miners?
Thank you

Ordinary Bitcoin users would not care about the IP addresses of miners. Every Bitcoin node simply tells its peers (the "neighbors" of the node) about any new transactions they hear about. This way, the transactions get relayed across the network until everyone has heard about them, including the miners.
The waiting period is independent of how quickly the transaction gets to miners. Miners are constantly trying to find a block and succeed at random intervals. Whenever they find a block, they include whatever transactions they know about that pay the most fees, so beside a transaction just missing to get into a block, the wait is independent—it's simply until the next block is found that they fit into.
It's not clear to me in what scenario people might be trying to find the IP addresses of miners. Two that come to mind would be researchers that are trying to map Bitcoin mining activity, and attackers that want to hijack hash power.


text:
How many transactions are there in one block
What I understand:
When a transaction is made , miners compete to  validate it and create a hash . If one miner creates the hash and more than 51% of miners agree on the validity .Then the a block is added to the blockchain.
Am I right?
My doubt:
1)When a block is added it contains one transaction that is validated or more?
Thanks.

When a transaction is made, miners compete to validate it and create a hash.

Miners will compete to confirm the transaction in a block. 'Validation' of a transaction is completed by each and every full node on the network. Notice the difference between confirmation and validation:
Validation checks to see if the transaction is valid according to the network rules.
Confirmation involves having a valid transaction included in a block that is a part of the longest (most-work) chain.

If one miner creates the hash and more than 51% of miners agree on the validity.

As with transactions, a block is either valid, or invalid, and this fact does not depend on what other miners have decided. Full nodes perform this validity check, while miners just keep adding more blocks to the chain.

)When a block is added it contains one transaction that is validated or more?

Miners can choose whichever valid transactions they would like to include, up to the 'weight limit' of 4,000 kilo-weight-units. In practice, this generally means the block can be anywhere from a few hundred bytes, to 4 MB. These transactions are chosen prior to finding the valid hash, which means that once a valid block has been found, the transactional content of that block is locked in; the miner cannot add or remove transactions without invalidating the block.

A block contains more than one transaction. Look here: https://www.blockchain.com/btc/block/0000000000000000000c01fc2e09f4aa22244d2b6fc2de793a3da3c782c544a4
There you see all transactions from a specific block. Validating a transaction is easy. Miners compete for finding the nonce for a block. So they dont mine a transaction they mine a block. Thats the complicated thing here.


text:
What happened to Bitcoin Core v0.20.1?
About 11 days ago, I updated to v0.20.1 of Bitcoin Core from their "official" website (https://bitcoin.org/en/download).
Ever since, it's been syncing every day but just keeps lagging behind. Now it had reached 11 days, so I went to the same website to check if there's a new version which fixes the bug (which I assume is present in this version).
I was shocked to see not a v0.20.2, but rather: bitcoin-0.20.0-win64-setup.exe
It's gone back to v0.20.0... I felt a cold sensation down my spine, fanatically checking the GitHub issues for any clue that v0.20.1 was a "dud" or something, but found not one mention of it.
Now I'm starting to wonder if what I got was actually malware or something. Why would they just revert to an old version and pretend as if the v0.20.1 one never happened? It makes me feel uneasy to say the least. I installed the old version now, but so far, it still says the same thing:

Processing blocks on disk... 11 days behind...

This kind of thing is what makes me very worried about Bitcoin's future. With all the scams and scumbags everywhere, constantly trying to steal Bitcoins and/or give Bitcoin a bad name, the last thing we need is for the "official" project/client to be this flimsy and unstable. If I, a Bitcoin fanatic, gets this worried, what would an old granny be? She probably would never recover from this state, perpetually unable to make Bitcoin payments because Bitcoin Core has "locked" somehow.
I frankly don't know what to do now other than wait and hope for it to finish doing whatever it's doing. It seems locked/frozen again. I don't dare to click anything inside its GUI window because that tends to make it crash.
Update: At least it now, with the old version, slowly climbs down in the number of days left.

No ones grandma is going to run a full client. After all it’s just a reference client anyway not the holy grail. Old versions in software development are often rolled back and its better to just remove a potentially bad version then leave it around for others to download.

@mschuett "Just a reference client"? I certainly have never found any other one which I would ever trust to install on my machine at all, let alone use to power any kind of automated payment system. In fact, even Bitcoin Core has serious issues in regards to that, but that's off-topic here.

@DaltinS. Your grandma doesn't need to run a full Bitcoin node. A majority of users do not need to run a full Bitcoin node. Bitcoin Core isn't the "official" bitcoin wallet. Bitcoin is decentralized software with no singular "official" source. It was the first of its kind, thus dubbed a "reference client" upon which other developers can use as a loose set of guidelines to follow when making other clients. A good example of a popular Bitcoin client is Bitcoin Knots. If all you need to do on Bitcoin is make transactions and not worry about its inner workings, use a "wallet" program, not a node.

Hi, I just checked and I found the 0.20.1 version that was publised on the Github repo on Aug 2, so I think you're confused. Besides I doubt that your issue has anything to do with version, did you check the debug.log file that is in the bitcoin data directory? You might find what's wrong there. Be more specific, it's actually unclear what you're asking here.

Are you sure you actually installed 0.20.1 before? It seems that the pull request to add the 0.20.1 release to bitcoin.org never got merged: https://github.com/bitcoin-dot-org/Bitcoin.org/pull/3435
If you look on the project's own site, https://bitcoincore.org, you'll see that 0.20.1 is available just fine.
I would be very surprised if anything at all changed regarding block chain synchronization in 0.20.1 vs 0.20.0. I suspect what happened is that your node initially just picked bad peers to synchronize from, but after (re)installing 0.20.0, that went away on its own.

You do not always need to run the latest version of Bitcoin Core (or any software for that matter). The difference between v0.20.0 and v0.20.1 is a "minor" release, which only introduces typically very small changes. According to the Bitcoin Core's GitHub Releases page, the latest minor release is v0.20.1 (no mention of v0.20.2, and the GitHub repo is pretty much the "home" of Bitcoin Core, not the Bitcoin.org website)
Additionally, https://bitcoin.org is a beginner-friendly resource for those new to Bitcoin, which does have a download section for Bitcoin Core, but Bitcoin Core itself should be downloaded from https://bitcoincore.org (which is the link that is referenced on the GitHub page) since the latter website includes minor releases whereas the beginner-friendly site only lists major releases.

This is wrong. Minor releases are for bug fixes, and can contain security fixes; installing those may well be more important than upgrading to new major versions (which bring new features that not everyone may need). https://bitcoin.org has historically listed all Bitcoin Core releases, including minor ones - but it seems something just went wrong with 0.20.1: https://github.com/bitcoin-dot-org/Bitcoin.org/pull/3435

It's fixed now, FWIW. Bitcoin Core 0.20.1 is on bitcoin.org.


text:
How would you find the Merkle Root with a Block that contains 6 transactions?
Let's use block #100205
https://www.blockchain.com/en/btc/block/0000000000033d0de6f4ebe93b3b142424cdbecf4bd98b948e856c4a55f09f76
This block contains 6 transactions. After the second level of hashing you end up with 3 nodes. What is the fix for this? Do you create two 5's and 6's?

You would duplicate the hash of the last two txs. The tree would "look" something like this:
             abcdefef
              /  \
           /        \
        /              \
      abcd             efef
      /  \            /  \
   /        \      /        \
  ab        cd    ef        ef
 / \        / \   / \
a   b      c  d  e   f

TXID 1
438edc1b0d7ad70f289bb9c082681aa50ee1c3d63dbf106b092abe224f0636a7
Byteswapped: a736064f22be2a096b10bf3dd6c3e10ea51a6882c0b99b280fd77a0d1bdc8e43
TXID 2
B91aad22dcfe4fca4b03143682642994c607a832d1c4c11c5fd6616310468f8b
Byteswapped: 8b8f46106361d65f1cc1c4d132a807c6942964823614034bca4ffedc22ad1aB9
Hash12 =
601bffd3fa633bc7cc0ede9f486a5bef88dc8781a58ee4e8c0dd15401000cb71
TXID 3
Daadc472b760fb0586ed2841a9160e99175f05813ce51455f3c08c9765a2a60e
Byteswapped: 0ea6a265978cc0f35514e53c81055f17990e16a94128ed8605fb60b772c4adDa
TXID 4
6543b2025fea04eac45b81304ace9a7672b7a0969a8e9460e4f5cc93062414ce
Byteswapped: ce14240693ccf5e460948e9a96a0b772769ace4a30815bc4ea04ea5f02b24365
Hash34 =
6c06a7a9e71f66ad01ccf6606176005cad6f5a1a897041f7f8b38a46e62a253a
Hash1234 =
D4ff4562b9a0fcd529e9dc80b4466a3a78d6cb03909f8303ae5f38774ed7db2d
TXID 5
E4cb63ed4d06c90be633985f2d6902833c4b502d77fdcb883d5217dfaa75dcc5
Byteswapped: c5dc75aadf17523d88cbfd772d504b3c8302692d5f9833e60bc9064ded63cbE4
TXID 6
B64212bc2fc6e1b469d31bc9140d7164794615b257c51f02d067f2a42aad943d
Byteswapped: 3d94ad2aa4f267d0021fc557b215467964710d14c91bd369b4e1c62fbc1242B6
Hash 56 =
49622b3e9ab2aaa1fdd94b56d9f88d9a5604eb5b053781a7668f3056a92e272c
Hash 56 =
49622b3e9ab2aaa1fdd94b56d9f88d9a5604eb5b053781a7668f3056a92e272c
Hash5656 =
2d8a2fb663d0d018f5343321598d3647b342b06a52306b0e8392bf8273d746a7
Hash12345656=
af72e3305e599e39381b45dd328abf2cf740280ca8328fa15fc76820e9bdc5ca
Byteswapped: cac5bde92068c75fa18f32a80c2840f72cbf8a32dd451b38399e595e30e372af
Worked Like A Charm - Thank You @Raghav Sood


text:
How does a miner get selected in Proof Of Stake?
I am trying to understand POS. I get that POS uses currency held analogous to the hash power held in POW system. More the stake we have, more are our chances of mining the block. At various sources I read that, a miner is chosen deterministically.
Can someone please explain, how miner selection takes place. And how everyone agree on the same miner, there has to be some algorithm involved.
Quite a lot is mentioned here: https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ
but, I can't seem to find the answer to my query.

The minting algorithm for staking is different for various coins; for example, it is different in BlackCoin from Cardano.
There are several approaches to staking, but most of them are susceptible to "grinding attacks" and almost none of them are proven secure against every attack (only argued secure intuitively by showing that certain specific attacks do not work).
To give a concrete answer to your question, I will describe a specific case of a proof-of-stake protocol which is proven secure: the Ouroboros Praos protocol.
In the Praos protocol, you can imagine each satoshi corresponds to a public/private key pair. The Praos protocol for staking works as follows: If you are an honest staker, you look at the current date and time and round it to the nearest second (the time unit you round it to is configurable in general and corresponds to the synchronous "slots" of the protocol). Say, for example, that you get d = "2018-07-01 00:19:24". You take that date and time as input, and you sign it with your private key corresponding to your satoshi, obtaining a signature s. You then compare that signature against the difficulty target T to see if s <= T, similar to how bitcoin compares block hashes against the difficulty. If it is, then you have been "elected leader" and you are allowed to generate a block. You first generate the block contents x which consist of the transactions in your mempool as well as a pointer to the previous block. You then sign x using your public key, and produce another signature s'. You then broadcast to the network your signature s illustrating that you have been elected; the current date and time d for election confirmation; the confirmed transactions x which also include the reference to the previous block; and your signature over the block contents s'. The tuple (s, d, x, s') is the block.
Now, other validators can check that you are the rightfully elected leader. They check that s is a signature for d, that s' is a signature for x, that x contains valid transactions and points to the tip of a previous blockchain (with an older timestamp and non-conflicting transactions). Finally they must verify that you meet the target: s must be below T.
This is quite a simple protocol, but, perhaps surprisingly, it can be proven secure. This is what makes it elegant. It's also quite similar to how bitcoin generates blocks. If you are intrigued about why this protocol is secure, I encourage you to read the paper.
A few details:

It is possible for bad actors to generate multiple block contents for the same datetime that they have been elected leader. This doesn't cause a problem because honest parties will only generate blocks committing to one older block, thereby breaking ties.
It's possible that two honest parties generate a block at the same time. This is not a problem and can also happen in bitcoin. Such ties will be resolved, as long as the protocol parameters are tweaked to not allow blocks to occur very often among slots (the exact parameters are specified in the paper)
I said above that s is a "signature" on the current time d, but a technical point is that it's not a signature but actually what we call a VRF - Verifiable Random Function. This is like a signature, except it has the assurance that the output behaves like a random output (such as a perfect hash behaving like a "random oracle").

(in reality, you are trying to generating blocks as far in advance of the current time as other nodes will let you)

It doesn't let me post a comment so I'll post as an answer instead to dioyziz's answer. I don't see how this is secure because private keys are free to make. So the person with the most private keys and running the most nodes has an advantage as they can generate the most hashes for that particular timestamp. Which essentially turns it into proof-of-work race again. Who can generate a private key that combined with this particular timestamp meets the difficulty condition.

Each possible staking input is used to hash a result based on it's properties and compared to difficulty,
a succesful block is created and propagated.
These calculations are consistent and verifiable over the network so it's a matter of propagation and verification as to whether it's accepted.


text:
Electrum issue restoring via seeds
I have an electrum wallet on a server
I use 'electrum getseed' and the 12 word seed is returned.
Then on a separate local machine I restore the wallet with the seed.
No funds available.
Any thoughts on what might be causing this.
Edit:
It looks like the local electrum wallet is not loading addresses that the server created outside the gap limit with --force. Any ideas on how to make local machine load these
Note: Wallet has under 2$. Could this be a 'too little btc issue'
Note: Tried seed on Exodus, says 'Invalid Key'

Are the wallets on the server and local machine both using the same version of Electrum?

It looks like the local electrum wallet is not loading addresses that the server created outside the gap limit with --force. Any ideas on how to make local machine load these

Increase the gap limit. Go to view menu > show console, switch to console tab and enter this command:
wallet.change_gap_limit(100)

Then wait for the balance to update in the bottom left corner. If that doesn't do it try a slightly larger number.
Also note that you have to be using a recent version of electrum. Old versions don't sync anymore so make sure you are using the latest version from electrum.org. A version that doesn't sync will not reflect an accurate view of your wallet.

on a separate local machine I restore the wallet with the seed ... No funds available.

See

How to recover an electrum wallet from seed
A Beginners guide to Electrun

The latter says:

After restoring your wallet, Electrum may list previous transactions as “unverified.” This condition will persist until all Electrum finishes synchronization with its server. You can monitor progress from the Network window. Access it by clicking on the circle to the lower right of the main window. When the block count under “Blockchain” equals the height indicated for the servers you’re connecting to, Electrum will be fully synchronized and all confirmed transactions should be displayed properly under the History tab.

Tried seed on Exodus, says 'Invalid Key'

Electrum has it's own systems for generating private-keys from seed phrases. It does not normally use the BIP-39 standard which is commonly used by other wallets.
Exodus' documentation doesn't mention importing Electrum seed-phrases so far as I can see.
In Can I import a private-key they say

IMPORTANT NOTE: This does not actually "import" the private key. It just moves the funds from the address into Exodus and this transfer has transactions fees. This is because Exodus uses one 12-word restore phrase to restore all funds. So, to be able to restore funds from the 12-word phrase, Exodus must do this transfer.

To me, it seems that using Exodus is a poor choice to check the balance of an Electrum wallet.


text:
Is it possible to keep bitcoind running with the blockchain synced up to only a certain height?
I am currently using bitcoind to do some transaction analysis on a small part of the blockchain. However, after the local copy of the blockchain reaches the -stopatheight value, it quits. Is there a way to keep it running at that height? Or do I need to sync the full blockchain to keep it running? I want to keep it running so that I can run the bitcoin-cli and perform a few RPC calls

You can use any parser for to analyze any part of blockchain that you need. For example, my script https://github.com/ragestack/blockchain-parser can do it. If you need chainstate data, you can also calculate it from parser's output data.

@DenisLeonov Thanks for that, do you have any benchmarks? I have read in academia that Python would be slow to parse the full blockchain, have you done any sort of testing to see how it compares to parsers built with cpp or others

i think there is no need for extreme speed for onetime blockchain parsing

You can run with -connect=0. If it's not connected to anything, it can't sync further.


text:
Failing on autogen.sh for bitcoind
I am installing bitcoin core. I cloned bitcoind source code from github.
Before starting to install it, I already downloaded all dependencies by referencing on here.
https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
$ git clone https://github.com/bitcoin/bitcoin.git
Cloning into 'bitcoin'...
remote: Counting objects: 113049, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 113049 (delta 2), reused 1 (delta 1), pack-reused 113045
Receiving objects: 100% (113049/113049), 101.22 MiB | 7.31 MiB/s, done.
Resolving deltas: 100% (78687/78687), done.
Checking connectivity... done.
$ cd bitcoin
$ git tag
...
v0.9.2rc2
v0.9.3
v0.9.3rc1
v0.9.3rc2
v0.9.4
v0.9.5
v0.9.5rc1
v0.9.5rc2
$ git checkout v0.9.5
Note: checking out 'v0.9.5'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at b880967... Merge pull request #6169
$ git status
HEAD detached at v0.9.5
nothing to commit, working directory clean
$ ./autogen.sh
configure.ac:118: installing 'src/build-aux/compile'
configure.ac:12: installing 'src/build-aux/config.guess'
configure.ac:12: installing 'src/build-aux/config.sub'
configure.ac:37: installing 'src/build-aux/install-sh'
configure.ac:37: installing 'src/build-aux/missing'
configure.ac:707: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
configure.ac:707: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am: installing 'src/build-aux/depcomp'
configure.ac:707: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
configure.ac:707: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
parallel-tests: installing 'src/build-aux/test-driver'
configure.ac:707: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

I am going to install 0.9.5 release version. But what is this error ?
warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS'

Even I ignored above warnings and executed make, but some errors occurred.
If I execute autogen.sh on master branch, there is no error.

Why are you trying to build 0.9.5? That version is old and the build instructions and dependencies have changed since then.

I had a mistake. I confused that I saw over 0.10 versions as 0.1.0 versions.