text:
Cryptocurrency scam, can anyone help me?
I received a serious scam from a platform called Lemintero.com, can anyone help me reconstruct the flow of money transfers?
Can anyone track my money if I provide the blockchain of transactions? Please help me, these scammers took all my money. I am not an expert and I got scammed by them.


text:
Trying to recover old wallet using what I hope are private keys - need help
I know I was trying to purchase bitcoin in the very early days 2009-2010. I moved across far away in late 2010 and left some belongings behind with family. As years have went by and bitcoin got valuable, I couldn't remember if I actually figured out how to buy from someone back then or where I had it stored if I did. But I have always felt like did purchase some.
I recently recovered those items I left behind and found an old external hard drive. The hard drive contains a folder named Crypto created in September 2009. Inside this folder is another folder named RSA, which I learned means Rivest-Shamir-Adleman, a public-key cryptography algorithm.
Inside that RSA folder is another folder named S-1-5-21-1234567890-0987654321-1122334455-9999 (edited for this post), which I have also learned indicates it's a Security Identifier (SID). Inside this folder are two Unix Executable Files and the files names are both in this format: 1234567890abcdef1234567890abcdef_abcd1234-5678-90ab-cdef-1234567890ab
There are 64 characters in each file name (0-9 and a-f), same as private keys. Also, the first 32 characters in each file name are unique, but the last 32 characters in each file name are identical to the other file. As you can see there is an underscore after the first 32 characters in each file name and several dashes within the last 32 characters.
Are these bitcoin private keys? The parent folder was named Crypto and created in 2009 so I can't imagine what else they would be. I have tried to import each file name minus the underscore and dashes as private keys into a popular wallet platform and it says Invalid Keys for both. I then tried to combine the first 32 characters of each and import that as the key and again it's saying Invalid Keys.
I am stumped. Any advice?

Are these bitcoin private keys? The parent folder was named Crypto and created in 2009 so I can't imagine what else they would be.

They are nothing to do with Bitcoin.
They are typical of security-related files created by Microsoft Windows. Files like this are present on probably every primary hard disk in, or extracted from, any computer that had been running Microsoft Windows.
The folder name "Crypto" refers to cryptography, literally "hidden writing". "Crypto" does not, in this case, refer to cryptocurrency.

Inside this folder is another folder named RSA,

The Bitcoin network uses ECDSA not RSA. Any Bitcoin software that encrypts locall storage of keys is likely to be using AES256 not RSA.

Related:

Lost bitcoin - advise and help
What are the formats of a private key?

Oh well. Thanks for the answer.

source: Stack Exchange

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

sort: votes


text:
Is server based cpu mining worth it?
Can we get an updated version of this question. I believe the answers will be factually different because bitcoin was at a 1000 usd per coin and it is basically x 100 that now.
I have come into posession of a nice little server for very little money. It has an Intel Xeon cpu, 4 cores, and 32 gigs of RAM.
I want to buy a windows server 2016 liscense for. Install awesome miner on it and mine some bitcoin on it. It costs 0.20 usd per kw of power where I live
Now I don't expect to get rich of this. To be frank I would consider 10 usd a day a massive succsses. My livelyhood is in no way dependant on this. All I really would want is for this to produce some fun money.
Is this estimate achievable with this hardware?

The answers to this question (linked from the one you linked) are still correct. You can use a bitcoin mining profitability calculator such as this one (select SHA256 and your CPU) or review calculations in answers to this question

I’m afraid that CPU and GPU mining have been unprofitable for over a decade. While the exchange rate has gone up since then, the hashrate has gone even more.

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


text:
Lost Bitcoin wallet
If I have wallet address only, part seed phrase can I get access to Bitcoin wallet. Can bitcoin.org find IP logs from date of wallet download.

Can bitcoin.org find IP logs from date of wallet download.

No. Bitcoin.org mostly provides links to sites that provide downloads. Their website has no way of knowing if you clicked on a provided link.
Even if they were able to keep a log of IP-addresses and chose to retain that log long term, I doubt you would be helped by a list of IP-addresses that were mostly dynamically assigned by ISPs.

If I have wallet address only, part seed phrase can I get access to Bitcoin wallet.

See

I have lost my wallet, what can I do?
Difficulty of brute-forcing a seed with missing words?
19 out of 24 words of BIP39 passphrase (brute-force last 5?)


text:
Is it safe to reveal the private key that generates the R nonce in schnorr sigs?
I'm curious about stuffing data in the auxiliary parameter of generating the schnorr nonce.
Something like "Alice agrees to pay 1 BTC to Bob within 5 days of Monday March 20th".
I want to put data in there to prove to people that it's there without jeopardizing security. Or does it open me up to an attack once S is revealed on chain?
Or should I put it in the hash that scales the public key. Adding it to the tweak?

No, it’s not safe. If the random nonce k is revealed, the counterparty can calculate your private key.
A Schnorr signature is composed of two scalars (r,s). Where r is the x coordinate of a point R generated from a random nonce k. If I understand you right, you are asking whether it’s safe to reveal this k.
A Schnorr signature is generated in the following manner:

m: message
x: private key
P: public key; P = x×G
k: random nonce
R: random point; R = k×G
r = R.x (x coordinate of random point R)
s = k + hash(P,R,m)•x

If both sides of the last equation are multiplied with the generator point G:
s = k + hash(P,R,m)•x
s×G = (k + hash(P,R,m)•x)×G
s×G = k×G + hash(P,R,m)•x×G
s×G = R + hash(P,R,m)•P

So, any third party can check whether the signature is valid by plugging  (r,s), the message m from the context of the transaction, and the public key P from either the prior output or the witness structure into:
s×G = R + hash(P,R,m)•P

If the equation holds, the signature proves that the signer knew the private key x corresponding to the public key P.
No, it is not safe to share k, because given k the counterparty can solve for the private key in this equation only composed of scalars:
x = (s - k) / hash(P,R,m)


text:
Linting check isn't passing on GitHub but doesn't trigger locally
I have a pull request thats struggling to get past linting.
Python's open(...) seems to be used to open text files without explicitly specifying encoding='utf8':

test/functional/feature_chain_arg_collision.py:        with open(
Success: no issues found in 251 source files
^---- failure generated from lint-python-utf8-encoding.py

Running the linter locally doesn't trigger the error warning.
The only place I use open is in the functional test
with open(
             os.path.join(self.nodes[0].datadir, "bitcoin.conf"), "a", encoding="utf8"
         ) as conf:
             conf.write(f"includeconf={inc_conf_file_path}\n")

         with open(inc_conf_file_path, "w", encoding="utf8") as conf:
             conf.write("chain=regtest\n")

I'm running
/Users/${USER}/git/bitcoin/test/lint/lint-python-utf8-encoding.py

with my file staged in git.

The version of the linter in CI may differ from the one you use locally, which may cause it to trigger or not trigger in slightly different conditions. I'd suggest commenting on the PR to get guidance from other reviewers. I don't think this is the right place to ask.


text:
How to add scripts to pull requests to show due diligence of work
I'm wondering if there is a workflow that allows developers to share due dilligence of work in a pull request.
To give you some insight, I noticed that if you have a network parameter in your config, like chain=main and then use chain=test in the commandline, you get an error message but It doesn't really tell you what is going on.
This change provides a little bit more verbosity letting the user know where and how the collision is happening.
For example, my change breaks the test
util_tests/util_ChainMerge
You can run it as per the instructions
CHAIN_MERGE_TEST_OUT=results.txt {build_dir}/src/test/test_bitcoin --run_test=util_tests/util_ChainMerge
an excerpt for an example
Current:

 -regtest=1 -noregtest=1 noregtest=1 notestnet=1 || main
 -regtest=1 -noregtest=1 testnet=1 regtest=1 || error: Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.

Mine with a more verbose error message:

 -regtest=1 -noregtest=1 noregtest=1 notestnet=1 || main
 -regtest=1 -noregtest=1 testnet=1 regtest=1 || error: Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one./n Too many network flags being set in the commandline.

So I would like to show that I have a script that compares these results appropriately and shows that my change doesn't break anything.
What is the best way to package helper scripts up to help reviewers? Should I make a separate repo for reference?

Some answers I got from irc.
luke-jr:
Kaizen_Kintsugi_: if they're short enough, I've seen them inlined in ``` blocks
Earnestly:
Kaizen_Kintsugi_: If I ever have to dump a large log, I use a  element.  So name of log newline ``` ... ``` newline  -> blank lines are important for ```


text:
Can I create multisig vault using same private key with different passphrases
I tried Blue wallet. I created vault using same private key with 3 different passphrases for vault key 1,2, and 3. However, I can only receive the fund, but can’t send it because of an error that says “ can not add duplicate data to array.” My question is that because of the app bug or I created a burn vault that isn’t fully functional?

It could be a bug in the app, but let's consider what you are telling the app to do.
If you added a passphrase to a single WIF private key via a BIP38 passphrase (simply encrypting the private key) you still have the same resulting public private key pair upon decryption. So you are telling the app to create a multisig wallet with the same public key (which really isn't multisig anymore). Also someone only needs to know one of the passphrases to spend since they all resolve to the same public private key pair.
There is nothing technically wrong with this, you absolutely can add the same public key 3 times, and require 2 to spend. I don't know why you would, but it is "allowed".
I believe the result you are looking for would be more easily achieved with a BIP39 mnemonic and adding a separate passphrase to each. Different passphrases on the same bip39 mnemonic will produce a different public private key pair for each passphrase. This way you actually need the correct amount of passphrases to spend instead of just one.


text:
What is the optimal way to lnurl-pay without running a ln node?
I am working on a service that would receive payments through lightning and would need to use a static lnurl-pay QR code (no screen available). When payment is received I would like some automated action to occur (like flip a switch, I would check for payment via api + polling, websockets or anything like that).
I am having a difficult time understanding what is the minimum I need to setup the payment address that I can then monitor when is it paid. I would like to avoid having to run my own lightning node, as that brings additional server management + funding requirements.
Any suggestions where to start?

The LNBits project has many good integration extensions, but you would need an LNBits instance to use that. With LNBits it's possible to use an instance run by someone else (whom you trust).


text:
How do I find out where my bitcoins got sent to?
I withdrew bitcoin from my account in Binance in 2018 and still have the email they sent with address it said it sent to,18bVuA2FxDdz5gE4qf9MgbsNxp2F46PaLD
The time and amount looked correct. Now I don't remember if it was a wallet or to another account. Blockchain.com says the current value is 0. But I didn't do anything to it. How can I find out what happened to the bitcoin amount and where it was sent to? Thanks for your assistance.

Does this answer your question? Can a Bitcoin address be traceable to a crypto exchange?

Just use the "blockchain explorer" to search for that address.


text:
How can we derive all work ever done on the system from the lowest hash ever found?
If not mathematically (I imagine the proof might be quite rigorous), could you please provide an intuitive explanation for why the lowest hash ever found tells approximates the total amount of work ever done on the system? Source: https://youtu.be/zYzEmBlJ77s?t=4720
My thinking: We can figure out the probability of finding a hash that is lower than the hash we found. From there, we can find the "mid-point" of a distribution for how many attempts it would take to find such a hash. So it just gives you a point on a distribution.
Thank you!

Every hash attempt, regardless of who does it, or what difficulty it occurs at, is an independent evaluation of a hash function, resulting in a number uniformly distributed between 0 and 2256 - 1.
Now consider the distribution of the minimum of N independent samples. See this question for a derivation, but the result is that the average of that distribution is approximately 2256 / (N+1).
This gives an intuition about the relation between the smallest observed hash and the number of hashes performed: on average, the minimum will scale approximately proportional to 1 / (N+1) with N performed hashes.
The statistical tool for estimating N from the observation is called likelihood estimation: we have a probability distribution with unknown parameter N, and make one observation from that distribution. That distribution of the minimum of N hashes (if we simplify it a bit by turning the output of hashing into a continuous real function, uniformly distributed over [0, 2256]), has probability density function fN(x) = N(1-x/2256)N-1. Given an observation min_hash, the value for N that maximizes fN(min_hash) (the maximum likelihood estimator) is -1 / log(1 - min_hash/2256). For small values of min_hash, that expression is closely approximated by 2256/x - 1/2.

Proof-of-work as used in Bitcoin relies on finding low hashes, in other words finding hashes that begin with a certain number of zeros. To find a hash whose binary representation starts with 30 zeros, you would need to do, on average, 2^30 attempts. When you find this hash and present it, it is a proof that you have actually done about as much work. And it works both ways, when you perform 2^30 attempts, the lowest hash you will end up with will start with roughly 30 zeros.
Importantly, this works on any scale. The smallest block hash I could find starts with 23 hexadecimal zeros, or 92 binary zeros, which shows that the network has calculated around 2^92 hashes in its existence.
If you want to see it even more intuitively, check out this answer from a different thread that shows how the number of zeros in the lowest ever hash has been rising over time.


text:
How Do I unlock a Bitcoin Blockchain with my Proof Of Work?
Can anyone help with some good explanations on next steps for Bitcoin mining.
Hypothetically let's say I create an algorithm that successfully guesses the code to unlock a Bitcoin blockchain
gives me a result such as: 000000000000000000008d0cff17edbe038f81208fecf9a66be9a2b8321c6ec7
I believe the results of this computational effort is called 'Proof Of Work'
Where do I paste this 'Proof Of Work' on the internet to claim the Bitcoin?
Also can you refer me to any helpful API where I can check my 'Proof Of Work' against already claimed 'Proof Of Work'
A basic video on how I might create such an algorithm can be found here https://youtu.be/ZhnJ1bkIWWk unfortunately it doesn't mention next step.
I am sorry if this seems like a really basic question, after much googling I am still confused.
I would like to try and make edits to such an algorithm and see if I can unlock a blockchain and claim bitcoin reward. I am not asking how to write an algorithm to unlock bitcoin, I would like an explanation of what I do with the result of the algorithm i.e. how do you cash in that lottery ticket?
Any advice appreciated.

Does this answer your question? What exactly is Mining?. You broadcast to a few peers  your new block, the first transaction in that block is one you created that pays you the block reward + mining fees. Spending that is  deferred for 100 blocks.

It was an interesting question and set of responses, but I am looking for more practical advice, suppose I was to run this code link and generate proof of work, how do I broadcast that to peers. Does this code on github that uses sha256 automatically inform the network? Can I just add the resulting characters into a bitcoin wallet?

The code you link doesn't implement bitcoin at all, just a toy scheme that is partly similar to a few small parts. And even if you used code that is correct but still in python it would run only on CPUs, and today CPU mining is uncompetitive by many orders of magnitude. To 'win' a block with python code you would need to own many times more computers than exist in the world and buy probably most of the electric power; I consider that impractical.

Thanks for the answers. Why the down votes? I was new to bitcoin.stackexchange asking for practical advice on how to create a proof of work with Python, instead I got links with theory.

To generate the proof of work your program first creates a block template from a set of transactions. The first transaction is normally called a coinbase transaction and it is invented by the miner, it has outputs of the miner's choosing, typically it pays the miner. It has no explicit inputs, the sum of outputs is no more than sum of transaction fees from the other included transactions (if any) plus the current block reward which halves every few years. The program chooses a value for a nonce field in the block and calculates the hash of most of the data described above. If the hash is greater than the target, the miner must vary the nonce or other data in the block and retry.
If the hash is less than the target, the program makes its few peer nodes aware of it's new block. It does this using the inv message type described in the bitcoin protocol documentation

suppose I was to run this code [link] and generate proof of work, how do I broadcast that to peers.

Firstly, that code has the following function. you need to write more appropriate code to populate the parameters including transactions
def mine(block_number, transactions, previous_hash, prefix_zeros):

I doubt that code actually works. The structure seems far too simple.

It doesn't create locking scripts
The transaction data is way too simplified. It is conceptual not real.
It doesn't look up Transaction-Ids and output-indices for inputs
It has prefix_zeros but real codes tests for less than target,
not for number of leading zeroes.
etc.

Does this code on github that uses sha256 automatically inform the network?

No.

Can I just add the resulting characters into a bitcoin wallet?

No. It is far more work than that code suggests. Start elsewhere.
Remember

Bitcoin wallets don't contain money.
Bitcoin wallets contain a secret number called a private key.
There are many different types of transaction and a mining program
needs to know about them to validate them.
A mining program should collect unconfirmed transactions.
this is all much more complicated than you are yet aware of.


text:
Changing the blockchain requires more than just recalculating all hashes..?
New here!
I read this everywhere - "To change some data in a blockchain, the malicious user will have to recalculate hash for every block starting from that particular block".
My doubt is - Is that enough?
My understanding is that even if someone manages to recalculate all the hashes, the other nodes will still have the original, untampered blockchain. So the malicious user has to change those blocks for every single node (or at least 51% of the network). Is this correct?

Is that enough?

Yes. If you can produce all the revised blocks plus produce new blocks faster than all other miners combined can produce just new blocks, then you can force a blockchain reorganisation.

the malicious user has to change those blocks for every single node (or at least 51% of the network).

That's the much easier part. You make your new block data available and other nodes will collect it and distribute it for you. Since all nodes have to allow for blockchain reorganisations, which are relatively routine though usually very small in scale, the mechanism is part of the Bitcoin network.
The much misunderstood 51% figure is concerning the total hashing power of all active miners in the network, it isn't anything to do with the number of nodes.

See

Questions about 51%


text:
What is the chance to recover an 8 character wallet password?
I found an old BTC wallet. The password should have about 8 characters but forgot it unfortunately. Is there a realistic chance to recover it or is this hopeless?

This depends on the char set you used for your password. The numbers below are from Wikipedia (no guarantee) and describe how long it takes to crack a password with a standard PC + GPU. They are for the case that the password exactly 8 characters.
[0-9]: 100 ms
[a-z]: 4 min
[A–Z; a–z; 0–9]: 3 days
[A–Z; a–z; 0–9] + Special Characters: 84 days
So in the case of 8 characters there is a certain chance that you can crack it. However, if you only used a 9 characters pw, the last two cases already way more difficult.
[A–Z; a–z; 0–9]: 159 days
[A–Z; a–z; 0–9] + Special Characters: 22 years.
So for passwords with special characters 8 is the maximum length you have a chance. If the password only contains [0-9] or [a-z] there is a chance until 11-12 chars.

This seems to assume, with no justification, that each attempt takes 1 ns.  That number could vary greatly depending on the hash or encryption algorithm used for the password, which we don't really know.  So I'm not sure these numbers are at all meaningful.

first of all, it depends on hashing algorithm used in wallet encryption,
that is to say, in some hashing algorithms the cracking software can check 1 or 2 password per second and in some other hashing algorithm it checks about 20000 passwords per second. therefore, this is crucial index to have in mind. overall, 8 characters can be cracked, though it might take  while to do it


text:
Is this a transaction?
I found an old wallet.dat but i dont know what is this. Is it a transaction that is not signed? If yes please help. I dont have a clue about cryptography. I have read and seen some tutorials but i dont get it.

I don't have a clue about cryptography.

That's OK, The Bitcoin protocol doesn't encrypt anything. Although implementations like Bitcoin core can use a wallet password to encrypt private keys stored in a wallet file. Anyway the text shown doesn't include any encrypted data.
So if the wallet isn't encrypted, you don't need to know anything about encryption.
Cryptography or crypto-graphy literally means secret writing. Cryptography is the study and use of methods of writing secret (encrypted) messages that can't be understood by an enemy. Many forms of encryption use an encryption key - a set of letters or a number that can be used with an encryption method to turn readable plain text into unreadable ciphertext. Or vice versa.
In the late 20th century, new forms of cryptography were invented that used mathematically related pairs of numbers as private and public keys such that the public key could be used to decrypt a ciphertext that had been encrypted using a private key (and usually, vice versa). At the same time, the idea of a digital signature was created. By checking the signature a general could be sure that the order to "nuke Baltimore" came from the president and not from the enemy.
The Bitcoin network doesn't use encryption but it does take from cryptography the idea and methods of digital signatures - and hence it uses the mathematical methods of creating and using public and private keys that are required for digital signatures.

Is this a transaction?

No.
Your image shows a data structure in JSON text format.
That JSON text isn't what I would expect to find in a wallet.dat file produced by Bitcoin core. It might be something produced by a wallet reading tool of some sort.
That JSON  appears to show data relating to an address. Some of that sort of address data can be found as part of a transaction but what you show isn't a description of a transaction.

(later comment by question author mentioned the use of decodescript in Bitcoin-core)

Decodescript

decodescript takes a hex-encoded script and produces a JSON "decoding" of it. Note that the "decoding" is not "decryption", it isn't anything to do with encryption. It is trying to make a more easily understood description of the Bitcoin script that you gave it in Hexadecimal form.
A Bitcoin script is the part of a transaction that specifies how someone can prove they are entitled to spend one of the output amounts of a transaction.
A script consists of operators (instructions) and data items. Things like OP_DUP are an operator that says to duplicate the top item on the stack. There are a small number of operators. There are standard scripts that use those operators in specific ways.
When you spend the bitcoin amount (the unspent transaction output or UTXO amount), you create an unconfirmed transaction that includes the input data needed by that script. Typically that input data includes a digital signature. Your wallet software will take care of this for you. See signrawtransactionwithkey

Wallet contents
A good source of information about the contents of a wallet.dat produced by Bitcoin-core is an answer to dumpwallet output documentation & explanation?
I summarise that as

Extended Master Private Key
List of derived Private Keys

List of Addresses

To fully understand wallet.dat, you'd also need to understand the storage format used - which is a kind of database structure. This Q&A website has answers to other questions that cover this.
Bitcoin Addresses
Bitcoin addresses are a presentation abstract of a bitcoin script. However the addresses themselves don't really appear in Bitcoin transactions as transmitted, only the bitcoin script they represent. So strictly speaking, we could say that addresses are not present in Bitcoin transactions. Saying that transactions contain addresses is a sort of convenient shorthand to try to make things easier for beginners to understand what they are doing.
For a particular type of Bitcoin script, popularly used over many years, such as P2SH, the Bitcoin address is formed from information including the public-key of a key-pair.
For some other types of Bitcoin script present in transactions in the blockchain, there is no standard way to form a  Bitcoin address.
Since an HD wallet like Bitcoin core creates a large number of key-pairs in advance, its wallet.dat will contain many unused key-pairs and hence contain many unused addresses.

Specifically, it's a JSON dump with information about an address, not a transaction.

Well. I will explain a bit more. I ran bitcoin core, downloaded the blockchain, changed the wallet.dat and rescan. Found some receiving adresses. Validateadress of some of them and checked with decodescript. Actually this is one of the decoscript i have seen. Some of them shows op_dup op_hash160....op_equal op_checksig (reqsig:1) and some only op_hash160....op_equal (reqsig:1) What is that means? Do they need to be signed or something like that? Sorry if i ask too much but im really newbie and have 0 experience and 0 knowledge in cryptography

Apart of that. The wallet is not encrypted at all. It doesnt have a password

@Kazuhiko: see updated answer.

Just to reiterate: it is telling you information about an address your wallet has. It has nothing to do with transactions, or coins you might have. It's just information about an address which your wallet would be able to receive coins on.

@PieterWuille: Thanks for the feedback (whether to me or OP) I have updated the answer in an attempt to incorporate the point made in your comments. My understanding of this area isn't as complete as I would like (obvs), so any edits or further helpful commentary would be appreciated.

Thank you for the help. One last question please. The first adress startin with 1 show ismine,the third address and 4th ( bc1...and psh2-segwit) also shows ismine. But the one in the middle p2sh 37tsb... its shows that its not mine. What it could be? I apreciate your comments

@Kazuhiko What are you trying to achieve?

@Kazuhiko: The documentation I linked for decodescript says "address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)" -- reading Redeem script. script hash, witness script and witness program might clarify this further for you.


text:
Lightning Network Channels - Should we have 1 channel or 2 channels per peer?
In short I just wanted to ask for clarification, is it optimal to open two channels with each peer e.g,

Or it is better to have one channel e.g,

I look forward to your advice/response.
Sincerely,

Optimality is a very strong word and in general it is very hard to make statements about optimality without properly defining what one is optimizing for and conducting a rigerous analysis.
However I can give you a few things to consider when addressing the question. Recent research has showed that larger channels have a higher liklihood to sucessfully route payments on the Lightning Network which is one reason why one might want to use one large channel instead of two channels.
On the other hand one might want to increase the overall capacity with a peer. Since splicing is not implemented yet it seems cheaper to just open an additional channel instead of closing and opening the channel in particular if one considers the downtime of the channel while being closed.
Another thing to consider are the HTLCs limits and congestions considereations which currently do not seem to be a problem but might very well be in the future. Having two parallel channels will allow more concurrent HTLCs between the two peers in comparison to a single channel and could this be considered like a parallel street.
Also there might be things with respect to privacy and protection from balance probing. As far as I know nodes with parallel channels will opt to forward and htlc that was designated for one channel through the other one if they see fit. This might help nodes to protect their channel balance better from probing attacks though I personally think that JIT-routing is the better mitigation.

Noted Rene,
I will continue reading the references you have shared, but, it seems like there are Pros and Cons on setting up both ways.  I will be also checking the work you, Andreas, and Olaoluwa are putting together, Mastering the Lightning Network. Peace!


text:
How does a node know if there are two conflicting blockchains?
I am curious to know how a node first knows if there are conflicting blockchains, I'm assuming, when two miners send a node a valid block, the node accepts the one it received first, and restores the second one in a cache. When new miners broadcasts blocks, and its previous hashes match the one in the cache, and it is the longer blockchain, it updates the blockchain to contain the new blocks.
Also, is it possible for a miner to send a blockchain instead of a block to be validated, if so, how does the node check if the transactions verified, does it only check the blockchain and the mempool to see if the transactions exist?

how a node first knows if there are conflicting blockchains,

It receives two or more blocks each containing a pointer (block ID) to the same previous block.

it is the longer blockchain

Loosely speaking yes. In fact it is the chain with the most accumulated work. A long chain with low difficulty levels won't replace a shorter chain with higher difficulty levels.

, is it possible for a miner to send a blockchain instead of a block

No, the network protocol has no message type for that

how does the node check if the transactions verified

Nodes don't ever trust miners. Never. Nodes do all the validating themselves. Nodes don't use miners as a validating service. The only function of miners is choosing an order (sequence) for transactions.
The number of confirmations (not validations) of a transaction is simply the position of a transaction in the sequence. A transaction in the 19th block from the top has 19 confirmations.

Everything described above, verification, confirmations, mining, nodes, blockchain fork and fork resolution would work just the same if Bitcoin blocks contained photos of cats instead of transactions. Nodes don't need a miner to tell them a photo of Pluto is not a picture of a cat, they can see that for themselves. They don't need a miner to tell them they have already seen a particular photo, they can check that themselves.

Bitcoin has the longest chain rule as one of its consensus rule. Which means that the node should accept and extend the longest valid chain. If there are miners validating blocks that extend the same "longest chain" than a fork happens. you end up with multiple blockchains for a temporary amount of time. To resolve this miners will mine on whatever chain they believe is valid and eventually one will be larger than the others and is declared the canonical chain.
Basically whichever chain ends up longer first wins.
Nodes on shorter chains disregard them and switch over to referencing the longer chain as the source of truth
Miners dont send entire blockchains for validations as a response for your second q.

https://braiins.com/blog/bitcoin-chain-splits-explained-temporary-forks

Check the above article out


text:
Do nodes maintain a download window after the initial syncing?
I was going through the Bitcoin P2P guide. https://developer.bitcoin.org/devguide/p2p_network.html
It says that the nodes maintain a 1024-block download window during the initial syncing. However, at any time a node can parallel download only 128 blocks.

Suppose the current window starts from Block 100 to Block 1123. If Block 100 is not downloaded yet (may be because of faulty peers) but the rest 1023 blocks are downloaded. What happens? Will the node wait until it finishes downloading Block 100? Or will it start parallel downloads from Block 1124?

What happens after the initial syncing is finished. Do the nodes still maintain a download window?

This is a network policy used in Bitcoin Core, could be changed in future releases in response to network observations, and isn't universally implemented in all node software. Nodes may synchronize in different ways. Before Bitcoin Core's 0.10 release, a completely different mechanism was used.
But to answer your question:

If all blocks in a window are downloaded, except for a number of outstanding requests from one peer, and this situation persists for some time (a few seconds, I believe), that peer will be disconnected.

Yes and no. After IBD, an additional mechanism is enabled: blocks are requested immediately in response to incoming announcements, under certain conditions. As a fallback, for example when a large reorg happens, the parallel download logic may still trigger.


text:
Choosing main chain based on difficulty
If a node observes a fork in the bitcoin chain, then the node will choose the chain that has the highest difficulty (sum of difficulty in each block of the chain).
But the difficulty changes only once every 2016 blocks. So, if a fork occurs somewhere in between, then the difficulty is the same for both the side chains right? How does the node pick the main chain then? Just randomly?

It only considers valid chains. If either chain has an invalid block in it, it is excluded from consideration.
If the chainwork (sum of the inverses of the targets of the blocks in the chain, approximately proportional to the sum of the difficulties) differs,  chains with less than the maximum chainwork are excluded from consideration.
If there are still multiple candidates, the one whose full block data of the tip was received first is considered active.

Thanks a lot for the wonderful answer. Suppose a node receives a block and observes there's a fork. The node determines the main chain as per the above logic. After that, will the node propagate the blocks in the non-main chain to its peers?

No, it won't. Only the active chain is relayed.


text:
Blockcypher new transaction request returning more than input and output
I am new to Bitcoin and Blockchain, and Blockcypher..
I am trying to use Blockcypher APIs to create (and sign) and send a transaction (on testnet). The request i provide has 1 input and 1 output, but the response i receive has 2 inputs/outputs/tosign 50% of the time.. Why would this be? Thanks
Sample Request:
Posting to https://api.blockcypher.com/v1/btc/test3/txs/new?token=XXXXXXXX
{
    "double_spend": false,
    "inputs": [{
        "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"]
    }],
    "outputs": [{
        "value": 2,
        "addresses": ["tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"]
    }]
}

Response:
{
    "tx": {
        "hash": "b520ccb4b9ab96075c3cf1a91b0c7710a22332f0bb4d25409bcf9693a35477dd",
        "block_height": -1,
        "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD", "tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"],
        "total": 55000,
        "fees": 30000,
        "relayed_by": "35.226.46.118",
        "received": "2021-07-22T10:19:47.853381661Z",
        "ver": 1,
        "vin_sz": 2,
        "vout_sz": 2,
        "confirmations": 0,
        "preference": "high",
        "double_spend": false,
        "inputs": [{
            "prev_hash": "34e749b34cc75b996e7b28638cc4648958942b046bf9961837af7ab0046e53d1",
            "output_index": 0,
            "output_value": 10000,
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }, {
            "prev_hash": "106ad632e2474e683b2180181c1b911bc4d5727db5ab341ee8aded3b78fb2da7",
            "output_index": 1,
            "output_value": 75000,
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }],
        "outputs": [{
            "value": 2,
            "script": "00144e537472b30a412b474cd6b20b6b397a216ef94f",
            "addresses": ["tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"],
            "script_type": "pay-to-witness-pubkey-hash"
        }, {
            "value": 54998,
            "script": "76a91471b6e0ce39475cbe5cd43966f5c7eb80a886952088ac",
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }]
    },
    "tosign": ["c0859bbf0f964af14c01d9ff2da9e5254279d02c5c75c902e3a8180db6bb67e5", "91a6c5b3003047c0af81348f12867918ebc4efd70f3ff1a5ee9e4566bf361de8"],
    "signatures": [],
    "pubkeys": []
}

Thanks

Without actually studying your data, it seems to me that as Its possible for an address to have multiple UTXOs and for a transaction amount to require using two of those, the second output would be change -- does this make sense to you?

Nope :) Not really, but there a few things for me to go on there thanks. What would be great to understand in short term is if this response is valid (sure it is) and that i can proceed with signing.

Also, if u had a min to look at data, that would REALLY help me. The only thing i can deduce, is that the second output has a value of 2, which maps to my requested value. Not sure what other amounts relate to. Thanks

Not sure what other amounts relate to.

    "total": 55000,

The amount being transferred to outputs in this transaction
    "fees": 30000,

The difference between total input amounts  and total output amounts.
Note that the above two values sum to 85000.
        "output_value": 10000,

An amount associated with one UTXO with the specified spending address
        "output_value": 75000,

An amount associated with a second UTXO with the specified spending address
Note that the above two values sum to 85000.
        "value": 2,

The amount you specified be sent to the destination address
        "value": 54998,

The remainder of the 55000 ("total", see above) being returned as change.

Thats fantastic!! Thanks for stepping thru that


text:
Is signrawtransactionwithkey secure?
is the node API signrawtransactionwithkey (as documented here https://developer.bitcoin.org/reference/rpc/index.html) secure or recommended? This API takes a private key, so i want to understand how that private key is handled by the node. Thanks!


text:
Could the threat of centralization be realized if a sufficiently large entity acquired enough Bitcoin?
This is primarily a hypothetical, but not an impossible one.
If a sufficiently large entity such as a massive company with a lot of cash or the U.S. Federal Reserve were to acquire more than half of the available Bitcoin, would it then become a more centralized type of currency given their control? Some alt coins start out like this, with a single entity owning the majority of the coins so that they can maintain centralized control. Bitcoin has always been against that type of centralization, but if one of these entities decided they wanted to gain centralized control, could they do that by taking the action of acquiring a majority of the coins in circulation?
If so what are the ramifications of that? How would we combat that? Is it a real danger or is my hypothetical a little too paranoid?

The bitcoin protocol does not grant someone with a large amount of BTC any explicit control or influence over the consensus operations of the network. If someone owned a majority of coins, it wouldn't really make any difference to the rest of the users.
However, there is a little bit of nuance here that wasn't explicitly addressed in @Prayank's (otherwise good) answer, in that an entity with a huge number of coins may have some amount of 'economic influence' over the outcome of a network fork. To explain:
A network fork describes an event where network participants (nodes) disagree on what the valid chain is (in this case, due to a disagreement upon what the consensus rules are/should be), resulting in a network split (with some number of nodes following each chain that is valid in their view). If the fork persists, then any user that owned coins pre-fork, will own coins on both chains post-fork.
This is the crucial point: if an entity owns a huge portion of coins, they may make a point of only adopting the post-fork chain that they prefer, while selling all of the coins on the post-fork chain that they don't prefer (and assumedly, using that money to buy more coins on the post-fork chain that they prefer). This action can push the price of the coins on each fork around, and that price action may influence other market participants to follow suit. Importantly though, note that owning a large number of coins grants the entity no extra influence over the ability to create a rule change / fork, it only allows them to push the price around, post-fork.
All that said, there is even further nuance to the situation, and the game theoretical reasoning around most of it is messy at best. For example, the relative proportion of miners that are pointing hashpower at each post-fork chain is relevant to the conversation (it doesn't matter how much the entity holding a majority of coins wants to push their fork, if no miners are supporting it!). There is also a consideration of soft-fork vs hard-fork (it is perhaps 'easier' to push a soft-forking change, as legacy nodes will still follow the same chain - though again miner participation is again a large and relevant variable that will decide whether or not the network segments).
To further complicate things, there is no way to reliably predict this 'economic influence' over the outcome of a fork in consensus, it is at best only measurable in real-time as it plays out on the free market.

To note, this exact sort of situation played out in ~2016-2017, as a large number of prominent businesses and miners pushed to change the consensus rules to their liking. Despite claiming to be an 'economic majority', these entities found themselves unable to force any changes upon the network, and ultimately their goal (naively raising the block size via a hard fork) failed.
Perhaps the lesson to be learned is that the incentives for network participants to stay in consensus are quite large, and thus not even a rich entity can force other participants to change the rules against their will.

A final note: the issues described above may become worth worrying about if one entity controls a huge majority of coins. For example, consider what the situation might be if one entity (or just a few colluding entities) were in control of >90% of all coins. In that case, it may be more reasonable to worry about their ability to unjustly influence a consensus rule change on the network. However, if one entity obtained that much BTC, then I think there would be other issues that would come up sooner. Assuming that the entity controlling the coins is a custodian for a huge number of users (which seems more likely than one entity actually owning a vast majority of the world's wealth), then it is absolutely relevant to worry about the potential censorship (and privacy) of that entity's depositors, as well as the authenticity of the funds (ie, is this entity only holding a fractional reserve of user funds?).
But this is an extreme situation that seems unlikely to be realized, especially if network participants are aware of the risks, and build out the bitcoin economy/infrastructure in a way that seeks to avoid this (seemingly unlikely) risk.

I think this answer should be voted/atleast mentioned in the accepted answerer. Trivially, if an entity owns all 21 mil bitcoin they can set whatever rules they want.

Ethereum, which is going to use Proof Of Stake, would be under danger.
Bitcoin uses proof of work, which means there is danger if the majority of the hashpower is controlled by a single entity/cartel. This is much harder for governments to hijack, because there is very high demand for new energy-efficient Bitcoin miners. The government would be at loss if they used older miners


text:
Why is there still a lack of Bitmain chips for miners?
All of the ASIC miner producers still claim that there are not enough chips for miners to produce anything.
But if China is allegedly fully back to normal and has been for some time, why is there still a lack of Bitmain ASICs for miners?

According to a Bloomberg article

That explosion in demand—unexpectedly goosed during the Covid-19 pandemic for certain industries like smartphones and PCs—has caused a near-term supply shock triggering an unprecedented global shortage.

...

The crunch has sideswiped the General Motors and Volkswagens of the world and swung politicians from Washington to Beijing into crisis control. It’s also catapulted Taiwan Semiconductor Manufacturing Co. and Samsung Electronics Co. to the top of investor and government agendas. Asia’s two largest chipmakers are responsible for making the vast majority of the world’s most advanced silicon, yet don’t have the capacity to sate all demand. It’s a bottleneck that could last several quarters—or into next year.

So there is unprecedented global demand on chip fabs. Those businesses are doubtless prioritizing their largest customers and their biggest selling products. ICs used by relatively low volume manufacturers like Bitmain might be a long way down on the list.

I just knew this just in time manufacturing wasn't going to work out.


text:
Solo mining: Stratum from pool 0 detected new block at height
I'm using ckpool which is a solo Bitcoin "pool". If I see this message
"Stratum from pool 0 detected new block at height"

what does that mean in the context of a solo pool?
In addition, what is the significance of a "share" in a solo pool?

"Stratum from pool 0 detected new block at height"

The first stratum server you are connected to updated its work to match the state of the rest of the network. That is, someone else found a block and you switched to mining on top of it.

In addition, what is the significance of a "share" in a solo pool?

It has no meaning at all.


text:
How would I ever know if my solo miner found a block?
I've tried solo mining in two ways:

using cgminer, ASIC and ckpool
using minerd connected to my own instance of bitcoin-qt.

Either way, I've never seen any indicator showing that I have mined 0 BTC, let alone > 0. What would it look like if I did beat the odds and mine some BTC?

cgi miner shows
A:   The number of Accepted shares
R:   The number of Rejected shares

minerd reports yay or boo. see What do `minerd`s feedback messages (LONGPOLL, yay, boo) mean?

You could try solo mining another SHA256 PoW coin with a much lower difficulty factor, just to see what it looks like when your setup does solve a block and it's accepted by the other nodes in the network.
A couple of low difficulty SHA56 PoW coins to try:

Deutsche eMark (DEM) has a current difficulty factor of 2844931
(https://github.com/emarkproject addnode=5.9.141.86 )
FireFly Coin (FFC) has a current difficulty factor of 0.00186396
(https://bitcointalk.org/index.php?topic=318589.0.
addnode=91.206.16.214)

When your mining software (e.g., cgminer, minerd) successfully mines a new block or discovers a share, it should display some information indicating your mining success. You would typically see details such as the block height, block reward, and your share of the reward (if using a pool).
ransaction in Your Wallet:** If you are using Bitcoin Core (bitcoin-qt) as your wallet and mining software, a mined block's reward would be added to your wallet as a transaction. You can check your wallet's transaction history to see if any BTC has been successfully mined and added to your balance. Keep in mind that successfully mining a block alone (solo mining) is exceedingly rare, and it could take an incredibly long time to achieve.


text:
How to create a Crypto wallet for a start up(Bitcoin and Ethereum)?
I have beginner skills as Full stack Developer and am looking to help developing a crypto wallet with a small start up. The idea is to create a wallet that will store our users cryptocurrencies (with a function to send it to a different users or institution). Have you used a specific library and can you recommend one?

I have beginner skills as Full stack Developer and am looking to help developing a crypto wallet with a small start up.

Building a wallet from scratch is a major endeavor and fraught with security responsibilities. I'd recommend that you instead use an existing wallet or service. You will probably find that getting a small startup off the ground will keep you adequately busy, even if you "only" integrate an existing wallet into your user experience.

Bitcoinj is a java bitcoin library that has a wallet class that can be used by any JVM compatible language. Web3.js can be used for Ethereum. I have used both but not for any application done for the mainnet.

You can do it and build one like this https://codeamigo.dev/lessons/preview/53


text:
Regtest mode lose blocks?
I'm playing with bitcoind, I'm an started in this subject and I'm playing with the regtest=1 option of course.
The thing is that after one day all the transactions are lost, I'm trying to get the balance of some wallets and it's always 0.
Is this something related to the regtest mode? has someone had the same issue? If I restart bitcoind again everything is working as expected but is annoying since I have to create a lot of transactions again.

I'm getting a balance of 0. Also I can not fetch old transactions, this is happening after running regtest mode for a week (more o less)

I see the same issue using bitcoind 0.21.1

The same here for 0.25. Any solution?


text:
Is there a tool like Ethereum EVM at present for Bitcoin script?
Is there a tool like Ethereum EVM at present? Users can write bitcoin scripts in a syntax just like python(or like other programming language); through this tool, they can be translated into bitcoin original scripts; it sounds like a new programming language has been invented.
In my opinion， Bitcoin script programming is based on reverse Polish expression; this is not friendly to programmers;
In fact, Bitcoin's opcode expression ability is very rich, and it may be unfriendly, which has affected the promotion of Bitcoin in the technical community.

@Prayank  sorry sir, Maybe I misled you by using EVM; indeed, what I want to know is whether there is a bitcoin script compiler that allows programmers to write scripts in a high-level language programming mode; this question may be more appropriate;

As Murch says below, check out Miniscript (encoding of Script), Policy or Minsc for a higher level language for writing scripts. Best resource on Miniscript and Policy is http://bitcoin.sipa.be/miniscript/. Best resource on Minsc is https://min.sc/

@MichaelFolkson  AGREE about best resource points.

FYI, EVM is also reverse Polish notation, although there exist compilers from higher-level languages. The same is possible in principle for bitcoin script, although by design, only a very restricted subset of the things that are possible with EVM are possible with bitcoin script.

@MichaelFolkson Thanks for your reply. If I use miniscript, how to compile miniscript to bitcoin OP_CODE script? I don't find a compiler to do this.

The easiest way is to put the Miniscript in the Analyze a Miniscript section of http://bitcoin.sipa.be/miniscript/ and then press the Analyze button. That's useful for learning. But Miniscript is just an encoding of Script there is no compiling between Miniscript and Script. You'd need to use the C++ or Rust encoding/decoding code to convert Miniscript to Script in a software project. Or if you use Policy, that compiles to Miniscript and there is compiler code in the C++ and Rust implementations.

See https://bitcoin.stackexchange.com/questions/91565/what-does-bitcoin-policy-language-offer-the-developer-that-miniscript-doesnt-w for more details

People creating smart contracts on a cryptocurrency network are designing cryptographic protocols—frankly, it might be a good thing if not every JavaScript programmer takes a go at that. Bitcoin does not have a virtual machine, but there are Miniscript, Minsc, or Sapio as higher level languages that translate to script. Additionally, there is an on-going development effort with Simplicity as a language specifically engineered to express smart contracts with provable outcomes.
And if you insist on EVM, check out RSK.


text:
How to earn benefit for bitcoin core developer?
Will there be any benefits if we directly provide core source code development for bitcoin? I like Bitcoin very much and I hope to join this community and at the same time have income to subsidize my family.

There are such jobs:

https://blockstream.com/careers/
https://chaincode.com/jobs

these companies work with or around the Bitcoin Core code.
You might also find some companies willing to hire you for introducing backdoors.

@Prayank Isn't it likely for NSA to hire those who know Bitcoin's code well and who can inentionally write use-after-free and buffer-overflow vulnerable code? Especially parsers. Who knows, maybe someone creates a script-address format proposal that needs parsing and unless the Core team writes it in Rust, it would be likely for them to add those backdoors unintentionally.

@Prayank The same can be said about Linux but it happened https://news.ycombinator.com/item?id=26887670

Both modern C++ and Rust make it easy to write code without buffer overflows or use-after-free bugs. To the best of my knowledge, there has never been any of those in the Bitcoin/Bitcoin Core source code (excluding dependencies like miniupnpc). I think focusing on those when being concerned about intentional damage are a distraction.


text:
What are the ways to obtain public key of a wallet with no outputs
I was wondering if there is a way to obtain public key of a public address where the address does not have any output transaction

Are you looking for the public key to your own address or someone else's?

I'm looking for the public key of the btc puzzle

I assume that you are talking about a Pay to Public Key Hash (P2PKH) address.
Cryptographic hash functions have the pre-image resistance property:

Given a hash value h, it should be difficult to find a message m for which h = hash(m).

P2PKH addresses encode a locking script that commits funds to the hash of a public key. Given that the address only provides the hash, it is not possible to guess the public key from the address as that would require breaking the pre-image resistance property of RIPEMD-160.

So it is not possible to get the public key?

No, you cannot learn the original value if you only have a hash.


text:
how are new bitcoins created
I have read that new bitcoins are generated by a competitive and decentralized process called "mining" i want to know how the first coin was generated? From where is it genrated? Mining is just a prosses of authenticating a transaction right? From where do the new coins come from?

Go to a blockchain explorer like https://mempool.space/, pick any block and at the top of the list of transactions you will see what's called a "coinbase transaction" that creates new bitcoins and pays them out as a reward to the miner of the block. All bitcoins were originally created this way.


text:
How many SHA256 hashes can a single thread compute?
ASICs use many threads to compute SHA256 hash functions in parallel.
At the time of this post, Antminer S19 can compute 110TH/s.
How many SHA256 hash functions per thread can the best SHA256 ASIC compute?
I would like to know the maximum number of iterative hashes per second, i.e.,
SHA256^N(s) = SHA256(SHA256(....(SHA256(s)))) that can be computed on the best hardware.

There's no "threads" in an ASIC, and bitcoin miners don't compute SHA256 at all, they do partial fragments of the end of one, and the start of another, never the whole thing.

Also Bitcoin mining does not involve iterated hashing, so ASICs are almost certainly incapable of that.


text:
Is there an up-to-date and viable rust implementation of Bitcoin?
I saw 2 rust implementations of Bitcoin.
Parity Bitcoin: https://github.com/paritytech/parity-bitcoin
Rust-Bitcoin: https://github.com/apoelstra/rust-bitcoin
They are not updated for some time now.
Are there any other up-to-date and viable rust implementations?

https://github.com/rust-bitcoin/rust-bitcoin looks actively developed.

Parity bitcoin has last commit on Aug 24, 2020.
Rust bitcoin has last commit on Oct 12, 2018.    I believe there are changes in Bitcoin after that right?

I'm not sure what you're looking at but (a) rust-bitcoin had a commit (and a release!) yesterday and (b) "changes in Bitcoin" isn't very well-defined; in general, just because some changes are implemented in one piece of software doesn't mean they need to be incorporated everywhere. Almost everything is opt-in, so if you don't make use of a feature, you generally don't care about it (this is true for consensus changes, p2p protocol changes, wallet standards, ...).

Oh, you're looking at apoelstra's fork whose master branch is outdated. That's not the right place to look; use the project repository https://github.com/rust-bitcoin/rust-bitcoin

This should probably be in https://github.com/igorbarinov/awesome-bitcoin or https://en.bitcoin.it/wiki/Software rather than here.


text:
Pseudocode for Bitcoin's P2P block propagation
I am going through Bitcoin's block propagation method at https://developer.bitcoin.org/devguide/p2p_network.html
Are you aware of any pseudocode available on how blocks are propagated during the initial syncing and when new blocks are generated? It would be nice to understand all the checks that happen in P2P layer.


text:
What happens if a peer doesn't respond to "getheaders" or "getdata" on time?
Suppose a node receives the same "inv" message from many peers.

Will the node send "getheaders" requests to all the peers or only one of them?

Does the node keep a timer for getting the "headers" response from the peers? How big
is the timer?

Suppose the node sends "getheaders" requests to only one of its peers and the timer expires. How many other peers does the node then send "getheaders" requests to? Does the node store a map data structure map<"inv", peer id from which the inv is received> to do this?

Are you asking about Bitcoin Core (and which version?), or nodes in general? This is all local policy that each node/implementation can decide for itself.

@PieterWuille I'm asking about how Bitcoin Core (the latest version) implements it, and if there is a general node policy laid out somewhere that many implementations use.

During IBD, Bitcoin Core will only send getheaders to one peer. After IBD, it will send it to all on connection.
15 minutes. After that it will disconnect the peer if nothing is received.
As after timeout peers get disconnected, that opens up the slot for "headers requesting peer" to go to another one.

Interesting. Isn't 15 minutes a pretty large timeout to wait? The node waits only for 2 seconds for receiving a response from "getdata", and disconnects the peer if it didn't send "block" within 2 seconds right?

What about "getdata" message? Does the node send "getdata" to all the peers that sent the corresponding "headers" or only one of them?

Bitcoin Core never requests the same block or transaction twice from the same peer. They all have timeouts that are tracked, and reassigned when the timeout expires.

Got it. I understand that after IBD, if a node gets the same "inv" message from 5 peers, then the node sends the same "getheaders" request to all 5 peers. It makes sense as "getheaders" and "headers" are pretty small messages and don't add too much communication.   Suppose the node gets the same "headers" from 5 peers. Will the node send "getdata" request to all 5 peers? Or will the node send "getdata" request to one peer, wait until the timer expires, and then send "getdata" to another peer?

Sorry, I meant to say: Bitcoin Core never requests the same transaction/block twice simultaneously, even from distinct peers. The existing request has to time out before it is asked elsewhere.

That's perfect :) Is the timeout for "getdata" also 15 minutes?

For transactions it is 2 minutes, but we don't disconnect on on timeout; just mark the peer as not having that tx, and asking another. For blocks I don't remember the details. You can look in https://github.com/bitcoin/bitcoin/tree/master/src/txrequest.h for some of the design choices for tx requesting. The block fetching code is spread out over a few places in net_processing.cpp.


text:
How do full nodes get the information about stale blocks?
In Bitcoin, many forks occur when multiple miners mine blocks at the same time. Then there will be multiple blocks at the same block height.
I was looking at the Bitcoin P2P developer guide at https://developer.bitcoin.org/devguide/p2p_network.html
For propagating blocks, a relay sends an "inv" message to its peers. The peers request header info with "getheaders" and relay responds with "headers" message. Then the peers request block info with "getdata" and relay responds with "block" message.
In this case, how can peers be assured of getting multiple blocks at the same block height? A relay could deliberately propagate "inv" and "headers" messages for only one of the blocks at the same block height.
How can peers even know that a fork happened? Is getting the information about the fork the responsibility of the relay or the peer?

A security assumption is that nodes are connected to at least one honest peer. If all of their peers are malicious, is is perfectly feasible for them to withhold information about certain blocks or transactions from a victim. Look up eclipse attacks, if you want to know more about this style of attacks, or the mitigations that exist against them.

So, is an honest relay expected to send headers for both the side chains in the "inv" and "headers" message?      If multiple relays send "inv" message to a node, will the node send "getheaders" message to each one of them and compare? Or will the node send "getheaders" message to only one of the relays?

Assuming at least one of the relays is honest, what checks/mechanism does the node use to ensure it has a complete view?

There is no such thing as a "complete view". Every node independently decides which block it considers to be the currently active one based on the information they have, and honest nodes will relay this information to their peers. Nodes only know about stale blocks because at the time they were relayed, from the perspective of the relayer, they weren't stale.

Thank you, Pieter :) Please let me know if this is right. Suppose a node is connected to 8 peers. Each of the (honest) peers that has a new block sends "inv" message to the node "if the peer considers this block will be part of the main chain". The node responds with "getheaders" message to "all the peers" that sent "inv" message. Whenever a peer returns a header, the node requests for "getdata" to the same peer. If the node doesn't get the "block" within 2 seconds, the node picks another peer that sent the same header and requests "getdata" from it.

Is there any (somewhat) formal specification of the required assumptions of the Bitcoin block propagation to work? Eg: What does "honest" peer mean here? What information is an "honest" peer required to propagate, and what is optional?   I'm trying to integrate Bitcoin with another blockchain. Knowing formal assumptions is kinda important.

Is there any pseudocode somewhere for how the nodes work when propagating blocks?

There cannot be a formal specification of the Bitcoin protocol, because there is no authority that can decide one. The rules of the network are defined by what people run, unsatisfying as that may be. Imagine we write a document and somehow bless it to be the Bitcoin protocol specification. And now someone finds a discrepancy between that document and the node software actually running on the network. Absent an authority that can force everyone to download new software, the only conclusion is that the document is wrong, and needs to be fixed.

There is of course documentation, where people describe the rules (rather than prescribe) them. Some of it can be found on the https://bitcoin.it wiki (though a lot there is outdated) and https://developer.bitcoin.org/. Most significant changes that affect interaction between different implementations are first proposed as BIPs (https://github.com/bitcoin/bips), but a lot more client-specific policy like relay behavior is simply in the client's respective source codes.


text:
Unable to use UNIX timestamp for locktime on testnet
I am trying to create a timelock transaction, but I am unable to use a UNIX timestamp on testnet. However, if I use a block height the transaction works.
When I use a block height that is in the future and broadcast the transaction, I get:
sendrawtransaction RPC error: {"code":-26,"message":"non-final"}
When the block height is reached, the transaction goes through as expected.
When I make the locktime above 500,000,000 I get a different message:
"non-mandatory-script-verify-flag (Locktime requirement not satisfied)"
I have tried several different random timestamps from various years (2013, 2020) and I get the same error message. If I make the transaction with a large locktime like 400,000,000 I get the expected "non-final" message. It only happens when I go over the 500,000,000 minimum.
I have decoded both transactions, and the only noticable difference is the locktime.
Here is the raw transaction with the UNIX timestamp from 2013:
0200000001ab306f83a06f006f76695f0911fbe095d2443798f232e91e7a78e8bbf2050ec40000000088483045022100c381bfb9de6930ecb45cf2cc13581aca8c42e9f570615cabf1a631fbf137270b022026636856bbf250d169f7608abe1ab4fcba13c495ffa27ee4e821d38d626365ab012103803a5bbbe00dad7dbb29dd5f4d7883ac049bad52d78b456cda12591e26ae70241c00b17576a91450840658811828e04f5501bf3fe87f012d297bdd88acfeffffff01e4250000000000001976a914f005b469eb92525da0294247b5d0ae169efd78f588ac2e377452
Here is the raw transaction with block height:
0200000001ab306f83a06f006f76695f0911fbe095d2443798f232e91e7a78e8bbf2050ec40000000087473044022011704ab11cf526e656aaf681c9ab2c3002fd8a3982383afcad8ec46af68f099d022061c06671dcc7cf6e192c541b4692a809ea97711ed2866c004780054028cc5237012103803a5bbbe00dad7dbb29dd5f4d7883ac049bad52d78b456cda12591e26ae70241c00b17576a91450840658811828e04f5501bf3fe87f012d297bdd88acfeffffff01e4250000000000001976a914f005b469eb92525da0294247b5d0ae169efd78f588acfbb22400

The input to your transaction has a script that uses OP_CHECKLOCKTIMEVERIFY. This opcode takes the item at the top of the stack and compares its value to the locktime given in the transaction. However, because the locktime can be either a height or a timestamp, it also checks that the comparison is comparing two heights or two timestamps, not both. So it applies the same height and timestamp mode switching rules.
If you we look at the redeemScript in more detail, we find that it pushes a 0 before the OP_CHECKLOCKTIMEVERIFY, so 0 is the locktime to compare against. Since 0 is less than 500,000,000, this value is interpreted as a height locktime of 0. However your transactions locktime is greater than the threshold, so it is interpreted as a timestamp. Since height and timestamp cannot be compared, the script interpreter throws an error here and causes the transaction to be invalid. Thus the only way to use this script is to use exclusively height based locktimes.

Thank you so much! I’ve been hacking at this for days. I found the problem in my code.


text:
Why in crypto casinos payment is mainly in bitcoin?
Why in crypto casinos payment is mainly in bitcoin, ethereum, tron and other cryptocurrencies, but there is no payment in stablecoins? Isn't it more profitable to accept payments in usdt, usdc, busd? So you will not be afraid because of the fall in the rate of cryptocurrencies


text:
bitcoind getinfo or getbalance freeze
I am a bitcoin newbie. I am testing solo mining (I know it is not financial feasible in general). I installed bitcoind on Debian and it ran okay as far as I could tell. I've experienced a couple of problems. The size of the bitcoin data directory is still growing when I use:
du -ks .bitcoin/

I ran
./bitcoind getinfo

and got information like this:
{
    "version" : 80600,
    "protocolversion" : 70001,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 225436,
    "timeoffset" : 0,
    "connections" : 9,
    "proxy" : "",
    "difficulty" : 4367876.00084220,
    "testnet" : false,
    "keypoololdest" : 1389424771,
    "keypoolsize" : 103,
    "paytxfee" : 0.00000000,
    "errors" : ""
}

When I ran
./bitcoind getbalance

I got 0.000000000
The problem is sometime,
./bitcoind getinfo

simply freeze and I have to use Ctrl-c to kill it.
Another problem is I cannot connect to bitcoind using
./minerd --url http://127.0.0.1:8332 --userpass username:password

The result I got is:
[2014-01-12 20:54:03] Binding thread 0 to cpu 0
[2014-01-12 20:54:04] Binding thread 1 to cpu 1
[2014-01-12 20:54:05] 2 miner threads started, using SHA256 'c' algorithm.
[2014-01-12 21:01:36] HTTP request failed: The requested URL returned error: 500
[2014-01-12 21:01:36] json_rpc_call failed, retry after 30 seconds
[2014-01-12 21:02:15] HTTP request failed: The requested URL returned error: 500
[2014-01-12 21:02:15] json_rpc_call failed, retry after 30 seconds
[2014-01-12 21:02:56] HTTP request failed: The requested URL returned error: 500
[2014-01-12 21:02:56] json_rpc_call failed, retry after 30 seconds
[2014-01-12 21:03:35] HTTP request failed: The requested URL returned error: 500
[2014-01-12 21:03:35] json_rpc_call failed, retry after 30 seconds

Again, I had to use Ctrl-c.
Any information is appreciated.

Usually this type of conf file works :
server=1
daemon=1
rpcuser=any_username
rpcpassword=any_password

if not then allow ip 127.0.0.1 in bitcoin.conf
rpcusername=your_usename
rpcpassword=your_password
allowip=127.0.0.1
allowport=8332

This may help, you may also try allowing ip 0.0.0.0 if both of the above does not works

Good advice and the likely answer, it should be noted that allowip need not be set for localhost or 127.0.0.1 (as it is allowed by default)

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


text:
Can a signed raw transaction's locktime be changed?
If I create a signed raw transaction with a locktime in the future, and give this raw transaction to somebody else, can they edit the locktime so that they recieve the bitcoin immediately?
For example, I have this signed raw transaction:
0200000001f27efa829294d2af440c9ddae788d07171253dc1142224d3512b8b4ae422b605000000008b47304402204f586d2d127e469f162fc0ac28b87ed8fca153b61aa3260ecb54d661b6f70a1202205cee581c013c2f89d2695522484f698d788bb940f722fb616368d64cfdf7b640012103803a5bbbe00dad7dbb29dd5f4d7883ac049bad52d78b456cda12591e26ae702420040165cd1db17576a91450840658811828e04f5501bf3fe87f012d297bdd88acfeffffff01e4250000000000001976a914f005b469eb92525da0294247b5d0ae169efd78f588ac40974a65
I have tried changing the ending to ...ac00000000 and that didn't work.
For the record, I am not trying to hack a bitcoin transaction to receive funds early. I'm just wondering if it is safe to give someone a raw transaction with a timelock.

A transaction's locktime is part of the data committed to by the transaction's signatures. If you change it, the signatures become invalid, and so the transaction becomes invalid.
If the locktime could be changed by anyone, it would be completely useless.

Thank you that is reassuring.


text:
A way to access all child addresses from HD wallet xpub
Is it possible to retrieve all the infinite addresses of a HD wallet from just its parent public key?

According to https://en.bitcoin.it/wiki/Deterministic_wallet

Master public key
Certain types of deterministic wallet (BIP0032, Armory, Coinkite and Coinb.in ) additionally allow for the complete separation of private and public key creation for greater security and convenience. In this model a server can be set up to only know the Master Public Key (MPK) of a particular deterministic wallet. This allows the server to create as many public keys as is necessary for receiving funds, but a compromise of the MPK will not allow an attacker to spend from the wallet.

So yes, if that is correct, with a BIP32 wallet you can create all the HD addresses from the master public key. The method is explained a little in BIP32.
There is a complication from choice of hardened or non-hardened keys etc. See ELI5: What's the difference between a child-key and a hardened child-key in BIP32


text:
how can I launch my blockchain through bitcoin-core?
How can you run your blockchain, not through regtest, but a real one

It provides no such feature.
Bitcoin Core is designed to interact with the Bitcoin blockchain and network, including some of its test chains/network (regtest, testnet, signet).

and how was the bitcoin network launched then?

@SlimThugs The Bitcoin network was launched by defining its rules in code and by people running that code. If you wanted to launch a different network, you would have to change the code, otherwise you'd just be joining the existing network.

and if you launch your bitcoin network , will it be possible to connect via bitcoin core by changing the sources ?

You can modify the source code, and distribute the source code, and if you do that right, all others that use the program may end up participating in a network that defines an alternative currency. But it won't be Bitcoin.

You are free to fork the code, with the only limitations described in COPYING.
After you do so, if that creates an alternative chain, then any troubles you have onwards are off topic in this site.


text:
What is lack of extension on a wallet?
I received this message below, is this an attempt to scam ?
Dear customer,
Your bitcoin transaction is awaiting for clearance on end-wallet.
The transaction could not be completed due to the lack of extension on the wallet.
For such transactions you need to pass through an additional check.
The transactionwill be confirmed and released automatically once the wallet is verified.
Note that the current clearance level is BTC 8.36601711
Current balance which is awaiting clearance BTC 9.78821802
Your wallet requires additional clearance BTC 1.42220091
TxID:
cd6654ddddfce0c14cdd2fb3ea201c108041346c0032a6a10513dc89893fd569
Regards
Support team
Coin-to

That message appears to be nonsense, so I am thinking it's a scam.

It is very obviously a scam. See the question I linked to.


text:
only synchronize the memory pool transaction by bitcoind daemon
I want to use bitcoind to only synchronize the memory pool transaction, and close the block synchronization; I am going to monitor the dynamics of the memory pool in real time; are there parameters that can help me do it with bitcoind?

It is not possible to only sync things in the mempool because the blockchain is needed in order to verify mempool transactions. Before transactions can be added to a node's mempool, they need to be validated. This requires knowing the UTXO set, and this can only be learned by also syncing the blockchain.


text:
how to decode cryptocurrency wallet with mnemonic phrases
I want to create multi-coin wallet on Golang language and I faced with issue about how decode wallet with mnemonic phrases.

how to decode cryptocurrency wallet with mnemonic phrases
I want to create multi-coin wallet on Golang language and I faced with issue about how decode wallet with mnemonic phrases.

The main use of mnemonic phrases in Bitcoin wallets is in BIP-39 Mnemonic code for generating deterministic keys but this has nothing to do with encoding of wallet data or with encryption of wallet data.
If you want to protect the privacy of wallet data, the normal approach is to use symmetric encryption (e.g. AES) of private keys using a wallet login-password as an encryption-key.
Golang has support for this in the standard crypto library, (e.g. import (crypto; crypto/aes; crypto/elliptic; crypto/ecdsa) etc).

Thanks for your answer. but you mean, when I create wallets for user I need to crypto their and save to database?

@user125261: Your question didn't mention creating wallets for users. I was answering "how to decode cryptocurrency wallet with mnemonic phrases"

oh, yea, sorry) But anyway Thanks for help :)


text:
How can I get RawTX transactions?
I used to be able to get RawTX transactions on the Blockchain using the link:
https://blockchain.info/tx/60183ab915f2f4b0190605f98bd0e9f8eafe13a1c902b3ae87ecd0dfc8a599a0?format=hex
But the site switched to another domain and changed the api. If scripts for Ubuntu to get RawTX from a set of hashes?
How can I get RawTX now? Tell me the ways?

You can get this data by running a bitcoin-core full node with txindex=1 in the configuration file. You can then use the command bitcoin-cli getrawtransaction (TX_HASH) to get the raw transaction info.
For example:
$ bitcoin-cli getrawtransaction 60183ab915f2f4b0190605f98bd0e9f8eafe13a1c902b3ae87ecd0dfc8a599a0
0200000001a1565a3e50056710a250abaf55bd8b3f9bcf7ff413e23e7f8ff5d3dd25d66117020000008b483045022100ded45306a6ac022f13a16e994c87bb3f348d13e5039a5e088fe94c79e1d1ab5e0220311339632ef240d633510516c2536ae091eb176f14548412375f6f80d45e1a6b0141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10cffffffff0803170400000000001976a914817f1daf3b1080aa9d06b6969fa162b8d75a490d88ac80f773000000000017a9142c4154736c01c24d66a9e9f08df10a717e8dc81e87dbb9f4000000000017a91442771b8871e5df7baa107253c3ba156feb17db498776ecf900000000001976a9145b90ceac145472d39366f5c174e495e754e2016a88ac10037d01000000001976a9142c7c79f6a4a19b8a6071144dd9ee438d1e60c3c888ac00c2eb0b0000000017a914eade7d94aa4077025a322002a3d4f662d0bb8f1b8780fb4c2b020000001976a914d5458947802140d1ca099ef3f5b25151183e285f88ac42e3a413040000001976a91443849383122ebb8a28268a89700c9f723663b5b888ac00000000

Adding a 1 to the end of that command will return a more verbose output:
$ bitcoin-cli getrawtransaction 60183ab915f2f4b0190605f98bd0e9f8eafe13a1c902b3ae87ecd0dfc8a599a0 1
{
  "txid": "60183ab915f2f4b0190605f98bd0e9f8eafe13a1c902b3ae87ecd0dfc8a599a0",
  "hash": "60183ab915f2f4b0190605f98bd0e9f8eafe13a1c902b3ae87ecd0dfc8a599a0",
  "version": 2,
  "size": 456,
  "vsize": 456,
  "weight": 1824,
  "locktime": 0,
  "vin": [
    {
      "txid": "1761d625ddd3f58f7f3ee213f47fcf9b3f8bbd55afab50a2106705503e5a56a1",
      "vout": 2,
      "scriptSig": {
        "asm": "3045022100ded45306a6ac022f13a16e994c87bb3f348d13e5039a5e088fe94c79e1d1ab5e0220311339632ef240d633510516c2536ae091eb176f14548412375f6f80d45e1a6b[ALL] 047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c",
        "hex": "483045022100ded45306a6ac022f13a16e994c87bb3f348d13e5039a5e088fe94c79e1d1ab5e0220311339632ef240d633510516c2536ae091eb176f14548412375f6f80d45e1a6b0141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.00268035,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 817f1daf3b1080aa9d06b6969fa162b8d75a490d OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914817f1daf3b1080aa9d06b6969fa162b8d75a490d88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1CoiSvDYA5KLJMpriJsZumg2iZ5Ds31r33"
        ]
      }
    },
    {
      "value": 0.07600000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_HASH160 2c4154736c01c24d66a9e9f08df10a717e8dc81e OP_EQUAL",
        "hex": "a9142c4154736c01c24d66a9e9f08df10a717e8dc81e87",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "35j1vBeT4iPeTM3zdzHpaz4byPcSUEp27Z"
        ]
      }
    },
    {
      "value": 0.16038363,
      "n": 2,
      "scriptPubKey": {
        "asm": "OP_HASH160 42771b8871e5df7baa107253c3ba156feb17db49 OP_EQUAL",
        "hex": "a91442771b8871e5df7baa107253c3ba156feb17db4987",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "37kTCwc3q8UF8wyqmSMkbzesMPbN6Bj3B1"
        ]
      }
    },
    {
      "value": 0.16378998,
      "n": 3,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 5b90ceac145472d39366f5c174e495e754e2016a OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9145b90ceac145472d39366f5c174e495e754e2016a88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "19M9xr1r3Un2XpUDEPxEapsHrnZNF3KdBj"
        ]
      }
    },
    {
      "value": 0.24970000,
      "n": 4,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 2c7c79f6a4a19b8a6071144dd9ee438d1e60c3c8 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9142c7c79f6a4a19b8a6071144dd9ee438d1e60c3c888ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "154DrDQEkazY4k27PW6khJ3LyPH7ZTjGp1"
        ]
      }
    },
    {
      "value": 2.00000000,
      "n": 5,
      "scriptPubKey": {
        "asm": "OP_HASH160 eade7d94aa4077025a322002a3d4f662d0bb8f1b OP_EQUAL",
        "hex": "a914eade7d94aa4077025a322002a3d4f662d0bb8f1b87",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "3P6taM3ogQJpzMDFkNg8coxZinbudUsNND"
        ]
      }
    },
    {
      "value": 93.16400000,
      "n": 6,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 d5458947802140d1ca099ef3f5b25151183e285f OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914d5458947802140d1ca099ef3f5b25151183e285f88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1LSgEKji3ZoGdvzBgkcJMej74iBd38fySb"
        ]
      }
    },
    {
      "value": 175.09442370,
      "n": 7,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 43849383122ebb8a28268a89700c9f723663b5b8 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91443849383122ebb8a28268a89700c9f723663b5b888ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"
        ]
      }
    }
  ],
  "hex": "0200000001a1565a3e50056710a250abaf55bd8b3f9bcf7ff413e23e7f8ff5d3dd25d66117020000008b483045022100ded45306a6ac022f13a16e994c87bb3f348d13e5039a5e088fe94c79e1d1ab5e0220311339632ef240d633510516c2536ae091eb176f14548412375f6f80d45e1a6b0141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10cffffffff0803170400000000001976a914817f1daf3b1080aa9d06b6969fa162b8d75a490d88ac80f773000000000017a9142c4154736c01c24d66a9e9f08df10a717e8dc81e87dbb9f4000000000017a91442771b8871e5df7baa107253c3ba156feb17db498776ecf900000000001976a9145b90ceac145472d39366f5c174e495e754e2016a88ac10037d01000000001976a9142c7c79f6a4a19b8a6071144dd9ee438d1e60c3c888ac00c2eb0b0000000017a914eade7d94aa4077025a322002a3d4f662d0bb8f1b8780fb4c2b020000001976a914d5458947802140d1ca099ef3f5b25151183e285f88ac42e3a413040000001976a91443849383122ebb8a28268a89700c9f723663b5b888ac00000000",
  "blockhash": "000000000000000000203285ed3cdc4928fa74ccfc9a278c4a79caf09a0d00b1",
  "confirmations": 178585,
  "time": 1523893268,
  "blocktime": 1523893268
}


text:
Why is signature S value is unnecessarily high not safe?
I get frequent warning when sending RawTX to PushTX message
(Non-canonical signature: S value is unnecessarily high)

Why is signature S with a large value dangerous (that is, when the first HEX digits begin with FF ...) ???
I understand this was done for TX's safety judging by this answer by Pieter Wuille
But I want to understand how it works in calculations? Can you explain with an example how this can be applied when determining the secret key K?

It is not dangerous in that the private key can be revealed. Rather it is dangerous in that an attacker can make a version of that transaction which is functionally the same but has a slightly different signature and so has a different transaction id.
This issue is a part of a set of issues referred to as transaction malleability. Transaction malleability is the ability for a 3rd party to modify a transaction after the fact which makes it have a different transaction id, but is still functionally the same as the original. This means that the transaction still spends the same inputs and creates the same outputs. This does not mean that an attacker can take any Bitcoin - it is not possible to change the transaction's outputs.
In general, the ECDSA s value is malleable. Any 3rd party can take a signature, modify the s value in a very specific way, and the signature would still be completely valid. Because of this, it introduces a way that transactions can be malleated. It is important to note that this does not reveal the private key, does not reveal the nonce, and does not allow for signatures to be forged. All it does is change the actual bytes of the signature.
The way this modification works is by negating the s value. If you do s - n (mod n), the result, typically denoted -s, is still a valid s for that signature. A consequence of this is that there will always be 2 possible s values, with one higher than the other. Additionally one will always less than n / 2, and one greater than n / 2. Bitcoin has chosen to require that s be the low value - we could just as easily chosen to require s be the high value. It doesn't really matter whether low or high is used, just that one is used consistently to avoid this form of transaction malleation.
The reason that transaction malleation is an issue is because it results in a different transaction id for the same transaction. This means that most wallets and nodes will consider the transaction to be a new transaction which conflicts with the original one. Many wallet software have had issues with conflicting transactions. They may show an incorrect balance. They may also show the conflicting transaction indefinitely which can cause confusion to users. It is not that transaction malleation can cause Bitcoin to be lost or stolen, but rather that it can cause a degraded user experience, and potentially lost coins due to software errors.


text:
How to get the hex for a tx input (for btcdeb tool)
I am trying to understand how btcdeb (Bitcoin script debugger from Bitcoin core) works.
In the usecase of btcdeb --tx=<tx hex> --txin=<txin hex>, how does one obtain the hex of the input of interest? In the example there:
$ btcdeb --tx=010000000001019086ce64fce1bb086395faf6fac37c73f32ba4ea89330432bf8ee8035e9315aa0100000000ffffffff021353b9030000000017a914c3f413d0918853a8e23766678d2e3c2e5c8138bb8725e4973100000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d040047304402207f874ef00f11dcc9a621acad9354f3fca1bf90c43878f607b7e2d358088487e7022052a01b47b8eef5e1c96a6affdc3dac46fdc11b60612464dc8c5921a852090d2701483045022100c56ab2abb17fdf565417228763bc9f2940a6465042fd62fbd9f4c7406345d7f702201cb1a56b45181f8347713627b325ec5df48fc1aee6bdaf937cbb804d7409b10c016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000 \
txin=0100000000010170a6ee35199eae2d8ea659561374fa704f8fd95188ff5931157e4598dd0c44020100000000ffffffff0280f0fa02000000001976a914eec426a744f7a3b2ffd346925ac832e248834dd788ac4013543500000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220054c0b331a31496d9123aeabe8415b8d2f877f1cf67709120af4eb1e09de59e002206cdf84e733e23be531aff202f868d200773e22aa0037033a74fc6752df2fd19601483045022100b54fa12828d13b58cb654dd910b9e8b36d471d644d8f66516577990ca099ee19022048ea2ac78f964d1b823af70c13c5607a29b14bb2348022190b3c280f51ec5df2016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000

the hex of the txin (0100000000010170a..., 383Bytes) is actually longer than the hex for the whole tx itself (010000000001019..., 381Bytes). How was the hex for txin obtained?
When I run bitcoin-cli decoderawtransaction <txin hex> to see what txin hex is, it gives full JSON of the whole transaction, same as running bitcoin-cli decoderawtransaction <tx hex>

The txin hex is just the normal hex for a transaction whose output(s) you are spending. It's not something you can compute from the tx hex itself (if you could, you would't need to provide it). It's there because to validate a transaction input you need to know what output(s) it is spending, and those are part of the earlier transaction(s).

Thank you. I still do not understand, if the --tx=<hex> has more than one input that reference the same --txin=<reftx hex>, which tx's input script btcdeb is going to pick to debug?

I do not know the answer to that.


text:
How can the max fee be corrected when building a transaction?
Im not sure why i keep running into this problem, but what are the ways to correct the high fee error?   i have done settxfee etc.. is there a switch to indicate when building out the createrawtransaction -- sign --- send ?
absurdly-high-fee, 53064013 > 10000000 (code 256) (code -26)
Also is the following suppose to be populated once you sign/true .. or after its sent?
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""

When you use createrawtransaction, you have to do everything manually, including the selection of inputs and fee. The fee is defined by the difference between input amounts and output amounts. The error is there to help you: it is detecting that the transaction you'd be sending does have a huge fee, which you probably don't want to send.

I hope you are on testnet, because you are about to send half a bitcoin in fees.


text:
Buy alt coin with bitcoin and both go up 300%, so did I even make any money?
Seems that my poor and rich bitcoin holding friends don't seem to even know the answer to this  :/
Say I used coinbase and transfer BTC to an exchange like bittrex and exchanged BTC for some alt coin lets call it  XYZ.
If say Bitcoin was at the time (months ago)  $5,000 USD, and then say the value of this alt coin called XYZ was valued at $100 USD  ( via the BTC estimation)
If we ignore fees...

XYZ goes up 300%   from $100 to $300  ,  but at the same time period , BTC also went up 300% and goes from $5000 to $15,000
Exchange XYZ for BTC ,
Send BTC to coinbase  ... send to bank account   ( ignoring fees )

Ignoring fees,  did I just break even????   serious question as it seems like I did, right?
Example say monero went up from $30 to $300 ,  and BTC did a 10x increase ... well then on one hand I was about to say I didn't make any money ,... but now that doesn't make any sense    Ugh   Help

I'm voting to close this question as off-topic because investment advice is off-topic

Not investment advise,  its an exchange rate and pure math question.   I mostly mention bitcoin against a fake alt coin XYZ.   I happen to mention Monero for a specific example.    In no shape or form is this asking for investment advise. That is very very obvious.

It's a bit of an opinion based question, but I agree this is not investment advice. Voting to keep it open.

Of course you profited, because your market value just increased by 300%.
In your case:
You had 1BTC (worth $5000) on Monday.
You sell 1 BTC and buy 50 XYZ( 50 * $100 = $5000).
Then comes Tuesday, both XYZ and BTC goes up 300%.
Now your 50 XYZ is worth $15000, you exchange 50 XYZ for 1 BTC.
You see, your total market value increased from $5000 to $15000.

So if  XYZ didn't grow in value at all, and BTC went up,  THEN I or anyone would lose because the money was in something stagnant and then it was then exchanged months later to say BTC that say went up 3x  ....       Thus lost money or just stayed the same?

Meaning -  If BTC goes up 300% , but the XYZ contained the money value and stayed neutral , thus not going up or down in value   ( albeit if it was at say $30 ... that is valued in USD per the being tied to BTC ... )     I'm wondering if the money (without fees considered )  stayed neutral which exchanging back after BTC went up and XYZ did no movement in value ..    Or if it would be a loss ?

As long as the XYZ price stayed unchanged, your market value will stay the same.
The correct term will be "missed out on the chance to profit". Is not considered a loss, since your portfolio market value didn't decreased.

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


text:
no schema for stratum

I am trying to bring up stratum mining on a pool and get this error -> exceptions.Exception: There is no shares table. Have you imported the schema?   Obviously my database is empty but no package I have download from git has a single .sql file to populate the db.  How do you populate the schema?

https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide
https://github.com/ahmedbodi/stratum-mining/issues/97
gentoo001 stratum-mining # locate .sql
/usr/portage/dev-db/mysql-udf-base64/files/mysql-udf-base64.sql
/usr/portage/mail-filter/gld/files/tables.sql
/usr/share/doc/mysql-5.1.70/scripts/mysql_fix_privilege_tables.sql.bz2
/usr/share/doc/mysql-5.1.70/scripts/mysql_system_tables.sql.bz2
/usr/share/doc/mysql-5.1.70/scripts/mysql_system_tables_data.sql.bz2
/usr/share/doc/mysql-5.1.70/scripts/mysql_system_tables_fix.sql.bz2
/usr/share/doc/mysql-5.1.70/scripts/mysql_test_data_timezone.sql.bz2
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/mysql_fix_privilege_tables.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql

This table isnt part of the MPOS schema you have to create it yourself, my schema for this table is:
mysql> show columns from shares;
+-----------------+--------------+------+-----+---------+----------------+
| Field           | Type         | Null | Key | Default | Extra          |
+-----------------+--------------+------+-----+---------+----------------+
| shareID         | int(11)      | NO   | PRI | NULL    | auto_increment |
| rem_host        | varchar(100) | YES  |     | NULL    |                |
| username        | varchar(100) | YES  |     | NULL    |                |
| our_result      | varchar(255) | YES  |     | NULL    |                |
| upstream_result | varchar(255) | YES  |     | NULL    |                |
| reason          | varchar(255) | YES  |     | NULL    |                |
| solution        | varchar(255) | YES  |     | NULL    |                |
+-----------------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

I keep this in a seperate db to MPOS but there is no reason you cant add it manually to the MPOS table.  I will also add that while this works I'm not certain if varchar is the correct datatype to use here.

Where does this table comes from? I found the same issue here https://github.com/Crypto-Expert/stratum-mining/issues/52 but the solution doesn't yield the exact same schema. What does it mean?

Its one I made after looking through the source code.

Thanks. I guess I'll post as an answer what I found out, since some might be interested in this other solution.

I stumbled upon the same issue when trying to install php-mpos. Fortunately, the quick start guide provides an answer.
Just run sudo mysql -p mpos < sql/000_base_structure.sql from the root of the php-mpos repo. It means using this file: https://github.com/MPOS/php-mpos/blob/development/sql/000_base_structure.sql