text:
If I receive a LN payment from an anon sender... is there a way to send back to this individual?
I see the preimage, hash, and payment request but all of those are transaction specific and unrepeatable. Any idea how it would be possible to send back the other way without knowing the individual?

No, there is no definitive way to detect the source of a payment on the Lightning Network.
However, there exists techniques (either active or passive, such as probing or some heuristics) which may be used to try to deanonymize parties involved in a payment.
So, while you can't reliably identify a party, you cannot assume it's totally anonymous either.

Appreciate the quick response. I ask because i'm in the late stages of building this www.satoshie.com ... and I cannot figure out a frictionless way to do payouts ... am I down the creek w/o a paddle?

Looks like we are starting a back-and-forth conversation, you may want to join #lightning-dev on Freenode :-) To answer with another question: why do you need refund informations to be based on the Lightning Network ? EDIT: if you come at freenode feel free to ping me, same pseudo there

thanks, will join there. The site is based on micropayments (being able to place a bet of say 1 cents, on chain that would not be possible). Do you have an alternate in mind?

(Not a web dev, it might be a bad idea). Can't you just use session ids / cookies stuff to identify who's owned a refund ? And have a page asking them for an invoice in order to get refunded ? As you go, might be worth adding a basic accounting system too.


text:
Working with Bitcoin node on Windows as a developer?
I'm a web developer looking to integrate a Bitcoin node into a PHP application and I am unsure how I would go about interacting with the Bitcoin core in a developer environment for my machine.
My goal is to pull transaction history on a particular address without using any 3rd party APIs and as such I need to use some sort of Bitcoin interface to do that.
I believe that I need to use the Bitcoin daemon in some sort of manner however I do not know how to use it on my current PC as It is a Windows 10 machine.
Any advice would be greatly appreciated.

I'm a web developer looking to integrate a Bitcoin node into a PHP application and I am unsure how I would go about interacting with the Bitcoin core in a developer environment for my machine.

The most straightforward way of doing it would be to just use JSONRPC to hit bitcoind's API.

My goal is to pull transaction history on a particular address without using any 3rd party APIs and as such I need to use some sort of Bitcoin interface to do that.

bitcoind doesn't allow you to directly access an "address mapping". Some applications (notably Electrum servers) build additional indexes which allow them to expose you "by address" APIs and other handy informations.
This usually is a tradeoff between storage vs efficiency.

I believe that I need to use the Bitcoin daemon in some sort of manner however I do not know how to use it on my current PC as It is a Windows 10 machine.

Bitcoin-core allows you to build on Windows and provides Windows binaries as part of the releases.

More subjectively, I usually recommend the Esplora API (which is more precisely the electrs fork of Blockstream's API) which uses quite a lot of storage but is very efficient for address-based requests.
You can start it quite easily by using the Docker instructions, and for example set it up behind an nginx reverse proxy on a server so you can hit it (or just use Docker on your Windows machine).

Is there any such programs or apps I can use where I can locally map an address? Ideally, I'd like to enter an address and receive all transactions that have recently been made.

@Ethan I edited with a personal suggestion :)

Thank you mate, does this Esplora make API calls to 3rd parties or can it be used locally?

As I described, this is an open source project which is made easy to be self-hosted. It doesn't use a third party (that's kinda the point of using almost a terabyte of storage!)

If you launch bitcoin core with txindex option you have all transaction indexed and so you can query any transaction you want using RPC

source: Stack Exchange

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

sort: votes


text:
Bitcoin-cli transaction viewing
I am attempting to create my own Bitcoin API for a website I have been building over the recent years and I need some sort of transaction system to handle payments with Bitcoin. I currently own a plethora of Bitcoin addresses already and so if possible, I could recycle those without needing to have the computing power to constantly make a new address.
My logic behind the code it is that I will have a request sent to the server stating that a transaction has been started with a given address. Every so often, I need to check this address for a transaction that is newer than the timestamp of the log which says '[timestamp] a new transaction has started with x address'. I will then track the balance of this transaction and if it becomes the amount I wish it to be then I will respond to the server stating that the transaction has been complete.
Although this may sound complicated, it sort-of already works using a third part API but instead, I would instead like to use the Bitcoin-Cli to check transactions of a given address rather than relying on some shoddy API that stops my code from working half the time.
If anyone has the know-how please let me know as that would be fantastic! If anyone knows a better alternative to this system then please let me know too.

@Prayank Surely can't I just use Bitcoin core raw?

@Prayank Yeah I suppose so and appreciated, need at least a barebones project to get me off the ground really. Would you happen to know where I could how to use bitocin core in conjunction with PHP?

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


text:
bitcoin node take transactions fee and validate them
a bitcoin node check transactions and validate them . does it take transaction s fee. when validate transactions how much bitcoin transaction fees for a node.and possible reduce fees in a bitcoin node

Transaction fees are paid to the miner that includes that transaction in their block. Nodes do not earn transaction fees (or any other fees) for validating transactions.
You can reduce fees by using segwit inputs, and by waiting for periods when the mempool is relatively empty.

Transactions fees goes to miner along with the mining rewards. Fee is a function of how much transactions are in mempool and several other things.
Using cli of bitcoin node, you can get an estimate fee as per number of blocks time you want for confirmation.
Ex - Let's say I am ok with my transaction getting confirmed after approx n blocks are formed
./bitcoin-cli -conf=<path_to_conf_file> estimatesmartfee n

This will return you approx fee value. You can then set it using another command of cli
./bitcoin-cli -conf=<path_to_conf_file> settxfee <fee_value>

You can write it an script and then run time to time to use only what you need. vary n to increase or decrease speed of transaction confirmations


text:
so how many possibilties for 3 random missing words?
I have a combination of 24 words made from 2048 words. I have 21 of these words known and in order. I am missing 3 words that can be placed in any slot from the 24. How can I work out the number of outcomes that I need to try to find these 3 missing words and where they are in the code?

You have 21 words, out of 24. Therefore, 21 of 24 slots are taken, but not necessarily correctly.
There are 2048 possibilities for each word.
The first word can go into one of any 24 positions, therefore 2048*24. The next in any of 23, and the last in any of 22.
This gives you a total of 2048 * 24 * 2048 * 23 * 2048 * 22, or 2048^3 * 24 * 34 * 22.
That's a total of 154,206,505,795,584 possible combinations. While not impossible to compute, at a reasonable rate of 100,000 attempts per second, you'll be able to try them all in just under 50 years.
This task is highly parallelizable, so you could likely cut that down significantly if you can obtain enough hardware. Even simply knowing the locations of the missing words cuts down the brute force time at 100k guesses a second to just under a day.

ok..so here comes the next problem..when im running this program for 2 missing random words its total combinations are 1157627904...
so it works
2048242048*23 = 2315255808
but then looks like it divides them by 2
hence giving 1157627904 total combinations
could it be because once a word is found it deducts the process for teh next words?

You won't know if one word is found until you find all the words, assuming you have an address or some key you can validate the seed against. Your script might be wrong, or computing some other set of combinations

im using BTC recover
inserting address correctly
then inserting my 21 words and added anotehr extra word for a total of 22 words
as i start BTC recover it shows
seed sentence was too short, inserting 2 words into each guess
phase 1/1: up to 2 mistakes, 2 of which can be an entirely different seed word
total seeds tried 1157627904

also when i tried with 3 missing words in 3 definite poistions like 19,20,21 it worked correctly 2048^3

so the scripts runs well...but i cant just determine the number of total combinations for the 3 random missing words

My best guess is that it is either attempting to split the word into two halves over multiple CPUs/devices, or it does some kind of optimization that allows it to cut down on attempts with a high probability of not missing the correct solution - hard to say without spending time looking at the code

or could it be possible that since it works first x 24 then x 23 it divides by 2 as its running the process twice?

@RaghavSood Since the only relationship between the words is the checksum and the SHA256 hash used in creation of it can not be predicted, there is no way to skip any checks. So the entire 2315255808 permutations must be checked to find the valid ones according to checksum (usually ~6%) then derive child keys for those.


text:
Roadmap for beginners developers
I am Brazilian and would like to program functionality for Bitcoin and LN. But I have no knowledge of programming and am lost as to what to study. Could you help me?
What do you recommend?
*i do know nothing about programming.

I have no knowledge of programming ... What do you recommend?

If you are an adult, evening-classes in programming at your nearest educational establishment (school etc).
If you are not an adult and are in full time education, I would ask a teacher to suggest courses inside or outside school. In many countries, schools have courses that are relevant,
You could also contact a professional body. For example, in the UK, you could contact https://bcs.org.


text:
Bitcoin core wallet
Can anyone point me in the right direction I downloaded the bitcoin core qt wallet wee while back all the files that come with it are everywhere not in the right path I don’t know much about this there’s a lot of files just don’t know what to do with them would anyone have a idea for someone who knows where little about it which would be the easiest way to generate a new wallet to something that would be simple for me to use and what files to look out for some of the ones I’ve seen is a about rsa key,files about generating keys,wallet hash tree I think it was pools and stuff I’ve just no idea thanks

all the files that come with it are everywhere not in the right path [...] there’s a lot of files just don’t know what to do with them

What you wrote suggests you downloaded the source files. If I wanted to do this I'd follow guidance at https://www.google.com/search?q=build+bitcoin+core+from+source but I suspect you are not comfortable with this, so instead ...
I suggest you download the single-file precompiled-installer for your operating system from https://bitcoincore.org/en/download/ and run that.

Thank you for your reply I went onto it thats where I got my new wallet I downloaded that to see what to look for, for my old wallet to remember I thought I could transfer it over or generate that into my old wallet


text:
What is the size limit on the UTXO set, if any?
Other than limitations in growth of the UTXO set with regard to the block size, is there a cap either on the number of UTXOs or storage limit of the UTXO set in the Bitcoin protocol or Bitcoin Core?

There is no such limit. Growth of the UTXO set is somewhat regulated by the fact that creating UTXOs takes up blockchain space, which may cost fees to use. But there are no size limits as such.

Cant upvote but thank you! (new account).
I assume Murch has done calculations of "if we maximized block space to create new UTXOs for new BTC holders, how many blocks would it take for everyone on earth to have a UTXO" so Ill look for that stack exchange post next.

I don't think I've done that calculation, no. ;)

@quantumtightening: You may be interested in this answer I just wrote: https://bitcoin.stackexchange.com/a/115451/5406


text:
How much info share bitcoin nodes between other nodes?
1.If we assume bitcoin nodes share the other nodes addresses in the end every node know other nodes adresses right?

2.If we share data through network every node share the same information other nodes so if we have 100 member in network same message will arrive to me hundred times isn't it wastefull for network?

The IP-addesses of Bitcoin nodes are not a secret. See addr
Nodes don't explicitly tell other nodes their Bitcoin addresses. Since nodes pass on details of other nodes transactions, working out which nodes originated a transaction isn't straightforward.
Since the set of Bitcoin nodes is constantly changing, and nodes go offline temporarily (or permanently), no node ever absolutely and definitely knows the IP-addresses of all nodes existing
Nodes don't communicate with all other nodes. Only with a few at any time.


text:
How do I deposit bitcoins in my wallet to an exchange?
I just want to cash out my coinbase wallet. Can someone give me the simple steps to do this?  Why is this so complicated? Or is it?

Depositing your Bitcoin is easy. Each exchange may be different in the process they use, so it's best to check your exchanges documentation before doing so.
Each exchange will have a link that will forward you to your exchange wallet page. Due note that almost all exchanges are custodial wallets. This means: when you send any cryptocurrency to your exchange addresses, the token or coin is no longer your possession . When you send your asset to the wallet address that is designated for that particular asset, the assets are immediately transferred to a wallet that is controlled by the exchange --and you do not have access to that address.
Although your tokens are transferred to a wallet you don't have custody over, you will still show a balance in your account. When y0u have completed the trades you wanted to make you will withdrawl to your own address of a wallet which you control. The downside too this is--if an exchange becomes insolvent all of a sudden, then you don't get anything back and most likely will never be compensated for your assets.
So choose a notable exchange that you feel you can trust. Do your research to make sure they aren't in a position to become insolvent. (like what happened to Celsius)
But it's simple. Just go to the wallet page on your exchanges website or mobile app and find your deposit address and send your coins to the deposited address. Any reputable exchange will have directions that are obvious during the deposit / withdrawal process. They will most likely have two-factor authorization mechanisms--so be sure that your account access, email address, phone number, google auth, or whatever it is that you use to associate your account is squared away.
Not financial advice. Do your own research,
edit
I just read the title and didn't see the coinbase part. Coinbase has a section where you can swap your tokens for USD and then you can withdraw too your connected financial institution. Or you can send them to a custodial wallet like Bitcoin Core or Electrum and then sell privately on services like localbitcoins.


text:
Was bitcoin the first to use SEED phrase for recovering account?
I am trying to recall/determine if the coins I had on a USB stick was indeed bitcoins or not.  I sold an Item a long time ago (Either 2006ish or 2009-2010) and someone offered to pay me in coins.  Of course I laughed about it back then but decided to do it since it was like 100 bucks.  He gave me two types of coin, first one he called old and he gave me around 12-14k of it and then he also gave me a new type of coin 3-4k of them.  I recalled it had a Japanese name cause I thought he was joking.  Years later I eventually found that USB stick and saw a folder with the old coins which at that point from what I read online had zero value and was shutdown by the govt.   But there was another file with random words on there.  I recall a few of these words and they are all in the Legacy ELECTRUM dictionary.  At the time I forgot that I had gotten two types of coin and ended up deleted everything.  Recently I the piece of paper popped up out of no where and once again I was forgot about it and ended up throwing it away.   I took pictures of it but it was so blurry I deleted them as well.
I have been trying to backtrack my timeline to see if I really did lose millions in bitcoins due to pure stupidity.  I have been dealing with an overwhelming feeling of grief and guilt recently and I am hoping with the help of you nice folks I can put an end to this.  At this point I would rather hear what I had was not bitcoins.
So really the questions that needs to be answer to know the truth.

Was bitcoin the first to use a seed phrase design.

Going by the amount of coins I got it would mean the value of bitcoin at the time was still very low.  If it is bitcoin then the only timeframe that make sense would have been around 2009 up to mid 2010.  When you create a bitcoin account by then, do you get a seed phrase or was it just a private key back then.  From what I read the first wallet to use seed phrase was ELECTRUM so if that is true then what I had can't be bitcoins.

Was there a timeframe when 2 types of virtual coins existed at same time.  values for these coins were really low..  14k = 100 bucks or so..

The things that points to what I had was bitcoin - seed phrase and a sheet of paper with what looks like a private key.  Also the words I recall in the text file are in the legacy ELECTRUM seed phrase dictionary.
The things that do not point it as bitcoin.  Per info online, ELECTRUM did not come out till 2013 so there is no way when he sent me those coins they were bitcoin.  Assuming no seed phrases were used for bitcoin prior.
I have try to look online for any info that could prove or disapprove these questions but I feel a lot of info has been lost over time.  Hopefully someone on here that has been around for a long time knows the answer.  Thanks in advance!

Was bitcoin the first to use a seed phrase design.

I've no idea whether Bitcoin was the first cryptocurrency for which there was a wallet that supported a system of seed-phrases.
Not all Bitcoin wallets support seed-phrases. Notably the reference implementation Bitcoin- Core does not yet support seed phrases.
BIP39 - Mnemonic code for generating deterministic keys was defined or published on 2013-09-10.
According to Electrum their seed-phrase system was introduced two years earlier?

When you create a bitcoin account by then, do you get a seed phrase

Not in general.
Nor do you create a bitcoin account in general.
The archetypal process is to download a wallet program such as Bitcoin core and the first time you run it, it will generate a private-key. Wallets that support seed-phrases will instead generate a seed-phrase when first run and generate a private key from that.

Was there a timeframe when 2 types of virtual coins existed at same time.

Probably. I suspect the number of cryptocurrencies went from one cryptocurrency to thousands of cryptocurrencies in a very short period of time.
See

Some notable cryptocurrencies
A list of cryptocurrencies

Note that questions about any cryptocurrency other than Bitcoin would be off-topic here.

Thank you for your reply.  I also found similar info online to what you have provided.   All I can do is to continue to do research.

I think you are grasping at straws. There were no deterministic wallets back in 2010. Electrum was released in late 2011. Besides you don't have the words so what difference does it make?
If you want to pursue this attempt to recover the files on the USB drive. Then you have something substantial to work with.


text:
Where is the actual data stored in blockchain?
I know that the blockchain stores the transnational data and it is immutable but where is the actual data stored? If there is a use case to replace a centralized data center solution with a blockchain solution, where will the data be stored in blockchain? Data centers usually have petabytes of raw data, hence I am assuming that a decentralized solution like blockchain won't be able to accommodate large amounts of data.
For e.g. bitcoin as of today is ~270GB, meaning that every node requires this much amount of storage. But the problem here is that the data is an ever increasing entity. How does blockchain try to solve this problem ?
Note: Many links on google say that blockchain is not an ideal solution for large data, but then any solution will eventually produce an ever increasing amount of data.
I have referenced the following question on the forum but it does not answer by doubts:
Where is the data stored in Bitcoin?

where is the actual data stored?

Each full node on the network will download and validate the blockchain history, it will request and receive this data from other full node peers. Each node does not necessarily have to keep that data after validating it though, it can choose to 'prune' data that is not relevant to the user's wallet.

For e.g. bitcoin as of today is ~270GB, meaning that every node requires this much amount of storage. But the problem here is that the data is an ever increasing entity.

By running a pruned node, you needn't keep the entire blockchain history on file, though you will still need to download and validate it in the first place. So while the blockchain will continue to increase in size, it is through careful engineering that we can hope to limit the rate of increase, hopefully such that technological capacity will increase at a comparable rate (ie, faster and cheaper CPUs for validation, faster and cheaper storage, etc). This is important, because the health of the network depends on there being a sufficiently large number of nodes online.

Many links on google say that blockchain is not an ideal solution for large data, but then any solution will eventually produce an ever increasing amount of data.

The key point with this is that not all types of data usage are equal. It is preferable to get the most utility you can per byte of data stored. Compressing a ton of economic happenings into a bitcoin transaction (eg the opening/closing of a lightning network channel) represents a ton of utility per byte. Storing your favourite funny-cat-video on a blockchain is the opposite, and there already exist far more efficient ways to store and transmit that sort of data.


text:
Why is not possible for a hacker to intercept the hashes calculated by a miner, and send it all himself as if he was a miner?
(I tried to make a more specific question, but is a bit confusing to me. Sorry.)
When a miner calculate a hash, where exactly does he send to in order to validate it? To all the nodes in the network?
Which protocol does it use to send this hashes? For example, HTTPS requires a trusted third party to sign server-side digital certificates, but there is no "server-side" in a decentralized network.
Why is not possible for a hacker to intercept all the hashes been sent by a miner or pool, and send it all himself as if he was a miner?

Miners don't send hashes, they send blocks. Blocks are public information to be broadcast to the entire network. When a miner completes a block, he sends it to nodes that he is connected to. Those nodes verify the block, and if they find it to be valid, they will send the block to the nodes that they are connected to. This peer to peer gossip is how blocks and transactions reach every node in the Bitcoin network.
An attacker an intercept a block, but that won't do anything for him. He would just become another thing relaying the block to nodes on the network.
Miners aren't paid by submitting aa block to something specific. They are paid by including a special transaction in the block which pays them Bitcoin by essentially creating them from nothing. There are rules about what amount this can be, so if it doesn't fit those rules, the block is invalid. The miner essentially pays himself and the rest of the network agrees on whether he is entitled to that payment. An attacker intercepting this cannot change the miner's payment without having to completely redo the proof of work, i.e. mining the block themselves.

I'm not sure if I understood, you said "Miners don't send hashes, they send blocks", the miners keep searching for a number that gives de correct hash (something like this sha256(sha256(data+nonce)) < difficulty), this is the block, right? Let's suppose I've found this nonce that makes the hash for the true return on the equation, where and how I'd send it?  I'd send to a Pool? Using which protocol? TCP? HTTPS? A hacker couldn't sniff this post and change my request to an invalid hash then send my valid first claiming the reward since he got my POW before claim it?

The miner hashes a block header. The block header contains a hash of all of the transactions in that block. It also contains the nonce which is what miners are primarily changing when performing the PoW. When they find a block header that meets the PoW rules, they send the block using the Bitcoin P2P protocol to other nodes. The reward paying them is a special transaction in that block. Changing that transaction would mean redoing the PoW. Hence a MiTM can't steal the reward.

@LucasAraújo inside the blockheader they hashed, miners put in the Submit block a coinbase transaction and that special transaction will send the reward to an adress from miner's wallet, so even if  hacker send the share, the reward will be sent to the miners and not to the hacker


text:
Is there a widely used symbol for satoshi yet?
Has a symbol been widely adopted for satoshi yet? I've seen Ș suggested but it's already a letter in Romanian. Ꞩ, Ȿ & ẜ (long s with stroke) all seem to be otherwise unused. Has anyone suggested using any of them?

related: https://medium.com/coinranking/satoshi-deserves-its-own-symbol-43138fe1ddf9, https://en.bitcoin.it/wiki/Satoshi_(unit), https://twitter.com/dickerson_des/status/1155560643635884032

Also related: https://twitter.com/murchandamus/status/1292966320732925952

Is it so hard to use the existing reference ₿ in the same way we use the basic units such as m (meter) or g (gram)?
We've always just added a multiplier like m (milli), μ (micro), n (nano) etc. to get smaller (or larger) versions of these base units. Everyone is already familiar with units like mm, mg, and (larger) km, kg and, bytes (for example) kB, MB, GB, ...
For bitcoin we just need ₿, m₿, μ₿, n₿ where 1 μ₿ is 1 'bit' or 100 sats, and 1 n₿ is 0.1 sats.

agree with everything you changed.

i dont remember why i removed the spaces between number and unit decades ago. Probably it was just more compact and didn't cause any confusion.
mu for micro is the correct way to write it; I just think that most people won't find that character in simple text messaging apps
my apologies for adding the line notifying the edit. I'm still not sure what I should have done :)

Hey Harry, when you edit a post, others can easily see that it was edited per the "edited" block at the bottom of the post. If you click that, you’ll be able to see the history of changes to the post. On this site, we just keep improving stuff to improve it, or keep it correct and up-to-date as needed.—The space between numerical value and symbol is a pet-peeve of mine, hope it doesn’t bug you that I added the spaces back. :)

I can't find where I first saw this symbol used for sats, but I've seen it a few times now and it is kind of growing on me:
§

That's called a section sign: en.wikipedia.org/wiki/Section_sign. I wouldn't have a problem using it, but some would certainly complain, just like with the '฿' for Bitcoin itself, because it's the symbol for the baht (Thailand's currency).The symbol I'm referring to is .

No.

Satoshi is often abbreviated to sat or s, although no currency symbol
has been widely adopted.

https://en.bitcoin.it/wiki/Satoshi_(unit)

how about ₛ , , or ⓢ? "ₛ" is a subscript s. currently $1=0.00001004/1,004sat.
With suggested symbols it would be:
1,004ₛ
1,004
1,004ⓢ
personally, I like  or ⓢ. ⓢ would be a good fit considering the standard bitcoin symbol has always been ₿ in a circle.


text:
How to setup hd wallet using mnemonics with bitcoin-core?
I'm currently learning Bitcoin wallets using Bitcoin Core, and I need some guidance and help especially when it comes to mnemonics and hd seeds.
This is what I have read about mnemonics and seeds: bip-0039
Creating wallet
I can create new wallet using the createWallet command. This wallet has hd seed set automatically.

As I understand there is no way to restore mnemonic for such a wallet and the only way to restore it later is to backup hd seed from the file generated by the dumpWallet command?
If I want to be able to use mnemonic I need to generate it myself, transform to hd seed, and then set it using the sethdseed command? Bitcoin Core does not provide any command line tools to do this, and I need to use external tools for this?

HD seed generation
There are multiple tools to generate mnemonics and hd seeds: Online or command line tools like Bitcoin Explorer.
Both these tools for mnemonic: rival hurdle address inspire tenant almost turkey safe asset step lab boy
generate seed: 020b67fd929e0eb9f963443138057ceec0d62601d69b4b2327c00d74f0fd1862d164c53d49227d9dadedbbec305236bc2149d9a5267aa7c5aa004235c3c66c29
The problem I have is that this generated seed is not accepted by sethdseed command. Apparently it is not hd seed.

How to transform this calculated seed to hd seed accepted by sethdseed command?

What are the best practices for generating mnemonics and hd seed completely offline?

Thanks and hope this will help someone in the future.

@Raghav Sood that explains partially my 3rd question, but I still don't have any idea how to transform mnemonic to hd seed accepted by Bitcoin Core. And there are other questions. But this thread is useful. Thank you.

You can't. They're two incompatible seed types

You should split up your other, unrelated questions into separate questions - this site isn't really designed for multiple independent questions in a single post

hi @Jubert. have you figured out something for your 4th question? what are the best practices for generating mnemonics and hd seed offline?


text:
electrum get transaction amount command line
How to retrieve transaction amount via command line? Seems gettransaction return hash which contains only some inputs outputs info without any amount.

maybe ... | electrum deserialize -


text:
bitcoind: why sendmany allows only double-precision floating point numbers?
I am switching from electrum to bitcoind. On electrum is function paytomany which accept usual bitcoin amounts like 0.0001. But why method sendtomany accept only double-precision floating point numbers? Maybe there is another option for that purpose and I just missed it?

What is the difference between 0.0001 and "floating point numbers"? The Bitcoin Core RPC accepts amounts either as strings or as numbers (JSON has no concept of floating-point or double precision; everything is just a "number").

it only allow number like 0.02, 0.01 etc, only two digits

That's just wrong. Any valid amount can be provided in the JSON-RPC interface or the GUI (meaning up to 8 digits after the dot, because BTC can be subsidivided into 10^8 units).


text:
how can I delete raw transaction
How can I delete funded raw transaction? When I call another fundrawtransaction method, it just appends new info to already created hash.


text:
doubled payment
I had one strange situation. I created payment transaction, broadcasted it but electrum couldn't execute request due timeout, network weren't accessible. Then after 10 minutes I created one more transaction, broadcasted and  gone two transactions to the network  old and new one, but I expected only one new transaction to go out. How to avoid such situations? Why did it do that?

How to avoid such situations?

You should be able to view the status of your first transaction in the history tab in Electrum. You can right click on a transaction to get some options to affect that transaction.
If using the Electrum daemon and command line you can use the electrum history command.
I suspect if you had seen a pending transaction, you wouldn't have created a duplicate.

Why did it do that?

I guess it held onto the first transaction until the network became available and then sent it - that would usually be the most useful and helpful approach for a wallet.

I use electrum daemon, not a wallet. Also it didn't throw to the network on restore connection but after I broadcasted the second transaction

OK, I think you'll find you get better answers if you include that sort of information in your question.


text:
I can't get confirmations for transaction
Something weird happened with this tx 5a2b117611a4dc6ae53335b6e6d8ee9c146efaab54564f3ff1c3f3a4dddf5eed, it seems will never get confirmation. What the problem?

That Tx has a fee rate  of 61 s/vb. blockchair estimates 24 hours til confirmation.  A fee calculator says you need a rate of 325 to get a confirmation in the next 6 blocks.

@VojtěchStrnad actually no, because I don't see why it can't be confirmed. There was 2 confirmations and then they lost

@OleksandrIY That basically doesn't happen, it could be a bug in whatever software you're using to display confirmation status. Your fee rate of 61 sat/vB has been insufficient to get into a block for four days now, you just have to wait longer or increase the fee.

Your transaction just confirmed.


text:
What exactly determines how long it takes a given miner to mine 1 btc block? (not talking about hashrate)
So given the number of miners out there working on doing the same thing and that 1 block is mined every 10 minutes, it would appear at face value that only those with the highest hashrates would ever be able to earn a block reward as they would have to complete a new block in 10 minutes or less.
This is obviously not the case since lower hashrate hardware can still successfully mine blocks, albeit at a slower rate.
Is each miner starting at a different nonce and just getting lucky or is there some other variable that allows even slower miners to finish a block in 10 minutes?
What am I missing?


text:
How do you generate a Bitcoin wallet by hand?
I am interested in the exact process for generating the various components of a Bitcoin wallet by hand. Specifically, the components I'm interested in are:

Private Key
Public Key
Public Key Hash
Address

The kinds of tools I have in mind for doing the necessary calculations to generate each by hand is:

Pencil & Paper
Graphing Calculator
Any Other Non-electronic Mathematical Tool
Your Answer

If the process is not too tedious, I might try and give it go.

Unless the calculator can be programmed, I'd expect that it may well take days of work at least to compute an address, and again as much to spend. Given that, are you still interested in an answer?

A single mistake in some parts of the process will likely render your funds permanently unspendable. Be very careful here.

@PieterWuille Ah, it's as I feared. Hearing that it'd probably take days of work, I probably won't have the fortitude to do it myself. That being said, I am still definitely interested in the answer if you're willing to supply it.
EDIT: And who knows, maybe some brave soul out there might see your answer and take on the challenge.

@chytrik Ah, I kind of expected that, but one might say that's part of the fun of doing it by hand ;). At any rate, if I were to do this, I'd probably just test it by transferring a few cents worth of Bitcoin to the address.

"Mining Bitcoin with pencil and paper: 0.67 hashes per day" suggests that doing SHA256 hashes by hand requires on the order of 36 hours of work.
I've done some work on "Verifying Bech32 Checksums with Pen and Paper", though I have not timed myself.  That work is slowly being folded into my work on Shamir Secret Sharing (over the Bech32 alphabet) using paper computers in my SSS32 project to design a new master-secret format.
I have never tried to do any elliptic curve operations by hand and I have always assumed that it doing so many modular arithmetic operations over such large numbers is just too tedious and error prone to do by hand.
If you are willing to use a computer to pre-generate a list of nonces (and SHA256 midstates for your nonce/public key for BIP340), it might be plausible that you could compute an ECDSA or BIP340 signature, as the remaining steps only require a few modular arithmetic operations.  While such a list of nonces is independent of your private key and your transaction, if that data were leaked it would compromise your private key from your signature, so even pre-computing that data may not be secure enough for whatever your purpose is.


text:
Who in their right mind would waste their Bitcoin on taxes or buying random stuff?
First of all, I very much get the "argument" that Bitcoin has to be used as a currency for it to function long-term and it's a good thing if it is, etc. Not arguing against that.
But when I keep hearing about this company and that government/state/town "accepting" Bitcoin for payments of random stuff or taxes, I can't help but wonder to myself: Who in their right mind would be wasting their hard-earned Bitcoins like that? Why would they not pay taxes/stuff with fiat and hold on to their BTC?
Of course, excluding the remote possibility that they are all doing it "for the greater good", which sounds extremely unlikely.
The only explanation I can possibly think of is that maybe they expect it to go up in value, so if they buy some Bitcoin now, even if at a premium, and then wait for some time, and then use it to pay for taxes/stuff later, they would still waste less money even including the capital gains taxes that they have to pay to pay for the taxes... in fiat... because they used their Bitcoin to pay for... taxes... ugh... my head starts spinning just trying to make sense of that.

Paying taxes / buying goods / etc with Bitcoin, is equivalent to selling the Bitcoin and paying with fiat, except that it might be more convenient and save transaction costs to do it in one step.  Thus your question boils down to "Why would anyone 'waste' Bitcoin by selling it?"  And of course there are many rational reasons to sell Bitcoin:

you believe its price will go down

you want to reduce your exposure to its volatility

you need to pay your taxes / buy your goods right now, and you don't have, or don't want to use, enough fiat or other assets to do so.

So there's an implicit bias in your question: you're assuming that holding a given amount of Bitcoin is "better" than holding an equivalently-valued amount of fiat - in other words, you're assuming that Bitcoin is undervalued.  Whether that's true is a matter of opinion, and certainly there are people who wouldn't share that opinion.  They might just as well ask the opposite question: "Who in their right mind would waste their hard-earned fiat currency paying taxes, when they could instead take the opportunity to unload a bunch of crappy Bitcoins on the government?"  Only time will show which of the two of you was correct.
Note that the "hard earned" part is irrelevant (ignoring the effect of capital gains tax and the like).  Whether it's a good idea to sell Bitcoin is a function only of its current price, together with your personal model as to how its price will behave in the future.  How much you paid to get it is immaterial, except psychologically.

And paying with fiat is equivalent to paying with bitcoin, and then buying more BTC to compensate. And that too is in some cases more convenient.

But when I keep hearing about this company and that government/state/town "accepting" Bitcoin for payments of random stuff or taxes, I can't help but wonder to myself: Who in their right mind would be wasting their hard-earned Bitcoins like that? Why would they not pay taxes/stuff with fiat and hold on to their BTC?

Why wouldn't I pay my taxes with my used tissues? I don't want to keep them at all. And yet I pay my taxes with my hard earned dollars. Why?
Abstractly, it makes sense to use for payments whatever the person you are paying most wants. If I go to a car dealership and offer to pay them with dollars or toilet paper, they might be willing to accept either. But they're sure not going to give me a great deal if I pay with toilet paper because they don't want it as much.
So if everyone really wants to hold bitcoin, then it makes the most sense to use bitcoin as a means of payment. Sure, I could hold bitcoin and eventually benefit from its appreciation. But I can also use that bitcoin to pay right now and still benefit from its appreciation because I am giving that benefit to the seller in exchange for its full, current value.
Also, because bitcoin is easy to buy and sell, it makes sense to be fairly indifferent to what asset you buy with or sell with. If you pay with me dollars and I want bitcoin, I can buy them. If you really want bitcoin and I'd prefer to pay with dollars, I can just buy them.
So if you really like bitcoin, it makes sense to use them for payments whenever you can because that reduce the amount of dollars you have to hold.
The important thing to understand is that future appreciation is always already priced in if it is reliable. If bitcoin is sure to be worth $50,000 in a year, nobody will sell it for $25,000 today because it will be easy to find people who will pay more than that. Bitcoin has the price today because that is a fair consensus estimate of the present value of its future value.


text:
electrum increase fee from command line
is it possible to increase fee from command line in electrum? I walked through all electrum commands but can't find such command.

but with which command :)

but transaction is already in the bitcoin network, now I need add some extra fee

@Prayank thanks, I think you should post it as answer


text:
Requested wallet does not exist or is not loaded
I need to perform rpc requests per wallet. Here is my url
http://127.0.0.1:18332/wallet/another_wallet/wallet.dat

but I get error  Requested wallet does not exist or is not loaded
I run daemon with this command
bitcoind -daemon -rpcuser=myrpc01 -rpcpassword=password01 -testnet -datadir=/media/ax/6f6ceb40-fbbc-4959-b2b2-dbb1ae9ce24a/bitcoin/testnet3

So what the wallet path I should set for correct load?

The loadwallet is (perhaps surprisingly) not a wallet RPC. It can be sent to the normal non-wallet-specific URL. Once loaded, the wallet-specific URL can be used to interact with it. Does that help you?

If you are trying to load a wallet, then you do not need to be using a wallet specific endpoint. loadwallet is not actually a wallet RPC so it does not need the wallet specific endpoint.
If you are trying to access a wallet that has already been loaded, then you have the wrong endpoint. The endpoint does not include the wallet.dat file. Bitcoin Core gives wallets names based on the directory that contains the wallet.dat file, and when it creates wallets, it puts them in directories of the name that was provided. The wallet RPC endpoints work similarly - they use just the wallet name. So the URL to access a particular wallet should actually be
http://127.0.0.1/18332/wallet/another_wallet

Note that this URL does not have a trailing slash (/). If you have a trailing slash, then Bitcoin Core will incorrectly determine the wallet name to be another_wallet/ where it is actually another_wallet.

I loaded this wallet /media/alex/6f6ceb40-fbbc-4959-b2b2-dbb1ae9ce24a/bitcoin/testnet3/wallets/default_another_wallet/, then I try this url http://127.0.0.1/18332/wallet/default_another_wallet but says Requested wallet does not exist or is not loaded

You can use the listwallets command to see the wallets that are currently loaded. That will tell you what Bitcoin Core thinks the wallet name is.

here is [1] => /media/alex/6f6ceb40-fbbc-4959-b2b2-dbb1ae9ce24a/bitcoin/testnet3/wallets/default_another_wallet/

I tried different path combination, bitcoin/testnet3/wallets/default_another_wallet, testnet3/wallets/default_another_wallet .... and so on, every time can't find

When you load the wallet, instead of providing the full path to the wallet, just give the name default_another_wallet. The wallet is in the default walletdir for the datadir you have specified. There is no need to give the full path. Otherwise, Bitcoin Core is considering the wallet name to be the full path, i.e. /media/alex/6f6ceb40-fbbc-4959-b2b2-dbb1ae9ce24a/bitcoin/testnet3/wallets/default_another_wallet/.

here is my -walletdir=/media/alex/6f6ceb40-fbbc-4959-b2b2-dbb1ae9ce24a/bitcoin/testnet3/wallets/
here is url http://127.0.0.1:18332/wallet/default_another_wallet
in walletdir I can see folder default_another_wallet but still that message that can't load wallet

Can you post exactly what you are trying to do and what the error message is? By exactly, I mean the exact JSON that you are sending, and the URL you are sending to. Which command are you trying to use that is giving you the error?

{"method":"getwalletinfo","params":[],"id":1}
http://127.0.0.1:18332/wallet/default_payout_wallet/
Requested wallet does not exist or is not loaded

What result to you get for listwallets?

Array
(
[0] =>
[1] => default_payout_wallet
)

very odd, I just tried from command line curl --user myrpc01:password01 --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getwalletinfo", "params": []}' -H 'content-type: text/plain;' 127.0.0.1:18332/wallet/default_payout_wallet  and it worked well, but not with php script

Make sure your URL does not have a trailing slash (/). The URL should be http://127.0.0.1:18332/wallet/default_payout_wallet, not http://127.0.0.1:18332/wallet/default_payout_wallet/.


text:
settxfee: formula for fixed fee
I want to set fixed fee rate for transaction. I calculated tx size which is 222( here is this tx), called rpc settxfee
$o->settxfee(sprintf('%f', (0.00001/222)*1000));

and sent to the network. I supposed fee would set for tx to 0.00001 but set to 0.00000662 TBTC instead. Here is wallet info  "paytxfee": 0.00004500,, seems  settxfee worked as expected. What do I do wrong?

for some reason blockchair doesn't show vbytes for testnet as it does for mainnet, blockstream block explorer instead shows it: https://blockstream.info/testnet/tx/d8c00cc75dde9b1f29e0f06e9da766a8b24cd30e515ac50cd1533cc27a67ae87

Big disclaimer: you really shouldn't do this. Transaction prioritization works based on fee per size, so that's what you should be configuring.
As for an explanation of what you're seeing: the block explorer you're using is showing the wrong size. For fee computations what you need is the vsize, not the serialized size. This is the size that takes the discount for witness data introduced by BIP141 (segwit) into account.
The vsize of your transaction is 141, not 222.


text:
listtransactions weird offset workflow
I need to extract last wallet transaction. But seems  listtransaction has some wrong logic. When I perform this function
listtransactions '*' 50 9

it just return me first records not last. In my case I have 11 records, so it return me record 1 and 2, instead of 10 and 11 as I expected. Thus I get first two records instead of last. Maybe I understood something wrong or missed some other params?


text:
wallet.dat inserted into .jpg image
I was wondering if anyone ever came across a situation where a wallet.dat file was encoded into an image like a .jpg?
I have this wacky idea of taking a wallet.dat file and somehow encoding it into an image. For example, you would like at a painting, but in the lower right corner, there would be a bunch of encoded jibberish out of which one could reconstruct the wallet.dat file?
Did anyone come across something like this before? How would one do this?
I'm wondering how to translate a wallet.dat into some kind of an image.

Do you mean encoding a private key in the image, or steganography? There are a few similar ideas mentioned in the following news articles: https://www.coindesk.com/theres-more-money-to-win-in-the-310-bitcoin-challenge-heres-some-hints, https://www.vice.com/en_us/article/kzpqzz/heres-the-solution-to-the-3-year-old-dollar50000-bitcoin-puzzle, https://bravenewcoin.com/insights/steganography-how-antonopoulos-hid-a-us12m-transaction-in-a-picture-of-kittens

This is called steganography. Invented in Greece two and a half thousand years ago.
Usually, to make the embedded data inconspicuous the embedded data is distributed throughout the whole image as small variations in hue or luminance etc.
People viewing an image would notice an ugly and obvious rectangular patch in a corner. Especially as wallet data might result in noticeable patterns within that patch when interpreted as image data.


text:
Study bitcoin core source code
I have read a lot of documentation and books where they explain the general functioning of Bitcoin and I think that the time has come to study the source code of Bitcoin core.
I have knowledge of c++ and python but due to the large size of the project and the number of files, I don't know where it would be correct to start.
Could someone help me on how to properly perform that task?

Well, which part of its functionality are you most interested in?

I would like to start with the creation and validation of transactions. I am also interested in how the wallet works.

See https://bitcoin.stackexchange.com/questions/87450/where-in-bitcoin-core-does-it-do-x

Does this answer your question? Where in Bitcoin Core does it do X?

Thank you very much for all your advice. They will be very useful to me.


text:
why is bitcoin-qt connecting to port 9051?
Running bitcoin-qt with default policy in the OUTPUT chain to DROP I see lots of packets from localhost to localhost with destination port 9051 being dropped. If I open that port the node syncs. I do not see any service listening on that port. Why is it connecting? This is a tor port and I am not currently running tor here.

9051 is usually a Tor transport controller port. Bitcoin might just be looking to see if it can connect to the network via tor

You're seeing probes for automatic configuration if it were running.


text:
How long would it take for all smartphones on the planet to fully reverse a SHA-256 hash?
I am aware that, theoretically speaking, there is no way to guarantee that a reversed hash is actually what is inputted to the hashing function. However, let's say that I have an image, I write down the file size of that image and then run it through the SHA-256 hashing algorithm. I then distribute the hash to all of the ~6.5 billion smartphones on our planet, along with the initial file size. How long would it take for all smartphones in existence on earth to fully brute force a SHA-256 hash, unlike Bitcoin where you only have to reverse some of it?

An Apple M1 CPU can do around 2 GB/s of SHA256 (based on the optimized 2-way hardware-accelerated ARMv8 code in Bitcoin Core added in PR24115) on a single core.
Smartphones are significantly slower than M1 laptop CPUs due to power usage limitations, but let's ignore that, and conservatively overestimate every smartphone has a hexacore CPU that can do this much, so 12 GB/s per device in total.
SHA256 operates on blocks of 64 bytes. Let's assume that the attacker picks a fixed prefix, and then just needs to grind the last 64 bytes + padding (one extra block) of the file. So they're just hashing 128 bytes. (12 GB/s) / 128 B ≈ 94 million tries per second, per device.
6.5 billion devices times that means 6×1017 files per second in total.
Every file attempt has a probability of 2-256 of yielding a correct preimage. That means one needs in the order of 2256 tries to have a reasonable chance of finding a preimage.
2256 / 6×1017 ≈ 2197 seconds
The age of the universe is around 13.7 billion years, or 258.5 seconds.
Thus the attack would take around 2197 / 258.5 ≈ 400000000000000000000000000000000000000000 times the age of the universe.


text:
How the system works when there's no block reward?
I've came across some articles arguing that it is a good idea to have no block reward at all, but I struggle to understand, how this would work.
I understand that the incentive for miners would be just transaction fees; but how new coins would be created? Even if there would be no new coins as a principle - where any coins come from? From some initial phase of PoW mining/any other initial distribution? If so, doesn't it give to much advantage for the early nodes (and therefore discourage others to join)?

You should link the articles for context. We can only speculate otherwise about the views expressed in them. In a PoW system, coins are brought into circulation by the block subsidy. If you start at genesis with no subsidy, there would be no coins, and transactions could not exist.

It would be very helpful to reference the articles ._.

how new coins would be created? Even if there would be no new coins as a principle - where any coins come from? From some initial phase of PoW mining/any other initial distribution?

Coins would be created the same way as today: from coin base transactions. That coin base transactions include fees and rewards, only fees (in a distant future), or only rewards (in the past), makes not much difference.

If there is no subsidy, there are no coins. I think OP is not asking about Bitcoin, but about a hypothetical system which never had any subsidy.

Thanks. I'll leave this for a while and later probably delete it.


text:
How to check the number of BTC sent from one address to another via API?
I need to count the number of sent coins from an address to another address.
I found this API https://blockchain.info/rawaddr, is it enough for me, using this method, to simply calculate the "outputs" of the transaction to the address?
JS Code example:
const valueAddreses: IValueAddress = {};

axios.get(`https://blockchain.info/rawaddr/${address}`)
  .then((res) => {
    if (res.data.txs?.length) {
      res.data.txs.forEach((tx) => {
        tx.out.forEach((out) => {
          if (out.value > 0 && out.addr === findAddress) {
            if (!valueAddreses[out.addr]) {
              valueAddreses[out.addr] = {value: out.value};
            }

            valueAddreses[out.addr].value += out.value;
            valueAddreses[out.addr].valid = valueAddreses[out.addr].value >= minLimitSat;
          }
        })
      });

      res.json(valueAddreses);
    }
  });

Does JavaScript support back ticks?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

What have you tried? Why don't you trust this code block?


text:
Add wallet feature to bitcoind (full node) after installation with --disable-wallet
I installed bitcoind with this configuration:
`./configure --without-gui --disable-wallet`

However, after it finished downloading the blockchain for a week, now I realize I actually do need the wallet feature. Is there a way to add it back (without another week of verifying the blockchain)?

The data directory is independent of the installation. Just recompile with the wallet enabled, install the binary over your existing one, and it'll use the same data directory and all of the data inside of it.


text:
Importing bitcoinj mnemonic into electrum or deriving private keys from mnemonic
I am having a really hard time backing up my bitcoinj mnemonic and importing it somewhere else.
I am backing up the mnemonic like so:
    Wallet wallet = Wallet.createDeterministic(params, Script.ScriptType.P2WPKH);
    DeterministicSeed seed = wallet.getKeyChainSeed();
    System.out.println("seed: " + seed.toString());
    System.out.println("creation time: " + seed.getCreationTimeSeconds());
    System.out.println("mnemonicCode: " + Utils.SPACE_JOINER.join(seed.getMnemonicCode()));

This gives me: cram approve decline tobacco truly giant remember author install dirt spare law
The wallet dump for this wallet/mnemonic looks like this:
Keys:
Earliest creation time: 2020-09-10T23:01:55Z
Seed birthday:     1599778915  [2020-09-10T23:01:55Z]
Ouput script type: P2PKH
Key to watch:      xpub685v329L5UXezQQmCRgftKRud7hYHHR2U9RPCzRVwQNNWQuTHawgzBXD5RgAYLroJFiqTxEhF5jmbXJAWB341x8r3hdUFWfZd1Rh9uycNR3
Lookahead siz/thr: 100/33
addr:13ScJMSbxg6JYVaWNJAawZMaKW9KDdsz2H  hash160:1ac81dec190ab5981f5b8d9627136c806b013ff8  (M, root)
addr:18jGHhTXzKJcU1TqpMkozYQQBKHsnExT1H  hash160:54c71cd14809d8e4695d0ab8881b9c971c28d833  (M/0H, account)
addr:1HJbGGSZ42tG9nrTU6aGS2xJwCSEb6rKfg  hash160:b2d5af74fb0d34e5a072cf0514c9d0a6d949a699  (M/0H/0, external)
addr:19kEr724cNCXWgybTDPhNqN5rTVCcajdjD  hash160:5fee7381e26b401c7aca2d031e950aa7b6ff634d  (M/0H/1, internal)
Seed birthday:     1599778915  [2020-09-10T23:01:55Z]
Ouput script type: P2WPKH
Key to watch:      zpub6mkSeMVANqccjQLrtYC39g9eob95YG9cNvGFFBvXVgsT7mrJno4ChARSa1WWYdtuygHLDdkc5Bg6Lc45wx8xL2tSzgHsnzfqt4oSYR1Lecv
Lookahead siz/thr: 100/33
addr:bc1qrtypmmqep26es86m3ktzwymvsp4sz0lcurmxp8  hash160:1ac81dec190ab5981f5b8d9627136c806b013ff8  (M, root)
addr:bc1qppm602vv0ee29mndy37c3h5h4y753vyz82h5qt  hash160:0877a7a98c7e72a2ee6d247d88de97a93d48b082  (M/1H, account)
addr:bc1qz88ttzmmlr2w6d5wz40e9ejqxmr5avtmq2d6qq  hash160:11ceb58b7bf8d4ed368e155f92e64036c74eb17b  (M/1H/0, external)
addr:bc1q0v7emmg95uj738fnge70hwle23jdehpqxezqne  hash160:7b3d9ded05a725e89d33467cfbbbf95464dcdc20  (M/1H/1, internal)
Now importing the bip39 mnemonic into electrum or the iancoleman site gives me completely different adressess no matter what derivation path I use. How can I import the mnemonic so that it creates the exact adresses as bitcoinj/android schildbach wallet? Or how else should I backup?

Just restore as normal using electrum and on the screen where you have to enter the derivation path you set it to m/0' and choose legacy as the script type. Then create another wallet via file > new/restore for the p2wpkh addresses. This time choose native segwit as the wallet type and enter m/1' as the derivation path.

Sir, I am in your debt. Thank you very much.


text:
Restore BIP39 mnemonic in Electrum using command line and custom derivation path?
How would I restore a bitcoin wallet using the Electrum command line on Linux with a BIP39 mnemonic and custom derivation path?
I need to use m/0' for legacy and m/1' for native segwit?
I cannot find anything in the documentation about BIP39 mnemonics or using a custom derivation path without using the GUI interface of Electrum.
Thanks!

You can't do it from the console, but you can do it through the python API.  Stuff like this is done in their test scripts all the time.
Look at the test_bip39_seed_bip84_native_segwit in their github repo for some hints
Another alternative would be to convert your bip39 seed to an xprv and use the restore command line option with the newly minted xprv.
Here's some sample code to convert your mnemonic to an xprv.  Obviously change the derivation path and mnemonic seed:
#!/usr/bin/env python3
from mnemonic import Mnemonic
from pycoin.symbols.btc import network as btc

code = ("abandon abandon abandon abandon abandon abandon" +
        " abandon abandon abandon abandon abandon about")
path = '84H/0H/0H'
mnemo = Mnemonic("english")

xprv = btc.keys.bip32_seed(mnemo.to_seed(code)
           ).subkey_for_path(path).hwif(as_private=True)

print("Issue the Electrum commands")
print(f"\tconvert_xkey {xprv} p2wpkh-p2sh")
print(f"\tconvert_xkey {xprv} p2wpkh")

Do keep in mind that Electrum imports are assumed to be at the Account Extended Key level.  This means that importing an xprv at the derivation path m/5' level (random example) will have you a first receive address of m/5'/0/0 and your first change address of m/5'/1/0.  Only way around this behavior would require importing the WIF keys one at a time.  A simple change to the pycoin code, but there is no simple xprv way to do it.

Thx for the answer but would I be able to set derivation path or choose legacy or native segwit from the console when restoring the xprv?

@super.yang, yes.  Basically you will need to write some python with pycoin or mnemonic to go from mnemonic+derivation -> xprv, then you can use the electrum command convert_xkey to convert the xprv to yprv, or zprv.  I'll dig up some code and update the comment, but there is no path I can see that won't involve python


text:
Warning Newbie: How does a Ledger hold multiple currencies?
So you startup your ledger, copy down your 24 words, and you now have a public and private key. (I think). Now you add the BitCoin App to your Ledger and you can add BTC to your "hardware wallet" using those keys. (Though phrasing it that way is a bit of a misnomer since the only thing your Ledger ever really stores is your private/public keys.)
So far so good for one currency. However, a Ledger will hold multiple currencies. That I can find there is no asking for another 24 words. You just add the second app and you now have a wallet in that new currency. So I assume that means that if you purchase Ethereum coins it is going to use the same public/private keys that you used on BitCoin?
That would also imply that you cannot have two BitCoin wallets on the same Ledger because attempting to do so wouldn't make sense without a second set of keys which the Ledger doesn't have.
Is what I am saying correct?
Frank

You've discovered that with a Hierarchical Deterministic wallet like the Ledger, a single 24-word phrase can be used to derive (essentially) infinite public/private key pairs and addresses.
This standard is a combination of:
BIP32 - HD Wallets
BIP39 - Mnemonic code
and
BIP44 - Multi-account hierarchy
Notice that BIP44 takes that seed phrase and standardizes a series of values that make up a "path" from the seed phrase to a specific key:
m / purpose' / coin_type' / account' / change / address_index

That coin_type value I believe is the answer to your question.
Satoshi Labs (developer of the Trezor hardware wallet) maintains a list of values for the coin_type field here: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
This list is accepted as standard by many hardware wallet manufacturers and cryptocurrency software developers although it's important to note that there are no consensus rules around it - just compatibility standards between wallet applications.
SO, starting with your BIP39 seed phrase and using BIP32 derivation you can compute the first Bitcoin receive address for account 0 at this BIP44 path:
m/44'/0'/0'/0/0

Similarly, your first Ethereum private key will be computed from this path:
m/44'/60'/0'/0/0

That's how the keys for different currencies are all derived from the same single source of entropy.
The reason Ledger has this concept of "apps" is that many of these altcoins do not use the same signature scheme or transaction message digest as Bitcoin. So although the series of private keys for each currency can be computed arbitrarily by the device itself, once you have the key you need additional software for each use case to instruct the device what to do with that key.

A mostly understandable reply, though it would probably take me a couple of weeks to understand it all.  I scanned the three "standards" you pointed me at.  Again, it would take me weeks to fully understand them, if, for instance, I was writing cryptocurrency software of some kind.  Having said that, you answered my question and several more I hadn't thought to share yet.  Thank you!


text:
Can I receive bitcoins to a address which was used 2017
I have a receiving address which was used in 2017,someone said they sent me coins to that address 5 years later (today) is that address still mine,its showing nothing since last time i used in 2017?

Addresses are forever. If someone sends sats there, then anyone with access to an up-to-date blockchain explorer can verify if the transaction successfully completed.
Owning . It's difficult to know if you're the only owner, but verifying you have a key is easy
"Ownership" of an address really just means control, "being in unique possession of a corresponding private key". In other words, whoever knows the private key for an address can spend any coins there.


text:
Is blockchain.com the only place where you can see the blockchain?
I've been investigating Bitcoin and when I would try to find out where the blockchain is stored, I was told that it is stored on everyone's computer. Then I would ask where was the blockchain stored on my computer and the response was it is stored in your wallet.
Since Bitcoin is decentralized, I supposed that it must be found anywhere. But I found no information about that.
My question is actually: Where can I see the blockchain without going to blockchain.com?

Can you tell us more about what software you are using on your computer to send and receive Bitcoin? Also, note that even if you are looking online, there are many sites you can use -- blockchain.com has nothing to do with the blockchain, they just got a good domain name before anybody else did. Search for "bitcoin block explorer" and you will see lots of others.

Blockchain.com is a wallet service and provides a "blockchain explorer". The company is named after the Bitcoin network's transaction journal, the blockchain.
Bitcoin is a permissionless peer-to-peer network. Users interact with the network by running software that implements the Bitcoin protocol.
There are various types of software that interact with the network to different degrees, but the backbone of the network are the so called "fully validating nodes" or fullnodes. Fullnodes distinguish themselves by downloading and verifying the complete blockchain. Archival nodes maintain a complete copy of the blockchain, while pruning nodes discard the oldest parts of the blockchain data after using it to calculate the current ledger. New nodes joining the network download the blockchain data from existing nodes.
Most Bitcoin software does not download, verify and store the complete blockchain. These "thin-clients" rely on other nodes or central services to serve data about the Bitcoin network's state to them. Wallet software (such as e.g. the Blockchain wallet) usually belongs to this category of node.
So, to answer your other question: your computer only stores the blockchain if you run a fullnode, e.g. Bitcoin Core. Then you can "see" the blockchain by requesting data from the fullnode. There are various projects that bundle visualization or blockexplorer software with the fullnode, to make the "seeing" part a bit more user friendly. ;)

Where can I see the blockchain without going to blockchain.com?

Other blockchain explorers
Use your favourite search engine to find other "blockchain explorers"

If you run a full-node wallet like Bitcoin core
Access your local copy of the blockchain. For example, Bitcoin core on
Windows stores it in %APPDATA%\Bitcoin
You can examine this copy using the
bitcoin-core command line tools,
The bitcoin-core debug console or a third party
"blockchain parser"

"Use your favourite" followed by a Google link, hmm? :)

The blockchain is information.  It is not a "thing," and it is copied wherever one wishes to have it.
Distributed systems like this are interesting, and it may help to think about a heretical phrasing: a blockchain.  That's right.  There is more than one.
A blockchain is any set of information (i.e. bytes) which describes a valid block chain.  There are two ways to identify them:

There is the original block, a block chain of length 1, which was defined to be a valid block chain in Satoshi's original publication.  This is called the genesis block for any block chain system (This could be seen as a minimal level of centralization, but we usually don't pay much attention to it)
Any sequence of blocks which meets the mathematical requirements of a block chain and starts with Satoshi's original block is a valid block chain.

So how do we get from a blockchain to the blockchain?  Bitcoin defines the longest block chain to be "the" block chain at any given moment.  More precisely, it is the most difficult block chain.  Each block includes the answer to a math problem that requires a great deal of computational work, and the sum of that work is used to identify which block chain is the "longest."
Now bitcoin has been around long enough and enough CPU time has been burned on one chain that we can be extraordinarily confident that it is indeed the longest block chain in the bitcoin universe.  We call this "the blockchain."
Sites like the blockchain explorers listed in RedGrittyBrick's answer will show you a block chain that they assert is the blockchain.  And, due to the raw length of the chain, and the solid agreement between the explorers, we can be quite confident it is "the" block chain.
At least, we can be confident up to the last few blocks.  There are many rules of thumb for how deep a block has to be before it is deemed truly irrevocable.  I've heard the number 6 blocks thrown around.  The idea behind this is that its possible for people to disagree about the tail of the block chain, just due to networking issues.  There may be several valid block chains floating around the world at any point in time which are vying for the title "The Blockchain."
The bitcoin algorithm is designed to resolve this.  The honest miners will pick which chain to add to, and will select one chain (this chain is selected both by the desire of the miners to keep the algorithm working, and from raw greed -- mining on a chain which ends up not being "the chain" was wasteful)
Once enough blocks have been mined, it becomes increasingly unlikely that anyone will ever contest which chain is longer, and the longest re-earns the title "the block chain."
So really, the blockchain is wherever someone wants it.  It's public knowledge, and can be downloaded from many sites, or from the peer to peer network itself.  You can verify that it is indeed a valid block chain.  And, as Murch points out in his answer, you can choose to run a "fullnode" which is a node in the peer to peer network which regularly maintains the block chain to the best of its ability.


text:
What's the best strategy to send btc from one wallet to a address list with transaction id for each payment?
I'm triyng send a mass btc payment, but using "sendToAddress" i'm limited send a new transaction only when the last was confirmed, if i try send when the last was pending of confirmation i'll not have balance on my wallet because the my founds was send to change addresses and is pending.
If i use sendMany i'll only had transaction to all payments and i need an transaction to each address and get controll for the fees for each.
If i wait for the last confirm to send a new my batch payment will spend a lot of time and  will stuck my payment list, i'll limitaded for some payments for day.
What's is the best approuch to this problem? Can someone help me? I tried found solution in older topics but i don't had success with this, maybe i cant express myself correctely or do not know the correct terms.

i can use any wallet, what you recommend?

i'm programming an API to interact with btc core.

@Prayank i'll search about, thanks!

You can do this with sendmany.
It accepts a minconf parameter (which defaults to 1, for 1 confirmation) - it will spend outputs that have at least minconf number of confirmations.
Setting minconf=0 will allow you to spend unconfirmed coins, such as from the change output of a previous sendmany transaction.

Cool, i'll make some tests with sendmany, i was trying send using sendtoaddress. Thanks!


text:
Segwit transaction - Non-canonical DER signature
Error (when sending)
error code: -26
error message:
64: non-mandatory-script-verify-flag (Non-canonical DER signature)
Transaction
010000000001020dcc23ccdb3665779a7657577cd33c5c0660e969ea2ffaf5438c58306ebc9dd201000000fd880100473044022075e1c8751f948b71a79e864040b8e9698e257f0dd65acb3cb6da852a1da8d96602204767d05ac1b75e1f85963c117e51cc8869711e1fe307b51cfdd7763b39e38aa9014730440220647678c47d4a4be2a5f70044e4cf5bf547fb513311401819a114e5a1e72e642002204e9f3847cb2789493446b96dce62acb7abdad06655aefef084bb0d6a49bc99c001473044022079be75240f2a1519559fc3eacfdbeee123403466879d720b9e7f68a45a2b3bef0220585ea1c34766d57e54103ec5102c8fd0925ee2bc1a847797176da9e878d21448014cad53210289d20d3d6e36f28537af3521ce05548fb16baf7d47ac67fbf318db6ed983b9ba21034712e706c1643ec0e9519edf093578886bac1c9c17893138a76111d9a14a2f1b2102a21047ac1a83c8cce21475240b2107a11d76212573a86f0dffe44cdd326f4dab2103430166298971c6282241ef46e866fa9077b4a48eafe4b370e94aef24050dda13210329446142884a33e6100603c6eead5300ec5cf438437f8374ea76dda2daced12855aeffffffff49508924c21b25ee2ff6aed61ccc202793aa992d3e033f12f2bf4a94d6346d0100000000232200207677cf0e71ff26dc2ac7e6b93a5f6b893d39c05a1367ca100cde7a62713ddb4affffffff0240420f00000000001976a9140d7ca1e17524d6c96209cf503fb053613cecf8f688acc0b606000000000017a914fa1cee87827866df00431b5c9a3506b5e31ef4ed87000500473045022100cd569e7f8e5fb6490ef3240d68abdd147f0c3ce4e77bcfd59f587b9a14848bdb02207fe31882d22518af84d3961809b6133c06b34ce6f91c1e579dcff0c58b7519d347304502210099699d11f3fa427c2739580de08fc3a305202a6b1f39c01d8f82e6ad8a9b191902205153041c9a291b81c3ef94cba9d22f3a8df6ee45faab13407ec8a56843051043483045022100b57e36875906add1edeb57badc92f5b4287f9e33b609fad5ae35912cdc0596ff022073338c6e14637dfc11abdb18c2396a58b8e537670d06084981799f64bcd7c3f401ad53210289d20d3d6e36f28537af3521ce05548fb16baf7d47ac67fbf318db6ed983b9ba21034712e706c1643ec0e9519edf093578886bac1c9c17893138a76111d9a14a2f1b2102a21047ac1a83c8cce21475240b2107a11d76212573a86f0dffe44cdd326f4dab2103430166298971c6282241ef46e866fa9077b4a48eafe4b370e94aef24050dda132102c877ef10e8dc5ca83f06263971f133f71e01e9b2a91a4184eb730026f2c3968f55ae00000000
Question
What is wrong with the signatures here?
My thoughts and a bit of context
So basically we have two inputs here. Both are from multisig addresses. The difference is that the second one is just P2WSH.
The first one is mostlikely fine. The second one is my concern. So let's look at witness signatures for the second input.
We have three signatures:

3045022100cd569e7f8e5fb6490ef3240d68abdd147f0c3ce4e77bcfd59f587b9a14848bdb02207fe31882d22518af84d3961809b6133c06b34ce6f91c1e579dcff0c58b7519d3
304502210099699d11f3fa427c2739580de08fc3a305202a6b1f39c01d8f82e6ad8a9b191902205153041c9a291b81c3ef94cba9d22f3a8df6ee45faab13407ec8a56843051043
3045022100b57e36875906add1edeb57badc92f5b4287f9e33b609fad5ae35912cdc0596ff022073338c6e14637dfc11abdb18c2396a58b8e537670d06084981799f64bcd7c3f401

First two are generated by hardware wallets. The third one is created by Bitcoin Core.
So basically each of these signatures claims to be 0x45 (69 bytes long). But the third one has additional 01 at the end.
Questions
Is this the reason of the error?
If not what is this additional byte?
Any clues what is wrong with this transaction?

The "01" byte at the end is the sighash type byte (specifically, 01 means SIGHASH_ALL, indicating that all inputs and outputs are signed). Such a byte is required for all signatures in Bitcoin scripts (both in legacy and segwit signatures). However, that byte is part of the DER-encoded signature; it's appended to it.
Presumably your hardware wallet produces the DER signature without the sighash type, and whatever software you use to construct the actual transaction is responsible for adding it.

I assembled this transaction manually, and it was my fault for not adding sighashes to the signatures.
The transaction is still wrong, but at least a different error occurs :) Seems that the generated signatures are just wrong.
But your answer solves the problem described here. Thank you.


text:
Old wallet problem
Hello bitcoin comunity in need help with an old wallet on a Toshiba tablet. Stuck at synchronisation ... I have some btc in it but i have this problem.
The tablet runs Bitcoin core v0.8.7.4-unk-beta on windows 8.1.
It has reach about 576412 block till about 51 weeks ago then it stopped synchronising.
I encripted the wallet , made a back up ant transfer it on a laptop with the new 0.21.1 version.
The transfered amount was sent in 2015 , but when i transfered the wallet.dat it reads 0 btc.
I reached 99.1 % of sync on my laptop but it went past that date and didn,t verify that transaction of the incomings btc. The balance stayed 0.
I tried searching the addresses manualy on the blockchain , and all results were , this address dont exist.
I noticed when i transfered the dat file all original transaction adresses changed completely. And everyone shows either non existant or 0 inputs or outputs.
I believe the wallet hide somehow the original addresses and i cant get the corect priv key.
I tried dumping the wallet and checking all addresses individualy still returns 0 in every one.
I cant use dumpwallet on the tablet because that command is not available in v0.8.7
How can i find the original btc address.
But since the tablet is of friend of mine ,he asked me for help.I cant start it synchronising. Im afraid to update it forcecfuly , because i've red you can loose the amount of the wallet. I believe the original version is not installed but copied over , i dont find the btc core in the remove programs tab on windows.
All help will be apreciated.
I can give adittional info if needed.
Sorry for my bad english.

You can try the command dumpprivkey into the console.
First get all your UTXOs typing the command listunspent into the console, then you will have all your BTC address with funds, then you can take their private key with the command dumpprivkey <address>. Once you have it, you can use a light wallet like Electrum and import your private key there, then you will be able to spend your funds.
Keep in mind as your wallet is still syncing, your final balance may not be correct, but if you are sure you have some Bitcoins in that wallet, you should be able to recover them through those steps.


text:
What does it mean to make mining more difficult?
Really I don't know nothing about bitcoin but now I got curious read something and immediately come to something on mind.
I mean, there's a social economic comunity somewhere generating value based on the transactions registered, but as they're cheap and bitcoin wants to add value it adds some senseless? dificulty.
By the other way there's a full community of scientists and mathematicians fighting for devealing mysteries of nature and knowledge, but most often they don't have the economic resources for their task, hence there's a lot of simulations and sequances to solve and here we have a lot of people wasting non renovable resources adding up to climate change doing useless calculations just to generate esteemed value.
Do you see the equation here? If the difficulty added be practical intead of needed, bitcoin would be based on real value, even the mayor value of all that is knowledge.
So Instead of do nothing in order to increase value why not solve some practical mathemathical sequence or do x simulation of some deterministic experiment and share the results with science?
Or am I being the idiot that believes that the world has solution with a naif approach?

You're reinventing PrimeCoin

A couple of things are at play here:

The way proof of work mining works is competitive. The first computer to solve a block receives the reward. A bunch of other computers tried to solve it, but did not find the solution first, so they get nothing (this is one of the reasons why mining pools exist).

Because of this, the fastest computer is more likely to get the block, thus making it more difficult. It's like an arms race.

The fewer unmined coins exist, the less the reward will be (called a reward halving, this is exponential). This delays the time it will take for 21 million coins to have been mined. Once all the coins are mined, the miners are just paid by transaction fees.


text:
how to make own coin with soft fork?
What I am looking to do is soft fork on litecoin and create my own coin! I know that I need to make a node but I can't find any process that shows me how to create my own coin.

Soft forks are generally used to upgrade an existing protocol in a backward compatible way. If you were to create a new coin you would need to hard fork the Litecoin protocol. How you do that depends on your motivation. If you just want to create a new coin to make money I would strongly advise against it. There are thousands of altcoins that have no unique selling proposition. It sounds like any coin you would make would also have no unique selling proposition.
If you want to experiment with your own network I would recommend looking into Signet.

my problem statement is i want new coin but ledger should be same.(example if i fork litecoin and the address in litecoin ledger should be available in my new coin with same balance but name should be different).
User,A have LTC,1 same value should be available in NCoin,1 for the same address

Right, you get that with a hard fork.

how we can share ledger in hard fork ? as per my understanding for hard fork everything will be separate , network ,address prefix, all stuff can you please explain and provide me any guide line so i can start

@AwaisSakhi Could you clarify whether you mean that the ledger should continue to be the same after the split?

@MichaelFolkson yes same like what you are thinking . after splitting ledger should be same is that possible ?


text:
Why use `update_add_htlc` when paying directly across a channel?
If Alice opens a channel to Bob and sends a payment directly to Bob, the following messages are exchanged:
    +-------+                            +-------+
    |       |---- update_add_htlc ------>|       |
    |       |---- commitment_signed ---->|       |
    |       |                            |       |
    |       |<--- revoke_and_ack --------|       |
    |       |<--- commitment_signed -----|       |
    |       |                            |       |
    |       |---- revoke_and_ack ------->|       |
    |       |                            |       |
    |   A   |                            |   B   |
    |       |                            |       |
    |       |<--- update_fulfill_htlc ---|       |
    |       |<--- commitment_signed -----|       |
    |       |                            |       |
    |       |---- revoke_and_ack ------->|       |
    |       |---- commitment_signed ---->|       |
    |       |                            |       |
    |       |<--- revoke_and_ack --------|       |
    +-------+                            +-------+

(source: running lnd with TRACE logging and inspecting the logs)
Why is it necessary to use HTLCs at all, instead of just exchanging updated commitment transactions directly?
For example:
    +-------+                            +-------+
    |       |---- commitment_signed ---->|       |
    |       |                            |       |
    |       |<--- revoke_and_ack --------|       |
    |   A   |                            |   B   |
    |       |<--- commitment_signed -----|       |
    |       |                            |       |
    |       |---- revoke_and_ack ------->|       |
    +-------+                            +-------+

It is not necessary to use htlcs in the case of a direct payment. However as the protocol was designed with the idea to have a network of payment channels. This should allow multi hop atomicity of payments via htlcs.  For that the process with the htlcs to move forward the state in the channel operation protocol were necessary
I think from a design perspective it was cleaner to reuse this protocol for direct payments instead of implementing two protocols and make case distinctions

I guess the added complexity with having both would be signaling when it is payment directly to B and when it is a routed payment through B. You wouldn't use the Lightning protocol if you were never interested in the routed aspect.


text:
Full list of "special cases" during Bitcoin Script execution (p2sh, p2wsh, etc.)?
When executing a Bitcoin Script, there are some "special cases" where the interpreter performs extra verification beyond just executing scriptSig and then scriptPubKey.
For example, if the scriptPubKey has the following specific format:
OP_HASH160 <20 byte hash> OP_EQUAL

then the interpreter will additionally apply the BIP 0016 "Pay to Script Hash" (P2SH) rules.
What's the full list of "special cases" that could be encountered during Script execution, and when is each encountered?

As of September 2023, "high-level" script validation with all active consensus rules on the network is approximately this:
Top level evaluation

Execute the scriptSig, and call the resulting stack stack. If execution aborts, fail.
Execute the scriptPubKey with stack as input, and call the resulting stack result. If execution aborts, fail.
If result is empty, or its top element has numerical value 0, fail.
[from BIP141] If scriptPubKey is exactly equal to an OP_n (with n between 0 and 16, inclusive) followed by a direct push of exactly 2 to 40 bytes inclusive:

If scriptSig not empty, fail.
Run segwit validation with the 2-to-40 byte push in scriptPubKey as program, the n value as version, and witness as input (see further). If this execution aborts, fail.

[From BIP16] If scriptPubKey is exactly equal to OP_HASH160 + a 20 byte push + OP_EQUAL, run P2SH validation:

If scriptSig does not consists of only pushes, fail.
If result is empty, fail.
Interpret the top element of result as a script, and execute it, with the rest of result as input. Call the resulting stack p2sh_result. If this execution aborts, fail.
If p2sh_result is empty, or its top element has numerical value 0, fail.
[From BIP141] If the top element of result is exactly OP_n (with n between 0 and 16 inclusive) followed by a direct push of 2 through 40 bytes inclusive:

If scriptSig is not exactly a direct push of the top element of result, fail.
Run segwit validation with the 2-to-40 byte push in the top element of result as program, the n value as version, and witness as input (see further). If this execution aborts, fail.

If segwit validation did not trigger, but a witness is provided in the transaction input, fail.
If no failure occurred before this point, the input is valid.

Segwit validation
Segwit validation for version version, with program program, and input input:

[From BIP141] If the version is 0:

If the program is not 20 or 32 bytes, fail.
If the program is 20 bytes hash:

If input is not exactly 2 elements, fail.
Execute the script OP_DUP OP_HASH160 hash OP_EQUALVERIFY OP_CHECKSIG, with initial stack input. If execution aborts, fail.
If the resulting stack is not exactly one element, or that element has numerical value 0, fail.

If the program is 32 bytes hash:

If input is empty, or its top element's SHA256 hash does not equal hash, fail.
Execute the top element of input as script, with the other elements as input. If execution aborts, fail.
If the resulting stack is not exactly one element, or that element has numerical value 0, fail.

[From BIP341] If the version is 1, the program length is 32, and this is not operating inside a P2SH wrapping:

If the input consists of 0 elements, fail.
If the last element of input starts with byte 0x50, call it the annex and remove it from the input.
If the (remainder of) input consists of a single element, evaluate it as a Taproot key path spend:

The element is interpreted as a single BIP340 (Schnorr) signature for the transaction, using a message hashing scheme described in BIP341. If the signature is invalid, fail.

If the (remainder of) input consists of two or more elements, evaluate it as a Taproot script path spend:

The last element of input is interpreted as a Taproot control block, encoding a leaf_version, an internal x-only public key, and a Merkle path, and the penultimate element of input is called the taproot_script. The control block and taproot_script are removed from input.

Recompute the Merkle root of the script tree, starting from the leaf (leaf_version and taproot_script), and then tweak the internal x-only key with that Merkle root. If the result does not match the 32-byte witness program, fail.
[From BIP342] If the leaf_version is 0xc0, taproot_script is evaluated according to the Tapscript validation rules, with the remaining of input as initial stack. See BIP342 for how this differs from normal script execution.

If no failure occurred up to this point, return success.

Source: https://github.com/bitcoin/bitcoin/blob/v25.0/src/script/interpreter.cpp, functions VerifyScript, VerifyWitnessProgram, ExecuteWitnessScript.
TL;DR: only the BIP16 P2SH pattern (OP_HASH160 <20 bytes> OP_EQUAL) and the BIP141 segwit pattern (OP_n <2 to 40 bytes>) are actual special cases that trigger additional rules. But the details are more complex.

In the P2SH wrapped case, should this be "Run segwit validation with the top element of result as program" (instead of scriptPubKey as program)?

@Elliott Fixed.

@PieterWuille For P2SH validation you wrote: "If scriptSig does not consists of only pushes, fail." But the redeem script (i.e. the top element of result) can contain whatever OP codes we want?

Yes, the scriptSig must consist of only pushes. The last of those push is the redeemscript, which when the data being pushed is interpreted as a script contains opcodes.

@PieterWuille I didn't ask the question well. I wanted to say that the redeem script can contain any opcodes we want, they don't have to be push only?

Yes, the redeemscript is any script, it can contain any opcodes. It's just the scriptSig that must be push only for P2SH spends.

@PieterWuille Taproot (BIP341, BIP342) doesn't break any of the rules you wrote in your answer? It would represent just another "if the version is 1" in the Segwit validation section with some rules of its own?

@joke Correct, it's just adding a "if version is 1, witness program is 32 bytes, ..." branch.

@PieterWuille Couple of additional questions. 1) For P2WSH in P2SH you wrote: "If scriptSig is not exactly a direct push of the top element of result, fail.". Does it mean that in this case any additional pushes are not allowed (opposite to P2SH)? So only the push of the redeem script and the redeem script is "OP_n (with n between 0 and 16, inclusive) followed by a direct push of exactly 2 to 40 bytes". 2) For P2WSH you wrote "If input is empty, or its top element's SHA256 hash does not equal hash, fail.", is it more accurate to say the last item of witness data since it's not stack?

@PieterWuille 3) For P2WSH you wrote "Execute the top element of input as script, with the other elements as input. If execution aborts, fail.". Are these other elements i.e. the other elements in the witness data, the initial stack? 4) Do these other items have to be push only, like in classic P2SH, or can some other OP codes as well?

Yes, no other pushes are allowed (because inputs need to provided through witness, not through scriptSig). 2) The list of witness items is called a stack too, though admittedly that name isn't very accurate. But yes, last element. 3) Yes, for P2WSH the witness stack consists of the witness script's inputs, followed by the witness script itself. All but the last element become the initial stack for execution. 4) The witness stack is not a script, it's just a list of elements; it has no notion of opcodes or pushes - rather, it's the resulting script stack itself.

@PieterWuille Okay, for the last (4) question/answer. In P2SH, the scriptSig consists only of OP_CODES for push + the data being pushed and the last push is the redeem script. In P2WSH, there is no push OP_CODES in the witness script, it is just one element next to another, which will be placed in order on the stack, while the last one will represent the redeem script itself which will work with previous items as initial stack. So there are no classic: op_code_push data, op_code_push data etc. as in P2SH, instead it goes: data data data (last data = redeem script) etc.?

All correct. The witness stack is just an array of byte arrays. For P2WSH the last one is interpreted as the witness script, the rest becomes the initial script execution stack.

@PieterWuille You wrote that If the top element of result is exactly OP_n (with n between 0 and 16 inclusive) followed by a direct push of 2 through 40 bytes inclusive SegWit validation is started. For SegWit, you only wrote the if case for version 0 (and let's assume for version 1). But what will happen if the version is, for example, 2 or 3? Will it be recognized as a normal SegWit and then checked the scriptsig. If it is not empty, an error is thrown, and if it is, the script is immediately accepted without any additional checks of witness data since if case for v2/v3 not exist?

Indeed. Future segwit versions are effectively anyone-can-spend outputs (until there is a consensus change that does introduce rules for them, of course), subject to things like empty scriptSig.

@PieterWuille Sorry, but no sure if I understood correctly subject to things like empty scriptSig. So, for example scriptPubKey OP_2 <26-bytes> will be recognized as segWit since it is, as you said: exactly equal to an OP_n (with n between 0 and 16, inclusive) followed by a direct push of exactly 2 to 40 bytes. Since nothing has been defined for v2 yet, it will be anyone-can-spend and only check will be if the scriptSig is empty. Empty = accept, otherwise not. The content of witness is not important in this case (it will become important after the rules for v2 are introduced). Right?

@joke All correct. The contents of the witness does not matter when spending a v2 segwit output (for now). If the scriptSig is not empty (or in the case of P2SH-segwit, consist of more than the redeemScript), that makes the spend invalid. Also, non-segwit outputs require that no witness is provided when spending them.

@PieterWuille Should it be added for P2WPKH right at the beginning that if the input is empty, fail?

@joke There is no separate rule needed for that, actually, nor do I believe such a rule is implemented. If the input is empty, the execution of the OP_DUP OP_HASH160 ... script will fail.

@PieterWuille Checking whether the input (witness data) is empty does not exist in P2WPKH, but is there a check that there are exactly 2 elements? Vojtěch Strnad wrote in his answer  that such a check exists.

@joke There is no specific separate rule for that either in implementations. If there are not exactly 2 input elements for implicit P2WPKH script, it will fail execution (due to the "cleanstack" rule that says exactly 1 element must be left after execution). You can certainly say that to be a valid P2WPKH spend must have 2 witness input items, but whether or not you consider that also a rule is unovservable.

@PieterWuille What about this?

@joke Interesting. I misremembered, and you're totally right; both the specification in BIP141 and the implementation in Bitcoin Core specifically check for 2 stack elements exactly. I still believe that this rule is unnecessary (the exact same scripts/witnesses would succeed and fail without it), but my claim in the comment above was wrong.


text:
Why are `update_add_htlc` and `commitment_signed` separate messages?
BOLT #2 indicates that a node will send one or more update_ messages before a subsequent commitment_signed.
Since it seems like sending a payment over a channel involves update_add_htlc followed by commitment_signed (without needing a response from the peer in between), why do these need to be two separate messages?

The  commitment_signed message is also used at other places to move forward channel state. The entire process is not only described in BOLT02 but also in Mastering lightning
https://github.com/lnbook/lnbook/blob/366a65b33045cbb9e95a3d4060005c240f1f1778/channel-operation.asciidoc
There you can see that after Alice sends and update_add_htlc message and a commitment_signed message Bob will later in the protocol also send a commitment_signed message so that Alice can also move forward her state. Remember Bob and Alice both have an asymmetrical version of the commitment transaction for each state and both need a signature from the other side. It would be strange if Bob replied with an update_add_htlc message to send over signatures even though he does not want to add an htlc.
So yes while signatures could have been included in the update_add_htlc message we still would have needed the  commitment_signed for Bob to reply. Also when stetteling htlcs the commitment_signed messages are needed again. I guess in that way it seems more reasonable to make the exchange of signatures explicit with its own message instead an reusing it. But of course that was a choice that could have been taken differently.


text:
LND doesnt create macaroons or directories
I installed lnd and got to the point of creating a wallet with "lncli create" but I get an error "unable to read macaroon path" and gives the path of where the macaroon should be. I believe when you start lnd for the first time it creates these macaroons along with some other files and folders but mine only created
tls.cert
tls.key
logs/bitcoin/mainnet/lnd.log
data/graph/mainnet/channel.db
And no macaroons. Does anyone know why it would create only some of the files and folders?? Stumped!
Running on Ubuntu 20

So I installed v0.11.0-beta and it fixed the problem. There are definite bugs in the master.

What version of lnd is this? I had the same problem on git master, it vanished when I changed it to 0.11.0-beta. Seems to be a new bug. I already passed it on to a dev, but you might want to open a formal issue as well.