text:
What's the difference between decoderawtransaction and decodescript?
I'm looking for an explanation on the difference between the bitcoin CLI for decoderawtransaction and decodescript please.
From what I know, decodetransaction will undo the hash and ECDSA elliptic curve calculations for the overall transaction data, and break it down into asm, hex, reqSigs, type of script & the original address. How is this different from decodescript & when should I be using one vs the other?
Thanks.

The Bitcoin protocol has its own serialization format for transactions, blocks, scripts etc. These formats optimize for space, which means they aren't particularly human-readable, so there are bitcoin-cli commands that can be used to decode them into a more human-readable form.
Consider the transaction 60267bfd9494e1a6a5218184c36bf4c97adccbbde40487a2f92fcfffc10d0500. Here is its serialization in hexadecimal:
010000000001018154f1677366e5799f61646e5cea1ea13ef23c0bd3ba4cc845dcdc3f061c47570100000000ffffffff01035a28000000000016001486918c31af903a4c7ed2dc8191156c0ef44a11b40141f33812c31e4c1ae9a46c55e1463121d42c1c5cd64afc86fe94d2a126b2e515823954b079e11bf1251aa9d585cf4a83a0473634f1c22891249dacf9f93c976ff40100000000
When you feed this into decoderawtransaction, you get this:
{
  "txid": "60267bfd9494e1a6a5218184c36bf4c97adccbbde40487a2f92fcfffc10d0500",
  "hash": "9aab2076ba5b8f2656d1a2b9f9928c6cb6a4d6f607ef88589ea6b6e842f3f320",
  "version": 1,
  "size": 151,
  "vsize": 100,
  "weight": 397,
  "locktime": 0,
  "vin": [
    {
      "txid": "57471c063fdcdc45c84cbad30b3cf23ea11eea5c6e64619f79e5667367f15481",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "f33812c31e4c1ae9a46c55e1463121d42c1c5cd64afc86fe94d2a126b2e515823954b079e11bf1251aa9d585cf4a83a0473634f1c22891249dacf9f93c976ff401"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.02644483,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 86918c31af903a4c7ed2dc8191156c0ef44a11b4",
        "desc": "addr(bc1qs6gccvd0jqayclkjmjqez9tvpm6y5yd5azp9qs)#h6rkqret",
        "hex": "001486918c31af903a4c7ed2dc8191156c0ef44a11b4",
        "address": "bc1qs6gccvd0jqayclkjmjqez9tvpm6y5yd5azp9qs",
        "type": "witness_v0_keyhash"
      }
    }
  ]
}

Among many other things, this also decodes the transaction's output scripts (under scriptPubKey). However, if you have a serialized script outside the context of a transaction, which in this case would be 001486918c31af903a4c7ed2dc8191156c0ef44a11b4, you can use decodescript on it:
{
  "asm": "0 86918c31af903a4c7ed2dc8191156c0ef44a11b4",
  "desc": "addr(bc1qs6gccvd0jqayclkjmjqez9tvpm6y5yd5azp9qs)#h6rkqret",
  "address": "bc1qs6gccvd0jqayclkjmjqez9tvpm6y5yd5azp9qs",
  "type": "witness_v0_keyhash",
  "p2sh": "3Np3NnSFbrdMjRi9ECcnoWCfHBPVVHe5iw"
}

Additionally, there are scripts that decoderawtransaction won't decode, for example redeem scripts in witnesses of P2WSH inputs.
Take transaction b4bb98f79c50ef7fe74fb9fac705e3952650161477bd82b2687c953b71a44594 which spends one P2WSH input with a 2-of-3 multisignature script. The serialized script will be given by decoderawtransaction as the last item of txinwitness:
5221020fc49e0380f0ba7d849609e746e36557d1ad457cb88888a73fdbd9a7d7ab3b6a210211bcd0fc487c5ed1c60adb5379c9b078874b4e525a4df2c27540c9db856760082102e8033bc9956afcd3abba9cfe0817ab16c5ec84e2f8edc1da4373bac54dacf57253ae
Decoded by decodescript as:
{
  "asm": "2 020fc49e0380f0ba7d849609e746e36557d1ad457cb88888a73fdbd9a7d7ab3b6a 0211bcd0fc487c5ed1c60adb5379c9b078874b4e525a4df2c27540c9db85676008 02e8033bc9956afcd3abba9cfe0817ab16c5ec84e2f8edc1da4373bac54dacf572 3 OP_CHECKMULTISIG",
  "desc": "multi(2,020fc49e0380f0ba7d849609e746e36557d1ad457cb88888a73fdbd9a7d7ab3b6a,0211bcd0fc487c5ed1c60adb5379c9b078874b4e525a4df2c27540c9db85676008,02e8033bc9956afcd3abba9cfe0817ab16c5ec84e2f8edc1da4373bac54dacf572)#d63cpu6r",
  "type": "multisig",
  "p2sh": "37CYRhHBjdgoTC7KQpUuTH3zAcm9akWqAd",
  "segwit": {
    "asm": "0 ec21a1b4e8cdaa89737895168ead0c3210fc2d1c6bf9805e45a475f714c75140",
    "desc": "addr(bc1qass6rd8gek4gjumcj5tgatgvxgg0ctgud0ucqhj9536lw9x829qqpnu64e)#2wsw9unx",
    "hex": "0020ec21a1b4e8cdaa89737895168ead0c3210fc2d1c6bf9805e45a475f714c75140",
    "address": "bc1qass6rd8gek4gjumcj5tgatgvxgg0ctgud0ucqhj9536lw9x829qqpnu64e",
    "type": "witness_v0_scripthash",
    "p2sh-segwit": "3PCgTmZsCjK6KHJeEHJ7iCjVPqb3ygf5jF"
  }
}

I see! Could decodescript do everything which decoderawtransaction is able to? (I'd like to further understand when to use each of them appropriately). Would also like to know more examples for decodescript use cases please. Thank you very much!

No, a transaction consists of a lot more than just scripts, so decodescript cannot do everything. I added an example of a P2WSH script.

Sorry, how did you acquire 5221020fc49e0380f0ba7d849609e746e36557d1ad457cb88888a73fdbd9a7d7ab3b6a210211bcd0fc487c5ed1c60adb5379c9b078874b4e525a4df2c27540c9db856760082102e8033bc9956afcd3abba9cfe0817ab16c5ec84e2f8edc1da4373bac54dacf57253ae?

Is decodescript typically used to decode ScriptPubKey & ScriptSig as well?


text:
Transcation is confirmed 13/6(needed) but still red in bitcoin core and not recieved in wallet?
I've used BITCOIN CORE to recieved bought BTC.
And then I've sent this to a "dwWallet" but still I've not recieved the funds, and I'm absolutely sure, it's not a mirror scam shit, and so on.
Well, the transaction it self, is confirmed by 13 , and needed for 6. Have been about 2 hours now, and still not even see in the wallet any "incoming soon" or something.
What, to do? or how long can it take, I thought when confirmed it's instant, you only need to wait for the confirmations and then it wouldn't be any delays, but I can be wrong for sure. But never ever been struggeling with this issue, always done in 40min before.
And I can see in BITCOIN CORE - it's marked confirmed, but still marked red in the overview.
TXID:  f580e936e3fbb3392b2aa3e53babb4af82bc94a899d23e7f7b8a995a8cec8693

Red just means that it’s an outflow of funds, while black is an inbound payment. Transaction f580e936e3fbb3392b2aa3e53babb4af82bc94a899d23e7f7b8a995a8cec8693 is confirmed on the blockchain. It sounds like “dwWallet” is out-of-sync and has not correctly recognized that it was paid. I assume you have verified that the address you sent to belongs to the intended wallet?

Yes ofcourse, there nothiung wrong with adress nor scam, thats for sure, but incredible how long time it can take since the confirmations are done?!

I’ve never heard of "dwwallet" nor can I find anything about it.—Either way it sounds that the software at the receiving end is at fault. Try to find whether it has a function to force a resync or rescan.

source: Stack Exchange

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

sort: votes


text:
Coinbase transaction UTXOs are prohibited until 100 confirmed? By what?
I notice that many coinbase transactions(like in block 720,815) with locktime=0x00000000 and sequence=0xFFFFFFFF, which means UTXO could be spent immediately.
There seems to be no limit to coinbase's immediate use.

duplicate of https://bitcoin.stackexchange.com/questions/1991/what-is-the-block-maturation-time

Does this answer your question? What is the block maturation time?

I know there is a block maturation time, i just don't understand how to implement it? when nodes verify UTXO, is there extra step to verify coinbase UTXO height ?  why don't just use CLTV or CSV ?

Coinbase maturity is verified here: https://github.com/bitcoin/bitcoin/blob/master/src/consensus/tx_verify.cpp#L182

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


text:
Is there any other form of coinbase transaction?
Could miners intentionally change the output address or reduce the output value before forming a block

A block must have exactly one coinbase transaction as its first transaction. This transaction may collect the transaction fees and create new coins according to the subsidy. It can assign those funds to one or multiple outputs. If the block includes any segwit transactions, it also has to include an op_return output with a witness commitment.
There have been multiple instances in which miners have collected less funds than they would have been allowed to. For example block 501,726 failed to collect any mining reward at all.
The only time when the coinbase transaction can be changed is before a block is found. Miners routinely amend the coinbase's extranonce during the mining process to add more entropy to their block candidates. Once a block template produced a valid block, the coinbase is fixed, since changing any byte in the block would change the header and the header's hash would no longer fulfill the difficulty requirement.

To my understanding, a miner will define the output address for the payout of the coinbase transaction prior to solving the hash and sharing the new block. Changing the output value of the coinbase transaction would break protocol rules and the block would be invalid and not added on top of the chain.


text:
Why do i need two signatures to enter 2nd stage in lightning network?
  |        +-------------+
  \--------| commit tx B |
           +-------------+

              |  |  |  |
              |  |  |  | A's main output
              |  |  |  \------------------ to A
              |  |  |
              |  |  |
              |  |  |                  ,-- to B (& delay)
              |  |  | B's main output /
              |  |  \----------------<
              |  |                    \
              |  |                     `-- to A (& revocation key)
              |  |
              |  |                                                ,-- to B (& delay)
              |  |                        +-----------------+    /
              |  |                     ,--| HTLC-timeout tx |---<
              |  | HTLC offered by B  /   +-----------------+    \
              |  \-------------------<     (after timeout)        `-- to A (& revocation key)
              |                       \
              |                        `-- to A (& payment preimage)
              |                        \
              |                         `- to A (& revocation key)
              |
              |                                                   ,-- to B (& delay)
              |                           +-----------------+    /
              |                        ,--| HTLC-success tx |---<
              | HTLC received by B    /   +-----------------+    \
              \----------------------<     (w/ payment preimage)  `-- to A (& revocation key)
                                      \
                                       `-- to A (after timeout)
                                       \
                                        `- to A (& revocation key)

The above is the logic  found in here.
And i find that when i go into the 2nd stage, it always needs a 2 of 2 multisig. I think it's enough to get remote signature to go to the 2nd stage, so why do i need to sign here by myself.

Because also in the second stage (which are the offered htlcs) there is the revocation and penalty mechanism. Since this mechanism always works via 2-2 multisig addresses this also needs signatures from the remote channel partner

To enforce the HTLC semantic, the offered and received HTLC outputs must only be spendable through the paths outlined in the schema.
If we were to require a single signature, from the remote party, on these outputs then they could unilaterally spend this output. We need both parties to commit to the logic of the contract, and this is done with a multisig and presigned transactions.


text:
What is the relationship between r in signature and the public key
I've been reading about ECDSA in here.
Step 11 says that

you only need the ‘x‘ value (20 bytes) for the signature, and that value will be called ‘R‘

Does that say that R is the x-coordinate of the public key.
But I don't see that happening in a raw transactions.
For the pizza transaction, it's scriptSig looks like that：

48

30450221009908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc41328702201aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e01

41

042e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b76426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb

The first one is signature,the second one is the public key.
I don't see any relationship between the two items.

Does that say that R is the x-coordinate of the public key.

That is not correct.
The R value in the signature is the x coordinate of a point, but that point is not equal to the public key. Instead, it is the x coordinate of the public nonce used in the signature.

And since this is a signature, there is of course also this relation:
G*m+Y*r == R*s

both sides of this equation evaluate to the point:
(0x75c79891ca4248d78c84bac2d4a1d787d5a53d77044b1ab46e7de24f23e860dc,0x6b4c968c2bbba0fdec5f119d577b5be812c804a6ca4ea2858335af36685a8994)
where:

G is the generator point
m is the message hash: 0xc2d48f45d7fbeff644ddb72b0f60df6c275f0943444d7df8cc851b3d55782669
Y is x*G, the public key: (0x2e930f39ba62c6534ee98ed20ca98959d34aa9e057cda01cfd422c6bab3667b7,0x6426529382c23f42b9b08d7832d4fee1d6b437a8526e59667ce9c4e9dcebcabb)
r is the r-value: 0x9908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc413287
s is the s-value: 0x1aa528be2b907d316d2da068dd9eb1e23243d97e444d59290d2fddf25269ee0e
R is k*G : (0x9908144ca6539e09512b9295c8a27050d478fbb96f8addbc3d075544dc413287,0x64c226b542a56976625decfa9717d7b649c4b77fed49fe13b770442467a246fa)
x is the private key
k is the signing secret ( aka nonce )

You can play with the equations in this calculator


text:
Why there are so many different basepoint in lightning network?
Here are the scripts found in BOLT 03.
Offered HTLC Outputs:

2nd stage output script:

Why not just use one pubkey, like localpubkey?

The split is intentional, and allows for trustless watching of revoked transactions, which is often outsourced with the help of watchtowers.
From Bolt3

Splitting the local_delayedpubkey, which is required for the penalty transaction, allows it to be shared with the watcher without revealing localpubkey; even if both peers use the same watcher, nothing is revealed.


text:
Getting "Public key is neither compressed or uncompressed" error when pushing a transaction, but everything looks fine to me
I am very new to Bitcoin development and trying to make some personal milestones, one of which is broadcasting a transaction to the testnet. However, I am having a hard time due to the following error. I tried to debug myself, and have been googling a while, but could not find a post specifically mentioning this error message. I believe there have been an infinite number of transaction related question here, so I was reluctant to upload yet another, but I could not solve it myself. :(
This is the error message I am getting when I push my transaction to https://blockstream.info/testnet/tx/push
{"code":-26,"message":"mandatory-script-verify-flag-failed (Public key is neither compressed or uncompressed)"}

My transaction is composed of ordinary pay-to-pubkey-hash scripts, sending some bitcoin to a wallet and myself. It looks like this:
0x01000000013b9b28d08f63b37326c0d13896aaf8a05102e3a4478a44ca3ebbd1659197f594010000001976a91
417c195d4043de16d73706a3701aa0a240ab54f9c88acefffffff0210270000000000001976a9145d08c7d64b
7122f674d1dbd85531698a4ec5158f88acb8880000000000001976a91417c195d4043de16d73706a3701aa0a2
40ab54f9c88ac1027000001000000

Or
{
"addresses": [
    "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2",
    "mozseyudq9DnEyb2mnGX1wiWSxPAEAU8eU"
],
"block_height": -1,
"block_index": -1,
"confirmations": 0,
"double_spend": false,
"fees": 5000,
"hash": "4f4ccb367412f4bf033d6da99a4d83e1a371c762abf54875e3b920754e765cc7",
"inputs": [
    {
        "addresses": [
            "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2"
        ],
        "age": 2135099,
        "output_index": 1,
        "output_value": 50000,
        "prev_hash": "94f5979165d1bb3eca448a47a4e30251a0f8aa9638d1c02673b3638fd0289b3b",
        "script": "483045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f1012003eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8",
        "script_type": "pay-to-pubkey-hash",
        "sequence": 4294967295
    }
],
"lock_time": 10000,
"outputs": [
    {
        "addresses": [
            "mozseyudq9DnEyb2mnGX1wiWSxPAEAU8eU"
        ],
        "script": "76a9145d08c7d64b7122f674d1dbd85531698a4ec5158f88ac",
        "script_type": "pay-to-pubkey-hash",
        "value": 10000
    },
    {
        "addresses": [
            "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2"
        ],
        "script": "76a91417c195d4043de16d73706a3701aa0a240ab54f9c88ac",
        "script_type": "pay-to-pubkey-hash",
        "value": 35000
    }
],
"preference": "low",
"received": "2022-01-19T06:12:04.937364983Z",
"relayed_by": "44.201.2.248",
"size": 225,
"total": 45000,
"ver": 1,
"vin_sz": 1,
"vout_sz": 2,
"vsize": 225

}
Assuming from the error message, I guess the issue should be in the input script. (The length is 0x6a)
0x483045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f1012003eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

which I could parse into a locking script
0x03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

which is further parsed into
X: 0xeefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8
Y: 0xe1e61bc26c7b62f3639e5a0fc61f64d05dabf35249473bc6d91c607493b397ad

It looks like the public key is valid.
On the other hand, for the unlocking script,
0x3045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f101

I could verify the transaction myself using a signature hash z=0x450e73dd9d2a81e316abeb238f8192a0df09fefdac707de6eac2aed94c493419
so to me it looks like a valid transaction with compressed public key. What am I missing here? Could anyone help me debugging this?
Thank you in advance!

'03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8' is not valid public key
It should be 33 bytes long, yours is 32.

Thank you for the comment. My understanding was that the first byte (0x03 in this case) is added for identification of the public key (0x03 for odd, 0x02 for even). Do you mean the it should be 32 bytes after adding that first byte?

My bad, I misread the comment. You are right. Thank you so much.


text:
Is it possible to make a transaction from multilple addresses to one address?

I am building a platform (in node js) that users are going to pay for items using bitcoin. Some of the items has low prices (perhaps, even lower than the BTC fee).

The problem is: if I make an address for every user, the user buy low priced items and, once I want to retrieve the money, the UTXO be close to fee price, it won't be worth for me.

So, I'd like to know if it is possible to make a transaction from multiple addresses to a main address, paying just one transaction fee. If it is possible, how?

For smaller transactions you should really consider using the Lightning Network.

So, I'd like to know if it is possible to make a transaction from multiple addresses to a main address, paying just one transaction fee. If it is possible, how?

Yes, it's totally possible to make transactions from multiple addresses even if these addresses aren't owned by the same person (entity). There is nothing in bitcoin that discourages this practice and from the standpoint of raising the privacy of the whole ecosystem, it's even highly appreciated.
The biggest issue for you would be the coordination of this transaction, it can make or break the feature. As all members of this transaction need to sign under it. You can check existing protocols (coinjoin) implementations like:

samourai wallet
wasabi wallet
joinmarket
btcpay server (P2E)

to get some inspiration for your case.
And I double the suggestion, for micropayments, it's better to use a lightning network. Adding inputs/outputs to the transaction raises the transaction weight, resulting in higher fees anyway.

The transaction fees in the Bitcoin network scale with the weight of the transaction rather than the amount spent. The biggest contributor to transaction weight are the inputs. You can spend unspent transaction outputs (UTXO) together and it is more cost effective to do so, but you will still need to create at least an additional input per UTXO.
Therefore, the cost of adding an input to the transaction is what determines the effective value of a UTXO. Besides spending multiple UTXO together, the cost can also be lowered by using more weight efficient transaction outputs. You should look to use a wallet that supports native segwit outputs since they cost less than half of legacy outputs to spend.
Still, it may be impractical to receive particularly small amounts per Bitcoin transactions. As Tony mentioned, the Lightning Network could be more practical for quick and cheap payments.


text:
Easybitcoin not working
I am new to this bitcoin world, I have installed bitcoin core on my centos server.
Bitcoin daemon is running fine. And commands like getinfo works fine on bitcoin-core.cli. But the same command getinfo does not work with easybitcoin.
My bitcoin.conf file looks like:
prune=4096
txindex=0
rpcuser=user
rpcpassword=password
rpcport=8332
server=1

Inshort, commands are working with cli but not with easybitcoin. Please help.

What is "easybitcoin"? Why do you think it would respond to the same commandline interface as Bitcoind. Are you sure that you didn't download some malware?

https://github.com/aceat64/EasyBitcoin-PHP
A library based on curl to use bitcoin core functions

If I had to venture a guess, I would say it's because EasyBitcoin-PHP hasn't been updated since June 2017, and the author actually states in the "About":

A simple class for making calls to Bitcoin's API using PHP. This is an old library, I suggest instead using https://github.com/denpamusic/php-bitcoinrpc

I used the php-bitcoinrpc but still no luck. Not working for me.
I am not even getting any error. What it could be ? Please help

This is the version info:
Bitcoin Core RPC client version v22.0.0


text:
What does the bitcoin username & password refers to?
I want to integrate bitcoin to a website to receive payments. I am going to use easyBitcoin (https://github.com/aceat64/EasyBitcoin-PHP). But i don't know what will be the username & password. Here is that line:
$bitcoin = new Bitcoin('username','password');
What does the bitcoin username & password refers to ? Please help!

I assume this is the Bitcoin RPC username and password which you can configure in your bitcoin.conf file (if you're running Bitcoin Core) as follows:
rpcuser=<yourusername>
rpcpassword=<yourpassword>


text:
Issue with constructing a correct Schnorr Signature for a Taproot transaction
I'm experimenting with creating and sending Taproot transactions programmatically and encountered an issue with the Schnorr signature. I'm trying to send simple transaction with one V1_P2TR input and one V1_P2TR output, using what I understand to be a key path spend approach, without any scripts. However, when I attempt to send the transaction, my node rejects it with the error:
mandatory-script-verify-flag-failed (Invalid Schnorr signature)
I'm using the following dependencies in my Rust project:
bitcoin = { version = "0.30.1", features = ["rand"] }
ord-bitcoincore-rpc = "0.17.1"   # (a forked version of bitcoincore-rpc, though I believe this detail is not crucial to the issue).

Here's the relevant part of my code:
fn create_and_send_tmp_tx(client: &Client, utxo: &ListUnspentResultEntry, fee_rate: f64, key_pair: &UntweakedKeyPair, address_to: &Address) -> Result<Txid> {

    let secp256k1 = Secp256k1::new();

    // Verifying that UTXO can be spent by provided key pair
    let (public_key, _parity) = XOnlyPublicKey::from_keypair(&key_pair);
    let address = Address::p2tr(&secp256k1, public_key, None, Network::Bitcoin);
    let address_script_pubkey = address.script_pubkey();
    let utxo_script_pubkey = utxo.script_pub_key.clone();
    if ! (address_script_pubkey == utxo_script_pubkey) {
        bail!("Can't spend utxo");
    }

    let mut tx = Transaction {
        input: vec![TxIn {
            previous_output: OutPoint {
                txid: utxo.txid,
                vout: utxo.vout,
            },
            script_sig: Builder::new().into_script(),
            witness: Witness::new(),
            sequence: Sequence::ENABLE_RBF_NO_LOCKTIME,
        }],
        output: vec![TxOut {
            script_pubkey: address_to.script_pubkey(),
            value: 0,   // tmp value for estimation
        }],
        lock_time: LockTime::ZERO,
        version: 2,
    };

    tx.input[0].witness.push(
        Signature::from_slice(&[0; SCHNORR_SIGNATURE_SIZE])
            .unwrap()
            .to_vec(),
    );

    let fee = Amount::from_sat((fee_rate * tx.vsize()).round() as u64);
    info!("Fee: {:?}", fee.to_sat());
    tx.output[0].value = utxo.amount.to_sat() - fee.to_sat();
    tx.input[0].witness.clear();

    let prevouts = vec![TxOut {script_pubkey: utxo.script_pub_key.clone(), value: utxo.amount.to_sat()}];

    let mut sighash_cache = SighashCache::new(&tx);
    let sighash = sighash_cache.taproot_key_spend_signature_hash(
        0,
        &Prevouts::All(&prevouts),
        TapSighashType::Default,
    ).expect("Failed to compute sighash");

    let msg = secp256k1::Message::from_slice(sighash.as_ref()).expect("should be cryptographically secure hash");
    let sig = secp256k1.sign_schnorr(&msg, &key_pair);

    tx.input[0].witness.push(
        Signature {
            sig,
            hash_ty: TapSighashType::Default,
        }
            .to_vec(),
    );

    let signed_tx_bytes = consensus::encode::serialize(&tx);
    // let signed_tx_bytes = client.sign_raw_transaction_with_wallet(&tx, None, None)?.hex;

    let txid = match client.send_raw_transaction(&signed_tx_bytes) {
        Ok(txid) => txid,
        Err(err) => {
            return Err(anyhow!("Failed to send transaction: {err}\n"))
        }
    };
    info!("Tx sent: {:?}", txid);
    Ok(txid)
}

The wallet I'm using is connected to my node. If I use the
client.sign_raw_transaction_with_wallet(&tx, None, None)?.hex; function, which allows the node to replace my witness with a correct one, the transaction is accepted. This suggests that my inputs and outputs are constructed correctly, and the issue likely lies with how I'm generating the signature.
I've successfully sent transactions using a script path spend with a similar approach, using sighash_cache.taproot_script_spend_signature_hash, without the node's intervention in signing.
Could someone help me identify what I'm doing wrong?

Have you looked at this example it might be helpful? https://github.com/rust-bitcoin/rust-bitcoin/blob/master/bitcoin/examples/sign-tx-taproot.rs I am having similar issues to you as well by the way...

Thanks, the problem was that I was using an untweaked key pair for signing.
let sig = secp256k1.sign_schnorr(&msg, &key_pair.tap_tweak(&secp256k1, None).to_inner());
fixed the issue.


text:
based bitcoin address decentralized IP address, Abolish ipv4 and ipv6
THE IDEAL PATH
What if we replace the controlled and surveilled IP addresses with new internet addresses that are based on bitcoin address? These addresses will inherit all bitcoin address features, i.e., they will be purely decentralized, secure, future-proof, robust, anonymous, unhackable, controlled by no single authority and many more.
Is it just a dream? For now. If this could be true we would be changing the internet as we know it.

bitcoin address + bitcoin DNS, access to bitcoin domain

win10 network adapters : Enter the bitcoin address
Wi-Fi  DHCP Static : Enter the bitcoin address

IPv4 and IPv6 are centralized. They are controlled by national companies, etc.

Try to Google “Who controls IP addresses?” You’ll promptly get “IANA: the Internet Assigned Numbers Authority.” IANA is the top authority behind IP address allocation and assignment. There are five different regional internet registries (RIR) with jurisdiction under the IANA.
As a matter of fact, as an individual or a normal internet user you cannot request IP addresses directly from IANA or one of the five RIRs, but only from internet service providers, such as the services offered by mobile or telecom operators.

True decentralization, no official singular Foundation, Committee, Corporation, or entities in permanent unitary control of the protocol.

This reads like a call to action, not a question. If this was meant as a question, please clarify what you are asking about.

Is it just a dream?

Yes.

Internet routers route IPV4 and IPV6. They won't route other protocols at the internetwork layer. You wouldn't be able to use existing Internet network infrastructure.

Bitcoin addresses are impractical as network addresses. Firstly because such use would compromise privacy. Secondly because their random distribution implies there would be the problem of gigantic routing tables to be solved somehow.

We already have Tor.

Protocols like HTTPS and others that encapsulate data in TLS etc already provide end to end protection against surveillance of IPV4 & IPV6 contents (if not against observation of occurrence and volume of communications)

If big companies like Google decided that they had to continue using not only IPV4/IPV6 but also TCP/UDP - it suggests that using anything other than TCP/UDP over IPV4/IPV6 on a network the scale of the Internet is infeasible without truly gigantic levels of support.

Other networks exist but I suspect they don't offer any special benefits of the sort you seek. One example might be a mesh of radio links. There are problems of scale, both geographically and in terms of capacity and latency.

As far as I know, many national ISPs have blocked TOR export ip.
You are using a bridge to link tor, some countries tor nodes are not available! The reason is that ISPs block the ip of tor outlets

Also of note: yggdrasil and i2p


text:
From a technical point of view rather than an economical one, is it possible to mine bitcoin on a laptop?
I would like to mine bitcoin on a laptop, the aim is not to turn a profit but rather learn how mining works without spending money on an ASIC and electricity.  I thought about buying a cheap low TH/s used ASIC but I am concerned that I will purchase a faulty one.  Also I will be mining at home so think an ASIC will be too noisy.  I also was planning to try and use the waste heat to off set my home heating but after some research it all seems to expensive and risky for what will essential be a learning experience.
So my question is can I mine bitcoin on a laptop? I'm not worried about turning a profit, just would like to understand how it all works.  Could I download bitcoin core, run a full node and let it hash away with a near zero chance of winning the block reward but happy in the knowledge I've gone through the process and learnt plenty along the way?

You  can't mine real Bitcoin on a laptop but you can mine worthless testnet blocks if all you want is to understand a bit more about Bitcoin.
See When did Bitcoin Core deprecate the mining function?
Obviously you probably won't learn anything significant about real-world current-day mainnet mining.

You can mine on a laptop, though the probability of finding a valid block would be ~0
Performing a single hash on a valid block header would technically be mining.
You could get the latest block tip hash from a block explorer, figure out how to construct a valid block header (you could only add a coinbase transaction as it's for learning) and perform a hash on it (double SHA256).
If the hash comes out at <= the target (also this) then well done, you've found a valid block! Your chance of finding a valid block is:
target / size of hash space
for block 809493 this is
0x00000000000000000004ed7f0000000000000000000000000000000000000000 / 2^256
= 4.0761137170366274e-24


text:
Is there a way to run bitcoind without being a full node?
I want to be able to run bitcoind on a VPS I rented, but I neither have good bandwidth nor RAM so I do not want to be a full node.  How would I go about configuring things so that I can run bitcoind without acting as a full node or relaying transactions?

What are you trying to do?

As David said, what are you trying to do? If you simply wanted to be able to receive bitcoins, we could give an answer. If you wanted to be able to talk to the P2P network of Bitcoin, we could answer that. But you haven't stated your full intent for avoiding a full node. Maybe you want a wallet that isn't a full node?

Bitcoind does not support running in anything but a "full" mode.

As of bitcoin core v0.11, there is a way to run bitcoind in prune mode:
How can I run bitcoind in pruning mode?

Which is neither relevant for ram or bandwidth. More appropriate would have been a pointer about blocks-only mode. ;) but really the question is answered and most likely a XY-problem.

You could try some commands like connect for direct control of its peering. Trying to run the daemon without its database may be difficult, it looks for the database on startup. It might be easier if the daemon and its blockchain could be run in different locations, I havent heard of this yet.

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


text:
What information is available from the blockchains of privacy currencies?
Some currencies such as Monero and Zcash focus on protecting user privacy as much as possible. What information is available from the blockchains of these currencies?
Number of wallets? Transaction details? Anything else?

Unlike many users might think, Bitcoin blockchain is completely transparent linking all your transaction history and those who you are transacting with. Everyone who has ever transacted with you or will be in future is able to see what amount you have received from or sent to which address, forever. Some (centralised) mixer/tumbling services try to mitigate this fact changing your BTC into some completely other ones, but they still have their history and you don't know what it is.
Privacy focussed coins try to solve this at protocol level, I'll try to summarise:

Dash (and Pivx fork) offer you an option to use a sort of CoinJoin which is performed by their Master Nodes and can have several rounds. This is pretty similar to tumbling services but you are not at risk to loose your funds. However, you still have to wait for mixing partners in every round you make and this can take minutes up to several hours for every single round. Since the amount of mixing partners is very limited, an attacker could simply offer high supply to mix with and be able to track your mixed funds anyway.
Verge is a joke. It's basically Dogecoin over TOR hiding your IP but having a completely transparent blockchain. Their Wraith protocol just uses some other notation for receivers addresses, but they are stored in plain on the blockchain.
In Zcash, Zcoin you have an option to use ZK-Snarks and send your transparent funds to a shielded z-address. Unfortunately ZK-Snarks are very computation heavy and need several minutes on modern hardware computers for each transaction to be generated, they are not available for mobile devices yet at all. They are fully shielded hiding sender, receiver and amount of a transaction. However, they are barely used and no exchange or payment service is accepting them to date, so you have to claim them back on their completely transparent t-address blockchain before being able to spend them.
Monero (beside some small forks of it) is the only coin with mandatory privacy enabled for every single transaction. Ring signatures obfuscate the real sender, stealth addresses hide the receiver and (ring) confidential transactions hide the amount of the transaction by default. Unlike all the optional private coins you cannot tell how many Monero wallets are in existence nor how much has been transacted. An external observer cannot say who send how much money to whom. Even as receiver you still don't know the sender's address, you can only determine it by your sub-address or payment id used.

From my knowledge Monero is the most "private". It obfuscates the number of coins held on every account on the blockchain (you wont find a Monero richlist), but most important, it obfuscates in every transaction by default: the sender, the receiver and the amount.
One of the flaws in Monero is that it doesnt obfuscate the ip adress by default but someone using TOR or i2p would still manage to do this. But monero team will implement this in the future with the Kovri release.
I dont like Zcash because there is a 20% block reward for the creators of the coin built in its blockchain, seems not much decentralized, but I dont know much about its tecnology, just that it has a richlist so for me it doesnt work (if someone knows my adress therefore knows how many coins I hold).
Verge: This coin obfuscates just the ip adress of the user, the information is pretty much linkable. And its a fork of Dogecoin '-'
Dash: Not much of a privacy coin, the majority of users dont use the privacy option so if you are one of the few using it someone can link you to a transaction.
Pivx: Hadnt studied much about that one, but has a richlist...

In Zcash the privacy features are optional, but when used they're similar (but stronger) than Monero's. In Monero, each transaction input still explicitly lists a number of previous coins it could be spending (and proves one of them is actually being spent). In Zcash, every input can spend any previous shielded output.

Even in Bitcoin, the originating IP of the transaction is just speculation.

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


text:
Do physical bitcoins or altcoins actually carry value?
This question establishes that there are physical bitcoins that can be bought and I recently just bought a physical Dogecoin as a trinket but I can't help but wonder if there's a solid value related to these coins.
Bitcoins can be found for 1, 10, and 25 BTC and I just bought my Dogecoin coin for 10 USD (18947 Doge after shipping and handling). If someone were to hold onto these coins for years and attempt to sell later on, what would they be worth? Is a 1 BTC coin always worth 1 BTC or, like a collectible, is it only guaranteed to be worth what somebody will pay for it?
I know it's not officially backed or anything, but is it reasonable to think that if I bought it for 1 BTC that somebody else would pay me 1 BTC for it later even if the value of BTC changes?

Does your physical Dogecoin come with a private key (perhaps under a hologram sticker) that holds some amount of Dogecoins?

I'll know in a few days when it comes in the mail.

@Scott's comment answers your question: should they have a private key hidden somewhere, pointing to a wallet whence you can extract some DOGE, then yes - those physical coins carry value. If not, or if such coins have already been spent, they're just pretty tokens, nothing more.

The place you bought from, ShibeMint.com, sells nothing more than keepsake tokens.  They are made of copper or silver and are worth only what someone else is willing to pay for them.  They will not include a private key that allows you to then spend Dogecoin somewhere else. These are simply mementos and not a crypto currency.
Quote ShibeMint.com, these physical dogecoins are for

displaying additional shibe pride, starting an exciting conversation, more accurate decision making, extra inspiration, a lovely gift for a dogecoin enthusiast, attracting quality shibemates

There is nothing to stop another website from creating and selling their own version of Dogecoins.  In fact, here's another that does.
You can purchase physical bitcoins or altcoins with or without a private key that would allow you to spend that currency.  Here is a full list of physical crypto coins.  Without the private key, the crypto coin is worth the metal/plastic/material from which it is minted.
That said, it will still carry the value that someone else is willing to purchase it for.

What about the Bitcoins? Or are all physical crypto coins the same in this respect?

@CoreyOgburn No. There are physical coins that are redeemable for the actual currency.

Some physical coins contain private keys. In this case, the coin has value as a cryptocurrency until the private key is used and the address emptied of funds. You could also transfer more money to the coin, so it could be worth more or less than the cryptocurrency amount that's printed on the coin.
The coins are typically made out of a metal, which has a value of its own. One ounce of copper is only worth about $0.19, but Shibe Mint's silver dogecoin is made of 1 oz of silver, so it's worth at least ~$19.63. Since it's selling for $35, you could say that the "collectible" portion of the product is valued at ~$15. Even if it actually includes a private key for the 100 dogecoin it's denominated as, this doesn't significantly change this figure, since 100 dogecoin is about $0.06.

Okay, so this whole topic stems from the originator of physical renditions of bitcoins which is Casascius.  As you can see, this site is no longer providing this service.  There are a few other companies in existence.  It is novel to have them, but this concept has fueled the paper wallet craze, for which you may want to consider bitaddress.

I find it curious that this has been down voted since it is, in fact, the answer and history pertaining to this post.

Upvoting this answer since it mentions Casascius coins, which started the trend of physical bitcoins and are one of the most valuable physical bitcoin due to being discontinued and therefore scarce. The value of a physical bitcoin is in the trust and scarcity of them: otherwise, the value would simply be the cost of material the coin is made from.

Some physical bit coin ads are at least confusing if not just devious. Like for example , some say just scan the code and you will be shown the value of the bit coin. ( that's actually the current value of bit coin  but is not the value of the physical coin you have in your hand.)  But hey ! You can sell it anyway at some point  for a reasonable price considering its    metallic quality and appearance etc. Somebody somewhere  wants it.


text:
After generating my own private key, what's the proper way to add it to official wallet software?
I've got some Go code that successfully generates private keys and vanity addresses as described by the wiki.
So I have all the parameters around the private key but I'm not sure what to do with that info to make it usable by the bitcoin core application.
Should I build a wallet.dat file to point the wallet software at? What's the format for that file? Is there an alternative format so I can import my new key alongside my old keys instead of replacing the existing file so that the software has more control of what the structure of the wallet.dat is?
I could layout the key in the same format that paper wallet QR codes use but I'm not sure what I'd do with that string for a desktop computer to accept it.
What format should I put the raw private key into and where should I put it for wallet software to use it?

That sounds perfect! The second answer calls it Wallet Import Format or WIF and that's 100% what I was after! I guess that makes this question a duplicate. EDIT: they deleted their comment, but not after linking to this question.

My bad didnt mean to post as comment. Reposted as an answer

In Core, go to "Help" and "Debug Window". Go to the console and type importprivkey [key]. This might also interest you: How do I import a private key into Bitcoin-Qt?

It might also be worth mentioning WIF in the answer as for what format that key needs to be in.


text:
Just installed bitcoin, but it won't connect
Total newbie at bitcoin; long time Linux user.
kubuntu precise 64: My first attempt was just to download it (a slightly older version than the one from the ppa below), untar it and run the executable. That worked fine and it was downloading the data (block chain?). Then I played with some settings and it stopped downloading. I tried a bunch of things with no success.
Among other things, I tried encrypting my wallet and changing the network settings in bitcoin about the time things stopped working.
Then, I deleted the whole tarball, the expanded files, and the .bitcoin directory tree and installed from apt using the instructions at:
Installing Bitcoin-Qt on Ubuntu
It still won't download anything. It says "No block source available ..." and debug.log ends with a ton of messages which say
2014-04-19 13:36:21 connect() to 192.168.1.2:8333 failed after select(): Connection refused.
I went into my Actiontec gateway and saw that a port forwarding rule had been created by uPnP for 192.168.1.2:8333 (that's my notebook address with the port added) that says TCP any -> 8333. I have other rules using this IP - without the port on the address - which forward ports 587, 995, 5192.
When I go to http://www.canyouseeme.org/ , it tells me port 5192 is open (I have another application using that port), but it says "connection refused" for 587, 995, and 8333.
Any clues as to what I'm doing wrong (or what I should be doing instead) would be appreciated.
I can't figure out why the original attempt was working and then stopped.

Ok, so you changed the network settings when it was working. Would it be too much to ask what settings you changed?

@GregHewgill @George I don't use any proxy settings with my computer for anything else, so I tried to turn off the proxy setting in bitcoin. I also fooled around with opening ports 9050 and 8333 on my gateway. All of this was before I completely wiped my bitcoin install and reinstalled it with apt. env|grep proxy returned nothing.

Have you tried just using a lightweight client to see if that works. Just thought you could eliminate network issues if that worked.

It's still weird. I also installed Armory and it was able to read the blockchain (until I ran out of disk space :(   ), It prompted me to install bitcoind (which may have been why bitcoin-qt was unhappy.) Now, bitcoin-qt works and Amory crashes. I'm working with the Armory folks to figure out why.

Forgot about this question. I moved the data directory onto a bigger partition and symlinked to it from the original location and I deleted ~/.armory/ArmorySettings.txt and let it recreate it. Then Armory worked. That's all I can pull from my old notes.


text:
Paper Wallet: can I use the import option in my case?
I have created a paper wallet and I generated the public/private keys with Ubuntu live + Electrum. Now I have 2 questions:

In this case, can I IMPORT ( instead of SWEEP ) my keys in electrum and avoid to pay the fee each time I want to send my Bitcoin?
I have read that if you use the IMPORT option, then when you spend a portion of the Bitcoin, then the unspent amount will go to another address. Is it true? Why? Then I have to store another pair keys for the new address?

Thanks, I am newbie ❤

You can import keys into Electrum. Imported keys cannot be recovered using a recovery / seed phrase, so special care is needed to avoid loss.
Sweeping transfers money into an address corresponding to a key that is generated from the seed of a wallet. So control over that money can be recovered using a recovery / seed phrase. The transfer takes place as a transaction on the Bitcoin Blockchain and so needs to pay a transaction fee. The transaction fee is effectively a bid for space in an auction of space inside blocks.

and is it true that when I send a portion of my bitcoins the unspent bitcoins will be sent to another address? then how do I access this address?
Thanks :)

How does change work in a bitcoin transaction?
Sending certain amount of bitcoin from an address
What does change address mean inside Electrum wallet? -- your wallet takes care of all this for you, you don't have to manage this detail yourself (unless you want to for some reason)


text:
How To Reach My Funds From My Wallet Years Ago
I have a wallet.dat
and a .txt file
inside this txt file
wallet number like : L1aC2...
and a hash like: $bitcoin$64$a2z...
How can I reach to my fund inside this wallet ? I kinda have some memory about password,  but I don't exactly remember.

Make a backup first, before you try anything else. Do you remember what software you used? What have you tried so far?

Im trying hashcat problem is that my password was long very long as far as I remember it was smth like
myname_wifename_surname_dd-mm-yyyy
it has many characters...
trying
??????s???????s??????s%%?s%%?s%%%%
but it seems like it will take millenia

The text beginning with "L1aC2" could potentially be a private key for a wallet. You have the option to import it into another Bitcoin Core wallet or Electrum to check the balance.
Instructions for importing a single private key into Electrum can be found here.
As for the hash, it is a Bitcoin Core wallet hash. Tools such as John the Ripper or Hashcat can be used to bruteforce the password.

I wish it was private key but unfortunately I figured out its just my public key,
other one is my passphrase which is encrypted, I tried a lot of wordlists and even created a lot of combinations which ending with dates (1 TB wordlist) still no result(
freak*n satoshi, while trying to make it so secure, he missed human error factor.
It would be great to put smth like "I forgot my password" :)


text:
importing data to a wallet as not watch-only
I am trying to use private keys, addresses, and public addresses I generated myself. (for educational purpose).
I am working with bitcoin-cli by inserting the inputs I've generated myself. (in CMD)
the following code:
C:\Program Files\Bitcoin\daemon>bitcoin-cli -regtest -named -rpcwallet="legacy" importmulti "[{\"scriptPubKey\":{\"address\":\"<my P2PKH address>\"},\"timestamp\":\"now\",\"pubkeys\":[\"<my compressed public address in hex format>\"],\"keys\":[\"<my private key in WIF format>\"]}]" "{\"rescan\":false}"

returns this output:
[
  {
    "success": true,
    "warnings": [
      "Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag.",
      "Importing as non-solvable: some required keys are missing. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript."
    ]
  }
]

but I don't know what keys are missing since I'd generated everything based on the same key
(the order I generated the data:

seed
master key
derived a child key - from now on, I only used the child key
public key based on the child key
P2PKH address based on the public key
copied the values: child key, public key, P2PKH and typed them in the correct place in the template I added above)

Is this because I use only the child key andf not the master key?
How can I prevent importing this data as watch-only?
my main goal is to try to do most of the functions by myself with the least amount of calls necessarily.

all the code for generating the data has already been checked and is working as excepted (can provide python code)
I intend to use the import so I could use this data in regtest mode for transactions

Thank you all in advance!


text:
are we on testnet4 already, or is testnet simply down?
on popular sites such as blockr and blockexplorer, I see standard testnet addresses show up as "false" and the last transactions/blocks seem to be sending coins to a black hole(unspent, but not linked to any actual address). I transmitted a few transactions that too seem to have gone into limbo(not spendable anymore but not in the recipient wallet either: transaction seems cryptic compared to normal ones. I tried claiming coin from faucets such as thePiachu's testnet faucet, and those seem to be malfunctioning too :(
Is this just an availability blip I ran into or is testnet3 now gone due to segwit testing etc. ?

testnet3 seems to be working and active for me.  It's possible that people are testing weird things on testnet that confuses the block explorers.


text:
anyone attempted a multiple p2sh(multisig) send (ideally using python)?
I attempted to use pycoin to do a "create_signed_tx" in python, but had no joy: Do you think it might be technically possible to use spendables(UTXOs) from multiple source P2SH wallets in a single push to the network ? Anyone done this successfully yet(ideally using python)?

what is a "multiple source p2sh wallet"?

sorry if that was unclear: I mean sending bitcoin from "more than one" P2SH wallet in one transaction(push) transmit. By saying "multiple source" I didn't imply a special case. P2SH(pay to script hash) is like a multisig wallet(most "multisig" transactions these days are actually P2SH). Multisig wallet: one where more than one private key is required to spend coins.

answer is yes, its possible: I was merely doing it wrong in my earlier attempt(s):
have posted a gist to illustrate how I got it working using a few python libraries on the testnet: https://gist.github.com/kumrzz/111f8ea12af3528f496cbe678d153fc0


text:
Loaded 0 blocks during reindex
My node is busy with a -reindex. In the debug.log file I see lines like the following:
Reindexing block file blk02620.dat...
Loaded 438 blocks from external file in 7133ms

This seems normal, however, there are a lot of lines like this:
Reindexing block file blk02775.dat...
Loaded 0 blocks from external file in 714ms

I checked the file size of blk02775.dat and it is 128M like all the other *.dat files. How can it be that the file contains zero blocks?


text:
Do nodes periodically check block hashes?
I am aware that, in Bitcoin, blocks are immutable because of the Merkle tree structure, which ensures that every block contains the (Merkle root) hash of the previous block.
Thanks to the properties of cryptographic hashes, even a 1 bit change in a previous block leads to a different hash, which can be used to detect tampering if you compare the hash of block (N-1) to the hash included in the next block N.
My question is: when is this check actually carried out?
Some claim that

yes, the blocks get recalculated regularly

but I haven't found any source on this claim.

It is unnecessary to recalculate block headers regularly. Whenever a new block is announced, the block header’s hash must meet the difficulty requirement to be acceptable. The combination of committing to the preceding block’s hash and the new block’s hash meeting the difficulty requirement, translates to an inductive commitment to all prior blocks in the best chain, as well as a proof of work. After this cheap check, the block is also tested to adhere to all other consensus requirements.
When a new block arrives, it checks whether this block extends its best chain or it constitutes an alternative chaintip with more work. If so, the node extends its best chain, or reorganizes to the new best chain’s tip.
If instead a block is published, that "changes a predecessor of the best chain tip", this would produce a distinct block header from the original, and the new block would constitute an alternative chaintip at a lower height than the best chaintip. (And the attacker would have to spend the same amount of proof of work to make the changed block pass the difficulty requirement.) As the successor of the original block commits to the hash of the best chain, and all further successors each inductively commit to the original block by committing to a successor of the original block, the best chaintip would have more work than the alternative chaintip, unless the attacker builds more blocks on top of their alternative block to outpace the prior best chaintip.
Anyway, we only need to check each block once, and then simply keep the block header chain in memory and extend from there, and it is unnecessary to revalidate blocks later, because we already know that anything that is part of our best chain has been checked before and cannot be changed without changing the header’s hash.

Receiving nodes independently maintain a copy of the UTXO set. This is the set of unspent transaction outputs that the node has checked previously. It is used to check fresh transactions.
When a new block is successfully found, its header and transactions are broadcast.
When a node receives the transactions, it:

Re-constructs the merkle tree from the transactions and checks the header is valid.
For each transaction, it checks that there is a matching output in the UTXO set, and checks that the spend is valid.
It removes spent TXOs and adds new unspent TXOs from the new transactions.
Note that for every block, at least one new output is added for the coinbase transaction1.

On full nodes, it is the UTXO set that is "recalculated regularly."

1: It's possible that a coinbase could have no spendable outputs, but it's unlikely!
 Note, in implementation, the UTXO set is spread over multiple separate structures, but can be imagined as a single entity for explanatory purposes.

As that answer says,

the nodes verify the transactions upon receiving a new block

So each node only needs to check once and it can then make a note of the block-id. A node never needs to refetch a block it has already seen. It would fetch a block at the same height with a different id in which case that block gets validated
There is no real need for a node to periodically revalidate data it already received. Bitcoin core does recheck it's stored Blockchain data at startup though. This guards against local interference not against other nodes trying to transmit tampered blocks.


text:
How to determine the output value to inscribe an Ordinal?

It's only mentioned the fee to inscribe the Ordinal.
But how about the output value?
For BRC-20, the suggested value in UniSat is 546.
For Ordinals, it's varied.
Most of the Ordinals collection like Bitcoin Punks, Bitcoin Frogs using 10,000 sats.
Others more or less than 10k.
I'm able to use 1 sats for 330kb image on testnet.
What's the downside?


text:
Reclaiming Disk Space
According to section 7 of the original bitcoin spec. by Satoshi:

Once the latest transaction in a coin is buried under enough blocks,
  the spent transactions before it can be discarded to save disk space.

In order to get the bitcoin-qt client running, I am currently downloading the ENTIRE block chain from the https://bitcoin.org/bin/blockchain/bootstrap.dat.torrent
Is there a smaller download somewhere? My google skills are failing me, plz help.

You could use a thin-client like MultiBit which doesn't require the entire blockchain to be downloaded.

Hi, welcome to the site. Have a look at the question Nate points to, according to the answers given therein the download size would not be reduced, only the storage.


text:
What Prevents the number of Bitcoins from being increased? After 21 Million?
Can the bitcoin MAX_MONEY attribute simply be changed from 21 Million to a higher number? If not what prevents this from being done?
What would happen to existing addresses and accounts if MAX_MONEY is changed and recompiled?

The problem is everybody else has to agree with your decision.

Just as in your other question, changing MAX_MONEY would cause a hard fork.


text:
How to Create a Light Wallet and Light Bitcoin Node, and run it on Mobile?
For example, instead of using my laptop to run bitcoind...how can I run bitcoind on a smartphone to create a light bitcoin wallet?
I understand hashing may drain battery, but is this possible? If so how?
I read somewhere a client is considered "light" if it doesn't download the whole blockchain, but just communicates by sending headers.
Thanks.

There are no mobile apps that do hashing (i.e. bitcoin mining); this would be absurdly inefficient.  But there is no technical obstruction to writing such an app if you really wanted to.

If you're looking to mine on your phone, it's literally useless. The hashing power on these devices is so low that you'd probably need a very large amount of phones (around the thousands) to reach the hashing power of a single ASIC machine.
Also, storage is an issue because a Bitcoin node needs all of the blockchain data (around 17gb as of today), so you'd need a high-end phone that has a large amount of disk space.


text:
Nonstandard type script's address
I have nonstandard tx output. txid is 03acfae47d1e0b7674f1193237099d1553d3d8a93ecc85c18c4bec37544fe386.
And I want to express the tx output with specific unique address. Blockchain explorers all seem to use the same convention for representing scriptpubkey.
ex)
https://blockchair.com/ko/bitcoin/transaction/03acfae47d1e0b7674f1193237099d1553d3d8a93ecc85c18c4bec37544fe386
https://3xpl.com/bitcoin/transaction/03acfae47d1e0b7674f1193237099d1553d3d8a93ecc85c18c4bec37544fe386
https://oraclus.com/transaction/bitcoin/03acfae47d1e0b7674f1193237099d1553d3d8a93ecc85c18c4bec37544fe386
How can I derive the address like them?
I tried sha256, sha256+ripemd160, md5 etc.

no :(
I want to know how to derive that address 272edf45031dd498e7b3ae89e11ff21b string.
Blockchair and other places use the same encoding.

Blockchair and 3xpl are projects by the same people. I have never heard of oraclus, and I don’t think this representation of non-standard outputs is used broadly.

Some other blockchain explorers show the address as NULL or UNKNOWN. Someone raised a support request at Blockchair for this. See https://github.com/Blockchair/Blockchair.Support/issues/1487

s-272edf45031dd498e7b3ae89e11ff21b is a special address in Bitcoin history: it's an error made by MtGox in 2011. It's not a valid address, it was named like that for unknown reasons.
You can find more about it here:
https://news.bitcoin.com/bitcoin-history-part-17-that-time-mt-gox-destroyed-2609-btc/

This doesn't answer the question. It might very well not be answerable unless Blockchair shares how their internal format works, or someone reverse-engineers it.


text:
Python code to create a two-input transaction in test net
I made a transaction that can be spent by anyone and now I wanna spend it and bring it back to my address. The problem in it doesn't have enough bitcoin for transaction fee so I'm using another input for that. This is my code:
def P2PKH_scriptPubKey(key):
    return [OP_DUP, OP_HASH160, Hash160(key), OP_EQUALVERIFY, OP_CHECKSIG]

def P2PKH_scriptSig(txin, txout, txin_scriptPubKey, private_key):
    signature = create_OP_CHECKSIG_signature(txin, txout, txin_scriptPubKey, private_key)
    public_key = private_key.pub
    return [signature, public_key]

def get_txout_scriptPubKeys(amount_to_send1, amount_to_send2):
    txout1_scriptPubKey = [OP_TRUE]
    txout2_scriptPubKey = [OP_FALSE]
    txout1 = create_txout(amount_to_send1, txout1_scriptPubKey)
    txout2 = create_txout(amount_to_send2, txout2_scriptPubKey)
    return txout1, txout2

def send_from_custom_transaction(amount_to_send, txid_to_spend, utxo_index, txin_scriptPubKey, txin_scriptSig, txout_scriptPubKey):
    txout = create_txout(amount_to_send, txout_scriptPubKey)
    txin = create_txin(txid_to_spend, utxo_index)
    new_tx = create_signed_transaction(txin, txout, txin_scriptPubKey, txin_scriptSig)
    return broadcast_transaction(new_tx)

def create_txin(txid, utxo_index):
    return CMutableTxIn(COutPoint(lx(txid), utxo_index))

def create_txout(amount, scriptPubKey):
    return CMutableTxOut(amount*COIN, CScript(scriptPubKey))

def create_OP_CHECKSIG_signature(txin, txout, txin_scriptPubKey, seckey):
    tx = CMutableTransaction([txin], txout)
    sighash = SignatureHash(CScript(txin_scriptPubKey), tx,
                            0, SIGHASH_ALL)
    sig = seckey.sign(sighash) + bytes([SIGHASH_ALL])
    return sig

def create_signed_transaction(txins, txouts, txin_scriptPubKey, txin_scriptSigs):
    tx = CMutableTransaction(txins, txouts)
    for i, txin in enumerate(txins):
        txin.scriptSig = CScript(txin_scriptSigs[i])
        VerifyScript(txin.scriptSig, CScript(txin_scriptPubKey[i]), tx, i, (SCRIPT_VERIFY_P2SH,))
    return tx

def broadcast_transaction(tx):
    raw_transaction = b2x(tx.serialize())
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    return requests.post(
        'https://api.blockcypher.com/v1/btc/test3/txs/push',
        headers=headers,
        data='{"tx": "%s"}' % raw_transaction,
    )

pv_key1 = "..."
pv_key2 = "..."

my_private_key1 = bitcoin.wallet.CBitcoinSecret(pv_key1)
my_private_key2 = bitcoin.wallet.CBitcoinSecret(pv_key2)
my_public_key1 = my_private_key1.pub
my_public_key2 = my_private_key2.pub
my_address1 = bitcoin.wallet.P2PKHBitcoinAddress.from_pubkey(my_public_key1)
my_address2 = bitcoin.wallet.P2PKHBitcoinAddress.from_pubkey(my_public_key2)

def send_from_P2PKH_transaction(amount_to_send, txid_to_spend1, utxo_index1, txid_to_spend2, utxo_index2):
    txout_scriptPubKey = P2PKH_scriptPubKey(my_public_key2)
    txout = create_txout(amount_to_send, txout_scriptPubKey)

    txin1 = create_txin(txid_to_spend1, utxo_index1)
    txin2 = create_txin(txid_to_spend2, utxo_index2)

    txin_scriptPubKey1 = [OP_TRUE]
    txin_scriptPubKey2 = P2PKH_scriptPubKey(my_public_key2)

    txin1_scriptSig = []
    txin2_scriptSig = P2PKH_scriptSig(txin2, [txout], txin_scriptPubKey2, my_private_key2)

    new_tx = create_signed_transaction([txin2, txin1], [txout], [txin_scriptPubKey2, txin_scriptPubKey1], [txin2_scriptSig, txin1_scriptSig])
    return broadcast_transaction(new_tx)

all_money = 0.00015883 + 0.000001
amount_to_send = 0.00000003
txid_to_spend1 = 'c21f572546f11ab142b3099db329c352937449c1757238c4461b6b13de927c7c'
utxo_index1 = 0
txid_to_spend2 = '38610341422c10bb433046e7bb200e4015af178d4031ab4be192c3a93a3c8363'
utxo_index2 = 0

response = send_from_P2PKH_transaction(amount_to_send, txid_to_spend1, utxo_index1, txid_to_spend2, utxo_index2)

The problem is I get scriptPubKey returned false for the second input and I don't know why.

Weird, I'm able to find the second tx but not the first one:
https://mempool.space/testnet/tx/38610341422c10bb433046e7bb200e4015af178d4031ab4be192c3a93a3c8363 => OK
https://mempool.space/testnet/tx/c21f572546f11ab142b3099db329c352937449c1757238c4461b6b13de927c7c => NOT FOUND


text:
Anti-exfil protocol can't be verified on multiple hardware wallets
Regarding the nonce side channel attacks detailed in posts like this one by Blockstream. Which references this mailing list by Pieter Wuille. The idea is to add another layer of protection against a malicious hardware wallet by requiring it to prove that it incorporates some randomness provided by the software wallet that is used to broadcast the signed transaction.
Comparing the anti-exfil protocol to deterministic nonce, Pieter says:

In case HW uses a deterministic algorithm, it is possible to protect against
the MHW case by spot checking HW's behavior, by using an externally known
secret/seed. However, we'd like to have better than just spot checking
security, and for protection against side-channel attacks we may want
something that keeps working even when randomness is used by HW.

But this is precisely what I like about the deterministic nonce. I can buy as many hardware wallets as I want to verify that they all produce the same signature. And even test it against some airgapped software wallets like Electrum. I can even write my own simplistic RFC6979-compliant wallet with python to verify the signature is the same.

With deterministic nonce, there is no limit to the number of hardware and software wallets with which I can sign the same transaction to verify that the signature is the same. With anti-exfil, I am limited to only the single HW and the single SW used to broadcast the transaction and must hope that at least one is not compromised.
The whole idea of hardware wallets is that we think of them as more secure than the software wallet/hot machine. So surely 2 hardware wallets (used to verify deterministic signature matches) is more secure than one hardware and one software wallet as mentioned in point #1?

Your analysis is correct, in that "verified" deterministic signatures obviate the need for a protocol like anti-exfil. However, the trade off that anti-exfil makes is that it does not require signing with multiple devices before knowing that the signature does not leak data.
Consider that without anti-exfil, you must sign and check every input with multiple devices before exposing the tx to the network. It is not enough to perform this validation after the fact; by the time you determine that different signatures have been produced, enough bits of your private key may have been leaked to allow theft either directly or by grinding the remaining bits.
Not using anti-exfil means that to achieve the same level of leakage assurance, you must sign every tx with multiple devices and verify the signatures before sending. That's probably fine for an offline vault or cold storage, but it is neither practical nor supported by warm/hot wallets for typical send flows.
Anti-exfil exists to provide assurance for the common case of a single signing device. If you are prepared to sign and compare with multiple devices then you likely don't need to use it. Like everything in cryptography there is a trade off between convenience and security; it is up to the individual to determine where on that spectrum they feel comfortable.


text:
Bitcoin accidentally sent to my mycelium wallet. I have seed words and keys. School boy error. Still a noob
thank you for your time in advance.
I’ve gone to send funds to another wallet but I’ve accidentally sent it to my, mycelium wallet by mistake.
Is there any way that can retrieve my coin? I have my seed words and keys to hand.
Thank you.

What is preventing you using your Mycelium wallet to send the received money to the intended recipient?

most likely you have done some spelling mistake on the seed words.
here is the list of 2048 words used as seed words
https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md
use the correct spelling and you are sorted


text:
Sent bitcoin to my new bitcoin core wallet, but not showing up
I am SUPER newbie to this stuff, please help and be patient.  I needed a place to send a large bitcoin transaction, and decided to impulsively download bitcoin core to receive it on my desktop.  There are over 6 confirmations, but its not showing up in my bitcoin core wallet.  Is this because it hasn't synced the multi-year transactions yet?  will it show up when it does sync? i'm so darn confused and kinda worried....

Bitcoin Core is processing the entire blockchain to synchronize with the network. Given that you have verified that your transaction was included in the blockchain and assuming that your address has been credited by the transaction output, your transaction will show up when your Bitcoin Core node has caught up to the block that confirmed it. Depending on the hardware and internet connection of your node, this may take a few hours to some days. If you received a sizeable amount to your Bitcoin Core wallet, please be sure to backup your wallet.


text:
Is the bitcoin still mine, available?
I purchased bitcoin 2x this week at $ $215.00 and $350.00. I put it in a wallet that I was instructed to by a “financial advisor”. I was told they ran it in trade on virtualfxtrade.uk I really think this was a scam. He said I made $8136 on the same day but is asking for $1600.00 fee for me to withdraw the $8136. If it is scam, do I still own the bitcoin? I have reciepts of purchase and wallet info.
How can I check?


text:
What is a good place to ask for bitcoin to fund a scientific project?
I have a great idea for an invention, but I am currently limited to purchasing parts for building a prototype of it with bitcoins. Unfortunately, I do not have that many bitcoins and need a way to ask the bitcoin community for donations. Yes, I have an address, I am not a newbie to bitcoin. I would like to know where I can ask for bitcoin for a scientific project that could benefit the world. If anyone is interested I will disclose some information about my project.

if you have scientific project, most how about asking for a fund in university? Speak with different professors.

You could look into posting about your project in the Einsteinium community. The coin is designed specifically to help fund science projects and research.
http://einsteinium.org/
https://bitcointalk.org/index.php?topic=494708.0


text:
Why am I not getting payments on my bitcoind on an amazon ec2 instance?
I have an amazon ec2 instance running a web server, MySQL server, and bitcoin daemon on ubuntu 14.04, and I ran ./bitcoind getnewaddress and the output was an address. I sent a few cents worth of bitcoin to that address, and I have been doing ./bitcoind getbalance for a few hours and still there is no balance.
Wondering if I needed to send to a particular accoutn instead of the main bitcoin daemon, I also sent a few cents to an address generated by ./bitcoind getnewaddress debug (just a test name) and did ./bitcoind getbalance debug. I have found nothing, I am not sure what the issue is. Port 8333 is open on the amazon vm, so I don't think the issue is there. bitcoind's rpc interface is running on port 8432 as specified by rpcport=8432 in ~/.bitcoin/bitcoin.conf. Any idea why I am not getting payments? I think there have been enough confirmations, I believe the number required is 6 required by default. I will check soon to make sure that there have been that many confirmations.

@GeorgeKimionis 281034, I'll check if that's up to date, one second please... (I started this bitcoind very recently, so maybe it hasn't finished syncing...)

@GeorgeKimionis Grr, thats about 50,000 blocks behind. Does that mean I have to wait a few hours still?

@GeorgeKimionis Alright, thanks. By the way, I am a free tier user of amazon and so I do not have very much storage on my server, 20 GB right now (I can get up to 30 if needed, I will probably have to). My storage is about 90% full, and I'm pretty sure that's because of the blockchain. Is there any way to only use the recent blocks or something so that I don't use this much storage?

Let us continue this discussion in chat.


text:
How to check if user sent me the BTC?
I am developing JSP web. User will be redirected to another page only if he sends the certain amount of BTC, is there any listener which could check if money arrived to my wallet from the certain wallet address?
And after leaving the page is there possibility to automatically send the money back to the user?
Maybe some good tutorial on bitcoinj or something? Any suggestions?

I would suggest using a Web API to get notified when a transaction happens on the address(es) you're interested in, it's by far the simpler. Something like this may help:
http://dev.blockcypher.com/#websocket_webhook

for small amounts 6 confirmations are overkill, you could just listen for the payment to be relayed by some bitcoin nodes which happens in seconds.
For your question, clone bitcoinj and look at the examples (more specifically the 'Kit' example). Use that as a basis and then read the chapter on 'Watching Wallets' in the docs:
https://bitcoinj.github.io/working-with-the-wallet
You can specify a listener which is called when there's activity on your address/wallet.

I don't know about bitcoinj but I suppose it has some kind of Api that you could poll for the wallet state. What really seems strange to me is the fact of redirecting. taking into account that you should have to wait for 6 blocks for a transaction to be confirmed with some security you'll have the user waiting for about an hour to redirect :)
Bitcoin payment verification is not instantaneous as you seem to imply from your post.

I am sorry it looks like I dont know how long it takes to send the BTC, I want to make it with different cryptocurrencies later on I just need to understand how it works that's why I have written BTC - its the most common. And yeah I am looking for that API.

don't be sorry!:)


text:
Usage of Markov chains to improve bitcoin mining
Discrete Markov chains have been used to approximate the probability distributions in games of chance in order to improve odds and do predictions e.g. winning numbers in a lottery. As long as the lottery,card game etc. meets certain conditions this will work or else the probability distribution will drift rendering the prediction useless.
Competing to find a nonce during mining is kind of like a lottery. Therefore theoretically Markov chains could be used to improve bitcoin mining as long as it satisfies conditions for discrete Markov chains. Has anyone ever explored this?
Thanks, Andrew

The probably distributions of hash algorithms are assumed to be completely uniform. I can't imagine how past information could in any way predict future outcomes.

A Markov chain is a mathematical model for a random process that has only short-term dependence on its history: if you know the current state of the system (or perhaps its recent history), any further historical information will not improve any predictions about its future.
This could be a useful model for analyzing a (flawed) lottery in which there is some dependence between today's number and tomorrow's; it could help you determine the nature of that dependence, and let you use today's number to make a prediction about tomorrow's number that would improve your chances of winning.
However, in a truly fair and random lottery, no such dependence should exist.  Each number should be chosen in a manner that is not biased or affected in any way by past numbers.  In such a case, a prediction based on a Markov chain would be no better than a random guess; and indeed, given enough data, Markov chain techniques would tend to confirm that there is no dependence.  (In the short term, such techniques might appear to detect some dependence, but this would be erroneous.)  So if the lottery is in fact fair, you can't improve your odds using a Markov chain analysis or any other method.
My understanding is that the cryptographic community believes, based on all current evidence, that the Bitcoin mining algorithm behaves like a fair lottery.  Of course, the output of the SHA256 hash function does in fact depend on its input data, but it is believed that there is no computationally feasible way  to describe or gain information about this dependence short of actually computing the function.  If so, then SHA256 outputs are effectively independent of their inputs, and past history of Bitcoin hashing gives you no useful information about the future; it does not help you improve your odds compared to trying nonces in sequence or at random.
If you, or anyone else, is able to "improve Bitcoin mining" via Markov chain techniques, or any other method, it would mean that SHA256 is seriously flawed and should be abandoned.  Fortunately, as far as I know, there is no evidence to suggest that this is the case.

Hi,
Thank you both for your answers.
But actually according to the Wikipedia article definition for Markov Chain: [Markov Chain Definition][1]: there is no dependence on history.
So I agree with your conclusions but for different reasons.
And I realize now that construction the state transition matrix for the Markov chain - leading to a "win: correct nonce" and a loss: incorrect nonce' would be too computationally intensive   [1]: http://en.wikipedia.org/wiki/Markov_chain

Markov chains don't depend on past history other than the current state of the system. For example, Markov modelling of text would predict the next word based on the current word, but not looking any further back than that (a hidden Markov model would look back further). On the other hand, Bitcoin mining is entirely random and doesn't even depend on the current state of the system. Markov models are useless for Bitcoin mining just like they are useless for predicting dice rolls.


text:
How to buy bitcoins with amex debit card?
I have a debit card and would like to buy bit coins, is there a way with amex?

See this question.  The short answer is: probably not, a Bitcoin seller who accepted credit or debit cards would be extremely vulnerable to fraud.

Most probably you won't be able to do so, for the same reasons most crypto-currency dealers avoid being paid via Paypal or other, non Am.Ex. credit cards (fear of charge-backs). Don't know if AmEx allows you to withdraw cash from your credit card, that would be accepted by anyone.

Coinbase has options for both debit and credit.

I just wanted to comment on this to clarify the credit card option works with Coinbase.  I logged into my Coinbase account and it does have an option to add a credit card, but it says it charges credit cards only as a backup, similar to the way PayPal works.


text:
What's causing the number of utxos to increase so quickly?
I was using gettxoutsetinfo a couple weeks ago (maybe a bit longer, can't remember) and the total number of txouts was something like 115 million. Now it's sitting at around 124 million.
What's up with the super fast increase here? Any concerns with how much RAM the utxo set will use in the near future if this rate of increase is here to stay?

What's causing the number of utxos to increase so quickly?

An old article at Yahoo finance pointed out

the UTXO count of bitcoin (BTC) is ticking upwards

...

UTXOs also tells us that despite a new, large cohort of people interacting with bitcoin thanks to Ordinals,

That reinforces my feeling that, although the payload of Ordinals Inscriptions are not in the UTXO data, they do cause a great number of UTXOs to be created with tiny Bitcoin values. I think this is especially true with BRC-20 usage. It seems people create large numbers of tiny-valued UTXOs as preparation for recording BRC-20 actions.

Any concerns with RAM? Am I right in saying it's important for mining that the utxo set doesn't take up too much memory? Last time I checked I think gettxoutsetinfo was showing close to 9 GB. RAM should continue to get cheaper over time but maybe not fast enough. I know Utreexo is being considered as well


text:
How does stratum v2 work?
I want to know how much independence miners have when they join a pool. Do the individual miners create the block headers and choose which transactions to include in their block or is the block just made by the pool operator?
I’ve briefly read that the stratum v2 protocol gives miners some more independence. Was curious to see if anyone here could give me some technical details.

Do the individual miners [...] choose which transactions to include in their block

According to the relevant website:

Stratum V2 is the next generation protocol for pooled mining. It increases security, makes data transfers more efficient, and reduces mining infrastructure requirements. It also introduces three new sub-protocols that let miners select transaction sets and improve decentralization by negotiating with pools.

(my emphasis)

Job Negotiation Protocol
A Miner's Template Provider negotiates a block template (which includes the transaction set) with a Pool's Job Negotiator. The Pool can reuse negotiation outcomes across all end-miner connections to reduce computational intensity. A single negotiation can multicast to multiple farms with hundreds of thousands of devices. This protocol is a separate, optional piece of infrastructure from the Mining Protocol and can be provided as a 3rd party service for mining farms. Separating job negotiation as a sub-protocol lets pools terminate negotiation connections independently of mining protocol connections (i.e. share submissions). Work negotiation likely requires, at minimum, validity spot-checks and (potentially) rate-limiting.

The details are at https://github.com/stratum-mining/sv2-spec/blob/main/06-Job-Negotiation-Protocol.md which includes

6.1.4 CommitMiningJob (Client -> Server)
A request sent by the Job Negotiator that proposes a selected set of transactions to the upstream (pool) node.

Field Name
Data Type
Description

request_id
U32
Unique identifier for pairing the response

mining_job_token
B0_255
Previously reserved mining job token received by AllocateMiningJobToken.Success

[etc]

So yes, miners can negotiate with the pool about the transactions the miner would like to include in the block. Note that support for this is described as optional. Perhaps some pools don't support the job negotiation sub-protocol.


text:
Using vanitygen To generate addresses for different cryptocurrencies
I know how to use vanitygen but how do you determine the number that will correspond to the -X parameter for a different cryptocurrency? For example it is -X 30 for Dogecoin.

Here's the biggest list yet: https://github.com/exploitagency/vanitygen-plus/blob/master/vanitygen.c#L547

I found some here.

LTC: 48
FTC: 14
NVC: 8
ANC: 23
PTC: 47
CNC: 28
DGC:30
NMC: 52
PPC:55
YAC: 77
BQC: 85
IXC: 138
DOGE: 30

Proper syntax for VanityGen is: (from this question)
Usage: vanitygen [-vqrikNT] [-t <threads>] [-f <filename>|-] [<pattern>...]
Generates a bitcoin receiving address matching <pattern>, and outputs the
address and associated private key.  The private key may be stored in a safe
location or imported into a bitcoin client to spend any balance received on
the address.
By default, <pattern> is interpreted as an exact prefix.

Options:
-v            Verbose output
-q            Quiet output
-r            Use regular expression match instead of prefix
              (Feasibility of expression is not checked)
-i            Case-insensitive prefix search
-k            Keep pattern and continue search after finding a match
-N            Generate namecoin address
-T            Generate bitcoin testnet address
-X <version>  Generate address with the given version
-t <threads>  Set number of worker threads (Default: number of CPUs)
-f <file>     File containing list of patterns, one per line
              (Use "-" as the file name for stdin)
-o <file>     Write pattern matches to <file>
-s <file>     Seed random number generator from <file>

That is pretty helpful. Do you know more. And what is the -k for?

Added the whole helpfile for vanitygen, from a different question. That'll help a lot :)

One last thing. How do you access previous results or save a result? And is there any complete list for these -X addresses except the link you provided?

In bash you can do something like codeThatGeneratesSomething > output.txt iirc. Then it will be in output.txt instead of the shell. Because the private keys are also in there IN PLAIN TEXT, be sure to use it WISELY.

Sorry I am a complete noob to this. I don't know what is bash and all. Isn't there an inbuilt command in vanity gen to save the output? I also see some OCLBIN files what are they?

Bash is the terminal you use it in :). So you append > output.txt behind the command you are using it. But the -o <file> does exactly what you want, and it is easier. Didn't read it (and you didn't either)

Ohh sorry I forgot to mention that I use windows. And what is the .oclbin file and how to open it?

If you want to use the option -k for something, you can also use the -o option.

And what is the point of using -k? You have already got your desired result. How can there be more patterns. Please can you give me an example?

Maybe if the Pizzahut wants to make btc-deposit addresses for their 100 different pizza-delivery boys, for clients to tip. It would be nice if all addresses contain 'PizzaHutDeliveryboyTipContest'. Or whatever. You and your wife (or husband) want to have addresses that both contain 'WeLoveEachotherVeryMuch'? Or you just want to select the best of 10 generated addresses? For example, if there is a swear in one, you want to drop that one (Imagine 'f*CkPizzaHut' as address).

Ohh ok thanks. And Just one last thing. Are there more of those -X addresses and how do you find them?

I cannot find more of the -X options. I just googled for it and came accross the linked site.

Do you also know how to use multiple GPU's. I cannot get it working.

No, I don't know that. Just be patient, let it run for a while. Or ask a new question


text:
How to use BlockChain API?
I am a complete noob to PHP. But I just wanted to know how can you use the BlockChain API to get your wallet balance. I tried but could get no result. I do not even know how to print it. Please help. This is my current code :-
    <?php

    $guid="xxxxxxxxx";
    $main_password="xxxxxxxxx";

    $json_url = "https://blockchain.info/merchant/$guid/balance?password=$main_password";

    $json_data = file_get_contents($json_url);

    $json_feed = json_decode($json_data);

    $message = $json_feed->message;

    ?>

And what exactly is the guid? Is it the wallet identifier?

Your code is close to what you need:
<?php

$guid="xxxxxxxxx";
$main_password="xxxxxxxxx";

$json_url = "https://blockchain.info/merchant/$guid/balance?password=$main_password";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$balance = $json_feed->balance;

echo $balance;
?>

The response looks like this (Wallet Balance in Satoshi):
{ "balance": 1000}

So you need to fetch the balance object not the message one.
Then add an echo to print out the balance.

balance; echo $balance; ?> this is the result I got. Don't know why.

just tested it with my own wallet it worked perfectly fine, maybe your put in the wrong credentials

is the guid the wallet identifier?

yes its is, maybe you missed out a semicolon or an php tag, seems like an syntax error in your php maybe try to copy paste again

ahh got it. The 2 factor auth was messing it up. Figured it out. Thanks. Just a little curious. How could I modify this to be performed after a certain time interval?

@rahulgarg12342 How did you bypass the 2 factor authenticator?
I am using the block chain api to do exactly the same thing, it is working but for 2 factor authenticator enabled wallets I am getting the error. How do I deal with that?


text:
How to schedule a bitcoin transaction?
I just wanted to know if you could schedule a bitcoin transaction. For example I want to send some BTC to someone exactly at 4:00 pm but it is 1:00 pm at my current place. Is that possible so that my wallet somehow automatically sends the BTC after a certain time?

This can actually be done on the blockchain itself, if you set the nLockTime value. But this would probably mean making a raw transaction.

Option 1
I'm not sure on which platform you are, but if you use a Linux or Mac, you can combine the following two commands (sources here and here. Check also the at manual):
echo "ls -l" | at 07:00

and
 bitcoind sendtoaddress <bitcoinaddress> <amount>

to make something like:
echo "bitcoind sendtoaddress    1MAtHias8yvaLcDgckkG5QnVLY7ucBZrGv 0.01" | at 07:00

to send me 0.01 BTC at 07:00 o'clock in the morning. I think you're computer should stay on for this, as it cannot send a transaction with it turned off.
Option 2
You can also work with sleep (Mac and Linux only):
sleep 120 && bitcoind sendtoaddress 1MAtHias8yvaLcDgckkG5QnVLY7ucBZrGv 0.01

The number behind sleep is the amount of seconds that there is nothing executed. So now it will send 0.01 BTC to me, after 2 (=120/60) minutes. The && will first execute the left side. If that executed succesful, the right side is executed. It is more insightful, but you'll have to calculate the amount of seconds and is as precise as your calculations.
Option 3
For windows:
timeout 120 && bitcoind sendtoaddress   1MAtHias8yvaLcDgckkG5QnVLY7ucBZrGv 0.01

timeout is the sleep variant of windows. Probably doesn't work on Windows XP, but works here on W8 and should work on W7. The && does the same as in Option 2.

I use windows and use blockchain. Is there any other option?

I don't have a answer in that case. I will leave my answer however, as it can be a solution to someone else who visits this page later on.

Even if I download the client, do you know the command for windows?

There are the same commands as the other clients. See the second link from my answer for the commands. A screenshot shows how you can use it, I suppose

Since you are a little experienced, please can you just take a look at blockchain API and help me make a command so I can use it to send. I think the blockchain API should enable that.

I am not into PHP at all. I think you can do the same approach as I did in option 2 (and 3). Otherwise you can do something with time and check if it is 04:00 pm on a specific day. If that is true, execute the send command https://blockchain.info/nl/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount (from here). I believe there is no built-in option to postpone a transaction.

To follow up on Mathias's answer/comments. For accessing the PHP API he linked, you can use wget (http://gnuwin32.sourceforge.net/packages/wget.htm). And to have it run once (or repeatedly) at a certain time, you can use the Task Scheduler built in to Windows, which you can find if you open Computer Management->System Tools->Task Scheduler->Task Scheduler Library

The third command you give in Option 1 is missing an echo; as written it will send the coins immediately, and then at 07:00 it will try to execute the transaction ID.

@mattburnett that is really helpful. But why do I need wget when I can just open the php file using the scheduler?

I wasn't aware that you could open a URL with the scheduler; i dont use it much. If you can then skip using wget.

you can have a php or python script and keep it running till the time comes, something like:
<?php
$hour = date('G'); // 0 .. 23
// YOUR VARIABLES FOR THE JSON REQUEST SHOULD GO HERE
//if time = 16
if ($hour == 16) {
    $json_url = "https://blockchain.info/merchant/$guid/payment?password=$firstpassword&to=$addressa&amount=$amounta";
$json_data = file_get_contents($json_url);

 } ?>

this is more of a pseudo-code for what I meant and might not work without modification.


text:
How to send money using blockchain API?
I am not very familiar with php but I just want to know how this works. I am trying to use the blockchain API to send some money for testing purposes but the transaction isn't taking place. My current code is this :-
<?

$guid="xxxxxxxx";
$main_password="xxxxxxxx";
$amount = "50000";
$to = "xxxxxxxx";

$json_url = "https://blockchain.info/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&shared=$shared&fee=$fee&note=$note";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed->message;
$tx_hash = $json_feed->tx_hash;

?>

Please tell me what is the error in my code and also how to print out the response on the screen.

You don't have to use all the optional variables in your request link, specially when you have not set a second password, etc...
this suffice the request to send your transaction:
$json_url = "https://blockchain.info/merchant/$guid/payment?password=$firstpassword&to=$addressa&amount=$amounta&fee=$fee";

even if you remove "fee" variable, it would still work but you should consider 0.0001 miners fee that is there by default for minimum miners fee.
also you can get these values from the response:
$json_feed = json_decode($json_data);

$message = $json_feed->message;
$txid = $json_feed->tx_hash;
$notice = $json_feed->error;

and what happens if I purposely put a wrong address?

it would send the btc to the wrong address...

you can add a "from=$addressb" to your request to indicate which address you are sending bitcoins from.

I meant an invalid address. And how do I print the message on screen with tx hash?

you would get the following fields in the response json:
$json_feed = json_decode($json_data);
$message = $json_feed->message;
$txid = $json_feed->tx_hash;
$notice = $json_feed->error;

But when I enter an address and run the php, I get no result.

@Shayanbahal better put the code of your comment into your answer otherwise its rly hard to read


text:
ZMQ hashblock doesn't work
I'm running a full node,
bitcoind .. -zmqpubhashblock=tcp://0.0.0.0:3001 -zmqpubrawtx=tcp://0.0.0.0:3001

rawtx events work great, but not getting any hashblock ones.
Node is fully synced, I can see new blocks received in bitcoind output, but it's not announced over zmq.
I consume zmq as fast as possible, so I don't understand why I'm not seeing the hashblock events.

Are you certain that your client is subscribed to receive hashblock?

Maybe the same endpoint is causing conflicts in receiving events? Using separate ports for hashblock and rawtx events might help.

No idea why, but adding this solved the problem: -zmqpubrawtxhwm=50000


text:
No inv messages from inbound nodes
I'm writing a tx relay-only node that can accept inbound connections and make outbound ones. Just for research.
What I'm seeing that on inbound nodes the initial handshake completes and the connection just hangs, I should receive invs shouldn't I?
For outbound it works great, I receive invs and redistribute to others.
Tx relay flag is set in version msg for both direction. Services field is 0. What else do I need?

Are you sure that you aren't being disconnected? If you don't have any service bits set, nodes will probably end up disconnecting from you since they are expecting their outbounds to have at least the service bits NODE_NETWORK and NODE_WITNESS.

Turns out there are a lot of scanner nodes just connected to me and asked version then just sit silently, I have set up a full node that only connected to me and to another node and I was seeing incoming invs. Thanks though!