text:
How to calculate a bitcoin transaction hash of a coinbase transaction in 2022?
According to all internet sources i have found, the hash/ID of a transaction is the result of the double_sha256 algorithm that takes all raw data of the transaction. I tried to calculate it in Python but get incorrect results in recent blocks. Here ist my test script for block #745778: https://www.blockchain.com/btc/block/745778
import hashlib

def d_SHA256(hex_string):
    return hashlib.sha256(hashlib.sha256(bytes.fromhex(hex_string)).digest()).digest()

# https://www.blockchain.com/btc/tx/aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856
coinbase_hash = 'aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856'

# https://blockchain.info/rawtx/aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856?format=hex
coinbase_data       = '010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff640332610b2cfabe6d6ddcb8d8f2a2ddf5191d8191cfa7aa4fd9d85c529f2ce8ed4363c1a8942f14810b10000000f09f909f092f4632506f6f6c2f6500000000000000000000000000000000000000000000000000000000000000000000000500540000000000000004b1bbbb26000000001976a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac0000000000000000266a24aa21a9edd02fc86dcb2b66db1a5add17b3660e4046f50cde03199425f0944c7becb6546a0000000000000000266a2448617468e62698d5bdd57572ff76305ed48933e8b787a67df4319ade7d798df03c706edf00000000000000002c6a4c2952534b424c4f434b3a3c622bf845a23d0ee4927d14fe0455d8e30af6e68e7e3620aa1af6270044738b01200000000000000000000000000000000000000000000000000000000000000000730b053f'
tmp_coinbase_hash   = d_SHA256(coinbase_data)       # big-endian in bytes
my_coinbase_hash    = tmp_coinbase_hash[::-1].hex() # litte-endian in hex

print('coinb_hash:', coinbase_hash)
print('my_cb_hash:', my_coinbase_hash)

coinb_hash: aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856
my_cb_hash: b33db7a32051e9cf9f73bcbcfb2f6f454c8baa9317738f2c8a703593dd01bf44

I don't get what I do wrong. Did the protocol change? Because it works for older blocks but not for recent mined blocks and I can't find any information on this issue.

I don't get what I do wrong.

That coinbase transaction has a segwit output.
I think you need to exclude the witness data. You need a transaction-id that is compatible with the transaction-id that would be produced by non-segwit nodes. Those non-segwit nodes receive a copy of the transaction that has the segwit data edited out (to avoid freaking them out).

Probably relevant?

How to compute SegWit txid?
https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Transaction_ID

Definition of txid remains unchanged: the double SHA256 of the traditional serialization format:
[nVersion][txins][txouts][nLockTime]

A new wtxid is defined: the double SHA256 of the new serialization with witness data:
[nVersion][marker][flag][txins][txouts][witness][nLockTime]

I think you have calculated the wtxid not the txid.

Yes you are right. When i call bitcoin-cli decoderawtransaction... It shows ID and HASH of the transaction which are different: txid": "aa7f5b5f200feac9364ec40b4a5c0cb5c291f846422dec373a71cf30c55ce856",   <br/>"hash": "b33db7a32051e9cf9f73bcbcfb2f6f454c8baa9317738f2c8a703593dd01bf44",


text:
How do i mine block #59502
I am not sur how to combine the information in block #59502
https://www.blockchain.com/btc/block/59502 in order to mine it how do you get the seconds on the timestamp

how do you get the seconds on the timestamp

Many blockchain explorers don't show the raw block header and don't show the timestamp to full precision. You can just try different explorers until you find one that gives the information you want.
For example:
https://explorer.viawallet.com/btc/block/59502?page=1 or
https://explorer.btc.com/btc/block/59502

Block Hash 000000000e58d0b24a8ac96d29e9fffdf1fcce48ae1fec7b42b28061f2025cf0
Summary
Height 59502 (Main Chain)
Time 2010-06-05 22:25:06

If you run a full node wallet, you may be able to get the full information from it
For example, with Bitcoin core ...
18:16:25 ￼ getblock 000000000e58d0b24a8ac96d29e9fffdf1fcce48ae1fec7b42b28061f2025cf0 1

18:17:10 ￼ {
  "hash": "000000000e58d0b24a8ac96d29e9fffdf1fcce48ae1fec7b42b28061f2025cf0",
  "confirmations": 603455,
  "height": 59502,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "e69e6f6fc8d2f6e5c78e18fdaa2378a954616a633964a5c8f7927fd2cb6981f5",
  "time": 1275773106,
  "mediantime": 1275770592,
  "nonce": 2864328653,
  "bits": "1c0f675c",
  "difficulty": 16.61907875185736,
  "chainwork": "0000000000000000000000000000000000000000000000000002f18a195244f3",
  "nTx": 1,
  "previousblockhash": "000000000d111de83e0873c8d643d8625d43691cddf199d075ba75ea260e978e",
  "nextblockhash": "000000000be629c7f83850270ebfef3e403e0883bda7e93d1f6856025750c800",
  "strippedsize": 215,
  "size": 215,
  "weight": 860,
  "tx": [
    "e69e6f6fc8d2f6e5c78e18fdaa2378a954616a633964a5c8f7927fd2cb6981f5"
  ]
}

Now you can convert "time": 1275773106, (UnixTime) into Little Endian Uint32 (binary) or whatever form you require.

source: Stack Exchange

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

sort: votes


text:
Create a multisig wallet using Sparrow wallet with keys (A and (B or C))
Further to the following question:
Can the same set of private keys be used multiple times in a multisig wallet?
I tried to create a multisig wallet with keys (A and (B or C)) in Sparrow wallet using the policy suggested by @Vojtěch Strnad. However, it threw an "invalid output descriptor" error. If I try to create a simple 2 of 4 multisig wallet, Sparrow wallet generates the following descriptor:
wsh(sortedmulti(2,Keystore1,Keystore2,Keystore3,Keystore4))
This appears to be a different notation. What should the descriptor be in Sparrow wallet for a multisig wallet supporting keys (A and (B or C)) ? The Sparrow wallet GUI doesn't seem to provide options to create more complex wallets such as this.

Have you tried putting wsh(...) around the miniscript compiler output? It can only be used inside P2WSH for now.

So overall it'd be wsh(and_v(or_c(pk(B),v:pk(C)),pk(A))), possibly replacing the A/B/C with the kind of key expressions that Sparrow uses (which I'm unfamiliar with).

Such a policy would have to be described using a Miniscript Output Descriptor, which i believe the Sparrow wallet does not support yet (as of August 2023).
A simpler k-of-N multisig policy can however be described using a non-Miniscript Output Descriptor (multi or sortedmulti), which are supported by the Sparrow wallet.
If you want to use the Miniscript Descriptor, you could import it on a Bitcoin Core wallet (starting with version 25.0 for full support) until Sparrow supports Miniscript.

Could the same thing be achieved using a simple 3 of 4 wallet with keys AABC? This would result in key A always being required for a withdrawal and at least one of B and C?

Yes, but you'd have to derive another key from the same xpub (or duplicate the key, but that's worse).

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


text:
Finding Hash with 11 leading zeroes
For an exercise, I'm trying to find a sha256 hash with 11 leading zeroes.
For this reason, I wrote a Python script that basically tries all intergers from 1 to N and brute forces the hash. Now my N is at 16^11.
Am I mistaken or is there a problem with my code as there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes?
Thank you for your input!

Why must there be? And are you sure you really did 17 trillion SHA256 hashes? What do you mean by "brute forces the hash"?

@DavidSchwartz I did 1.1 Trillion and found no 10. But I guess there is a flaw in this logic the longer I think about it.

11 leading zeros in binary or hexadecimal?

@bordalix hexadecimal

Every attempted a hash has an independent probability of 1 in 1611 of having 11 leading zeroes.
That means a probability of not finding such a hash after n attempts is equal to the probability that n attempts are all unsuccesful: (1 - 16-11)n
That means the probability that you are successful increases with n, but never reaches 1:

1% chance after 176,807,378,144 attempts (~169.34).
5% chance after 902,361,177,698 attempts (~169.93).
20% chance after 3,925,582,869,332 attempts (~1610.46).
50% chance after 12,193,974,156,573 attempts (~1610.87).
80% chance after 28,313,531,182,477 attempts (~1611.17).
95% chance after 52,701,479,495,622 attempts (~1611.40).
99% chance after 81,015,010,678,098 attempts (~1611.55).
99.9% chance after 121,522,516,017,148 attempts (~1611.70).
...

there must be a nonce somewhere between 1 and 16^11 where the hash has 11 leading zeroes [in fixed-length hexadecimal encoding]?

You cannot assume this.

Bitcoin doesn't encode in hexadecimal and then test for number of leading zeroes. The test it uses is literally if (hash <= hashTarget)

As you probably know, for current hashTarget values, miners expect to exhaust all nonce values and vary other block values such as the so-called "extranonce" etc - and retry many many times.

See

How many nonces on average do I need to try in order to get n leading zeros?

you need difficulty * 248 / 65535 attempts.

Also note that's on average. You might never find one. The probability of finding a sufficiently small hash after n attempts is never 100% for any finite n.

No,the "nonce" could be alternate.Not limited in 1 to N.
But the expect time of finding a target hash is 16^11,that meaning if u try 16^11 different "nonce" u are likely get a target.

From execution time perspective:
For every additional leading zero in the hash, it will approximately consume 16 times more. For e.g. suppose finding one zero takes 10 ms, then finding 11 leading zeros should take 16^10 * 10 ms.
I have also published an article in Medium to get leading zeros upto 10X faster.
You can visit here:
A Fast Approach to Finding Strings with Leading Zeros in SHA Hashes!


text:
Low vs High R value signatures
I have a conceptual understanding of the R value in so far as it can fall either above or below the X axis in the elliptical curve and that positive R values use an extra byte in the signature to indicate that they are in fact positive R values. I am trying to look at transactions to try and get my head around this in practice. For example:
TXID: 4a8f2d489008f60c7d02526b5f264ae70c465e1ea4fe710243f04ca6b1e3b103
ScriptSig:
OP_PUSHBYTES_71 304402200222918fd7512cd5ecbdfda82dd48cb57677b5b6d42e17b5505fe2f2873d9651022032aab83fece0a48a338e8c003e2907fcd3d2a8798f16ddb5b206351452189cee01
OP_PUSHBYTES_33 034607e699d21f3a4b0c0523869eb185ba23a40a2ffaefe1c567b3b7a6eeb43026

Versus
TXID: 4247bbae1e7d08ed31aee8fc1f65bf4dc7411fe7ff5f64d2d7d0f4ad3117c148
ScriptSig
OP_PUSHBYTES_72 3045022100ba76172000fa3c943a714b1152dc370060805b1cc8cbbd466710325e5874bfc002203e57b406e6af2f52ded43a45bfcb8402acff88f752a5806612bbbc3e80c49c1601
OP_PUSHBYTES_33 023ac3778b0e613501c0469c3232a0b3ff62e53b9849c891c446c44cffa74dd8ce

Does this mean that because the signature is only 71 bytes in the first transaction (as opposed to 72 in the second) that the R value for the first signature would be negative?

In DER-encoded signatures, the r and s values need to be prepended with 0x00 only if they start with the byte 0x80 or higher (i.e. have their first bit set). The r-value of the first signature starts with 0x02, so it doesn't need the extra byte.
This is unrelated to elliptic curve points falling above or below the X axis because 1. point coordinates on the secp256k1 curve are integers modulo p so they cannot be negative, and 2. because p is slightly less than 2256 there are r and s values that fall into the upper half of the range but start with the byte 0x79.

Clearly the first sentence of my question was a lie - I need to do more study. Given what you mentioned about points on the curve being modulo p therefore they can't be negative, then how do we distinguish points above and below the x axis if not by calling them positive or negative?

In elliptic curves over finite fields there simply aren't any points below the X axis. The point coordinates can only take values between 0 (inclusive) and p (exclusive).


text:
What are the privacy implications of multsig wallets if one half is compromised?
I am trying to work out the privacy implications of the following scenario. Alice and Bob have a multisig wallet together (say Electrum but it doesn't really matter). Alice's computer is somehow compromised and the attackers gain full access to her Electrum wallet so as they have access to the private keys, the master key, the whole works. What are the privacy implications for Bob in this situation? How much information would the attacker be able to derive about Bob from having full access to Alice's wallet?
Edit: just for clarification, I'm not asking about the security implications (for example where they impersonate Alice and get Bob to sign a transaction). Assume for the sake of the question that Bob knows Alice's computer has been compromised. I'm only trying to figure out what information can be derived about/to identify Bob.

Alice has Bob's xpub in the wallet. She needs this to be able to generate multisig addresses.
If Alice is compromised, full TX history of Alice & Bob will be compromised, and attacker will be also learn about unused addresses or any current UTXOs.
With the xpub, he needs any 1 secret key from Bob and he could crack the xpriv.


text:
What could this OP_RETURN value be
I was messing around on the blockchain learning about OP_RETURN outputs and the equivalent use of Input Data in Ethereum and came across something interesting and I can't make sense of it.
It starts with a ETH transaction:
0xd304e780755f46e62a42884421e39af06342f0a4989704ee02989043769c4f93
When decoded, the input data mentions a Bitcoin address:
bc1q0rggj4h837qcldhv8hwxpva32nf645excexqq2
When I looked at this Bitcoin address I noticed the following transaction:
444a6542a01d6ce10c9fe01e323447fcf73047b78d8de10a05fa14243233a3a2
Based on the timing and values in the ETH and BTC transactions I figured this was some kind of coin exchange (they were swapping ETH for BTC) which I thought was rather neat as I never thought of using OP_RETURN in this way. But then I noticed that in the Bitcoin transaction above we have another OP_RETURN output which decodes to:
OUT:D304E780755F46E62A42884421E39AF06342F0A4989704EE02989043769C4F93  <-- there is a space on the end
First I thought this might be a Doge Coin address as it starts with "D" but it is too long and now my curiosity has the better of me. Does anyone know what that D304... might be?

could be a Thorchain memo https://dev.thorchain.org/protocol-development/chain-clients/utxo.html?highlight=op_return#utxo

The decoded OP_RETURN output
OUT:D304E780755F46E62A42884421E39AF06342F0A4989704EE02989043769C4F93

matches the transaction identifier of the Ethereum transaction you mention first
0xd304e780755f46e62a42884421e39af06342f0a4989704ee02989043769c4f93

Don't know how I didn't see that. I got so hung up on it being a hex encoding and trying to decode it.


text:
How to schedule a BTC transation in 3 years later?
How to schedule a BTC transation? I want it to be executed like 3 years later if I would not cancel it before that time point.

Does this answer your question? Spendable by me or deposit to exchange after 5 years?

Share a pre-signed transaction containing the appropriate nlocktime with the recipient.


text:
I do accept bitcoins as a way of payment on my website. How could I stabilize value of accepted bitcoins to usd?
I have a website which accepts bitcoins (and other non-stable coins). The amount of ways to accept coins is pretty big: from btcpay to some proprietary solutions. But I do care about volatility of bitcoin. I could easily accept bitcoins equal to the sum of, saying, 100$. But later on, those could turn to be 20% overnight. Is there any way to stabilize it? The only way I see is to convert btc's to stablecoins, but I believe there are simpler ways.

https://en.m.wikipedia.org/wiki/Hedge_(finance)

A hedge is an investment position intended to offset potential losses or gains that may be incurred by a companion investment. A hedge can be constructed from many types of financial instruments, including stocks, exchange-traded funds, insurance, forward contracts, swaps, options, gambles,[1] many types of over-the-counter and derivative products, and futures contracts.
Public futures markets were established in the 19th century[2] to allow transparent, standardized, and efficient hedging of agricultural commodity prices; they have since expanded to include futures contracts for hedging the values of energy, precious metals, foreign currency, and interest rate fluctuations.

(My emphasis)

https://blog.btcpayserver.org/case-study-technical-prism-sideshift/

When it comes to merchants at events, there's often a common concern:
hedging against the wild swings of price volatility". Even those that
are game for holding onto Bitcoin earnings, want to ensure that when
it comes to fixed costs of their vendors, they are covered on every
sale.
In this guide we will showcase how Prism can be setup so that:
80% of incoming sats will be converted to stablecoin 10% will be sent
to another lightning address 10% will stay on the server for demo
purposes

Thanks! It's exactly what I was looking for!


text:
What are the correct "threshold" values of the nSequence in order to activate relative time lock and only absolute time lock?
Based on BIP68, relative lock time is activated if the most significant bit in nSequence value is not set. In other words, if the 32th (1<<31) bit is not set. So for the nSequence values less-equal than:

01111111111111111111111111111111 in binary
0x7FFFFFFF in hexadecimal

... relative lock time is activated.
However, in the Ugam Kamat's answer, he said that the relative lock time is activated for a nSequence values less than 0xEFFFFFFF.

If nSequence <= 0xEFFFFFFF, it implies relative locktime.

1. How is it possible? What is correct upper value to activate relative time lock?
Also, for activating just an absolute lock time without relative lock time, he said in his answer that the nSequence must be between 0xF0000000 and 0xFFFFFFFD (to also activate RBF).

So for using nLocktime along with Opt-in RBF, your nSequence value has to be between 0xF0000000 to 0xFFFFFFFD.

However, based on BIP68, to deactivate relative lock time it is only necessary to set most significant bit (32th bit) in the nSequence. So for the nSequence values greater-equal than:

10000000000000000000000000000000 in binary
0x80000000 in hexadecimal

... relative lock time is not activated.
2. What is the smallest value we can set for nSequences so that only the absolute lock time is activated without the relative one?

I assume this is just a typo/thinko in Ugam's answer.

@PieterWuille Okay, what would be the correct answer for example for the first question? I would say 0x7FFFFFFF and he said 0xEFFFFFFF.

@PieterWuille I think that confusion also comes from the way BIP68 is written. Since the Bitcoin uses little endian then the picture in this BIP can be assumed also as 11111111111111111111111111111110, that is FFFFFFFE. So most right bit is 0, since it is most significant bit in the case of little endian. Also, since hexadecimal does not have anything with endian it is 0xFEFFFFFF. However, for me it is more correct 01111111111111111111111111111111, that is 7FFFFFFF. In hexadecimal 0x7FFFFFFF.

@PieterWuille Almost 5 years ago, skaht in his question pointed to this problem.

1 << 31 is unambiguous. It means set the 31st bit (counting from the least significant bit). How that is represented in memory is irrelevant as numbers always have a least significant bit (0) and a most significant bit.
This means that 0x7fffffff is the threshold in big endian.

"1 << 31 is unambiguous. It means set the 31st least significant bit." Doesn't 1<<31 mean setting the most significant bit, not the least significant bit?

<< represents left push. Since you are pushing 31 times, you are setting most left bit and it is most significant bit?

1 << 31 is setting the 31st bit, starting from the least significant one. Is that clearer?

@PieterWuille Yes, that's clearer. In other words, it means setting the most significant bit, that is the most left one?

@LeaBit Whether that's the left or the right one depends on your notation. In C-like language parlance, a "left shift" is by definition a multiplication by two, so leftmost there means most significant. But in most computer hardware representations, the least significant bytes come first.

@PieterWuille I do not want to complicate and waste your time, so the answer on the first question is 0x7FFFFFFF and on the second is 0x80000000?

@LeaBit I believe so.


text:
Where can I buy bitcoin directly in to my wallet
I would like to buy Bitcoin directly into my muun wallet.
Possible options that I'm aware of

Buying directly from someone
Using a bitcoin atm Buying from
Coinmamma

What I tried
Bisq (Would not install on mac) and I understand that you get a wallet with them meaning you would pay miners to transact into my Bisq wallet and then I would have to pay again to transfer into my muun bitcoin wallet.
Are there any other options and what are the fees?

Does this answer your question? I am new to Bitcoin, how can I get started?

While  it does provide a starting point for me to go check out a lot of options with this link https://en.bitcoin.it/wiki/Comparison_of_exchanges
It doesn't directly mention if any of these sites have their own wallet or if I can transfer directly into my wallet.
I think having a comprehensive list of all the sites where to get coins directly into your wallet can be a huge financial saver especially since I plan to shop groceries on a regular basis with bitcoin. If no one replies with the answer then I would probably be able to answer msyslf in about a week.

Does this answer your question? How do you obtain bitcoins?

no my question is to buy bitcoin directly into my wallet, not through some exchange that has their own wallet.


text:
consensus on the moving average
I research on consensus and need a forced delay between submittability of new blocks.
In bitcoin you use stochastics + processor clock speed. This allows you to choose an expected forced delay, which you chose to be 10min.
Quote from White Paper:
"To compensate for increasing hardware speed and varying interest in running nodes over time, the proof-of-work difficulty is determined by a moving average targeting an average number of blocks per hour. If they're generated too fast, the difficulty increases."
I do not see a way to find consensus on the present value of the moving average without yet implementing another consensus mechanism. But it appears necessary to have a very accurate global consensus on the exact value of the average because this value determines the mining difficulty. So how do you do it? Please give all the details in a novice-comprehensible way.

Hi Kaisong, are you asking how the difficulty adjustment works, or requesting help with designing an alternative consensus mechanism? In the latter case, you may be looking for “Verifiable Delay Functions” and want to look at “Proof of Space and Time”.

Seeing your other question after it was moved here from Crypto SE, I assume this linked question explains what you were asking about. Let us know if that's not the case.


text:
How to add elliptic curve points from a file?
i'm just a tech newbie learning how ec cryptography works and stumbled into a problem with my python code
i'm testing basic elliptic curve operations like adding points, multiple by G etc, let's say i have
Ax = 0xbc46aa75e5948daa08123b36f2080d234aac274bf62fca8f9eb0aadf829c744a
Ay = 0xe5f28c3a044b1cac54a9b4bf719f02dfae93a0bae73832301e786104f43255a5
A = (Ax,Ay)

f = open('B-coordinates.txt', 'r')
data = f.read()
f.close()
print (data)
B = 'data'

there B-coordinates.txt contains lines like
(0xe7e6bd3424a1e92abb45846c82d570f0596850661d1c952f9fe3564567d9b9e8,0x59c9e0bba945e45f40c0aa58379a3cb6a5a2283993e90c58654af4920e37f5)
then i perform basic point addition A+B add(A,B)
so because of B = 'data' i obviously have this error
TypeError: unsupported operand type(s) for -: 'int' and 'str'

and if i add int(data) > Error invalid literal for int() with base 10: because letters in input (i.e. in points coordinates).
so my question is, please can someone knowledgeable in python and  elliptic curve calculations tell me how to add the coordinates of a point so as to bypass these int problems when extracting lines from a file into .py? I will be very grateful for the answer! I've been trying to figure out how to do it right for many hours now, and maybe just goofing off, but please I'll appreciate any hints

I’m voting to close this question because it is a basic Python programming question, unrelated to Bitcoin or the cryptography used in it.

please leave it - python stackoverflow answers have become very slow these days, maybe someone here can help me with this question. thank you!

@user136859: You know that 0x at the start of the string represents hexadecimal right? To add hexademical together https://stackoverflow.com/questions/45640652/adding-subtracting-hexadecimals. It is point addition too of course


text:
Bitcoin from an economic standpoint?
Anybody have any good resources to learn about bitcoin from an economic standpoint?  Specifically discussing the debate around its deflationary nature?

Hi, user13977: As you discovered, we already have tags for [tag:economics] and [tag:deflation], it is possible that some of the questions tagged thusly will help you along the way of satisfying your curiosity.

You can easily find defenses galore of the system. For criticisms of Bitcoin from an economic POV, you can try reading Shelby Moore IIIs posts, both in this site and elsewhere on the net. Even if you don't completely agree with him you'll surely learn a thing or two.

From what I gather, the deflationary aspects of Bitcoin are tied to the limited supply and  lack of central regulation. I'm still learning about it but here is a collection of articles I put together on the subject: http://wayfinder.co/pathways/530d0adaa30064b367000088/an-economic-primer-on-bitcoin

One resource I can recommend is reviewing the charts on blockchain.info.  There is tons of historical information you can gleam by analyzing what has happened previously.
Like past market price in USD, for example:

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


text:
Warning: Displayed transactions may not be correct!
After several weeks of not updating my QT wallet I get the message "Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade."  I tried uninstalling bitcoin QT and installing the latest version but that didn't do anything.  I don't know much about bitcoin wallets so a detailed explanation of how to fix this would be great! thanks

The latest version as of this writing is 0.8.6; are you certain that is the version you installed?

I'm absolutely positive.

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


text:
How can I get all the Bitcoin transactions data since its inception?
If I want to get all the Bitcoin transactions since it started, how do I go about doing this? Is it possible to get all that data from bitcoind database?

This is called the Blockchain.  You can access it yourself if you use a client like the reference client, Bitcoin-QT.  By reference, I mean that Bitcoin-QT downloads it to your disk... you have to write a program to access past transations, because Bitcoin-QT doesn't allow you to search past transactions other than your own.
Another way to access the blockchain is to use a web site like Blockchain.info. You can either use the web pages to review the blockchain, or use some of their APIs.


text:
How did transaction malleability/DDOS attacks allow an exchange's internal accounting system to get "out of sync"?
This Coindesk article says that:

“So as transactions are being created, malformed/parallel transactions
  are also being created so as to create a fog of confusion over the
  entire network, which then affects almost every single implementation
  out there,” he added.
Antonopoulos went on to say that Blockchain.info’s implementation is
  not affected, but some exchanges have been affected – their internal
  accounting systems are gradually going out of sync with the network.

How does this getting out of sync occur? Here's my understanding; as a transaction is created, malicious users create hundreds of transactions in the network that are identical except for a mutated signature. The original transaction may or may not be confirmed because a mutated version may get confirmed in the blockchain first.
For example, Mt. Gox, which used an automated system to approve withdrawals (as the article states), would consider a withdrawal transaction approved before it was actually confirmed in the blockchain. Once a mutated version of that transaction was confirmed in the blockchain, Mt. Gox's accounting system had a problem because a transaction it assumed was confirmed (and therefore had already "lost" the Bitcoins for) wasn't actually confirmed.
Is my understanding correct?

The reports that Mt. Gox's problems were actually due to transaction malleability are, at the moment, speculation with little evidence.

@GregHewgill I hadn't heard about that. The reports I heard were that Mt. Gox was drained through multiple withdrawals because of transaction malleability and the way they processed transactions. I've also heard other people saying that the person in charge just ran off with the coins; are both of those ideas basically just speculation at the moment?

Yes, it's all speculation. For example, see http://falkvinge.net/2014/02/28/the-gox-crater-crowd-detectives-reveal-billion-dollar-heist-as-inside-job/ for an analysis from a different perspective.

@GregHewgill That's a very informative article; thanks for posting that!

related: What is Transaction Malleability?, Collecting questions related to Mt.Gox' insolvency

I'll assume that MtGOX are being truthful here, to avoid undermining OP's question. Transaction malleability was absolutely an issue around the time. It affected a number of implementations, from BitcoinJ, to older bitcoin nodes.
The operator of http://faucet.xeno-genesis.com/ also informed me his service had huge issues around the time of the malleability bot.
The confusion that can occur in a wallet is like this: Imagine your node hears about a transaction with ID A, paying into your wallet. But, imagine this transaction was malleated, and the original was the one to be confirmed. Your wallet has no knowledge of this.
All transactions refer to unspent transactions, and although a various copies of a transaction transaction can exist temporarily in different parts of the world, eventually only one will confirm. We know inputs can only be spent once.
Some implementations might not handle this correctly. Imagine trying to spend a Tx that didn't exist, maybe your customer wants to withdraw BTC? It would fail if you don't check if newly published blocks have transactions that conflict with unconfirmed transactions. You could observe two transactions spending the same input, so you'd take the confirmed one as valid.
MtGOX also would have had issues sending coins they received before the attack. The reason is, if they broadcast their transaction, and a malleated copy ended up in the blockchain, they would assume it failed to confirm, so the customer can try again. Maybe even using other inputs! This cycle could have been repeated by one attacker over and over draining the wallet.
Another possible issue is that if they did correctly believe the transaction went through, but still tried to spend the incorrect TxID, then that transaction would fail, causing panic from the customer.
Wallets which sent a high number of transactions during the attack were most affected.

Transaction malleability has nothing to do with it.
Read http://www.reddit.com/tb/1zcrj8 to learn more.

Doesn't "transaction malleability" have everything to do with it?


text:
How can I find out how much bitcoin is in existence with PHP?
I'm running a Bitcoin blog and I'd love to display a ticket of the total amount of Bitcoins in existence. Unfortunately, I'm not sure where I can find a JSON feed for this (now that MTGOX is gone). Is there something like this I can utilize?

Take a look at this, its the blockchain.info api. it gives a json feed for many things.

The number of bitcoins in existence at any given time is predictable in advance. To get an approximate number, you just need to look it up in a table based on today's date. The Bitcoin wiki has one at Controlled supply.
To get the precise number of mined bitcoins at any given moment, you would take the current block height (available from any of a number of different places) and apply a fixed formula to get the current total number of rewards claimed so far. This number would be exact because there is no possibility of varying from the predetermined reward schedule (and there is no other way of conjuring bitcoins into existence other than mining).
The following is a simple Python function which calculates the total bitcoins in existence at any time given the block height. It should be straightforward to translate to PHP.
def total_bitcoins(height):
    total = 0
    reward = 50
    while height >= 210000:
        total += reward * 210000
        height -= 210000
        reward /= 2
    total += reward * height
    return total

https://gist.github.com/ghewgill/9821866


text:
How can an attacker change the address to receive someone's reward
At the end of my lecture, my lecturer asked a question that we never had time to cover:
A miner creates a block A, which contains address b, on which they want to receive their rewards. An attacker changes the contents of block A, replacing address b with an adversarial address b’. What needs to happen for the attacker to receive the rewards for block A?
I know similar questions have been asked before but they all explain why an attacker can't receive the reward, I would like to know if there is any hypothetical scenario in which they could if they weren't limited by hash rate or other factors.
I have been thinking about this and feel like it is a trick question because there is no way that the attacker can just change the address and receive the rewards, because if the attacker edits any data on the block it will produce a different hash and won't be validated by the network, so the attacker won't receive the rewards. So is there any way for the attacker to actually receive the rewards?

So is there any way for the attacker to actually receive the rewards?

If the attacker isn't limited by hashrate, then they can obviously just fix the proof of work on the modified block. But at that point, they are not an attacker anymore, they're just a competing miner who creates a competing block.


text:
Maximum cpu verification time
Do we know the maximum cpu verification time (or max cpu cycles) required by a tx that fills an entire block?
I get that the game theory of tx fees mitigates this, and that the answer will depend slightly on node version, compiler, processor, etc. But is there a rough way to demonstrate that a huge tx won’t take 24 hours to verify?


text:
replicating Hash160 with SHA256/RIPEMD160
I have a dumb question about Hash160 (specifically, going from a public key to Hash160).
If I take a public key: 04ce0ed35340803b0c21f2f7f5d5ab9d687e5fa95a79471c9b5c9d97a0bb170eac1045230cc51d13b85a5f64feb80f8fc19358a396797926e3f89d49066b1abc07
and I run it through a hash160 calculator (https://www.btcschools.net/bitcoin/bitcoin_tool_hash160.php), I get a Hash160 of: 1558c7cd9825447a31990ff964f347bb2dbfe9be
This is the correct Hash160 (according to other trusted sources).
I'm trying to go through the Hash160 steps manually (just to learn). My understanding is that Hash160 is just running the public key through SHA256, and then running that output through RIPEMD160. However, when I try to recreate the correct Hash160 output by running that public key through SHA256 and then RIPEMD160 (say, using online calculators, although I've tried on other calculators and via python so I could control binary/hex encoding), I get a SHA256 output of: a5d0a142f10031f9e2d3f806f4845005cd5b3b2722c335d5a352c268a0ee1ec9. Then, when I run that through RIPEMD160, I get other outputs (depending on what is going into the RIPEMD, like if it's hex or binary or whatever).
But none of them are the Hash160 output I was expecting. I'm guessing there's some step I'm missing... do I need to do anything to the public key first? Or do something after running it through SHA256 or RIPEMD160 or something?
Just really at a loss as to why literally every source I can find says that Hash160 is just RIPEMD160(SHA256( publicKey )) but that path doesn't seem to work when attempting to do this manually.
I found this post (OP_HASH160: Computing script hash in a concrete P2SH transaction) but I've tried all of the binary and hex permutations via the python hashlib that I could think of (tried all binary in, all hash in, some hash in some binary in, etc.)
Any help would be amazing, thanks!!

You should probably include your non-working Python code so that Pythonistas can identify where you are going wrong.
A common mistake is not first converting a (human readable) hex string into a (computer native) byte array.
Your theory is sound ...
Output:
1558c7cd9825447a31990ff964f347bb2dbfe9be

Source code in go:
package main

import (
    "crypto/sha256"
    "encoding/hex"
    "fmt"

    "golang.org/x/crypto/ripemd160"
)

func main() {

    pubKeyHex := "04ce0ed35340803b0c21f2f7f5d5ab9d687e5fa95a79471c9b5c9d97a0bb170eac1045230cc51d13b85a5f64feb80f8fc19358a396797926e3f89d49066b1abc07"
    pubKey, err := hex.DecodeString(pubKeyHex)
    check(err)

    hasher256 := sha256.New()
    hasher256.Write(pubKey)
    hash256 := hasher256.Sum(nil)

    hasher160 := ripemd160.New()
    hasher160.Write(hash256)
    hash160 := hasher160.Sum(nil)

    fmt.Printf("%x", hash160)
}

func check(err error) {
    if err != nil {
        panic(err)
    }
}

See that code running at https://go.dev/play/p/wNZzCv6l3tU

thanks—seeing this code made me realize my mistake... needs to be bytes into sha256 and ripemd. Guess you solved it for me, appreciate it


text:
How could I encourage my Customers to pay me in Bitcoin?
I run a small pharmaceutical business and send PDF Invoices to various accounts payable departments of medium to large businesses monthly. Could I generate a QR code for an on-chain Bitcoin payment and put it on the invoice as an image? Lightning QR code does not seem appropriate because of its expiry as most Accounts Payable depts will take 30 days+ to make a payment. I could self-generate Remittance Advice information by polling my public key using an API? I realise I am living in the future, but I want a practical and provocative way to move Bitcoin forward in my own heavily-fiat world.

"Moves so slowly... grows so smoothly..." Bitcoin doesn't need you. Let your customers pay with any means they want...


text:
non-full node bitcoin node
I will like to run a bitcoin node for web3 development, i only want to track transactions within last 30 days max, so i will like to only keep last 30 days of the bitcoin network at any time
is there a solution for this? i dont want or need a full node bitcoin node, this will be used for web3 development to track wallet addresses for current or recent transactions only
please help if you knowledgeable on this solution
thanks

I don't really know what you mean by saying 'web3 development', but I suspect that what you'll want to run is a pruned node (ie, bitcoin-core with 'pruning' enabled).
What this means, is that you'll have a node that discards older block data that it has already verified as being valid, such that your node will only store a configurable maximum amount of data.
This does mean you'll need to sync the node from the genesis block - after all, doing so is the only way your node will be able to make sense of the current network state (ie, know what is currently a valid transaction / block on the network). Once sync'd, you can configure your node to only store up to a certain maximum amount of data, and you can also configure it to watch certain addresses for activity if you'd like.

web3 development i think i explained it, just write an app that monitors wallet, if new transactions or balance changes etc...so i dont need a full node for that

@uberrebu: A lot of us in Bitcoin associate web3 with all the ICO, NFT stuff on Ethereum etc. To such an extent that people are using the term "web5" ironically. https://developer.tbd.website/projects/web5/

so if i want to use this docker image https://github.com/kylemanna/docker-bitcoind what env do i use to run the pruned node mode?

i just used bitcoin.conf file option and added prune=1024 so i think i should be good..thanks guys for this

@uberrebu a full node is the term for a node that has fully validated the current network state. So even a pruned node is a full node in that sense.


text:
How to use the base58 in c++
its been a while after i done with my python bitcoin miner
And i realize that python is slower to do mining stuff, so i decided to rebuild it in c++ as you guys know c++ the faster than other programming language
But i have a problem to use base58 decode to hexadecimal in c++
Python code
import base58

BtcAddr: str = "1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r"

base58.b58decode_check(BtcAddr).hex()

And the output will be this

00b9454405a39efcb023127cd6daacf9c133b84df3

But i need that in c++ code, i already search online but i didnt find anything helpful
Can you guys help me? I really need the source code in c++

This solution is used by Bitcoin Core
base58.h
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2023 Loopite.

#ifndef CRYPTO_BASE58_H
#define CRYPTO_BASE58_H

#include <string>
#include <vector>

/**
 * Encode a byte sequence as a base58-encoded string.
 * pbegin and pend cannot be NULL, unless both are.
 */
std::string encodeBase58(const unsigned char* pbegin, const unsigned char* pend);

/**
 * Encode a byte vector as a base58-encoded string
 */
std::string encodeBase58(const std::vector<unsigned char>& vch);

/**
 * Decode a base58-encoded string (psz) into a byte vector (vchRet).
 * return true if decoding is successful.
 * psz cannot be NULL.
 */
bool decodeBase58(const char* psz, std::vector<unsigned char>& vchRet);

/**
 * Decode a base58-encoded string (str) into a byte vector (vchRet).
 * return true if decoding is successful.
 */
bool decodeBase58(const std::string& str, std::vector<unsigned char>& vchRet);

#endif // CRYPTO_BASE58_H

base58.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2023 Loopite

#include "base58.h"

#include <iterator>
#include <cstring>

#include <cassert>

/** All alphanumeric characters except for "0", "I", "O", and "l" */
static const char* pszBase58 { "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" };

std::string encodeBase58(const unsigned char* pbegin, const unsigned char* pend)
{
    // Skip & count leading zeroes.
    int zeroes = 0;
    int length = 0;
    while (pbegin != pend && *pbegin == 0) {
        pbegin++;
        zeroes++;
    }
    // Allocate enough space in big-endian base58 representation.
    int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up.
    std::vector<unsigned char> b58(size);
    // Process the bytes.
    while (pbegin != pend) {
        int carry = *pbegin;
        int i = 0;
        // Apply "b58 = b58 * 256 + ch".
        for (auto it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) {
            carry += 256 * (*it);
            *it = carry % 58;
            carry /= 58;
        }

        assert(carry == 0);
        length = i;
        pbegin++;
    }
    // Skip leading zeroes in base58 result.
    auto it = b58.begin() + (size - length);
    while (it != b58.end() && *it == 0)
        it++;
    // Translate the result into a string.
    std::string str;
    str.reserve(zeroes + (b58.end() - it));
    str.assign(zeroes, '1');
    while (it != b58.end())
        str += pszBase58[*(it++)];
    return str;
}

std::string encodeBase58(const std::vector<unsigned char>& vch)
{
    return encodeBase58(&vch[0], &vch[0] + vch.size());
}

bool decodeBase58(const char* psz, std::vector<unsigned char>& vch)
{
    // Skip leading spaces.
    while (*psz && isspace(*psz))
        psz++;
    // Skip and count leading '1's.
    int zeroes = 0;
    int length = 0;
    while (*psz == '1') {
        zeroes++;
        psz++;
    }
    // Allocate enough space in big-endian base256 representation.
    int size = strlen(psz) * 733 /1000 + 1; // log(58) / log(256), rounded up.
    std::vector<unsigned char> b256(size);
    // Process the characters.
    while (*psz && !isspace(*psz)) {
        // Decode base58 character
        const char* ch = strchr(pszBase58, *psz);
        if (ch == nullptr)
            return false;
        // Apply "b256 = b256 * 58 + ch".
        int carry = ch - pszBase58;
        int i = 0;
        for (auto it = b256.rbegin(); (carry != 0 || i < length) && (it != b256.rend()); ++it, ++i) {
            carry += 58 * (*it);
            *it = carry % 256;
            carry /= 256;
        }
        assert(carry == 0);
        length = i;
        psz++;
    }
    // Skip trailing spaces.
    while (isspace(*psz))
        psz++;
    if (*psz != 0)
        return false;
    // Skip leading zeroes in b256.
    auto it = b256.begin() + (size - length);
    while (it != b256.end() && *it == 0)
        it++;
    // Copy result into output vector.
    vch.reserve(zeroes + (b256.end() - it));
    vch.assign(zeroes, 0x00);
    while (it != b256.end())
        vch.push_back(*(it++));
    return true;
}

bool decodeBase58(const std::string& str, std::vector<unsigned char>& vchRet)
{
    return decodeBase58(str.c_str(), vchRet);
}

Tests
[ RUN      ] App.base58_Basics
00b9454405a39efcb023127cd6daacf9c133b84df30ce3172d
[       OK ] App.base58_Basics (0 ms)

From C++ code:
/**
 * @Author: Loopite
 * @Description: Test for base58 encodings
 */

#include <gtest/gtest.h>

#include "crypto/base58.h"

#include <set>

TEST(App, base58_Basics)
{
    /*
     * Decode
     */
    const std::string data
    {
        "1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r" // P2PKH address
    };

    std::vector<unsigned char> decodedContent;
    decodeBase58(data, decodedContent);

    // ...Print content of decoded data...
    for (unsigned char i : decodedContent)
        std::cout << std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned int>(i);

    std::cout << std::endl;
}

NOTE
The output is 00b9454405a39efcb023127cd6daacf9c133b84df30ce3172d NOT 00b9454405a39efcb023127cd6daacf9c133b84df3 for the string 1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r. See https://appdevtools.com/base58-encoder-decoder.

I see but that includes with hexadecimal value + checksum right? Well i dont want the checksum value, i only want the hexadecimal value

The thing is P2PKH has this structure: networkFlag (1 byte) + address (20 bytes since it has been hashed by RIPEMD-160) + checksum (4 bytes). Therefore the checksum is required. However if you WANT the hexadecimal value WITHOUT checksum you can process like this:
1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r <=>
00b9454405a39efcb023127cd6daacf9c133b84df30ce3172d (With checksum) <=>
00b9454405a39efcb023127cd6daacf9c133b84df3 (Without checksum) <=>
13ahvXA4uoeMuX4iKJW1mQkYjCWbt (Encoded in base58)
You just have to parse output to get networkFlag and address separatly by using substr.

/!. You should know that the checksum is REQUIRED. So you'll have to keep it from LEGACY addresses. It's part of the protocol. Functions you see above allow you to encode/decode base58 sequence. That's it.

So what youre trying to say is that i need to include the checksum in order to make a raw transactions?

In a raw transaction this is different. You'll have just to provide the address. This field can be determined from the Base58Check (1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r).
To sum up: Base58Check requires a checksum. But raw txs need address only.

yeah i see, thanks for your help:)

hello sir, sorry to bother you but i face some issue with your code, the result from decodeBase58() only can be print through for loop, now heres the problem. How can i store the result inside a viarable?

decodeBase58 returns nothing. However, it takes a vector of unsigned char in reference : decodeBase58(..., std::vector<unsigned char>& vchRet);. For example, in my 'Tests' section, I store the result in my decodedContent variable. Then you can read data inside. But this is a variable of bytes. You can do whatever you want with it. Besides, I used here a for each loop in order to print the result of decoding operation (It was a debug option to give you the decoded result).

Ahh i see, you i cant store them in viarable?

Of course you can. It was done in my example as decodedContent variable. But that's a matter for the code. I recommend that you ask any other questions about this on the stackoverflow C++ forum unless you have other questions about Bitcoin.


text:
can u guys help me to check the raw_tx that i've made?
so i just learnt how to created a raw coinbase transaction, and i need to confirm if the format is correct, can you guys help me with this?
: this is just an example it doesnt exists in the blockchain network
im using BIP34 transaction format and my wallet address is
address: 1Htcz9y5sVuztuwTnfpWR4dhqirhLMcK7r

this is the raw transaction format:
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e03fc7903036370756d696e657203000000000100f90295000000001976a914b9454405a39efcb023127cd6daacf9c133b84df388ac00000000

extract format:
01000000 .............................. Version
01 .................................... Number of inputs
| 00000000000000000000000000000000
| 00000000000000000000000000000000 ...  Previous outpoint TXID
| ffffffff ............................ Previous outpoint index
|
| 0e .................................. Bytes in coinbase
| |
| | 03 ................................ Bytes in height
| | | fc7903 .......................... Height: 227836
| |
| | 036370756d696e657203 .............. Arbitrary data
| 00000000 ............................ Sequence

01 .................................... Output count
| 00f9029500000000 .................... Satoshis (25 BTC)
| 1976a914b9454405a39efcb023127cd6
| daacf9c133b84df388ac ................ P2PKH script
| 00000000 ............................ Locktime

Did i get all that right?

I'd recommend you use bitcoin-cli to check if the transaction you made is both syntactically and semantically correct. You can do so by running bitcoin-cli decoderawtransaction:
bitcoin-cli decoderawtransaction 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e03fc7903036370756d696e657203000000000100f90295000000001976a914b9454405a39efcb023127cd6daacf9c133b84df388ac00000000

That returns:
{
  "txid": "58857ef49cdfe7dc036bb0eb2463464aed859aae4abee915808ee51357e15abe",
  "hash": "58857ef49cdfe7dc036bb0eb2463464aed859aae4abee915808ee51357e15abe",
  "version": 1,
  "size": 99,
  "vsize": 99,
  "weight": 396,
  "locktime": 0,
  "vin": [
    {
      "coinbase": "03fc7903036370756d696e657203",
      "sequence": 0
    }
  ],
  "vout": [
    {
      "value": 25.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 b9454405a39efcb023127cd6daacf9c133b84df3 OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(mxQaHD44gXMFg2R5WEntEyr2hiTQFvZkwi)#80h6hw5r",
        "hex": "76a914b9454405a39efcb023127cd6daacf9c133b84df388ac",
        "address": "mxQaHD44gXMFg2R5WEntEyr2hiTQFvZkwi",
        "type": "pubkeyhash"
      }
    }
  ]
}

The fact that the command doesn't fail already tells you that the transaction is syntactically correct. With respect to semantics, it looks to me that it achieves exactly what you were going after.

Yeaayyyy, thanks a lot sirr


text:
What are all the rules related to CPFP fee bumping?
Here Murch defined the rules related to RBF, as one of the techniques for fee bumping. He also posted a link to Bitcoin Core's official documentation related to the implementation of RBF (link).
However, I am interested in what are all the rules for CPFP as another fee bumping technique? Posting just the official documentation, some documentation like Murch posted, (or some similar relevant material) would also be sufficient for me.

There are no specific relay policy rules that apply to CPFP, because unlike RBF, CPFP is not a relay policy. It's a completely normal new, additional, transaction that gets relayed. The fee-bumping effect is not achieved by a special relay mechanism, but by the miner's block building mining logic recognizing the combination of child and parent as better than the parent alone.
For this to work, the block building code needs to be sufficiently powerful to recognize this. This is the case if the miner directly or indirectly uses Bitcoin Core (version 0.13.0 or later).
Note that there are general policy rules that apply to dependant transactions (e.g. the ancestor and descendant count limits, which are by default 25 transactions). They're not specific to CPFP, but may impact its use.

e.g. the ancestor and descendant count limits, which are by default 25 transactions So, every transaction has the ancestor and descendant count. 1) I know that descendant count includes the transaction itself, is this also the case with the ancestor count? 2) Is the limit per count 25 (25 for descendant count and 25 for ancestor count) or in total?

Yes, ancestor count also includes the transaction itself. The limits are configurable, but as of Bitcoin 26.0 (and ever since these concepts were introduced), the defaults have been 25 and 25.


text:
How to display price of one Bitcoin on website in PHP?
Firstly, I know  this is a duplicate post but from what I can find all of the others are using the MtGox price (redundant now).
I was wondering - what is the current best way to display the price of one litecoin and one bitcoin in USD using PHP?

First example in linked question has a PHP example connecting to BitPay's rate API. Which is possibly better to use than exchanges. The basic gist is using PHP to read JSON from a url. See how to Get JSON object from URL

See the question that Jacob Torba suggested, I have added an answer there that might suite you.


text:
Cannot allocate memory
EXCEPTION: 11DbException
Db::get: Cannot allocate memory
bitcoin in ProcessMessage()

Downloaded 250k blocks, now it won't run anymore i'm running ubuntu 12.04, I have 20GB HD and 1gb ram. any way to fix without redownloading?

You have 20GB ram free or just 20GB ram with the operating system on it plus all your other data?

Oops mistyped that, I meant hard-drive of course.

bitcoind uses a ton of memory while it's downloading the blockchain. Check out these steps on how to set up your swap space correctly on Ubuntu:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
Additionally, you can check out the torrent download of the blockchain. As long as you trust the file, this can help speed up the time to download the blockchain.
http://sourceforge.net/projects/bitcoin/files/Bitcoin/blockchain/bootstrap.dat.torrent/download


text:
how to run bitcoind server on a ubuntu 13.04 server
I am trying to host a bitcoind on my server so I can connect to it on my website, how do I install it, run it, update the conf file? this is on a server not a desktop

How familiar are you with Linux?  There is nothing special about installing and running bitcoind as an app.  I installed mine over ssh.

first time. i managed to install it now I just need to figure how to edit bitcoin.conf file. Any idea?

http://kb.iweb.com/entries/21186923-Editing-files-in-SSH-using-VI


text:
cannot connect via 8333 port on website
MY bitcoind is on: http://207.12.89.181/ yet I cannot connect via any port, I've tried 8333 and 8332 any reason why? it's a ubuntu server. Im using that server to connect to from another server.

You need to add the rpcallowip setting to your bitcoind.conf file.
You can use a single IP or allow all. for example
rcpallowip=192.168.0.2
or
rcpallowip=*

I don't know where my conf file is, I'm using putty and ssh.

@user3162803 config file is at ~/.bitcoin/bitcoin.conf


text:
Cannot connect to bitcoin-qt server
 # server=1 tells Bitcoin-QT to accept JSON-RPC commands.
 server=1

 # You must set rpcuser and rpcpassword to secure the JSON-RPC api
 rpcuser=bhhtufhrt
 rpcpassword=ferhrhh

im trying to connect to my bitcoin thats my conf file but i cant connect to
http://127.0.0.1:8832/

im running on my local machine

The default port I think should be 8332 not 8832, however if you modify your config file to include:
RPCPort=8832
Then restart server and it should work

You may want to add the following line to your .config file:
listen=1

mmm, interesting, I thought that -server implied listen as well? Does anyone know for certain on this?


text:
how to hash a bitcoin address for transactions?
can someone tell me how bitcoin hash a btc address?
when you try to hash it on this website, you will get the same result as down below
Bitcoin Address : 1JKRgG4F7k1b7PbAhQ7heEuV5aTJDpK9TS
Result (Hash 160) : bdf63990d6dc33d705b756e13dd135466c06b3b5

but when i convert the address to ripemd160,  i got a completely different result
3da397753d32cea0858334e36fc58ae53f8c2529

so how do i get the same result as the first one?

To get the same result you must decode the address, which means convert the base58 to hexadecimal.
1JKRgG4F7k1b7PbAhQ7heEuV5aTJDpK9TS becomes 00bdf63990d6dc33d705b756e13dd135466c06b3b55850d39d
Where:

00 -> mainnet
bdf63990d6dc33d705b756e13dd135466c06b3b5 -> hash160 of
public key
5850d39d -> checksum

thank you sir, this really help me out

but how can i convert the address to hexadecimel?

Quite simple on this tool https://appdevtools.com/base58-encoder-decoder. You can also create an python file, import base58, then print(base58.b58decode(address).hex())

Whoaaaa thankk youu sirrrr, i really appreciate thisss....thankss a lootttt


text:
Is solo mining solve block as same as pool mining?
Guys i want to ask tht if solo mining has the same strategy as same as pool mining
I mean the way they guess the block hash
is it the same or not?

A solo pool does not perform shared accounting like a normal pool.
Solo pools also remove the hassle and overhead of running a bitcoin core node for solo miners. Most solo pools provide added features to the stratum v1 mining protocol such as quicker block propagation or job declaration improvements.
A solo pool miner gets the full block minus a (usually) small fee to the solo pool operator.

Can you explain what a "solo pool" is? I have never heard about the concept, and this answer only explains what it achieves, but not how.

A pool that does not perform shared accounting.

Huh didn't know that existed either or people wanted it. It is kinda like Blockstream's Greenlight service for Lightning but for mining.

Solo pools are primarily used by home miners trying to hit a bitcoin block. A lottery of sorts.

The block produced by a mining pool has to satisfy all the same rules that have to be satisfied by a block produced by a solo miner.
The fundamental approach is unchanged - varying contents until the overall hash is not greater than a target.
The details differ because work has to be divided between pool members but this doesn't affect the overall high-level method and goals.
The Bitcoin network protocols do not have specific provison for pools.
Mining pools have their own network protocols for coordinating the pool members but these do not replace any Bitcoin network protocols.
I guess what discourages solo mining is the effect of the granularity of mining rewards combined with the huge disparity between affordable equipment and total network hashpower.

so thats mean i can still mine on solo pool as usual like pool mining? right?

I've no idea what a solo pool might mean.


text:
Allow RPC connections from the internet to make RPC calls from Lambda?
I am trying to make RPC calls to my node from an AWS lambda function. Lambdas do not have a fixed set of ip address ranges. I know I can use a NAT gateway on AWS to give my lambdas a static ip, but this is expensive. In order to allow inbound RPC connections from my lambdas, would it be ok to set rpcallowip=0.0.0.0/0, so long as I keep my rpcuser and rpcpassword safe? Bear in mind, I do not use my node as a wallet.

In order to allow inbound RPC connections from my lambdas, would it be ok to set rpcallowip=0.0.0.0/0, so long as I keep my rpcuser and rpcpassword safe?

The Bitcoin Core RPC interface is not designed to be accessed by untrusted networks. It's not secured against DoS attacks, nor does it have any encryption, so any network operator between the client and the server can read the username/password off the wire.
You should only ever set rpcallowip to local networks.
If you need to be accessible from elsewhere, use a VPN, or a tunnel like stunnel.

Yes, it'd be perfectly fine.
Because, as you already know, you would restrict node access to both the desired AWS Lambda facilities and to any other AWS facilities you'd be using to query your AWS EC2 node (e.g. some other EC2 instance) by using AWS "security groups".
The rest of the universe, including the rest of the AWS-verse, won't be able to query your EC2 node, as long as you code and assign your "security groups" correctly, and as far as there is no security issue at AWS (note this includes many things, like black-hat honeypots, inside jobs by rogue-y employees, govt mandates, any sort of bad stuff).
You can use AWS for relying and exploring transactions, but remember, not your hardware, not your coin.

Could you please elaborate a bit on how I could restrict node access to my desired AWS facilities using security groups?

I'd rather not, it's been half a decade since I last used Lambda to process data coming from EC2, RDS...


text:
Import the seed phrases generated in Electrum
To which wallets can I import the seed phrases generated in Electrum?

Probably none? Nearly none?
So far as I know, Electrum uses its own system of seed phrases which it's developers consider to be better than the BIP39 system used by many other wallets.
I believe Electrum has some compatibility features that must be specifically enabled. Most users probably don't do that unless they anticipate the need.
The developers of Sparrow Wallet commented

Although it would be relatively simple to implement (as you note, Sparrow already supports the Electrum seed format internally), I've held off on doing so because:

it might be confusing to have two types of seed lists to choose from
I'm not sure it's a good idea to keep supporting such an isolated 'standard'

BlueWallet might have support for Electrum seed phrases.


text:
If I move my btc (private key), from Ledger to Bitcoin Core
.... can I still use my 24 word seed phrase (from when I setup Ledger wallet), to access those coins on the blockchain?
Thank you in advance.

So I would need to extract private key through Bitcoin Core?

To use a 24 word backup phrase / seed phrase, you would need to install wallet software that is designed to be able to import that type of phrase. Most use a type of phrase defined by BIP39 - But some wallets use a different incompatible scheme. You would then be able to use that wallet to spend money that is under the control of private keys generated from the seed number that can be created from that phrase.
Bitcoin core does not support seed phrases at all.

OK  Thank you for the explanantion


text:
How Do Addresses Function?
I understand that an address is needed to send Bitcoins to other people, but I do not understand why you are recommended to generate a new address for each transaction. Also, I have read that an address can be saved for easy payment in the future, but I don't understand how this function would be possible if new addresses are generated every payment. Thanks so much for your time and help! It is much appreciated.

I think you may be misunderstanding how addresses work in Bitcoin. https://en.bitcoin.it/wiki/Address

The simple answer is you have a keypair for each bitcoin address, public key & private key, you can think of this as a username (public key) and password (private key). You can share your username/public key with as many people as you'd like, whether you know/trust them or not, of course you must keep your private key to yourself. The interesting part is that the public key is derived from the private key, and you sign messages with your private key to prove that you know it without giving away what the private key actually is (this is verified by comparing your public key with the message you signed).
The technical way that you create a private key can be found at the offical bitcoin wiki here: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
This wiki has a LOT of information, and is the most accurate source on bitcoin related information I have found to date.

What they're saying is that you can use an address repeatedly, but you shouldn't because it hurts your privacy, and it hurts the privacy of anyone who sends a coins to a reused address.
New addresses are generated every payment as Change Addresses. As you may know, partial coins cannot be sent, just like you can't tear a banknote in half and give someone half of it. So every time you send someone money, unless it is a whole coin, your client will generate a new change address to receive change for. That is for sending money.
However, if you want to receive coins, you can just have a QR code that displays a single address that everyone can send to.
When I say "whole coins" and "partial coins", I don't mean ฿1, instead I mean the individual transactions' inputs and outputs. I could get into that if you ask.

Thanks for the response! I understand that your client generates a change address, but why would they recommend to save an address for future reference? Wouldn't this make it inconvenient for regular customers to make a transaction to the same business.


text:
Unspent Output Consolidation UX. Any wallets that have built-in consolidation feature?
Consolidation is important however sometimes nerve racking because you are sending your entire amount, if you accidentally send to the wrong address somehow this can be detrimental to anyone's Bitcoin user experience. Do any reputable Bitcoin wallets automate consolidation to avoid this failure?
I believe this would significantly improve UX for average end users.

Some wallets will detect that you're sending to yourself and will make this clear in the UI, for example by showing no money (except for fees) actually leaving the wallet.

@VojtěchStrnad do you know which wallets offhand?


text:
How do I configure BTCPayServer to use an alternative datadir and avoid 'Unable to open settings file' Error?
Similar to:
Ubuntu Linux, Unable to set bitcoin datadir to a folder in different drive
and
I can't start bitcoind on Raspberry Pi. Why do I need settings.json.tmp when I didn't need it before?
I am configuring BTCPayServer to use a datadir that is not my root directory because I don't have enough space on my root directory for my pruned BTCPayServer Node.
When configuring and running BTCPayServer I am logged in as root the entire time, root (obviously) has access to my alternative directory.
This can be verified by running ls -l altdatadir
It outputs (edited to be generic):
drwxr-xr-x 7 root root 4096 Mar 28 16:23 altdatadir
I applied the alternate paths to the appropriate lines in docker-fragments/bitcoin.yml.
When I run the setup script everything appears to start, however if I try to call bitcoin-cli.sh it tells me it is restarting along with its unique hash. When I run docker logs (unique hash) it outputs (edited to be generic):
Error: Settings file could not be written:
 - Error: Unable to open settings file /media/$USER/altdatadir/.bitcoin/settings.json.tmp for writing

I am assuming under the given setup core is already being run as root (because btcpay server is being run as root) , which is the only given solution to this issue when it has appeared in the 2nd similar question's situation. If it is not the case how do I force BTCPayServer-docker to run it as root?
If it is the case and I am root when running core, why do I not have the ability to write into the directory/files?

I am also curious about the solution to this problem. I encountered a similar problem but cannot figure out exactly what the problem is. So I just started the program with sudo command.


text:
How is a soft-fork activation block defined?
Every soft-fork must have an activation block. This is also important for the consensus rules, because through that block it is defined from which point the new rules must be respected for the nodes that will be synchronized in the future and will have the latest consensus rules (take a look).
I'm interested in how is a soft-fork activation block determined?

Does this answer your question? https://bitcoin.stackexchange.com/a/97047/208

@PieterWuille It does. Just have one question. For BIP16/30 timestamp is used, for BIP34/BIP65/BIP66 block number is used, but what is used for locktime, segWit and Taproot soft-forks? I can't find it in third part of your linked answer ("Versionbits-based signalling: BIP68/112/113, BIP141/143/144, BIP91, BIP341/342").

@PieterWuille I am not referring to the way of signaling (BIP 9), but the way of checking in the consensus from which the given rules are applied.

That is quite literally described in BIP9.

@PieterWuille I assumed that, but I do not have a time now to read entire BIP. Never mind, thanks anyway


text:
What incentive do miners have not to lie about the time it takes them to mine a block?
What encourages miners (all miners; regardless of how much hash rate they have) to include real time in the block and not to agree among themselves to include a time such as if it took them 10 minutes to create the block. I mean, it wouldn't change the probability ratio of "finding the correct block and distributing the rewards" if all the miners together pretend they need 10 minutes (we just lower the necessary threshold). In that case, the miners together would mine the block in 2/3/4 minutes or less on average (I put a random number), and set the time in the timestamp as if they needed 10 minutes (of course, all the miners would have to wait before sending the block , in order to comply with the +2h rule). I can only see good for them here because in this way all miners would benefit greatly as they would spend a significantly smaller amount of electricity to find one block.
So, what incentive do miners have not to lie about the time it takes them to mine a block and to reject such an agreement?

all the miners would have to wait before sending the block

Since miners are in competition, they have a large financial incentive to publish their block and reap the rewards before some miner outside the conspiracy does so.

Hmm, so my scenario would actually turn the probability of finding a block into a block propagation race, which would be especially detrimental to miners who have higher hash rates?


text:
Is it true that we don't care about parity with the key path, but it is not case with the script path? (Taproot)
I am reading materials related to the Taproot (specially, BIP341) and I know that there is two possible ways to spend the output:

via key path
via script path

I also know that the Taproot output contains only the X coordinate, while the Y coordinate is indirectly assumed to be EVEN. So, in case you want to consume the output via the key path, you need to create a signature for the (X, Yeven) point.
However, reading BIP341, one of the consensus rules for spending via the script path is:
If q ≠ x(Q) or c[0] & 1 ≠ y(Q) mod 2, fail.

From the content to the right of OR, it looks like the first bit (00000000) inside first byte within control block denotes the parity (sign) of the Y coordinate (0 - even Y, 1 - odd Y) and that we must set the correct parity, that is, indirectly, the correct (even/odd) Y coordinate in order to make valid witness.
It follows that although we always use an even Y coordinate when spending via the key path (regardless of whether a point with an even or odd Y coordinate is obtained after tweaking), for spending via the script path we still need to know what was that original point obtained after tweaking (that is, whether it has an even or odd Y coordinate) and to set the correct parity bit. Am I right?
Also, since tweaking by the consensus rules (BIP341) between underlaying key (P) and MAST root is done in a such way that the even Y coordinate of the point P is used, does it mean that if I get from the underlaying private key (not the tweaked one) a point that has an odd Y coordinate, I have to negate it first before further tweaking with the MAST root? And also from this, my private key becomes -private key, that is, the public key is private key * (-G)?
Thanks to all in advance.

Correct on both accounts.
In taproot spends there can actually be up to 3 kinds of keys:

The internal key (before tweaking)
The output key (the internal key after tweaking)
Script keys (inside the scripts, there can also be keys).

The signature algorithm (BIP340) uses x-only public keys. It follows that whenever a signature is used, the parity of the corresponding key is ignored. This happens with:

The output key (for key path spends)
The script keys (for script path spends)

During a script path spend, there is something else going on. We don't just sign, but have to prove that the output key is a correctly tweaked version of the internal key. The revealed revealed keys are all x-only (including the internal key and script keys), but to prove the tweak, it is also necessary to reveal what the original parity of the output key was.


text:
Are there already several ways to do "smart contracts" with cryptocurrencies?
I have heard a lot of "buzz" about Ethereum, but apparently its 1.0 version won't be released for a while yet.
I have heard a lot of talk about "smart contracts" from people who admire Szabo, but I haven't seen many implementations.
I notice that Ripple lists "contracts" under "future" features, which seems to imply that they are not ready for use yet.
https://ripple.com/wiki/Main_Page
The one implementation I have seen is at :
http://erights.org/
Are there any other, more popular ways to implement "smart contracts" that are already in use?
Thanks

There is Orisi.org - you can read the whitepaper here Orisi.org/distributed oracles whitepaper, and run an example Timelock contract here.
The differences between distributed oracles/Orisi and Ethereum are:

Orisi works on top of Bitcoin, so there are no other currencies inbetween
oracles can reference external inputs, so you can create a contract that finalizes based on weather/currency prices, or even mechanical turk
it's available today
on the other hand, it has a different trust mechanism than Ethereum - oracles are supposed to be run by trusted independent parties. So, instead of proof of work, you have a proof of identity.

You can also read this blogpost by one of the bitcoin core devs: bit-thereum. It explains why m of n oracles might be a good solution for contracts.

I think that multi signature can be used to implement smart contracts, meaning that 2 or more signatures are needed to confirm the transaction for it to go through. E.g. a signature from the buyer and seller. I am not very sure but it's probably worth reading.

In Bitcoin, confirmations typically refer to a transaction being included into a block, which isn't what's being discussed here.


text:
Bitcoins stuck in phone based wallet
So here is my situattion:
A while back I have purchased as and experiment some cloud mining, I ended up getting about $70 out of it. Anyway I use the official Android bitcoin app:
https://play.google.com/store/apps/details?id=de.schildbach.wallet&hl=en
I have it backed up. And now when I try to restore it, the app just freezes at certain point. At the beginning it is 8 months behind, and as transactions start to appear in it, under each transaction there is alert basically saying that due to the fact that these transactions send to multiple addresses at once that app may become slow over time. And boy.. are they right. After it reaches certain point the transactions don't even  show up anymore, and I can't seem to be able to send any bitcoins to some other adress before it is fully synced.
So my question is, can I maybe take the back up file and restore it to different wallet app (maybe one of the online based, or even some PC based  one (Ubuntu)), as my guess is that my phone just can handle it (tried HTC ONE m7 and some shitty Sony Xperia). If so, how would I do it? Or all I can do is just keep on waiting? Or any other way to get my bitcoins out of that wallet, and just to forget about that wallet?

Does the app let you display or extract the private key? If so, maybe you can tell it to restore the wallet and then get the private key out before it become unresponsive.

Actually, bitcoins are not IN a wallet. They are and will always be 'ON' the blockchain. The blockchain says how many bitcoins each address owns. Our devices merely save our private keys (you could say, our passwords) for us, since we can't really remember those very well.
If you can extract the private key from your wallet file, you can simply import the private key in pretty much every bitcoin wallet there is out there and claim the coins stored on the addresses.
(Keep your file(s) safe, because anyone with the private key can claim the coins and send them to another address you do not have the private key for!)

Yeah I understand that. I probably should of phrased my question how to unencrypt the wallet provided I know password (as the app handles all that), and then how to use the private key in other app. Anyway, i got most of the coins out eventually!


text:
How to import say 1million bitcoin privkeys in bitcoind / bitcoin-qt?
I was wondering if there are ways to automate / mass private key import into the bitcoin client. Anyone knows of a command or has a script or an idea to share?
thanks.

Use the importwallet command. Try dumpwallet to see thr file format.

Well...
You could automate it using the JSON RPC and slowly work through the keys, however this will be kinda slow. If you actually need to work with 1 million keys, you may need to consider an alternative option.
What is it you need to do with the keys?


text:
How do I receive my first bitcoin?
My first experiences with bitcoin: I downloaded Multibit and then went to the CoinbitGet website. I copied and pasted my address at the site as they instructed and after verifying that it was the correct address, I did some tasks where I earned 240 ubtc. I did all that yesterday. Then this morning on the Coinbitget site it said I was paid - but nothing was shown on multibit. So the Multibit help said I should "reset blockchain and transactions" so I did that and let it run for about 13 hours. But still nothing. (I know Multibit is connected to the internet because it always shows the current bitcoin to dollar price in the upper right - even though it always says "connecting" rather than "connected" In the lower left). So I checked at http://blockexplorer.com/. and it says - "(2014-03-28 04:27:08) Received transactions: 1 Received BTC: 0.00024" - which was 16 hours ago but I still see nothing in Multibit. I read that Multibit is fast since it doesn't keep the blockchain on the disk. So what might I be missing? It is not a lot of money so I am not worried but would like to learn and am not sure what to do now. The address was correct. Any help would be appreciated. Thank you all.

It's possible that your firewall is blocking the BTC node connections without blocking the price data. The price data is probably obtained through a normal port like HTTP or something, whereas the usual port for BTC connections is 8333. Other than that, the only other possibility that comes to mind is that it could have not got enough confirmations yet, blockchain.info can tell you how many confirmations your transactions have. Change the address in this URL to your own and see if the latest (top) transaction has 6 confirmations: https://blockchain.info/address/1DFNwqgF1HToPaveeoGZL4qdBDEZYUmC89.

Nitpicking: HTTP is not a port, it is a protocol that usually runs on port 80.

Jori, yes, I know. :)
Skimmel, I'm assuming you're using Windows. I'm not on Windows right now and I'm not sure when I will be, so I'm limited in how specific I can be. When my Peercoin wallet was being blocked by a firewall, it was by Windows' builtin firewall. Type "firewall" in the search box on the start menu. There are a number of tabs on the left, pick one of the bottom few. It will show a lot of programs with red Os (blocked) or green symbols (allowed). If you click at the top of the column of names, it will sort by allowed/blocked. Check to see if multibit is listed as blocked.


text:
ANXBTC.com / MTGOX v2 API "Authentication"
I've signed up with ANXBTC.com and I'm trying to learn the API (based off MTGOX v2 API):
http://docs.anxv2.apiary.io/
In order to issue commands, there needs to be authentication.
I have a "Rest-Key", but I have no idea how to generate/find a "Rest-Sign".
On the link above, it says that "Rest-Sign is an HMAC hash constructed from your API secret, your API method path, your post data, and uses the SHA-512 algorithm."
Also on the above link, there is sample code (PHP, python etc) which can be tested - however it needs both the Rest-Key and Rest-Sign.
Part 2: Are these APIs meant to be run solely off a personal computer, or can it be used online? Eventually I want to try and create a website form where I can show the current exchange rate, as well as place orders. Is that possible?
If anyone has insight, help is greatly appreciated.
Thanks, Michael

Michael,
To generate the Rest-Sign header, use the following code (example in PHP):

Rest-Sign function
 function hmac_512($msg, $secret)
        {
        $secret = base64_decode($secret);
        $result = hash_hmac('sha512', $msg, $secret, true);
        return base64_encode($result);
        }

Rest-Sign inputs
$post_data should be an array with a nonce and any relevant API post data, and $api_path should be the portion of the API after https://anxbtc.com/api/2/ that you are calling.
       $post_data_encoded = http_build_query($post_data);
       $msg = $api_path . "\0" . $post_data_encoded;
       $rest_sign = $this->hmac_512($msg, $api_secret);

Regarding your second question, you can run this API from your personal computer or a server.
Hope this helps,
Evan


text:
What happens when two or more transactions are covered ("hit") by RBF?
RBF (Full RBF, Opt-in Full RBF, FSS-RBF) is applied to a transaction when one of its inputs "matches" one of the inputs in the replacement transaction.
However, what happens if the inputs of a replacement transaction "hit" the inputs of two (three or more) different transactions?

Does the replacement transaction then replace all those "hit" transactions (transactions covered by replacement)?

In order for replacement to occur, does the fee of replacement transaction have to be greater than the largest fee among all "covered" transactions, or perhaps the fee of replacement transaction must be greater than the sum of the fees of all "covered" transactions (or something else)?

What would happen if the node works in Opt-in Full RBF mode and some of the transactions "included" in replacement do not accept the possibility of replacement (nSequence of all inputs is 0xffffffff)? I assume that the replacement then will not even occur and the replacement transaction will be just rejected.

For a replacement to be accepted into the mempool, it has to improve the mempool for miners. Therefore, it has to pay more fees than all the ousted transactions, additionally must pay for its own relay, and finally cannot oust too many transactions at once. Specifically:

If the node works in Opt-in Full RBF mode, the directly conflicting transactions must all signal replaceability, otherwise the replacement attempt fails.
The replacement transaction must pay at least as much fees as all replaced transactions (including the descendants of the directly conflicting transactions!) plus its own vsize times the node’s incremental relay feerate.
The replacement transaction does not spend any new unconfirmed inputs that were not already spent by one of the directly conflicting transactions.
The replacement transaction must pay a greater feerate than each directly conflicting transaction
The sum of the conflicting transactions' descendant counts doesn’t exceed 100.

You can read more about this topic for example in the policy documentation for Mempool Replacements for Bitcoin Core, and in glozow’s gist collecting her thoughts on RBF Improvements.
This answer omits FSS RBF, because I am not aware of any nodes implementing that policy on the network.

I have 2 small questions. 1) Isn't 5th condition redundant/unnecessary since with 3rd condition you already satisfy it? 2) In last, 6th, condition you only mentioned that the sum of all descendant of all confliction transactions can't exceed 100. However, you didn't mention the conflicting transactions themselves. In the material you linked they say The number of original transactions does not exceed 100. and by original transaction they denote conflict transaction + its descendants, so I would say that the sum of all confliction transaction + their descendants can't exceed 100?

I just saw that glozow's gist collection doesn't even mention the 5th condition, only the 3rd one. I guess then the answer to my first question is yes, i.e., it is redundant/unnecessary.

A transaction’s descendant count always includes the transaction itself. So, the sum of multiple transactions descendant count is potentially an overestimate, if they have overlapping descendants. What do you mean with "3rd and 5th condition"? My list has only five bulletpoints, but what you call "6th condition" appears to refer to the last bulletpoint. If you are referring to the rule about absolute fees and the rule about feerates, you should consider how things play out when transactions have differing sizes, i.e. what if the replacement is larger or smaller than the originals?

If two (three or more) directly conflicting transactions have some same/overlapping descendants, that descendants will be count as 2 (3 or more), not just as 1?

Sorry, I did not denote it good. By this question I actually refer to 2nd and 4th bulletpoints (conditions). If I understood correctly, you want to say that even if the fee of the replacement transaction (calculated by rules from 2nd bulletproof) is bigger than the sum of all fees (directly conflicting transaction + their descendants), in case when replacement transaction is too big it can still have smaller feerate than some of directly conflicting transaction. So 5th bulletproof is also required.

Yes, if the transactions A, B, and C are all ancestors of a transaction D, and R replaces A, B, and C, their sum of descendant counts would be 6 in context of this check. You got it right: If R is bigger than A+B+C+D, even if it pays a total higher fee than A+B+C+D + vsize(R)×incrementalRelayFeeRate, R's feerate may still be lower than one of A, B, or C—so both the absolute fee and the feerate criteria are needed to ensure that the mempool is getting more attractive to miners.

All clear, thanks


text:
How to create a new genesis block using CreateGenesisBlock() function
I'm trying to create a new genesis block, you know for science.
I saw a lot of write ups online but most of them seem kinda outdated.
I found the function CreateGenesisBlock() in the source code.
    genesis = CreateGenesisBlock(1317972665, 1337, 0x1e0ffff0, 1, 100 * COIN);

    std::cout<< genesis.GetHash().ToString().c_str() << std::endl;
    std::cout<< genesis.hashMerkleRoot.ToString().c_str() << std::endl;

    consensus.hashGenesisBlock = genesis.GetHash();

This is my current code.
When running my coind it fails with ERROR: ReadBlockFromDisk: Errors in block header at CBlockDiskPos(nFile=0, nPos=8)
From my current research it seem the genesis block failed the PoW criteria somehow.
I thought about putting the CreateGenesisBlock in a loop to generate blocks until I found a valid one but I'm not sure how to check if the block is valid.
Can someone gimme a tip?

I met same problem. Have you solved? How?

The genesis block still must meet the proof of work requirements that other blocks must also meet. So you must actually mine the genesis block. To do this, you need to put CreateGenesisBlock in a while loop and just keep incrementing the nonce, and if necessary, increment an extranonce in the coinbase transaction.
To check that it has a valid proof of work, use the CheckProofOfWork() function (grep for it and you can figure out what arguments it takes).

To check that it has a valid proof of work, use the CheckProofOfWork() function I think this is what I was missing. Cheers!

@soupdiver Please write all the code you used. I am also stuck at this stage for days...

@leegod I assume we're working on the same (demo) project as (most?) of the others who came up with that question in the recent months... In the end I found a python, which I had to modify, which "mined" a valid genesis block.

@soupdiver I am working on newest litecoin source. To make alt. So what  is that python? You mean GenesisH0? How you modified and what values should I input exactly to use it correctly?

@leegod yep it's GenesisH0. I don't know about requirements/specification of the coin you trying to create. So I can't give you exact values.

I just want to clone litecoin with some parameters change. And GenesisH0, I can't match right value, what values should I input there I don't know exactly, I tried various things, it just errors. so I give up using GenesisH0, just used printf method, now error says see debug.log file, debug.log says  ReadBlockFromDisk error.

and also, if use GenesisH0, it just mine in its script only, isn't it? Then no related with mycoind client? Then how make pre-mine reward to own wallet address? Because using GenesisH0 means no client-side's actual genesis block mining?

@Andrew Chow  Hi. Thanks for answering. But I am also stuck at this stage. Can you link or put he exact working code? I can't find anywhere.

@Andrew Chow Where that CreateGenesisBlock is? chainparams.cpp's original place? (line 123~5)
and wrap this up with while loop?
And is this the code you answered?
https://pastebin.com/EC4tVZQZ

@leegod I don't have any specific code that I can provide you. I have not written it nor do I plan to. I am not in the business of creating altcoins or helping people make altcoins.

@AndrewChow So I did at chainparams.cpp file like,
const CChainParams& chainparams = Params();
while(!CheckProofOfWork(genesis.GetHash(), genesis.nBits, chainparams.GetConsensus()) { ++ genesis.nNonce; }
But this does not even compiled. I added #include "pow.h" at top of chainparams.cpp, but when I try 'make' for compile, terminal error says,
chainparams.cpp:127 : undefined reference to "CheckProofOfWork(uint256,,,,, )'
How to pass this?... Plz.

You will need to modify the Makefile.am file so that the generated Makefile can find pow.h and link it when it compiles validation.cpp.

@AndrewChow So I revised Makefile.am, so now that [undefined] error solved. But now I get new error, says,
lee@newlite:~/Desktop/BitcoinEssence/src$ ./bitcoinessenced bitcoinessenced: chainparams.cpp:524: const CChainParams& Params(): Assertion `globalChainParams' failed. Aborted (core dumped)
Here is detail. https://bitcointalk.org/index.php?topic=3031897.new#new


text:
How to get instant notification of any Bitcoin transaction involving a specific public address as recipient without knowing the wallet or private key
Everything is in the title... For instance, Blockchain can do this if you import a public address and you set up their notification mechanism.
Is there a way to do this in an intelligent (=efficient) way with bitcoind even with some patches? Or is the only solution is to get all transactions and filter for the public address?

have you solve this issue using JSON-RPC?


text:
Can the claim that "Bitcoin has a fee model that can be easily manipulated" be proven? If so are there any proposed solutions?
phillipma1957 claims:

Bottom line is the fee setup is subject to attack at little or no cost if any major pool gets involved in the attack.
I am a small commercial miner maybe 160kwatts  of gear which is a drop in the bucket.
But if you have 100 megawatts and work with a large pool  with a few other big mines you can really do a whole lot to move fees from 0.15 btc a block last year to 1.50 btc a block now. I do think this is happening now.
But I also think it means we are about to see a large btc price increase. As this super sized blocks seem to happen in the beginning of bull runs.

https://bitcointalk.org/index.php?topic=5450797.20
Is this claim substantial? Is this somewhat of a known issue? If so what kinds of procedures (if any) have been proposed to attempt to resolve it?

I guess you'd have to ask them? They make a big claim without backing it whatsoever.

@AntoinePoinsot they added some details I wouldn't say its evidence but they at-least layed out the context in which it could occur. Limiting discussion between me and the person who already asserts that it is possible would only lead me to a circular argument. I am looking for anything that could futher substantiate the claim, if there is nothing then thats ok too.

Assuming that you are referring to the linked thread by philipma1957, the claim is weak in at least two points: it requires mining pools to not share the revenue from transaction fees with their participants, and it requires other Bitcoin users to outbid the mining pools that stuff the mempool a consistent amount of the time.
I’d like to note that I find the argument generally hard to follow due to the low-quality write-up, so I’m not sure if I correctly parsed what they mean. (If you have a better summary of what claim we’re discussing, you could perhaps include it in your question post.)
Since mining pools appear to have moved to also paying out the revenue from transaction fees, the first seems like an outdated assumption. The second is broken whenever a lull in blockspace demand occurs. Since the stuffers’ transactions remain valid, at that point the stuffers’ transaction fees are redistributed among the entire network’s hashrate.
As I understand it, I don’t find this claim convincing. Perhaps I could be convinced otherwise if it were more comprehensively explained and substantiated with a more complex model than “they make back exactly [their hashrate percentage] fees of the transaction fees they invested”.


text:
Is there a way to handle scalar multiplication with the Secp256k1 generator to finalize a Bitcoin script in an atomic swap?
I know that Bitcoin can do Schnorr which allows for one way to finalize an atomic swap but on the other side of the current swap implementation( that I am working with), the script needs to multiply a scalar by the curve generator to check for the correct secret scalar value. Is there a way Bitcoin script can handle this?

If I got your question right, you need to check if someone actually have a scalar s such that s*G == S? If you need to explicitly commit to s, like:
<s> OP_ECC_MULL_G <S> OP_CHECK_EQUAL_VERIFY
where OP_ECC_MULL_G multiplies a scalar s by secp's generator point. This is impossible to do with script, as it doesn't expose ECC operations directly.
If you just want to check whether the party has the secret, this is just a simple signature:
<S> OP_CHECK_SIG_VERIFY. One can only satisfy this script iff they known s

Thank you it does make sense to use OP_CHECK_SIG_VERIFY the main question now is will the public key for a script that just checks for OP_CHECK_SIG_VERIFY on s look like sG or something similar? If so then that will satisfy the requirements, but if the value can not be represented in a public way like this the other party can't audit the swap which is essential. Is this basically just creating a regular public key? Or would I need to do something else.

You have to publish the public key sG and the signature. For taproot, the public key will go in the spk, and the signature will be in the witness. The public key will always be available for verification...


text:
Looking for resources on doing Schnorr signatures in Bitcoin transactions
Please leave any resources you think will help, thank you.

Do you want a wallet that uses P2TR, want to build raw transactions with Schnorr signatures, or implement signing for Schnorr signatures yourself? Could you elaborate the scope of what you are trying to achieve?

Wallets that implement p2tr would be helpful for testing, however I am mainly looking for how I would practically implement schnorr transactions in custom code.

Bitcoin Optech has held a very good workshop that you could take a look at.


text:
How to import entire Armory wallet into Electrum?
I've managed to import a private key, but how to import an entire wallet?

The best way to switch to Electrum is to send all the bitcoins you have on your old wallet to one of the addresses on your Electrum wallet. This way you'll have all your bitcoins secured with your seed.
https://electrum.org/tutorials.html#switching-to-electrum

In Armory:

Select "Wallet Properties".
Select "Backup This Wallet".
Select "See Other Backup Options".
Select "Export Key List".
Select "Omit spaces in key data".
The important string is the PrivBase58 for every bitcoin address. It is the private key of this address encoded in base58 (encoded not encrypted), which is the (only?) format Electrum accepts when importing.

In Electrum:

Select File → New Wallet
Enter the private keys you took from armory into the textbox

Note that you have to remove all the spaces in the PrivBase58 string given in Armory.

To remove spaces, enable the "Omit spaces in key data" checkbox.


text:
Do all mining pools compete to unlock same block?
Are all the mining pools competing to unlock each new block, or is each pool assigned an individual block to unlock?

It is the former.

Considering that there is no central authority to "assign" blocks to anybody, you should be able to work out the answer.