text:
How can I tell if an address belongs to my cold storage wallet?
When I created an Electrum cold storage wallet, I started out with 20 receiving addresses. I quickly burned thru using those, sending BTC to my wallet while wanting to only use any given address once.
In addition to the offline cold storage wallet, I also created two Electrum watch-only wallets, one on my connected PC at home and a second on a connected PC at work. Oddly, when creating the watch-only wallet for my home PC, I simply chose to add the 20 original receiving addresses to the watch-only wallet; but when I created the watch-only wallet on my work PC, I selected the option to use the master pub key (xpub/ypub/zpub), which seemed to populate my original 20 receiving addresses without me having to import them (and now while editing in these additional details I am thinking this is likely the source of the unexpected 30 addresses that just showed up in my watch-only wallet).
So because I was using up my original 20 receiving addresses, I generated 110 more addresses using the console (something like: wallet.change_gap_limit(110)) in my airgapped cold storage wallet. But when I went to add those additional 110 addresses to my Electrum watch-only wallet, I saw that my watch-wallet had an additional 30 addresses already unexpectedly added to my wallet (since the last time I logged in), for a total of 50 (30 + the 20 original), not counting the 110 I generated in my cold storage wallet.
I compared the additional 30 addresses with the 110, and none of them match. So now I am perplexed and a little wary of those additional 30 addresses, since they just showed up in my watching-only wallet, coincidentally when I was just about to import/add the 110 addresses generated by my cold storage wallet.
Although I am wary, I hope there is a perfectly logical answer to explain the unexpected addition of 30 new addresses in my watching-only wallet.

Assuming you've sent some transactions from the wallet, have you accounted for change addresses?

@VojtěchStrnad I haven't sent any transactions "from" my (cold storage) wallet, but have only sent transactions (sats) "to" the addresses generated by my cold storage wallet, and I am using a watch-only wallet to monitor those transactions, keeping my cold storage wallet isolated.

@VojtěchStrnad and I am not sure what you mean by "accounted for change addresses." Do you mean change addresses as opposed to receiving addresses? I should have clarified that the unexpected additional 30 addresses in my watch-only wallet are receiving addresses. Although there are now a number of change addresses added that were also not previously there; but I wasn't overly concerned about those since I am only using receiving address atm.

Could you describe in more detail what you did when you "generated 110 more addresses using the console"? Which command did you use with what parameters (please obfuscate any private information please, obviously)? Is it possible that your cold storage wallet already had a bigger gap, e.g. had generated the 100 receive addresses 0–99, and therefore the 110 new addresses are e.g. index 100–209, whereas your watch-only wallet only was tracking 20 and the first 50 are obviously at a lower index?

@Murch yes, I used the console to increase the gap, using a command like: wallet.change_gap_limit(110). Unfortunately I do not know for sure what the gap was before running this command, but I think I read the default was 20. Is there perhaps a file associated, probably with the watch-only wallet, that mint hint at where the unexpected 30 additional addresses came from. For now I am ignoring them because I don't see how to verify they are indeed from or associated with my wallet.

@Murch one other oddball thing I did regarding my watch-only wallet, before ever creating the 110 addresses, is on my connected machine at home I created an electrum watch-only and added the 20 original addresses; but on my connected machine at work I created another electrum watch-only wallet, but I input my master public key (xpub/ypub/zpub), and I remeber th original 20 addresses got auto-populated in the addresses tab. Perhaps using the master pub key allowed that wallet to increase the available addresses as my original pool of 20 addresses began to get used up?

Hey naphelge, could you please edit your question post to incorporate the information requested in the comments (also see comments)? Could you also clarify, the watch-only wallet that created the 30 additional addresses, was it created by importing 20 individual addresses or was it created by importing an xpub (or something else entirely)?

@Murch Done. Yeah, sorry, I didn't even think of those additional details until you guys started asking helpful questions for clarity.

So the 30 additional addresses appeared on the work PC that was created with the master pub key?

I’m not particularly familiar with Electrum, so I’ll try to provide some highlevel ideas how to investigate this further.
To recap there are three wallets:

A: air-gapped wallet with private key
B: watch-only wallet from master public key
C: watch-only wallet from 20 individual addresses

There seem a few plausible sources of a discrepancy:

Wallet C does not know either the master public key or the master private key. If Wallet C were asked to generate more addresses, there would be not enough information to extend the prior series. I do not know what the expected behavior would be: my first instinct would be that a watch-only wallet from a set of imported keys would throw an error when asked to create more addresses, but I could see that a wallet might generate a new secret key to extend a watch-only wallet with more addresses when that is requested (although I’d be surprised). If the latter were the case, the private key to those new addresses would obviously not be part of Wallet A.
Wallet B automatically generated the first 20 addresses you saw on Wallet A from the master public key. It would be incredibly odd if it succeeded for the first twenty but then used an unrelated key chain for the next thirty subsequently. This would most likely point towards either Wallet A or Wallet B having been used in a different way for the second batch of addresses than for the first batch of addresses, e.g. there could have been another derivation path added, or Wallet A was switched to hardened derivation.
Alternatively, Wallet A and Wallet B may have generated addresses from the same series but in different index ranges. Wallet A may have had a larger gap limit than the original 20 addresses you saw, and when more addresses were returned, these addresses were actually beyond the first fifty.

I would try to look for RPCs that provide detailed information on wallets and addresses. If you can find an RPC that states the master public key and the used derivation paths, you would be able to determine whether the addresses are part of the same series and check on their indices.

thnks for the nice distillation, as I am still wrapping my head around all the parts here. Using the master pub key is surely the source of the additional 30 addresses on my work pc. I have subsequently created a new watch-only wallet on the work pc without inputting the master pub key and only importing the 130 addresses that I know for certain are from my cold storage wallet. That seems like the best way atm to add new addresses as required: generate them in the cold storage wallet and then import them to the watch-only wallets.


text:
How can I automatically create and broadcast transactions using NodeJS?
I have a:

Wallet public/private key pair with X BTC
Wallet address I want to sent Y BTC to

I'm developing an app in NodeJS and trying to initiate payments automatically. I'm very confused how I'm supposed to do this.
From my research, it seems like I have to generate some "raw" transaction hash, then encrypt that again with my private key, then I'm supposed to broadcast that encrypted data.
Is there some library/some simple API that can help me do this? I don't want to have to run a bitcoin server if I don't have to...

Follow this example: https://github.com/OutCast3k/coinbin/
This app does everything you need

source: Stack Exchange

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

sort: votes


text:
How Custody Settlement Blockchain-Based Solutions Work with Centralized Exchanges
I read How does clearing & settlement work on crypto exchanges and have a follow-up question:
Can you explain in more detail how our own custody for settlement on the blockchain would work if we want to integrate it with a public centralized exchange and a private sale?

When users deposit assets into an exchange, they make an on-chain transaction to their deposit address on an exchange. When they pay to that address, the exchange takes custody of the funds and credits the user a corresponding balance in the exchange’s database.
When users trade on the exchange, the exchange tracks orders in their trading engine and updates the user balances in the database as trades get executed.
When users withdraw funds from the exchange, the exchange makes an on-chain payment to an address provided by the user and correspondingly debits the user’s balance in the exchange’s database.
As far as I am aware, public exchanges only facilitate trades through their orderbook. If you were to perform a private sale, you would perhaps use an OTC desk or directly facilitate the trade with the buyer directly.

Thanks for the answer.

I need the solution for the custody like how's finical custody work with exchanges when we list any assets/commodities with tokenizations on blockchain

When a user deposits fiat currency through a bank, we need to mint a token on our blockchain. This token is then sent to the exchange’s hot wallet, and the user’s account balance is updated in the exchange’s database. The user can start trading using the balance reflected in the database.

If the user wins and wishes to withdraw fiat, we must update the balance in the database and either transfer the corresponding tokens from the exchange’s cold wallet or burn that amount to match the custody balance. If the user loses, someone else gains, and we adjust all trade balances in the exchange's database accordingly.

We only need to update the blockchain during deposit and withdrawal processes or when assets are listed or delisted. During these events, we update custody records, settle balances, and perform reconciliation to ensure that the deposited amount matches the withdrawn amount
That is whole system with centralised exchange & blockchain custody & settlement

We don’t need to add every exchange transaction to the blockchain. Instead, we only need to update the custody and settlement records and then reflect those transactions on the blockchain.
Custody settlement refers to deposit and withdrawal of tokens like USDC, as well as listing, delisting, or minting tokenized assets such as oil. These actions require transferring tokens to the exchange wallet after updating custody following the listing.

Hi Sohail, a lot of the things you bring up in these comments were not covered in your question post. Perhaps it would be best if you update your question to provide more detail about what you are trying to do. For what you describe, it’s not clear to me why you would need to take custody and mint tokens instead of just selling them. It sounds to me like you might be trying to create a brokerage for stablecoins. Either way, this page is only focused on Bitcoin, not on other cryptocurrencies, and neither on business design.

Hi Murch.
I totaly agree with you.
The things is i'm trying to get a best solution with custody and exchange so i wana understand when we talk about custody of assets on blockchain and able to trade into centrlized exchange, how we are able to bring the best solution based on tokenizam of assets.

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


text:
Eltoo: Does the relative locktime on the first UTXO set the lifetime of the channel?
When we open a lightning channel using eltoo / LN symmetry (standard 2/2 multisig), the setup/funding transaction must be recorded on-chain in order to prevent a "double spend" of the funding inputs (and effectively stealing the channel balance).
However, what I do not understand is why that UTXO, now recorded on-chain, cannot be spent via the settlement transaction after the relative timelock has expired. This timelock would otherwise, the way I (miss-)understand it, define the ultimate lifetime of the channel which would be very inconvenient.
What am I missing here?
Including the (great) graphic from Richard Myers to illustrate what I mean:

Yes, you’re reading it right. The construction presented here has a limited lifetime since the Settle_0 transaction becomes valid at some point. However, later in the paper, the authors introduce an additional trigger step.
From section “4.2 Settling a contract”:

In its current form the off-chain protocol has a limited lifetime since the shared output script has a settlement branch that becomes active after a timeout.
[…]
In order to avoid having to refresh the contract on-chain simply to keep the timeouts from expiring, we introduce an additional step in-between the setup phase and the settlement phase: the trigger step.

The time-lock for the Settle_0 is then defined relative to the confirmation of the Trigger transaction. Both Settle_0 and the Update transactions then spend the output of the Trigger transaction rather than the output of the Setup transaction. That way channels no longer have a limited lifespan, but an additional transaction is required to close channels unilaterally.

Thanks! So with the above construction, you could then just choose an extra long delay for the first state, right? It's unlikely the channel partner "disappears" right after opening a channel anyway.

Yes, but you don't want to give too much time, since a malicious counterparty can lock up your funds at whim.

Thanks for the feedback! I replaced "Update: 0" with a "Funding: 0" which is put on-chain when the channel is opened and the channel parties have both signed the first off-chain "Update: 1". Note that "Funding: 0" does not have  a settlement path, but can be spent by any of the updates (or cooperatively closed).
This diagram does not yet show all of the features of the current design, but hopefully still helps give the general idea.

Current thinking is (I believe) just to have a funding utxo on chain ("Setup_0") which is always spent by some update transaction ("Update_1" etc; there is no "Settle_0") which in turn can be spent either by a later update transaction, or, after a relative timelock, by a settlement transaction ("Settle_1" etc). (In this model the update transaction is acting as the trigger step)
See
https://github.com/instagibbs/bolts/blob/505ab7997bd72708266689a97dcdce9a8f727045/XX-eltoo-transactions.md
eg.


text:
Mining on your own network, or creating your own mini pool
I have one computer set up and solo mining away. The bitcoin client is running in server mode, and bfgminer connects to it with -o 127.0.0.1:8332.
I have a second computer that I'd also like to mine with too, but using the first computer as the server, so that I only need one instance of the blockchain/bitcoin client. Is that possible?
I tried to connect to it with -o 192.168.1.8332, which my router tells me is its network address. But bfgminer fails, saying that I probably got the address wrong.
The firewall is allowing bitcoin-qt.exe through, and I set it to allow port 8332 too, just in case.

I finally sorted this out, so I'm back 17 days later to answer my own question. I also wrote a short article about the steps, should anyone else need them.
Here are the basic steps. The coin is referred to as Coin, as this works with all sha256 coins, and probably (untested by me) Scrypt variants as well. If not, the process will be very similar.
To start, your coin.conf file should look something like this:
daemon=1
server=1
listen=1
gen=1
rpcuser=uncle_bubs
rpcpassword=your_mother
rpcallowip=127.0.0.1
rpcport=8332

In your coin.conf file, add the line rcpallowip=12.34.56.789, replacing the IP address with the address of the computer you want to allow, or more simply rpcallowip=192.168.1.* to allow any IP address on your network. You can have as many rpcallowip lines as you want. Note that doing this will send your password unencrypted over the network, so it’s not recommended except within a secure network that you control.
Make sure your firewall is allowing incoming connections to coin-qt.exe.
Start coin-qt.exe -server on your server, and give it a moment to get caught up. (You should have the blockchain current before starting).
On your second computer, go into your router’s admin settings and look at the connected devices. This is usually done by entering 192.168.1.1 in a browser. You’ll need the router username and password to get in.
Look for the computer running your server. Mine was 192.168.1.8.
Now add that IP address and computer to the list of reserved addresses. The reason is that even if you leave your computer plugged into the same router all the time, it sometimes shuffles IP addresses unexpectedly. This is normally not a problem, but you need a fixed IP address to connect to. This step ensures your server always has the same IP address.
Finally, start your second miner, using the new address and port obtained from your router settings. Mine was 192.168.1.8:8332.

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


text:
Is there software that can scan for reused R-values?
Is there any up-to-date program that can check for reused R-value for a specific Bitcoin address? (I don't want to scan the whole blockchain, just for a particular address.)

I'm assuming you will be looking for transaction input data from specific accounts?

It is not a problem to write such code. I am not familar with taproot signature encodings but checking R values for specific p2pkh address (adresses 1xxxxxx) can be coded in one day ))) If you have synced blockchain on your PC

I have parsed the entire blockchain and saved on drive. The address has 245 000 input transactions. There is some programmes on github for the purpose but unable to handle 245 000 reading inputs


text:
Unknown coin Bitcoin and network regtest combination
I know that this repo of kyuupichan is not supporting Bitcoin anymore
So I cloned this repo of spesmilo instead
However when I run the electrumx_server, I get the following error:
electrumx.lib.coins.CoinError: unknown coin Bitcoin and network regtest combination
Environment Variables:
export DB_DIRECTORY="/home/omarosman23/.electrumx/db"
export NET="regtest"
export COIN="Bitcoin"
export DAEMON_URL="http://rpcuser:rpcpassword@127.0.0.1:18443"
export SSL_CERTFILE="/home/omarosman23/.electrumx/server.crt"
export SSL_KEYFILE="/home/omarosman23/.electrumx/server.key"
export DB_ENGINE="leveldb"
export CACHE_MB=500
export SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc:/

Any insights would be much appreciated!


text:
How can I import a legacy private key without a wallet file?
I have legacy private key. How can I import it on the newest Bitcoin Core?
Please describe the steps I need to follow.

In what format is the key?

In 64 bit hexadecimal format


text:
Monitor multiple p2wpkh addresses
I'm actually making a crypto deposit gateway,
I succeed to create multiple public addresses with derivationPath using bitcoinjs-lib,
But the thing is I'd like to know what is the best way to monitor them ? (regarding to ressource cost and number of wallets I need to monitor)
Knowing that the number of address to monitor can be huge and exceed 10k for example (if I have 10k users).
The logic behind it is when a user create an account I'm gonna create him public address and assign it to him in database side, after that I just want to detect incoming transactions to be able to add him the amount present inside the transaction.
Regards,

If you intend to monitor an enormous number of addresses or output scripts, regular wallet software will probably not scale to your needs.
You may want to use a database based approach in conjunction with your own instance of blockchain explorer software (e.g. mempool.space, Esplora, or Electrum Server). If your needs scale beyond that, you may want to run your own indexer (see e.g. rust-bitcoin-indexer).
I suggest that you do not assign each user a single address, but rather an extended pubkey, i.e. an entire series of address. While some users might still reuse addresses, this will enable your savvy users to use fresh addresses for each deposit which will vastly improve your and their financial privacy.
You may also find it useful to look into projects such as BDK and BTCPay Server which may meet your needs out of the box at least initially.

Hello, thanks a lot for you answer, I think I'm just gonna follow your advice, I'll just make a deposit page where the user gonna select which crypto he want to deposit (bitcoin in this case for example), and then I will redirect him to a page where I will show him the address where he need to deposit and I will monitor it using blockchain.info websocket (I'm still not aware of their limits, still waiting for an answer from them) and monitor it for a restricted time, like 30mins maybe, and after this time, the "deposit page" will no be usable anymore

The problem here is that Bitcoin addresses remain valid indefinitely after you have handed them out, so stopping to monitor them after 30 minutes may lead to frequent support requests. I would suggest that you monitor each address in perpetuity after giving it out.—Otherwise, you may need to manually backfill frequently, as transactions taking more than 30 minutes for confirmation is not uncommon.

Yes you are right, I've checked BTCPay and it's very interesting, I can add altcoins with it etc.. to it, that's pretty cool
Do you know if BTCPay respect the privacy of their customers ? I mean if they collect any data etc.. ?

If you have a new question, please create another topic.


text:
In layman's terms, can anyone explain to me how miners generate Bitcoins and process transactions at the same time?
I don't grasp how to the activities are tied together.

miners are like accountants that do accounting for a business. they run the software that does the maths to "verify" transactions are valid. these accountants (miners) are rewarded for their time / effort in creating new ledger pages (blocks in the blockchain), which they in turn need to verify transactions

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


text:
Is it possible to assign a single "from" and a single "to" address to Bitcoin transactions?
I am working on a project where we need to get the "from" and "to" address for every transaction across a number of cryptocurrencies. In account-based currencies, this is pretty straightforward, but in UTXO-based it's not. Are there known algorithms that "normalize" between the two?

No, Bitcoin transactions cannot be cleanly projected on a single "from address" or a single "to address". Bitcoin can facilitate many payments in a single transaction and there may be multiple senders and usually are multiple receivers.
Even in a simple transaction where one user pays another user, the sender may use multiple inputs, and almost always will assign a change output to themselves. Thus, there is one sender (or more) and two receivers.
Nothing stops multiple users to create a transaction together. E.g. in a PayJoin transaction, the receiver contributes an input to a transaction that pays themselves, thus making it two senders, and one or two receivers (depending on whether there is change).
Two users may also join to make separate payments in one transaction. In a so-called CoinJoin transaction, they each are contributing their own inputs and assigning some funds to receivers and sending change back to themselves. So you might for example have two senders and four receivers.
The challenge gets a whole new dimension when you think about how custodial services work. When you e.g. send funds from an online wallet service or brokerage, the service will often batch dozens of payments/withdrawals together and pay them all from their omnibus wallet. The initiators of the payments and withdrawals do not control any of the addresses that fund the transaction, but are "senders" in the sense that they mandated the payments. The custodian is the actual sender, but may not know who any of the receivers are and is only executing payments on behalf of customers. E.g. sending to any of the "from" addresses of the transaction would likely credit some random user of the service which is neither the service or any of the senders.
There is no such thing as a "from" address in a bitcoin transaction, and you can usually not distinguish whether an output goes back to the sender or to a receiver.
I would suggest that you assume a general case of multiple senders and multiple receivers for each transaction in your model, and track account-based cryptocurrencies as the special case of a single sender and single receiver. Note that even for account-based currencies, a lot of smart contracts also allow sending to multiple recipients in one transaction.

Is there a resource out there with blockchain processing algorithms?

Well, there are a bunch of opensource libraries and wallets that do "blockchain processing", but it's hard to answer such a general question.


text:
What prevents miners from removing transactions when validating a node?
Simple question: when a miners receives a block of transactions, he can't add fraudulent transactions because they need to be appropriately signed, but what prevents him from erasing a tx? If he manage to find the correct nonce of the modified block, as I understand it will still be a valid block accepted by the blockchain.

I think that's a different question. That's can a miner ignore a transaction when mining a block versus can a miner receive a mined block and take a transaction out of it. Related though I guess.

Yes it was not exactly the same but still answered my question. In fact it doesn't matter, the erased Tx will still be available for others minors to pick it up and it will eventually be processed if corresponding fees are competitive. Thank you for the clarification.

If a miner makes any change to a block the proof of work is no longer valid and it has to start the mining process from scratch again. So a miner can refuse to accept a valid block mined by another miner but it generally isn't in their interests to as the rest of the miners will have moved onto attempting to mine the next block on top of that block.


text:
Using online exchange like ChangeNOW or FixedFloat to create anonymity?
Online exchanges like ChangeNOW, SimpleSwap and FixedFloat, unless they keep records for a long period, which theoretically might be later accessed by authorities, might offer considerable privacy. I used one of these, with the Tor Browser, to exchange a coin I had bought on a KYC exchange to another kind of coin that then went to my personal wallet. No information other than the two addresses was provided to the exchange. I took a chance by not providing an email address that I might have difficulties if something went wrong, e.g. losing my internet connection, but the exchange also provided a case number and, in fact, I had no problems.
Am I missing something, or does this provide anonymity to the bitcoin that ended up in my wallet? This might be something that one would not like to do with a large amount of coin, but that was not a problem for me!

Hi Frungi, it's not clear to me how we could provide insights about some services' internal data management policies. If you see how you can rephrase your question to make more obvious how it relates to Bitcoin in general, please edit your post and flag for reopening.

Assuming you're seeking financial privacy from other network participants, yes probably. Else it depends on what kind of information access your hypothetical adversary has.
I'm not familiar with any of the three services. Cursory search seems to indicate that they are centrally operated, but some are referred to as “non-custodial”. It's not obvious to me, what said feature is supposed to entail exactly or how it is implemented, but I didn't try too hard to find out.
I did not see any indication or promises that the services do not keep logs. In fact, since some of these services advertise their great customer support, I would expect them to keep comprehensive logs in order to be able to respond to customer support requests. Obviously, nobody but the employees (or maybe even just a subset of them) can tell you what the actual internal data retention practices of these services are.
That being said, trading to another coin will disintermediate your transaction history to all but the exchange that facilitated the trade (“swap exchange”). Depending on how the swap exchange receives the deposits or facilitates the trade, the service that you originally purchased from (“original exchange”) would not necessarily know who you sent to, but especially would have almost no chance to connect it to the later payment that sent you the other currency, except perhaps by the amounts transferred and the timing or via combined information from original and swap exchange.
There are still records of:

your original purchase at the original exchange with your full customer info
the onchain record of the transfer(s) connecting the original exchange and the swap exchange
the record at the swap exchange where you hopped chains
the onchain record of the withdrawal from the swap exchange
wallet fingerprints, transactions you made, etc. that might be linked by a sufficiently motivated sleuth

So, it does improve your privacy from other network participants in general, but depending on what your threat model is, an adversary might a) just ask customers of the original exchange what they did after purchasing there, and generally assume that you still own the coins unless you provide information that convinces them otherwise, or b) assuming that your purported adversary has access to the logs of both services simply be able to follow the path completely.


text:
Why are there more than two transaction outputs in a coinbase transaction?
In a coinbase transaction there are always more than two transaction outputs.
The first transaction output contains the reward. The second contains the witness reserved value.
But why are there other transaction outputs OP_RETURN with 0 Satoshis? Are they necessary?

A coinbase transaction can have as many outputs as the miner who created it wants. You may see that there are not just one output for the reward, sometimes there are multiple outputs so that the coinbase transaction pays to multiple miners. Additionally, there may be other 0 value OP_RETURN outputs if the miner so chooses. Typically this is because the miner wants to include some additional data for another protocol that they are using.
Additional outputs are not required by Bitcoin's consensus protocol. In fact, Bitcoin does not require any particular outputs. A miner could forfeit all of the generated coins by creating an output with less than the correct amount. A miner can include other OP_RETURN outputs just because they feel like it. Even the BIP 141 OP_RETURN is only required if the block contains any segwit transactions, so if it does not, it doesn't need to be included.
The most common reason for other outputs that go to addresses and have positive value is for mining pools which directly pay their miners from the coinbase reward. Most mining pools do not do this, but some do. There are also peer-to-peer mining pools such as p2pool which directly pay the participating miners from the coinbase transaction.
For additional OP_RETURN outputs, the miner is typically participating in another consensus protocol that require commitments in the block. These are not required for Bitcoin, but rather for something else. There are two common protocols that miners participate in: p2pool, and merged mining. P2pool uses an additional OP_RETURN output to commit to some p2pool data that is stored elsewhere. Merged mining uses the Bitcoin blockchain to help protect an altcoin's blockchain by including a commitment from the altcoin in a Bitcoin block. This is typically done by including a hash in an OP_RETURN output.


text:
Where does a full node get the blockchain from for Initial Block Download?
I understand that a full node needs to do an IBD before being able to verify transactions. So, it downloads the ledger up to now, which is known as Initial Block Download.
But what I don't understand/know is, from where is the blockchain information being downloaded? Are other full nodes contributing in this activity, or is this information stored somewhere, and is retrieved from there?

Yes, they download blocks from other nodes they connect to.
In Bitcoin Core you have the choice between being a pruned node or not. In both cases all blocks are downloaded and fully verified, but in pruned mode old blocks are deleted after a while after being verified. This has a number of implications, but one of them is that a pruned node does not help new nodes perform IBD.

A pruned node can't help other nodes perform IBD even for blocks that it has?

It can, but nodes generally won't find peers that can. Since BIP159 it is possible for nodes to advertize to the network they are a "full node, but only promise availability of the last 288 blocks", which does get used for syncing, but it's only useful for the last 1-2 days.

Each bitcoin node connects to a number of other nodes on the bitcoin network (peers). Think of it like friends you share information with. You can ask them for information, and they can ask you too.
So new bitcoin nodes, when they first start, find other peers on the network, and then the new node will start asking for bitcoin blocks from the blockchain that it doesn't yet have (all of them!). All the peers will respond, sharing the requested blocks from their own copies of the blockchain.
As the blocks arrive, your new node will validate that the block is valid and that all the transactions are valid, and that it is linked the the prior block, and having done that - add it to its own copy of the blockchain.
This process iterates for all the blocks from 2009, up to today and can take anywhere from a day to a few weeks depending on a whole bunch of factors. Good news is that it only has to be done once! After that Initial Block Download (IBD) is complete, keeping up to date is very little work - one block every 10 minutes or so.
Your node will be helped a lot by your peers during IBD, and then once you're fully synced, your node will be able to help others.
Equally, if your node, or one of your peers is switched off for a while, when they come back the same process repeats so that you get up to date again.
Pretty clever really :-)


text:
In Bitcoin Core, are compact blocks pre-filled with more than just the coinbase?
In the "How are expected missing transactions chosen to immediately forward?" section of https://bitcoincore.org/en/2016/06/07/compact-blocks-faq/ it states that "To reduce the number of things that need to be reviewed in the initial implementation, only the coinbase transaction will be pre-emptively sent."
I found https://github.com/bitcoin/bitcoin/blob/master/src/blockencodings.cpp#L23 which still lists pre-filling more than the coinbase as a TODO. I was wondering if that was in fact correct or whether it was an erroneous TODO. If not, is anyone working on that functionality or is there a reason it was never implemented?

Adding more advanced prediction of what transactions are useful to prefill was probably intended as a TODO when Compact Blocks were implemented, but to the best of my knowledge, nobody has worked on it since.
It is worth pointing out that Compact Blocks in practice (and in non-adverserial situations) works extremely well. On my own long-running node, as of right now, out of the last 1000 blocks (~1 week), 944 were reconstructed without asking for any additional transactions. Out of the 56 where this wasn't the case, only 5 had more than 3 transactions missing.


text:
What are the pros and cons of P2P mining pools?
I've heard P2P mining pools are the answer to the current threat of mining pools controlling 51% of Bitcoin's hashing power.  Is this true or not true?  Does anyone have a supporting or critical assessment of P2P mining pools? What are the trade offs? Thanks in advance.

P2Pool allows individual miners to band together and find blocks with the reward being shared directly with the miners who participated in finding the block.  If you didn't contribute a pool share during a round, you wouldn't receive a payment for a block found by the round.  The pool has a lower difficulty than the network but greater than an individual miner.  That is, your miner can be submitting shares to the pool but you won't get a pool share unless one of your shares has a difficulty greater than the pool difficulty.  When somebody submits a share with a difficulty greater than the network difficulty, a block is found and everybody who contributed at least one pool share gets part of the reward.
So the trade-off is a high variance since you only get paid if you were participating at the time a block is found and you contributed a pool share.  And finding a block itself is highly variable since it depends on the total hash power of the pool (luck also plays a large role).
Depending on your hash power, you could run your own p2pool or join a p2pool set up by somebody else.  The advantage of joining a common p2pool is it increases your chance to contribute a pool share and thus share in the block reward.

The only advantage to shifting miners from using a centralized pool to P2P pools is that it may spread out the hashing power across multiple independent groups - balkanization of the hash compute power. This doesn't solve the problem, it just disrupts it slightly.
A P2P pool is still a collective effort working together as a single block mining entity.  There may not be a central server involved in a P2P pool, but the pool is still collecting transactions and creating a block to add to the blockchain.
If a P2P pool is large enough to produce 51% of the global network hash output, the pool would have the same potential to disrupt blockchain transactions as any other pool - if someone with malicious intent were able to gain control of the block creation process.
So, while a P2P pool might change where the block is created (central vs super node vs any node) and therefore the point of attack, shifting everyone from GHash to one P2P pool won't change the 51% threat.


text:
How to safely open an old electrum wallet from before any fork(s) (not opened since 2017)
It's late 2024 and I have an old electrum wallet, not opened (or used) since before 2017 (and any/all forks that have happened since then).
How do I open it to minimize the risk of losing any funds?
(In bitcoin, or in any other forks that may be worth anything).
(Other questions I've found here, and google searches, all seem to have info too old or too new, or assuming knowledge I don't have).

This is probably not an exhaustive list, but just from the top of my head. Generally, don’t rush things, take your time.
Protecting against loss of access

Make at least two backups of your wallet
Ensure that you have the mnemonic seed phrase backup, and know where to find it, if applicable
Preferably before putting too much money into your wallet, test your backup
Test your backups regularly thereafter
Preferably keep one backup in a different physical location: Overall you should have at least three backups spread over at least two locations.

Protecting against malware and hacks

Download updates for your software only from the project’s website
Verify signatures on the installer
Consider using a dedicated machine for your wallet
Consider using an airgapped machine (an offline computer that you only use to sign transactions, creating the transactions with a watch-only machine that is online)

Reactivating your old wallet

Can’t repeat it often enough: before doing anything else, ensure that you have made backups of your wallet, and maybe also the Electrum installation on the old device.
Don’t fiddle with the old installation. It used to work as it was. If importing the wallet into a newer version of the software doesn’t work, we can fall back to it.
If you have any reason to believe that your device with the 2017 wallet is insecure, do not unlock the wallet on it.
Make a fresh install of the same wallet software on another device and import a copy of the wallet on the new device. Generally wallet software should be able to import any prior version’s wallet files.
If that works, consider moving to a fresh wallet. Create the wallet, set up backups, test backups, then move a small portion of the asset to the new wallet, familiarize yourself, and finally move everything a week or so later.
If it didn’t work, keep your old machine offline, and try to open the wallet on the old machine. If it opens, consider moving your funds to a new wallet in multiple steps as described above. As your device is offline, create the payment transactions on the old (offline!) computer, and only move the transactions to an online device to broadcast them.
If you run into any issues, don’t panic. You covered your bases with backups and by leaving your old install untouched, right? Ask about any issues you encounter on public forums like here. Do not respond to any helpful "recovery experts" or other direct messages. More often than not, anyone not engaging in public is a scammer trying to hoodwink you.

Claiming forkcoins

First recover your most valuable asset. Move them to a fresh wallet as described above.
Only after the most valuable asset has been completely moved to a fresh wallet, import the key material to a wallet for the next most valuable asset. Disburse the asset or move it to another independent fresh wallet, then move on until you feel it’s not worth the effort.
Note that selling your forkcoins may lead to a significant loss in privacy for your most valuable asset due to tying together your wallet history and revealing your ownership to the counterparty.


text:
How do I troubleshoot port accessibility to allow inbound connections on MacOS?
I'm wondering if anyone has experienced anything like this. IPv4 ports seem blocked. I have tried everything to open a port on my Mac but the port seems blocked.
It's like the only port that can be opened is 22. I have port forwarding setup and the firewall setup as well.
I'm confused why tor inputs work while ip4 and ipv6 don't.
         ipv4    ipv6   onion   total   block
in          0       0       5       5
out         9       1       0      10       2
total       9       1       5      15

Is there some tools I can use to trace where the port is blocked?

I’m voting to close this question because while it's a well formatted question, it is about system administration not Bitcoin.

Tor is not using the usual ipv4 or ipv6 connexion ports, it use the 9050, 9051 and 9150 ports, it can be why tor is running, maybe the port is blocked by your ISP or a firewall in your network ? you can try using a VPN or a proxy to go arround this problem.
To check your port you gonna need to do this from an external location, here is some on line tool: Nmap Online, Port Scanner Tool, HackerTarget.com


text:
How to fix tdr delay error?
I have Awesome miner installed with all pre-requisites. I have my wallet details entered. I have also entered the AM program as an exception to Windows Defender. Every time I start the miner it starts and then stops again. I get the Windows tdr delay value is missing error.
Any help would be appreciated.

Apparently

Windows tdr delay value is missing or invalid - there is a file windows_tdr registry file in the TRM folder, run it. That will fix it

Maybe that is applicable to your situation?
If not, maybe it is worth contacting AM support


text:
Really URGENT Problem with Electrum for Android
I have a really URGENT and complex Electrum issue on my Android Phone (Huawei P30 Pro with still official Google Play Services on it).
HOW do I turn my Electrum Hot-Wallet from ~2017 on my Huawei Android P30 Pro back to a "normal functioning" wallet where I can easily make transactions without needing a co-signer (which also doesn't work properly, or I might be doing it wrong)? The problem is that it’s been over 7 years, and I can't find my 12-word backup anymore. It also seems that there are no private addresses anymore, which disappeared after 2 years of not using the wallet. Maybe they are still somewhere on the phone, but I don't know where exactly. I have a few hundred on it, and I need that. This is very urgent to me because I have to pay my invoices, and Christmas is coming.
It's a native segwit (which wasn't there before either, or is this the watch-only?) with a shown public Keyphrase (zpub) with bip32. I know the Seed Password, but since the update, I only get a long Passphrase which only allows me to create a Watch-Only Wallet, it seems. Before that, I had the private addresses, and everything was running as normal as it should be, but now I can't get my money out or even transfer it to a newly created wallet.
I've bought coins, and these are now on an address. But when I want to make a transaction (no matter how high), I get a QR Code that says it's a partially signed transaction which I have to present to the Co-Signer. And under it, there's a yellow box that says something about: "Warning: Some Data (TXs before / 'full UTXOs') were not 'added' at all, because they didn't have enough space. This could cause a problem when it comes to the Offline-Signing. To avoid that problem, use the Copy and Paste Function or the Share Function."
Like I wrote, there is money/coins on it, but I don't know if it matters if they're "On-Chain" with a blue BTC symbol and above the money I had in EUROS. But if it helps, all transactions I made over the past years are still in the "used" addresses folder, and the address I got my money on 2 months ago is there too.
It would even be enough if somebody could help me transfer it to another fully new wallet. PLEASE, be kind. I'm so frustrated and can't get my money back or transfer it. I also don't know where/if the private keys are still saved on the phone anywhere. PLEASE HELP ME. I even wanted to contact the programmer of Electrum to see if they could help me somehow. I have too little knowledge about these kinds of things.
My current Electrum Version is 4.5.8, Protocol Version 1.4, Qt Version 6.4.3, PyQt Version 6.4.2, License WITH License. PLEASE HELP ME. I have no ideas or nerves left anymore.
Best Regards,
Dan
Oh, and over the field where you can read the Seed with the Password, there was always that Symbol "Encrypted" too. After the update, it's not there anymore. It seems like the update crashed the whole wallet. :/

Hey Dan, there is a lot going on in your post. Could you please proofread and format your post a bit to make it easier to read? If I understand right, your Electrum wallet was a full wallet and turned into a watch-only wallet. What happened in between? Did you uninstall the app or was it installed throughout?

Hey. I will try to make it more readable. Yes, correct, it seems so. Inbeteeed the App was inactive for 2 Years and did automaticly an Update over Google Play Store (which i have turned on to scan always for harmful Updates). Then it was on Version 4.5.7. and i wanted to use it again as im always did, you can see that I had the last made transaction 2 Years before. I opened it and buyed Bitcoins from where I always buy, It came without Problems and now I can do nothing with it. Always get the same output to need a co-signer for and yeah, i tried with all i could find but no chance. Regards

Oh and the 12 Words are NOW an very long Passphrase which i've never set on Setting up the Wallet 7 Years ago

And no, it was all the time at the same phone....

Hey Dan, I tried to help by doing some spell-checking and updating the formatting. Unfortunately, I’m not familiar with Electrum on Android, and especially not with upgrade bugs. I would recommend that you reach out to the Electrum developers directly as this probably needs some expert help.

Thank you @Murch i didn't had time, but now I have.

Yeah, I have...but they don't answer at all :(

I've wrote ThomasV on 2 different Mail-Adresses and the other one which I don't remmber the Name of...but no answer, no help, nothing :( For his own Product.....

Just to be clear, you are contacting open source developers that are donating their time to offer free software. They are in no way obligated to help you, so keep that in mind about the way you approach this topic. Given that it’s the weekend before Christmas, it may well be the case that they only find time after Christmas. Potentially a better contact point would be to file an issue on their GitHub repository: https://github.com/spesmilo/electrum/issues/new

I mean it is there Product what they've created, and I was getting ignored, no Answer, no Hint, how should I fix that Bug if I'm not even a Programmer at all. And this makes me sad, because the Mail was 2 Weeks ago. And to the other Programmer maybe 1 Week. :(

I have, probably 1 or 2 Month ago, i got no help at all. And i be friendly, write friendly, i'm just frusrtrated at this point. Sry

To be frank, if your email was of the same quality as your post here originally, I could see why they would have felt that it was too much work to respond. Electrum is a self-custodial wallet. It’s licensed under MIT: "The software is provided 'as is' without any warranty of any kind". It’s the user’s responsibility to keep a backup and use it correctly. If their update broke your wallet, they will probably feel like they should help, but if I were you, I’d try to make it as easy as possible for them, and make them feel that it’s a good use of their time.

I know what you mean, and i've gaved them the Link to this Discussion, it was 1 Supporter, who wanted to help, but I think he wasn't an expert at all, we just made an Software Update from .7 to .8 (the last one). And he didn't knew further. And that was it. I used the Wallet Corrrect, have an Backup but could not find it at all, i've used the Wallet correctly, but after I opened it 2 Years after it was in this condition. And I sat here day and night, researched, tried these and that....i mean it is unfortunley a matter of 30min for them of less to fix it that I get my Money out which I'm NEED.


text:
Bitcoin Core RPC for transactions of a new address without rescanning
I currently use the importaddress wallet RPC on Bitcoin Core to rescan the transaction history related to an address, which I then query using listtransactions. The address import takes about a hour as it necessitates to rescan the whole block chain.
Is there a faster way to query the historical transactions associated with an address using Bitcoin Core?

Hey, i've edited your post to make it clearer. It contained two questions though so i only kept the first one. Could you open a new question to ask about the providers?

The fraction of the problem solved for me by using Electrumx server. Electrumx rescan block files and indexed trx history information to the another database. It taken about 3 days. Therefore, I could get trx history and some other blockchain information using RPC call or opening web socket connections to the electrumx server.

You can rescan an address, or a bunch of addresses as defined by a range descriptor, using the scantxoutset RPC command. This will give you the current UTxOs paying to this (set of) address(es).
However, to rescan the transaction history you will have to use a watchonly wallet and perform a block chain rescan.

Actually I need to preprocess block chain addresses and rescan all balanced bitcoin addresses so far such that user does not sense slow rescan process. How do it?


text:
How do I get the private key of an address in descriptor wallets? How to dumpprivkey?
When I run dumpprivkey from Bitcoin Core 0.21.1. I get the following error message:
error code: -4
error message:
This type of wallet does not support this command

I came across achow's explanation stating that

"Descriptor Wallets store Output Script Descriptors in the wallet and
use these to generate the addresses that users can use. Legacy Wallets
(the non-descriptor wallet type, and the only type of wallet previous
versions would create) instead used private keys to generate
addresses."

If dumprivkey does not work, how can I get a private key from a descriptor wallet?

Master private keys for the wallet can be retrieved by using listdescriptors true and inspecting the output. There is also some ongoing work to make it easier to export these keys without having to interpret a descriptor.

Original answer from Aug 2021
It is currently not possible to export private keys from a descriptor wallet.
There is currently an open pull request which allows the listdescriptors command to optionally return descriptors with private keys. This will be the method by which private keys can be exported from a descriptor wallet.
Note that only the master private key used in a descriptor will be allowed to be exported from descriptor wallets. This is because descriptor wallets will be using unhardened derivation for the child keys and there is a known issue where having the parent xpub and a child key derived with unhardened derivation will allow the parent xprv to be computed. So to be clear to users that what they are doing is potentially unsafe, we will only allow exporting the master private key (it is more obviously unsafe when you have the master private key as users are unlikely to know about this weakness and may think that giving out child keys and the parent xpub is safe).

Is my understanding correct that the output of listdescriptors with the parent master private key is enough to recover the entire wallet using importdescriptor?

@MartinBraun Yes. The output of listdescriptors true is sufficient to recover your wallet.

This is too paternalistic. A user advanced enough to be able to extract the private key should know better what to do with it. This stuff just makes it harder to work with Bitcoin Core's wallet and forces us developers to go and look for third-party resources instead.

I feel like Bitcoin Core developers are going out of their way to make it difficult for wallet owners to manage their older wallets.  I have the important info (older wallet.dat and/or private keys) and "importing" or "migrating" these wallets seems unnecessarily daunting @Bilthon .  I go on blockchain.com and see that importing private key took all but 5 seconds.  Why couldn't I do something like that in Bitcoin Core GUI?

@JonGrah Importing has never been a feature meant for most users and it's always been a little obtuse. Migration is meant for most users, and there isn't really anything that you need to do with it except to click a single button.


text:
Mining in one years time
In about one years time, when mining is really difficult, what would be the incentive for people to mine?
And if there aren't enough miners, how would transactions succeed?

Won't happen because of pure greed, if people start leaving difficulty will drop and then it will become profitable again plus even if the normal person can't mine we will have some big company that will profit from mining and keep the network running. This poses other issues when big company's get involved but that's out of scope for this question.

If they're aren't enough miners then that means that people have lost faith in Bitcoin more than anything. If some miners drop out they will only make mining more profitable for others.


text:
Scenario: What would happen to Bitcoin if the internet would crash - world wide
What would happen to Bitcoin if the internet or power would be shut down for a moment, all over the world? Would this destroy Bitcoin or other block chain based money or technology?

Hi Artisan72, your question is possibly a duplicate of https://bitcoin.stackexchange.com/q/1738/5406, https://bitcoin.stackexchange.com/q/18958/5406, https://bitcoin.stackexchange.com/q/12207/5406

What would happen to Bitcoin if the internet or power would be shut down for a moment

It depends how long that moment is.
Generally there would be no long-term harmful effect on Bitcoin for any outage of a few minutes or even several hours.
Longer outages of many days or weeks would skew the next recalculation of mining difficulty and result in blocks being produced significantly faster than one every ten minutes for about two weeks.
https://en.bitcoin.it/wiki/Difficulty says:

The difficulty is adjusted every 2016 blocks based on the time it took to find the previous 2016 blocks. At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to find. If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced. If they took less than two weeks, the difficulty is increased. The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find.

For really long outages there might be other effects and different software might react in different ways.

The above is speculation. I'd either look for a prior study of the subject or inspect some source code (such as that for Bitcoin core) to see how it might handle these time-related aspects of Bitcoin.

Non-issues
https://en.bitcoin.it/wiki/Block_timestamp says

A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours.

So a long gap in the blockchain timestamps shouldn't be an issue for block validation.


text:
With constant TX throughput and increased TX requests will the mempool and/or fees grow indefinitely?
The Bitcoin network processes around 10-30 transactions per second with segwit.
With an increasing amount of TX requests as more and more users join the network, how will the network eventually accommodate a surplus of transaction requests?
In other words, once we get to an average of 31 transaction requests per second, won't the mempool grow indefinitely with some users perpetually waiting for their TX to be processed?
Note: I am not asking what happens when the mempool is filled. For the sake of my question, I'd like to even assume an infinitely large mempool. I'm merely referring to the inevitable scenario that
rate of transaction processing < rate of incoming transaction requests
To clarify further: Won't the network inevitably crash due to

indefinitely growing / overflowing mempool or
indefinitely growing fees

No, but I edit my questino and to clarify not.

Since nodes have finite resources, their mempools cannot grow indefinitely. As an aside, competition among transaction makers during mempool congestion naturally increases feerate which reduces demand.

@RedGrittyBrick Let me rephrase: I get that mempool practically can't grow indefinitely. But then what happens at the above described point in time? Mempools get more and more filled causing an increasing amount of transaction requests to be dropped. Increasing feerates reduce demand: For ordinary goods, of course that is true. But for transactions? How can transaction demand be reduced like that, people HAVE to do their TXs no matter the fee right? So then the fees will grow indefinitely with increasing demand? My point is, one way or another the network is bound to crash?

@csstudent1418: People don't have to do their Bitcoin on-chain TX's no matter what.  I wouldn't buy a 0.1 BTC car if the TX fee were 1 BTC, neither would you. People switch to LN, other methods or to other currencies.

@RedGrittyBrick But isn't this an extremely limiting factor to Bitcoin, in terms of not too many people being able to use it simultaneously? I just find it fascinating that you could essentially be "pushed" off the network like that, just when you needed to make an important transaction let's say.

@csstudent1418: Yes it is a limiting factor. One of many limiting factors. That's partly why there has been the development of LN, Liquid, etc. Also, if a transaction is important, it's presumably important enough that you would pay a reasonable extra amount to push it through. Otherwise, in the context of a digital cash system, is your transaction really important to you if you are not willing to pay a reasonable extra amount to expedite it?

Increasing demand for on-chain transactions and static block size means transaction fees will be higher. They can't grow indefinitely since there is a finite amount of money anyone in the world is willing to pay for a transaction, but they might very well become quite large in the future.
This might not be a problem because as transaction fees rise, people are incentivised to adopt Layer 2 solutions like the Lightning Network. If this does become a problem, some people will simply stop using bitcoin and that will also reduce transaction fees.

"If this does become a problem, some people will simply stop using bitcoin and that will also reduce transaction fees." - I get the logic of that. I guess what I am struggling with is the notion that people eventually being forced off bitcoin contradicts the universality and accessibility of bitcoin, but wasn't it the whole point to achieve that?


text:
Can you combine parts from multiple miners?
Is it possible to assemble multiple boards with required chips to create a home miner?
I have seen some miners with certain amount of boards and chips on them, so I was wondering if I can substitute those 3 boards with 10 boards+ chips for better hashrate to be like an upgrade.

I believe that Bitmain's current Antminer products like the S19 are not designed to be user upgradeable in the way you suggest.
Bitmain's products that support plug-in expansion are the AntRack and AntBox, but these are really industrial units and not what most people would describe as home units.


text:
How to calculate nBits from target?
I was wondering how the nBits are calculated from the target, I know how the the target is calculated from nBits, but how is the nBits calculated from the target?

Does one of these answer your questions: https://bitcoin.stackexchange.com/a/57186/5406, https://bitcoin.stackexchange.com/q/8806/5406, https://bitcoin.stackexchange.com/a/61951/5406?

No, I was asking how the target is compressed into nbits, not the other way around.

You can calculate nBits from the target value by first taking its base 256 logarithm and rounding that to the next higher number, which will give you the first Byte out of four, the exponent, of nBits. You now know how many trailing Bytes you can cut off the target (the exponent minus three) and you're left with the mantissa.
Putting that into a closed formula is a bit messy in my opinion. The existing formula for calculating the target is not very nice in the first place, since it actually tries to express an algorithm. But here you go (x being the target):

Example with the current nBits value 0x17073039:
x = 0x730390000000000000000000000000000000000000000

(floor(log(x, 256)) + 1) * 0x1000000 = 0x17000000

x / 256 ^ (0x17 - 3) = 0x73039

nBits = 0x17000000 + 0x73039 = 0x17073039

Please note that this formula does not work for all values. The mantissa, being a signed integer, should not exceed 2^23 - 1, which is why the exponent needs to be adjusted where this would be the case; e.g. for the maximum target 0x1d00ffff, where the expected exponent of 0x1c would lead to a mantissa of 0xffff00 and thus be interpreted negative.

The top bit of the mantissa is a sign bit, so the exponent has to be such that the rounded mantissa value is between 2^15 and 2^23-1 (because values above 2^23 are treated as negative). That's why the genesis nBits has an exponent that's seemingly off by one.

That makes sense, thanks! There probably isn't an obvious fix to the formula to catch this, is there? At least without complicating it too much.

Thank you for that. I've tried putting in some example targets and sometimes it has worked, sometimes it hasn't.

You have to check the mantissa as Pieter described in his answer and adjust the exponent accordingly

I believe the algorithm is this:

Let b be the number of bits in the target: b = ⌈ log2(target+1)⌉.
Let e be the exponent: e = ⌊ (b/8)+1⌋.
Let m be the mantissa: m = ⌊ target/(256e-3)⌋
The nBits value encodes both m and e: nBits = 224e + m.

The computed mantissa should always be between 215 and 223-1. If it's larger, it would be interpreted as negative. If it's smaller, a lower exponent would provide more accuracy.


text:
How to make a payment processor like Bitpay?
There are some payment processors such as BIPS, BitPagos, BTCMerch, and a few more like them.
In detail, what do I require to get a website like that going?

You can use open source Bitcoin Payment Processor Libriary -
https://github.com/cryptoapi/Payment-Gateway

Can you clarify whether you just need the ability to handle bitcoin-only transactions, or does your service need to be able to trade fiat currencies such as USD or EURO for bitcoins? If so, then you will need to invest in lawyers and find yourself a bank that is willing to extend you a loan, or supply your own funds to get it up and running.
If you're only needing to deal with bitcoins transactions, then I would suggest you learn about how blocks and transactions work at a low level. This is a good site for learning the nitty-gritty of how the blockchain stores data
http://codesuppository.blogspot.com/2014/01/how-to-parse-bitcoin-blockchain.html
Beyond that, understand how to set up a bitcoind server, and send JSON-RPC commands to it using the API explain here
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
Once you know how these commands work, you'll be able to build software that will accept payments. Again, if you need to get fiat currencies involved that's you'll have to deal with legal/regulatory concerns, but it is possible.

The easiest thing you could do, is just consider running an instance of bitcoind:
https://en.bitcoin.it/wiki/Bitcoind
With this, you can programmatically control the creation of wallets, addresses, and send/verify transactions ... the basis of a service such as bitpay. If you want to get a bit closer to the metal, you could look at using something like libbitcoin (which is what the guys at darkwallet are using):
http://libbitcoin.dyne.org/
Of course, you will have to know what you're doing when it comes to computer security, as running these on an unsecured server could result in a hacker stealing all of your funds.

Thanks man,I would look into that,sorry for late reply though,anyhow thanks a ton


text:
mining pcie 16x and 1x together caused rejects
I have 5 msi radeon R9 290 cards and this board https://www.asus.com/Motherboards/Z87PLUS/specifications/ . With 3 pcie 16x everything runs smooth but, as soon as I add the first 1x into the equation, I start getting tons of rejects.
How do you run the two technologies concurrently.
I am running Win8.


text:
Apple Removes Blockchain Bitcoin Wallet Apps from its App Stores
That Apple removed last wallet from their app store.  Just wrong....  Guess more people will move to Android.
Apple Removes Blockchain Bitcoin Wallet Apps from its App Stores
http://www.coindesk.com/apple-removes-blockchain-bitcoin-wallet-from-app-stores/
Will they add it back after seeing the pressure from worldwide bitcoin community?
I love the response from BlockChain to Apple
http://blog.blockchain.info/2014/02/06/blockchain-response-to-apple/
Blockchain’s Response to Apple
Posted on February 6, 2014
“Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in  the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward.” – Apple, Inc.

Perhaps Apple should have added a disclaimer: “As long as the ‘rebels’ don’t threaten our profit margin”. The rebels no longer run the show at Apple Inc; the beancounters are now firmly in charge.

http://blog.blockchain.info/2014/02/07/the-media-bitcoin-community-respond-to-apple/

Apple has had plans to convert iPhones into a mobile payment centre for a long time. Since they have such a grand bulk of the market and deep-pockets, they think they can have force banks and vendors to accept it, and then earn a lot of money from profits due to being the middle man - mimmicking the wild success they had with iTunes (where they have much more leveraging power than the music firms themselves by controlling the market).
They won't accept any crypto-currency app into their official market as long as they still have that business plan. Only when such adventurous proposal is tried and fails or when the business deals go nowhere after too much time will they ever consider allowing them back.
Right now there are tons of stuff Android phones can do that can't be done with (unjailed and unpatched) iPhones. Yet people still buy any iStuff by the dozen - so Apple executives know deep within most people don't really care about choice. Unless/until the market starts caring, that will still be their position.


text:
How can I retrieve all transactions for an address using the blockchain API?
Tell me how to interact with https://www.blockchain.com/.
1). I need to withdraw all transactions from the address, my code outputs transactions only for the last day?
2). How do I add additional transaction information (Sigscript, Witness)?
#!/usr/bin/env python
import bitcoin, sys

if len(sys.argv) < 2:
    ADDRESS = "1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s"
elif len(sys.argv) < 3:
    ADDRESS = sys.argv[1]
else:
    print('Wallet address must be provided.')

def main():
    #bitcoin.allTransactions(ADDRESS)
    bitcoin.simpleTransactions(ADDRESS)

if __name__ == '__main__':
    main()

As the API documentation specifies, the response of /rawaddr/$address will only return up to 50 transactions. There is an optional parameter &offset=n which let's you skip the first n transactions. The first call, you get fifty transactions. Then you add the parameter offset=50 to skip the first fifty transactions in the response to the second call. This will result in you retrieving the second fifty transactions (51-100). Increment the offset each time by 50, until you have collected all transactions for the address. Quoting from the documentation:

Single Address

https://blockchain.info/rawaddr/$bitcoin_address
Address can be base58 or hash160
Optional limit parameter to show n transactions e.g. &limit=50 (Default: 50, Max: 50)
Optional offset parameter to skip the first n transactions e.g. &offset=100 (Page 2 for limit 50)

After you have collected all txids, you look up the details of each transaction with rawtx/$txid:

Single Transaction

https://blockchain.info/rawtx/$tx_hash
You can also request the transaction to return in binary form (Hex encoded) using ?format=hex


text:
Is Bitrefill supported by lndhub?
I have sent 3BTC to bitrefill.com via lndhub but my account balance is not reflected on the website but my lndhub is showing it. Am I missing something?


text:
What kind of problems are solved when mining?
I am new to bitcoin. Before I decide to buy the hardware/software I want to know about kind of problems solved. And more importantly do I need to be skilled in any specific area (like mathematics or know of any software coding languages etc).
So my basic question is once I purchase the hardware and software and join a bitcoin pool, will I be assigned a specific problem to solve a problem by myself? OR is it just that my hardware/CPU is used to solve the mining problem(and I need not do any coding etc).
Thanks for any help or references.

-1 Question shows no previous research, has a nondescript title, and it is hard to tell what is being asked.

Your hardware will do the work for you and you won't have to do any coding.
I believe that this question will be a good read for you: What exactly is mining?

I think you need to take some time and do some reading about what Bitcoin is.
Ask yourself, What are your goals with Bitcoin? Do you intend to simply own bitcoin? Why do you want to own it?
If your answer is, you want to own it because everyone is getting into it, you may want to reconsider what your trying to do.


text:
Can Bitcoin work without Network Time Protocol?
After reading an article about the imminent retirement of David Mills, and the possibility that there could be some handover issues (imho just rumors), I wondered if the Bitcoin protocol depends by the Network Time Protocol (NTP) or not.
I guess that if NTP quitted working, blocks would be validated anyway, without any issue, thanks to the POW architecture. But are we sure that the Bitcoin Core software does not need NTP at all? Is a requirement for some minor features, dependency, library, tool or some third part software?

As far as I know David Mills was the original developer of NTP having authored RFC958 in 1985. He developed the reference implementation,
However there are other independent implementations of the protocol, notably Chrony. There is no reason to suspect that Mills retirement would affect Chrony. It also seems that the reference NTPD implementation will survive.
The Bitcoin network protocols have no interaction with NTP and Bitcoin node software has no direct interaction with NTP. Bitcoin doesn't require precise time and works with a time variation between nodes of up to a couple of hours. NTP provides for two computers clocks to be synchronised within milliseconds over thousands of miles. Bitcoin just doesn't need that kind of precision.
Even if NTP, GPS and other sources of accurate time disappeared, I suspect Bitcoin could continue working so long as people can set their computer's clocks occasionally by estimating noon within ten minutes or so.


text:
How to recover from forgotten password for Bitcoin Wallet for Android backup?
Back in 2016, I had a Bitcoin wallet with a couple of euros worth of Bitcoin. I used the Android app "bitcoin wallet" to backup my wallet but I had to use a password.
This week, I found the wallet save file but I had forgotten the password.
Now I want to try to decrypt it, but the file doesn't have a .dat extension, it doesn't have an extension at all.
What format does Bitcoin wallet use?
And how can I try to decrypt the wallet?
I do probably know part of the password, it's just that I don't remember what numbers I put after the password.

Does this answer your question? Are there Bitcoin password crackers I can use to recover forgotten passwords?  -- Note that BTCRecover includes support for the Bitcoin Wallet for Android (Schildbach wallet) - but there are probably other tools too,.


text:
Mnemonic from Node.js app not restoring in other wallets
I'm working on a Node.js app that makes RPC calls to my node, and I'm having trouble restoring a mnemonic created with bitcoinjs-lib, bip32, and bip39.
First, I create a blank wallet that accepts private keys with bitcoin-cli createwallet wallet false true
I also create a separate file called "wallet.json" and it stores the mnemonic. Then I run this code to generate a new address:
app.get('/getnewaddress', function (req, res) {
    const data = fs.readFileSync(`wallet.json`, 'utf8');
    const { mnemonic } = JSON.parse(data);
    const seed = bip39.mnemonicToSeedSync(mnemonic);
    const node = bip32.fromSeed(seed);
    const index = Math.floor(Math.random() * 100000);
    const keyPair = node.derivePath(`m/84'/0'/0'/0/${index}`);
    const { address } = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey });

    res.send(JSON.stringify({address: address}));

    bitcoin_rpc.call('importprivkey', [keyPair.toWIF(), "", false], function (err, rpcRes) {
        if (err) {
            res.status(500).send({ error: "I have an error :\n" + err });
        } else {
            console.log(`Address: ${address}`);
            console.log(`Private key: ${keyPair.toWIF()}`);
        }
    });
});

I know the code is working, because when I send bitcoin to the generated address, the balance is confirmed on my node. You can see I'm logging the private keys and importing them into the blank wallet. When I dump the wallet, all the private keys and addresses are there, and match what was logged.
However, when I try to restore this wallet in BlueWallet or Electrum, it says my balance is 0.
Please notice I am not trying to import a mnemonic into Bitcoin Core or set the hdseed. I am only importing individual keys.

You are running into the gap limit.
When restoring a wallet from a mnemonic, the wallet software checks the generated addresses one by one until it finds a long enough gap of addresses that have never been used in a transaction. It then assumes that no other used addresses exist beyond that point. The gap limit is set to 20 in most wallets, which will usually be less than a random number between 0 and 99,999.
References:

BIP44: Address gap limit
Electrum Docs: What is the gap limit?


text:
Import two wallet.dat into Bitcoin-Qt client
This is very closely related to Import wallet.dat into a new Bitcoin-Qt client, but I feel this is not a duplicate because the (great) answer to that Q is for only restoring one wallet.
I used Bitcoin-QT about a year back and had two separate wallets within it.  I have these backed up as two separate wallet.dat files.  After some computer wipe, I now need to restore the two wallets into the one Bitcoin-QT client.
Using the prior Q, I have been able to import one of the wallets back into the Bitcoin-Qt client.  I now need to bring the other one in.
How can I import a second backup into my existing account, without the need of sending my first wallets amount to a separate external wallet?

There is (yet) no multi wallet support in bitcoin-core.
You can try to stop Bitcoin-Qt, replace your wallet.dat (rename the old one, place the new one) and start Bitcoin-Qt. If your wallet is really old, it will perform a rescan for new transactions and this can take some minutes.
To merge your wallets:

Open Console and enter dumpwallet <filename>
Stop Bitcoin-Qt
Replace wallet.dat with your new wallet file (move the current wallet.dat file to a save place)
Start Bitcoin-Qt
Open Console and enter importwallet <filename>.

hey Jonas, does merging work between an HD wallet (v0.13.1) and a non-HD one(0.12.1)?


text:
Does one of these exchanges have a sandbox to test?
I want to test some trading. Does Binance, Bittrex, Poloniex, Kraken or Gemini have a sandbox to trade fake crypto to test systems?

Did you check their websites?! I use gdax and they have it documented, and that's what I would look into.

I checked polo and they had nothing obviously as far as I could find but then someone told me polo has a sandbox so I figured I would ask here.

If you have an account with them, I would ask them through a support request.

I work for an exchange, I don't know if I am allowed to say which, but have something called a test net, which is similar to what you are describing and which many people use to test trading strategies.


text:
How to read a transaction from a block? Who paid whom?
I'd like to know how to read a 'transaction', so if we take an example of this transaction (which comes from block #520156) it's easy to spot that 'th' paid 'U8' 0.005BTC and
'9E' paid 'Y5' 0.013BTC. but what are what are the 'DD' and the 'vf' for (marked in green)?
Also, why this transaction (..bac192) includes those 2 payments, are those payments related somehow? (shouldn't a transaction have one payment?)

When you send a Bitcoin transaction, your wallet software will use one or more existing Unspent Transaction Outputs (UTXO) to fund the transaction. The transaction will then specify the new owners of the consumed balance in the outputs. If the amount spent in the inputs does not match the amount in the outputs plus fees perfectly, the remainder will be sent back to the sending wallet in a change output. This particular transaction appears to have spent four UTXO to pay a single recipient, sending back the remainder of the input balance to the sender. Alternatively, this transaction may have paid two recipients, but that is not the most common pattern on the blockchain today.
Anyway, while multiparty transactions exist on the network (e.g. look at coinjoin here on the site), they are fairly uncommon today.


text:
2 unconfirmed transactions after 24hrs
Hey guys been looking through the forums and I'm still not quite sure how to speed things up or fix it. (Not very good with this kind of stuff)
Here's my wallet address - 1GZK3NYHCAScGRb4awAkXGVXszstwCVEEh
Both transactions say they have been seen by 50+ peers
I used the standard multi bit classic fee 0.0001
Which has never slowed me down in the past.
Any advice or help would be awesome
I'm happy to just get them back and send again with a higher fee.
Cheers
Edit: I'm using multibit classic. I have done a block chain reset. One of the transactions says it's in my balalnce (not spendable) and the other seems to have stayed the same (being sent to the same address) but has only had the peers reset. I've looked on blockchain info etc just not really understanding what I'm looking at. I assume the problem was the low fee, which I've now changed in my settings. Just not sure how to get it all back and start again.
Sorry I'm a bit of a noob

Do you own the wallet in your computer or is it in the clouds (p.ex., Blockchain)? If so, what is the version, model (Blockchain.info, Bitcoin.org core 0.140.)?
.
For now, export your wallet and encrypt it!
Also, check these steps: https://bitcoin.stackexchange.com/a/41972/47329

Why is it taking so long for my transaction to confirm?
If you have sent a transaction
without (or with an exceptionally small) transaction fee
expect it to be ignored for an unknown amount of time until a miner decides >to process it and solves the block; this could be several days to several weeks, possibly never. Your wallet and any Bitcoin node will show it as unconfirmed, your transaction is stuck in limbo.
Block sizes are limited, which means that only a limited number of transactions can be processed in a certain timeframe. In the beginning of bitcoin, there was lots of free space in each block because there were not many transactions. However, now that Bitcoin is quite popular there are more transactions than can be processed into the current block. This is why transaction fees have increased, and as long as someone is still willing to pay more they will keep increasing.
What can I do to speed-up the transaction’s confirmation?
Nothing. The next best thing is to cancel and resend the transaction.

Make a note of the individual bitcoin address(es) that the unconfirmed transaction was sent from.
Run Bitcoin Core with the -zapwallettxes option (or wait a few days until your wallet stops broadcasting the transaction and it falls out of the global transaction mempool)
Send all your bitcoins from the addresses recorded in step 1 to a new address with the recommended or higher than recommended fee.
Make original transaction again using the recommended fee

Which fee should I use?
The fastest and cheapest transaction fee is currently 220 satoshis/byte
For the median transaction size of 226 bytes, this results in a fee of 49,720 satoshis.

https://bitcoinfees.21.co/

I'm using multi bit classic on my laptop. Before you answered I did a reset on my blockchain. But nothing has seemed to have happened. I have upped the standard fee to max for when I'm ready to send. I'm just not sure how get them back into my wallet. At the moment 1 of the 2 transactions says it's back in my balance, but it isn't spendable. And the other is still listed as going to its original destination (peers have reset though).


text:
How do I get credentials on the bitcoin network?
I'm setting up an LND node so I can learn about Lightning Networks. I apparently need a set of user credentials so that I can connect to the network.
How do I get the credentials that I need to set this up? Is it possible for an average user who is just trying to learn about LND?
Ideally I would like to connect to the main net, so that I can connect my Zap wallet to it.
I have to fill in these values in the config:
bitcoind.rpcuser=bitcoind_rpc_user_string
bitcoind.rpcpass=bitcoind_rpc_password_string

Also can someone explain these settings to me:
bitcoind.zmqpubrawblock=tcp://127.0.0.1:18501
bitcoind.zmqpubrawtx=tcp://127.0.0.1:18502

Is 127.0.0.1 ok to leave for these values?
Thanks

I have to fill in these values in the config:
  bitcoind.rpcuser=bitcoind_rpc_user_string
bitcoind.rpcpass=bitcoind_rpc_password_string

These are user defined, and used to authenticate and communicate with your full node. There is no authentication to the network, anyone is free to join.
You’ll want to define a username and password in your bitcoind bitcoin.conf file, and then input them here so that lnd can connect to your node.

Also can someone explain these settings to me:
  bitcoind.zmqpubrawblock=tcp://127.0.0.1:18501
bitcoind.zmqpubrawtx=tcp://127.0.0.1:18502
  Is 127.0.0.1 ok to leave for these values?

ZMQ allows lnd and bitcoind to exchange info through a socket connection (getting new info about blocks and transactions). If the nodes (lnd, bitcoind) are on the same machine you can leave the address as the localhost (127.0.0.1).

Also yes, my bitcoin full node and my LND node are running on the same machine. So I'm good with 127.0.0.1. Thanks again!


text:
Armory synchronization takes forever. How can I speed it up or retrieve my coins?
I have an Armory wallet that has been offline for a long time. When I start up that computer it runs just fine, however it is taking forever to download the blockchain. Based on my estimate of the blockchain size 116 gigs, and how much space is on my computer, I estimate it will take another 12 days to finish. I can however run Armory in offline mode and view my private keys.
What is the best way to spend my bitcoins. I would like to set up a new wallet that does not require me to download the blockchain and import the bitcoin addresses from Armory, but I can't find information on how.
Thanks a lot

You can extract the private keys and import them in a lite wallet like Electrum.
You need to run Armory as expert, go to the Wallet's properties dialog and click on the backup center on the right side column


text:
Received Random Unconfirming BTC
I've been using BTC for years now. This is the first time this has happened.
Woke up yesterday to an unconfirmed transaction of around $30. Completely confused, I wondered where this came from.
Anyway, it's been 30+ hours since receiving the funds. Still not confirmed, and still completely confused.
My question really, could this be fraudulent BTC? How the hell did they get my address, and how long until I could possibly see this confirmed?
Txid: 987ee6a4930d7610ea081250dfc49d4fdd0ade093d740b4c18c5f78db2bc05c7

Which of those destination addresses is yours?  Is it   1FXK2XkUqaFevsZkdK8wa2AKfCph7iEo4D ?

My question really, could this be fraudulent BTC?

Not sure about fraudulent, but there are parties that send (near-dust) amounts of Bitcoin to existing addresses, hoping the wallet will merge the output with those sent to different addresses, as to figure out correlations for tracking.
$30 is a bit much for this, though! It could also be that someone copy/pasted a wrong address and accidentally sent to you.

How the hell did they get my address,

Have you used it before? If so, they probably just found it in the block chain.

and how long until I could possibly see this confirmed?

Depends on how much fee they attached. You could help it by creating a CPFP transaction spending it.
On the other hand you might not want to. If someone sent it by accident it is better for it to never confirm so that they can reclaim it at some point.

There are several reasons you can get random BTC:

Somebody is very generous and likes you
People send BTC to random addresses as part of mixing sometimes
Somone is trying to know the identity behind that address. So when you spend bitcoins, they are tracking the outputs to get clues. For example you may use that BTC on a exchange where you have a public profile.

Don't worry too much, enjoy the BTC while you have it and use a mixer while spending!

BTC transaction has been removed from my CoinBase history. I'm assuming this was a error in some way.


text:
Why are there 17 native segwit versions?
Given that computers operate in binary, we often see various limits and scopes come in powers of 2. How come there are not sixteen (0–15) but seventeen (0–16) different native segwit versions?

Segwit has 17 versions, because Script defines the constants OP_0–OP_16 explicitly, while any other numbers would need to be added to the output script with OP_PUSHDATA.

That's exactly right.

Can OP_1NEGATE be an 18th SegWit version?


text:
Will the Liquid sidechain be open to any user?
With the recent start of the private beta of Liquid, the first sidechain is now in production on the Bitcoin network.
One of the features advertised is:

User Control – Users can hold their Liquid funds off of exchanges and in a wallet they control, enabling them to rapidly transfer funds to and from any participating exchange in the network.

It was my understanding that Liquid was primarily to facilitate payments betweent larger users in the Bitcoin network such as exchanges and payment processors.
The above feature seems contradictory with the company focus. Will everybody be able to have a wallet on Liquid?

Liquid wallets are open and accessible to anyone. This could either be SPV wallets such as Blockstream Green or the Elements Liquid node.
With these wallets you can verify transactions (your own transactions with Green, all transactions with the node). However, you can't produce blocks. To do that, you need to be one of the Liquid members. To become such a member, you need to go through Blockstream. At the time of writing, there are 33 members full list available here.


text:
What is the maximum size for SegWit transactions?
Before SegWit was activated, transactions were limited to 100,000 bytes or 100 kB. Bigger transactions were non-standard.
What is the limit for transaction size after the activation of SegWit?

Is the virtual size limited to 100,000 vbytes?
Is the raw size limited to 100,000 bytes?
Is there a new limit altogether?

The standardness limit in all recent Bitcoin Core versions with SegWit support is 400000 weight.


text:
What is the maximum size of a DER encoded ECDSA signature?
I've been told by a seasoned Bitcoin contributor that signatures in Bitcoin could be up to 75 bytes. I'm curious to find out how that maximum comes to pass.
According to this answer on Why the signature is always 65 (1+32+32) bytes long?, the signature is always 6 bytes plus the length of R and S, where the latter two can be up to 33 bytes (Is that accurate?). In the worst case that would result in a length of 72 bytes.
Can signatures be longer than 72 bytes? Under what circumstances does that happen and what is the maximum?

A signature in Bitcoin (as used to sign transactions inside scriptSigs and scriptWitnesses), consists of a DER encoding of an ECDSA signature, plus a sighash type byte.
Overall, this means they consist of:

DER encoded signature data, consisting of:

1-byte type 0x30 "Compound object" (the tuple of (R,S) values)
1-byte length of the compound object
The signature's R value, consisting of:

1-byte type 0x02 "Integer"
1-byte length of the integer
variable-length R value's bytes

The signature's S value, consisting of:

1-byte type 0x02 "Integer"
1-byte length of the integer
variable-length S value's bytes

The sighash type byte

Summing this all up, we have 7 bytes (compound header, compound length, R value header, R value length, S value header, S value length, sighash type byte) excluding the actual R and S data bytes.
So we have reduced the question to wondering what the size of the R and S data bytes are. These encode 256-bit values, which ordinarily means 32 bytes. However, integers in DER are signed, which means that if their highest bit is set, they are interpreted as negative. For that reason, if the value being encoded is 2255, a 33rd byte is added in front.
There is a standardness rule on the network that requires the S value to be below N/2 (N being secp256k1 curve order) ("Low S"), but no such rule exists for R. Furthermore, it is only a standardness rule which miners are allowed to bypass.
So ignoring the Low S rule, signatures (including the sighash type byte) can be up to 7+33+33 = 73 bytes.
Perhaps the number you're citing also includes the push opcode used in scriptSig to push the signature onto the stack, but that still only gets us to 74.
Perhaps the 75th byte is the length of the scriptSig itself? But that would only be relevant for scriptSigs which consists of just a signature - for example P2PK spends.

what about the "v" value of an ecdsa ?

An ECDSA signature encodes a tuple (r, s), nothing more.

so the "v" value in ethereum signature isn't important?

I have no idea what you're talking about. There is no such thing.

OK, maybe isn't related to ecdsa, thanks :)

The 'v' you are referring to is the recovery id bit (0-3 inclusive), its not used as part of a DER serialized bitcoin signature. It is however, a ECDSA construct, not specific to Bitcoin or Ethereum. Hope this helps.

@PieterWuille I'm confused by: "if the value being encoded is 2^128, a 33rd byte is added in front." - Shouldn't it be ">= 2^255"?

@KalleRosenbaum Of course, fixed!


text:
What happens to the original bitcoin after a wallet restore?
I'm thinking of buying some bitcoins. Before I do I want to be sure that I can backup and restore my wallet - Bitcoin Core. This seemed to go ok, the bitcoin loaded into the new wallet which was on a different computer from the original.
The original bitcoin wallet still shows the old balance.
I'm sure it's unlikely, but what if someone stole my computer and I then restored my bitcoin to a new wallet - would the thief be able to spend from the original wallet after I'd done the restore?

I'm sure it's unlikely, but what if someone stole my computer and I then restored my bitcoin to a new wallet - would the thief be able to spend from the original wallet after I'd done the restore?

Yes. The two wallets 'hold' the same Bitcoin. If the thief steals your original wallet, it becomes a race to see who can spend the Bitcoin first. You have the advantage that only you know your password. (You did set a password, right? :) The thief has the advantage of surprise.
Additionally, if you generate a new address on the backup of the stolen wallet, the thief will have access to that too. This is due to the 'keypool' feature of Bitcoin. To avoid this, after your wallet is stolen, make an entirely new wallet, and transfer your Bitcoins to that. That will be safe, assuming you win the race.


text:
How to directly query leveldb database to get get a record by transaction hash or by sender's address?
I learned that the blocks and transactions are stored locally in .bitcoin/blocks/index and .bitcoin/chainstate databases, respectively.
I want to make a direct query to those databases to measure the response time.
However, I found it hard to understand the format and the best way to access to the data.
I am using Plyvel, but I couldn't formulate the exact query, for example to search for a particular transaction identified by its hash value, or searching for the all transactions made by a particular sender identified by the hash of its public address.
Any help, please.

This may help you https://bitcoin.stackexchange.com/a/52167/30668

I already see it, but how the transaction id is transformed from 246c5a81b6ad0dfc0dbc0b2ff5bde65ee1913f75a47d409b8ff8074a27ec1000    to c0010ec274a07f88f9b407da4753f91e15ee6bdf52f0bbc0dfc0dadb6815a6c24 ??

You should change the endianness. While txids are displayed in blockexplorers as big endian values, they are stored in the LevelDB in their little endian representation.

Ah ok, I see.  Then I have to convert txid from big to little endian before making the query. May be this can help in the conversion: http://stackoverflow.com/questions/13155570/reorder-byte-order-in-hex-string-python

What about the sender address, how I can search for transaction by sender address?

To my knowledge, You can't, at least by querying the LevelDB. The purpose of the UTXO set stored in the DB is identify which transactions are unspent in order to make it easier to validate a transaction that  tries to redeem one. If you want to know the addresses (or more generally the scripts) involved in each UTXO you will need to parse the information obtained when querying the DB by the txids.

Let us continue this discussion in chat.