Undo files format change and reorg process question for v0.19 This is a follow-up question for rev.dat file format

Pieter Wuille gave a great explanation that is easy to follow. Since that posting there was a replacement of CTxInUndo with Coin, does the format still stands for the CBlockUndo record?

4 bytes: network magic (0xf9,0xbe,0xb4,0xd9)
4 bytes: size of the CBlockUndo record (LE32)
data_size bytes: CBlockUndo record
32 bytes: double-SHA256 of the serialized CBlockUndo record

CBlockUndo results in a serialized vector of CTxUndo records. Which is right now the serialized vector of Coin records.

And here is the Coin (or at least how I get it right now):

varint that is serialized: 2*height (+1 if it was a coinbase output): the height of the block that created the spent UTXO. By the way, is uint32_t{2} the same as (uint32_t)2 in TxInUndoFormatter varint Serialize
version dummy value 0: we do not use version anymore but for compatibility using a 0000 or zero value in here
CompressedAmount: spent UTXO's nValue
CompressedScript: spent UTXO's scriptPubKey

Questions:

Is it correct?
Does anyone by any chance have a detailed mind map of undo process and a byte format map for the CBlockUndo record?

Just for reference, I draw some image of current v0.19  and previous v0.13 versions
of rev*.dat file:

NOTES:
Heigh and Version fields
Fields height and version are needed to identify Outputs if they are last spent in the Transaction outputs. In older revxx.dat files, only if Output was last unspent in a Transaction it's height will be there together with it’s Transaction’s Version. If it's a regular Output then the height field will be 0 (00 HEX in Varint format ) and there will be no Version field
In newer revxx.dat files height is written for every Output and the Version field is 0 (00 in HEX) to be backward compatible. I did not check the revxx.dat files myself if it’s so, so please test this note first.
Calculation of Height from the Field Value:
To compress the Amount of Statoshis this field uses the following logic:
If the amount is 0, output 0
First, divide the amount (in base units) by the largest power of 10 possible; call the exponent e (e is max 9)
if e < 9, the last digit of the resulting number cannot be 0; store it as d, and drop it (divide by 10)
call the result n
output 1 + 10*(9n + d - 1) + e
if e==9, we only know the resulting number is not zero, so output 1 + 10(n - 1) + 9
(this is decodable, as d is in [1-9] and e is in [0-9])
Then store it as a VARINT
nValue field(Amount)
To compress the Amount of Statoshis this field uses the following logic:
If the amount is 0, output 0
First, divide the amount (in base units) by the largest power of 10 possible; call the exponent e (e is max 9)
if e < 9, the last digit of the resulting number cannot be 0; store it as d, and drop it (divide by 10)
call the result n
output 1 + 10*(9*n + d - 1) + e
if e==9, we only know the resulting number is not zero, so output 1 + 10*(n - 1) + 9
(this is decodable, as d is in [1-9] and e is in [0-9])
Then store it as a VARINT
Calculation of nValue field(Amount):
To decode this amount go through the operation backward:
First, decode it from VARINT. Then use the following procedure(taken directly from the Bitcoin core implementation):
uint64_t DecompressAmount(uint64_t x)
{
    // x = 0 OR x = 1+10\*(9\*n + d - 1) + e OR x = 1+10\*(n - 1) + 9
    if (x == 0)
        return 0;
    x--;
    // x = 10\*(9\*n + d - 1) + e
    int e = x % 10;
    x /= 10;
    uint64_t n = 0;
    if (e < 9) {
        // x = 9\*n + d - 1
        int d = (x % 9) + 1;
        x /= 9;
        // x = n
        n = x\*10 + d;
    } else {
        n = x+1;
    }
    while (e) {
        n \*= 10;
        e--;
    }
    return n;
}

ScriptPubKey size and SriptPubKey fields
Current Bitcoin serialization is using a compressed format to store common types of scripts:

Pay to Pubkey Hash (P2PKH) is encoded to – 20 bytes
Pay to Script Hash (P2SH) is encoded to – 20 bytes
Pay to Pubkey (P2PK) is encoded to – 32 bytes

Other script types are serialized using the general rule shown in the table:

scriptPubKey size
scriptPubKey data

Where script size is a VARINT field of len(scriptPubKey data) + number of special cases, where the number of special cases is int(6), then goes the regular scriptPubKey data.
The compression algorithm is removing all OP_CODE values from the common types of scripts and leaves only the Key, KeyHash, or ScriptHash intact. Then it is using the  field to indicate the type of script in the next field.

P2Pk cases: 0x02, 0x03 identify compressed Public Key and show how which Y coordinate to use to reconstruct the full key. 0x04, 0x05 identify uncompressed Public Key, but the value in the  is still in a compressed format and, and the size value shows which Y coordinate to use.
For other script types be sure to keep in mind that  is VARINT(len(scriptPubKey size) + int(6))
A small addition to the script compression, while you be looking through the Bitcoin core compress.cpp/.h files you may find that during compression either 20 bytes or 33/65 bytes are being manipulated that are not identified as any opcodes.
That's because of in bitcoin scripting if a field(4-bit hex value) is smaller than OP_PUSHDATA1 = 0x4c=76 is interpreted as an instruction to push the following number of bytes (the exact value of this field) onto the stack – this is called an immediate push.
As I'm not that good in modern C++, it was much easier for me to follow the compression algorithm when it was done in Golang:
https://github.com/btcsuite/btcd/blob/master/blockchain/compress.go
and in VarInt logic in Python:
https://github.com/christianb93/bitcoin/blob/1241778dc51bd39022611916f90f1bfaf07ee331/btc/serialize.py#L54
Greg did a really really nice explanation of Var Int, that I found so easy to follow. Thank you.
https://learnmeabitcoin.com/guide/varint
Yes, everything is in the code of original BitcoinCore implementation, I think maintainers and developers are doing an epic job to keep it nice and clear. It's because I was lacking some C++ skills I could not understand it properly from the beginning and had to spend some time on it. I just hope my notes will help someone to speed their learning process. Good luck.


What is the most secure operating system that I can use to store bitcoins without having to fear a hacker stealing them? What is the most secure operating system that I can use to store bitcoins without having to fear a hacker stealing them?

The most secure operating system is no operating system. As Pieter mentioned in the comments, dedicated hardware wallets prevent private keys from leaking out of the secure hardware enclave, and therefore can't be grabbed from the Internet.

All operating systems are enormous, complex software systems with lots of ways to fail catastrophically. It is likely that all common operating systems have undiscovered security flaws. If you have to store bitcoins on a server, I would suggest Linux, since most malware targets Windows. But still, if planning on storing any amount of bitcoins large enough to worry about losing them, don't get your computer near the Internet.


Does Bitcoin RPC API have a realtime websocket? I am trying to create some app based on RPC API call from bitcoin core.

I want to make my btc core daemon send a notification whenever a new transaction is observed. Does BTC core RPC API have a websocket interface to make a call when new transaction happens ?

Since you only care about transactions involving your wallet, you can specify the walletnotify option in your bitcoin.conf or your bitcoind start command.

Since walletnotify allows you to execute an arbitrary command with the new tx info, it's fairly easy to make it call a webhook on your application, or invoke your application via the command line, or pass the information on in any number of other ways.


How is Electrum able to find my default wallet even though I deleted it? OK I didn't delete it. I closed Electrum, renamed the wallet to xxx.default_wallet.xxx and moved it to my Desktop from C:\Users\Chloe\AppData\Roaming\Electrum\wallets. I wanted to test wallet restore. However, it opened the default wallet still! How is it able to find the default wallet file when the file it's looking for doesn't exist? Does it store the wallet in the registry?

Oh, I had another instance open to another wallet. It must have kept all the wallets in memory. When I closed the last instance, it wrote another default_wallet to disk.


Transaction created with sendtoaddress didn't propagate to the network, how to resend? i am running Bitcoin Core 0.14.1 on a  Centos6 Server.
I had several transactions (receive, send) in the last days, and everything was fine.

I always did my transaction with the bitcoin-cli sendtoaddress ADDRESS  AMOUNT ... and that worked fine. Always after some minutes i could see my unconfirmed transactions at Blockchain.info

But yesterday i made a new transaction same as always and i get an transactions id successfully, but i cant find my transaction in the Blockchain. And the receiver does not the transaction also.

What i have tried:

I wait more than 24 hours ( but my transaction is not showing up in blockchain, and wasnt include in any block)
I turned off the IP Tables and make sure that the Wallet is connected to the network.
I stooped Bitcoin with bitcoin-cli stop and made an recan with bitcoind -rescan
I stooped Bitcoin with bitcoin-cli stop and made an recan with bitcoind -zapwallettxes
I deleted the memorypool.dat in .bitcoin directory
I reload the complete Blockchain

Who has the solution?

If you have the transaction ID you can get the raw hex transaction via:

bitcoin-cli getrawtransaction <txid>

That will produce a rather long string <rawtx> which is the serialized transaction. You can then use

bitcoin-cli sendrawtransaction <rawtx>

or any of the web interfaces that allow pushing a transaction (just search for pushtx and I'm sure you'll find a few providers). The raw transaction does not contain any private information. It is safe to publish, however services may attribute the transaction with your IP if you use them, so try sendrawtransaction first, which is the exact same behavior your client would use anyway.

Notice that your client will also automatically retry your wallet transactions every once in a while, so manual intervention may not be needed. It could be you haven't attached a large enough fee for the TX to be propagated in the network.


Access custom BIP32 paths on trezor So I really have 2 problems now:

I took xpub address for Dash from trezor and used it with blockcypher API to generate addresses with paths like m/0, m/1, etc
I sent some money to that addresses and noticed that trezor wouldn't show them, obviously it uses different paths than blockcypher.
I figured that easiest way is to take mnemonic and import it somewhere else, that would allow me to specify custom path, but I can't seem to find it. So I have trezor and I can access it, withdraw all the other funds from it, but I don't have mnemonic anymore.

What are my options to recover those Dash?

The Trezor doesn't actually only derive at specific derivation paths. Rather it has to be given a derivation path, and the Trezor web wallet software only uses predefined ones. However you can use another tool that connects to the Trezor and specify your own derivation paths.

Trezor has a command line tool as part of their python library that you can use. See https://github.com/trezor/python-trezor/blob/master/docs/OPTIONS.rst. You should be able to use that to construct a transaction that uses the addresses that you want.


Is there a Python or SageMath implementation for solving the ECDL problem for small secret multiplier? I am looking for a Python script or SageMath code implementation for testing the Baby Step - Giant Stepand Pollard Rhoalgorithms on the secp256k1 curve.

I have read that these algorithms are well known for solving the ECDL problem for small numbers but I haven't found any code to test this.

edit:

I am looking for generating a small secret multiplier over the standard  secp256k1 curve parameters.

Here is an example for E=EllipticCurve(GF(modi), [0,7]) using the standard NIST parameters for G.

G=E(55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424)

We know that for

P=E(69335761065767984070318781108127416310968753866933119760392423089576366173459, 113425617697416972613102767146321902225172329004525144463444008550345431352693)

when calculating discrete_log we get the small x=24734216105351567 as a result of P = x * G

Is there any such implementation that will calculate the small x?

Thanks!

In Sage.

Let's first define a finite field of size 2^32 (over which exhaustively searching would be painful but doable, but Pollard-Rho should be pretty fast).

sage F = GF(2^32 - 5)

And a prime-ordered elliptic curve over it (y^2 = x^3 + x + 13 happens to be prime)

sage: E = EllipticCurve(F, [1, 13])

Let's call the order of the curve n:

sage: n = E.order()
sage: n
4295040499
sage: n.is_prime()
True

Let's pick an arbitrary generator on that curve:

sage: G = E.gen(0)
sage: G
(4022957561 : 1193765470 : 1)
sage: G.order() == n
True

Now let's pick a random multiple of that generator:

sage: import random
sage: x = random.randrange(n)
sage: x
1334636724
sage: P = x * G
sage: P
(2051230087 : 1391923842 : 1)

And to find the discrete logarithm, simply use:

sage: discrete_log(P, G, n, operation='+')
1334636724

The same as our random secret multiplier x.

Sage uses Pollard-Rho and other algorithms internally.


Why does the Satoshi client not use blocking synchronous communication with peers? Why does the Satoshi client not use blocking synchronous communication with peers? I think that is mush simpler than the current asynchronous scheme.

I mean after a node sends out a request, it waits for the response in a blocking manner, with a timeout deadline. After the response has arrived, it starts to send the next request. Doesn't this way have better control of communication context?

If all clients in a network used blocking synchronous communications, then a single bad client could potentially bring down the entire network.

In a distributed untrusted network, asynchronous communications are required for robustness and reliability.


Can too big hosted mining service be mitigated by allowing customers to choose mining pool? Let's say a company is hosting mining hardware, either hosting customers' hardware or renting out the hashes produced by hardware owned by the company, or both. So the company is physically controlling the hardware.

What if this hashpower reaches a percentage of global hashpower that makes double-spends possible.

Can this be mitigated by the company allowing customers to select which mining pool they want their hardware/hashpower pointed at? For example through the company's web interface.

I think it primarily just gives you a false sense of security.

Let's say company XYZ is a hosted mining company like you describe. They grow so that they have 51% of the network's hash power. This may not be apparent on graphs like this one since it's spread among other (reasonably-sized) pools. However, since they are ultimately in control of the hardware, they can "go rogue" and make all of the hardware mine on their own pool. They now are able to execute double-spends, since they have 51% of the power. Note that this will not be a quiet thing: People will know that it has occurred.

A major reason why this probably wouldn't actually happen is that the company would be killing their golden goose. They could keep making money as a mining service, profiting from Bitcoin's success; instead they succeed in a few double-spends and then faith in Bitcoin is destroyed, and the value plummets. Or, since they no longer have cash inflow from new miners, they can't keep up with the rest of the network's improvements and they fall below 50% of the power. Either way, they're pretty much shot.

If we had a way to provably protect the hardware (via some private/public key system) so that the renters are really the ones that control what pool it points to (and the communication between the pool and the hardware was similarly tamper-proof), we could prevent this sort of attack completely. This would make the service more like a "customer buys some hardware, and we provide the space, power, and cooling in exchange for a fee" service than typical mining contracts.


Can I use the official wallet to recover bitcoins sent to an alternative wallet? I like alternative wallets like Armory and Electrum because they offer more features, some of which are fundamental for security and convenience. But I'm a bit worried about them not being "compatible", I mean you can't import an Armory wallet into Bitcoin-qt.

So what I would like to know is whether it is possible to recover my bitcoins (which if I didn't get it wrong, they are in the blockchain and could be spent with the private key) using the official wallet. For instance, the paper backup generated by Armory contains a "root key" and a "chain code". Is one of those the private key or what?

Most alternative wallets give you the possibility of exporting the private keys. Private keys can be imported in almost every other wallet.

In the case of Armory, the root key and chain code are used to generate a whole chain of private keys. You can ask for new addresses as you like inside your wallet, and by backing up only these two keys, you can recover all of them. This is a useful feature, but makes it harder to import in other wallets.

Luckily, Armory has an option to export the individual private keys of all the addresses you used. In the wallet menu there is a link "Backup Individual Keys" for this purpose. This exporting feature will always be available, also when Armory decides to stop, since it is independent of Bitcoin itself.

I don't know how other wallets support backing up individual keys, but I suppose most of them can.


Does bitcoin miner heat as much as a heater If someone want to heat a room or some water for a defined amount of time and without a worry about the sound produced.
Can a bitcoin miner be a good subtitute to a modern heather with the same power consumption ?

A device that consumes N watts of power (and doesn't output electricity or some other form of energy) will eventually produce N joules of heat per second.
Thus, if your goal is converting electricity to heat, every piece of hardware that consumes electricity is 100% efficient. It's completely irrelevant what happens with that electricity before it becomes heat.
Of course, you need to take hardware depreciation/maintenance costs into account.
Also of note: as heating devices, heat pumps have over 100% efficiency, as they simultaneously consume electricity (which is turned into heat) and move additional heat from a colder area to a hotter one.


Is it possible to run both bitcoind and bitcoin-qt as backend and frontend? Multiple instances of bitcoin-qt store the blockchain data separately causing lots of waste of storage and network.

I'm thinking of running bitcoind as a local server which stores the blockchain and each bitcoin-qt as a client that handles only the wallet data and connects to the bitcoind when needed, so that users don't need to wait until the chain is synced whenever they run bitcoin-qt.

Is this configuration possible? Ive read docs saying bitcoind and bitcoin-qt shares common sources but found no further instructions.

No, you cannot do that. Bitcoin-qt is not just a frontend GUI or wallet handling software. It is bitcoind with a GUI. It does all of the same functions as bitcoind as it is built from the same sources. bitcoind also has the same wallet handling components as bitcoin-qt. bitcoin-qt has the same node, consensus, networking, etc. handling code as bitcoind.


Supply Restriction on Bitcoin & Bitcoin Cash? Still a bit unclear then. How is Bitcoin at 13-18k USD/Bitcoin and Bitcoin cash is only around 2.5-3k USD/Bitcoin Cash? So will we ultimately have 21 million Bitcoin and Bitcoin cash is a fraction of it?

It's a very basic question - I'm sorry if it's too rudimentary, but please do expand.

Bitcoin Cash is a seperate fork, a seperate entity.

There will be (a bit less than) 21 million BTC, and (a bit less than) 21 million BCH.

Price differentiation is because of supply / demand for Bitcoin Cash.

You should see Bitcoin Cash as an altcoin, and not something that is in any way connected to Bitcoin.


if the cap is 21 million bitcoin does this mean that there will be only 21 million transaction? so as the tittle says , and if I got right , a bitcoin is given to the first miner who got the right hash , so with 21 million cap does this mean the limit of transactions is also 21 million transaction ?

No, this is not correct.

It is possible to spend tiny fractions of a bitcoin.
Coins can be passed on from person to person (just like any other kind of money).  So the same coins can be involved in many different transactions.

Incidentally, the reward for a valid block hash is currently 25 bitcoins, not 1, though this will decrease over time.  Even after this decreases to 0 (when the total number of bitcoins in circulation is 21 million), it will still be possible to have new transactions as people give each other bitcoins in exchange for goods and services.

There is no practical limit on the number of transactions.


How can I determine where a BTC transfer from one of my accounts to another went wrong? I have two BTC accounts on a Ledger S Nano hardware wallet, which I can check via the Ledger Live software. I've transferred BTC many times already, to my own accounts and to other people, and never had a problem before.
Today, I tried to transfer some BTC from one account (Bitcoin Current) to another (Bitcoin Savings). The BTC went out of the Bitcoin Current account instantly and has now been confirmed 36 times. However, the BTC did not appear on my Bitcoin Savings account and several hours have now passed. There is also no record of the transfer in the Bitcoin Savings account, i.e. it doesn't say 'received x BTC' as usual.
I transferred the money in the same way as I normally do:

Click on the account where the BTC will be transferred
Click receive
Connect Ledger S Nano
Confirm Bitcoin address shown in software on Ledger S Nano
Copy the address (Here I copied the address to Notepad, then copied again from Notepad before using, which I don't think I've done before)
Click on the account from which to send BTC
Enter amount to be sent, Bitcoin address, etc., and confirm transaction on Ledger S Nano.

I would like to know how I can check where the transaction went wrong. Is there a way of confirming that the Bitcoin address I used does actually belong to my Bitcoin Savings account? Is there a way of checking whether somewhere in the process I accidentally sent BCH to a BTC account or vice versa (although I'm not sure how this would happen?). I found another forum where someone had an issue with an address that was incorrectly copied/pasted or had extra characters added in to it or something, how can I check this?
Thanks in advance for any help here

I don't know how much it will help, but you can search for the transaction using the Bitcoin addresses on a Block explorer, then maybe you can see if the destination address was wrong:
https://www.blockchain.com/explorer


Wallet balance zero after restoring wallet.dat I recently restored my wallet.dat file from another machine. The wallet.dat came from a Linux machine (debian), and was restored to a Windows bitcoin install.

After restoring I can see the correct bitcoin address, but the balance is 0 BTC. The client is still downloading the block-chain (152,000 blocks at time of writing).

When will the balance show? It should have a balance of 0.66 BTC.

The wallet was restored using the answer from this question: How can I restore my wallet?

The balance will return as soon as the client catches up with the network.


Volume in the Charts is different than what gets returned from the API's when I pull volume data (BaseVolume?) from the Bittrex (for example) API every minute, draw a chart from that data and then compare that with the one minute timeframed volume chart (the study chart) on Bittrex it looks totally different.

I used BaseVolume, but i also tried to draw graphs with any other field that gets returned and I can't seem to replace these charts at all with any value. Does anyone have any idea?

Thanks

It's not clear which API call that you are using so I'll give my two ideas on what the problem might be:

If you are using the "getmarketsummary" API call and calling that
every minute then you will get wrong data because this is based on
24-hours. In my opinion, this is a useless feature.
If you are getting the market trades and then calculating the OHLCV
value in 1-minute periods, and those values don't match up with the
Bittrex candle charts then you are probably seeing the 2 to 4 minute
delay that Bittrex has. I use a service (ClueDex) that removes
that delay and I can literally get 1-minute OHLCV candle data as
soon as the minute closes.


Steal proof-of-work answer from a miner Is it possible to steal proof-of-work answer from a miner who has insecure machine? Consider a miner who has insecure machine found correct answer of proof-of-work and an adversary steals this it and broadcasts to the whole of network to receive the related reward. Is it possible? and if so, what the solution? I do not mean "sealing block" but I mean "stealing nonce" i.e. the answer of pow for a "unique block". Consicer two miners (rational and honest) are working on a the same block. If honest miner can find correct nonce then rational steals this nonce and propagates it in entire network.

The proof-of-work is the fact that the hash of the block is a low number, when you interpret the hash as a long 256-bit number. If you change anything in the block then the hash changes and is very unlikely to be low enough (below the target), so the proof-of-work is gone. And quite right, you did not do any work to create that modified block.

So you can't modify the block after it is mined, which means you cannot change the bitcoin address that this block sends its miner income (new coins and transaction fees) to.

You cannot steal the miner income from a block after the block is mined.

However, if a mining pool server is insecure you could hack into it and make the mining pool mine blocks that pay your bitcoin address instead of their own.

You could also make individual miners in a pool mine for you instead of themselves. They wouldn't even need to have an insecure system. BGP routing attacks have been used to hijack miners before, making them connect to the hacker's server instead of the mining pool server they want to connect to. See https://www.wired.com/2014/08/isp-bitcoin-theft/ This could be mitigated by using TLS, just like web servers use TLS (https addresses).

So there are multiple ways to steal from miners, but doing something with a block that is already mined is not one of them.


How do I calculate the value of some amount of bitcoins in my native currency? If I know the exchange rate, how can I calculate the value of some amount bitcoins in my native currency?

I will explain how to calculate the value of some amount of bitcoins in terms of USD, but obviously the USD can be replaced by any other currency, and the corresponding exchange rate.

There are three figures involved in this calculation:

The value in USD.
The exchange rate, which gives you the relation of USD to BTC.
The amount of bitcoins.

If you look at the units of the figures, you can figure out the following formula:

value in USD = exchange rate * amount of bitcoins

Or expressed in the units of the terms:

[USD] = [USD/BTC] * [BTC]

As you can see, if you multiply the exchange rate [USD/BTC] with the amount of bitcoins [BTC], the units of the right side will be reduced to [USD], which is what we are looking for.

Example:

We have 0.005 BTC and the exchange rate is 200 USD/BTC.

exchange rate * amount of bitcoins = 200 USD/BTC * 0.005 BTC = 200 USD * 0.005 = 1 USD

You can also turn the equation around to calculate any of the other terms:

To calculate the exchange rate, you take the amount of USD you paid, and divide by the amount of bitcoins you received.

exchange rate = 'value in USD' / 'number of bitcoins'

To calculate the number of bitcoins you might buy with a given amount of USD at a specific exchange rate, you divide the amount of USD by the exchange rate:

number of bitcoins = 'value in USD' / 'exchange rate'


Blockchain.info has a service to list all the transactions which involve a bitcoin addresses generated using a given xpub.How does this work? As per my understanding, there could be infinite addresses which can be generated, so how does this work?

Link: https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz

BIP-44 specifies a limit to how a wallet should look for public keys. The implementation should consider there's no address with funds beyond 20 addresses without funds.


Rounding in BTC exchanges Does anyone know whether exchanges usually round values or truncate them instead?

Different exchanges support different resolutions for prices and amounts. For instance, BTC China supports 2 decimals for prices and fiat amounts (in CNY) and 4 decimals for BTC amounts.

Now, if I buy, say, 0.625 BTC at price 1621.37, I would get 1013.35625 CNY, but since fiat amounts are allowed to have only 2 decimals, that number will lose the extra digits. But will it become 1013.36 or 1013.35 (that is, rounded or truncated?).

This can be verified empirically for any given exchange, but I was hoping someone already knew the answer, either for specific exchanges or a general rule that most exchanges follow (if that were the case).

Cointrader rounds it:

  All calculations are performed to 16 decimal places. The final fee for dollars is then rounded up or down to two decimal places, and final fee for BTC is rounded to 8 decimal places. For example: a fee of $0.114 is rounded down to $0.11, and a fee of $0.116 is rounded up to $0.12.

Coinfloor uses something called "weighted stochastic rounding", whatever that may be:

  In order to ensure fairness, Coinfloor uses an approach called "weighted stochastic rounding" to calculate the fees charged to our users when trading. Weighted stochastic rounding over time minimises the effects of rounding errors. To understand why this rounding method is preferable to traditional "round-to-nearest" rounding methods, consider the case of one hundred occurrences of a 4.71 fee, each rounded according to the nearest whole number. Using the weighted stochastic rounding method, the expected value of the sum of these rounded figures is 471, which is exactly equal to the ideal sum of the unrounded figures. Using the traditional method, the expected value of the sum of the rounded figures would be 500, which is far from ideal as it results in a much higher fee charged.

I didn't find the information on any other sites, but I think they will use round


Call function for block n on blockchain I've been going through main.cpp in order to roughly find out which function calls the best block and I found out depending on situation there are several similar-sounding function names and code extracts that I suspect of calling the best block.
Here's my list:

CBlockIndex *pindexBestKnownBlock
uint256 CCoinsView::GetBestBlock () const
CBlockIndex* pindexBestHeader
CBlockIndex* pindexBestForkTip
pindexBestInvalid
// move best block pointer to prevout block
view.SetBestBlock(pindex->pprev->GetBlockHash());
chainActive.Tip()->GetBlockHash().ToString()

Now my question: Which one of the list items above can I use and modify in a way that calls a block that is n blocks deeper than the best block on the same blockchain?

The chainActive variable stores the best known block chain. But this is essentially just the chain of block headers, not the actual blocks themselves. To load the actual block from disk, use the ReadBlockFromDisk() function. But, be aware that this is an expensive function to use, it does not return immediately.

chainActive[0] or chainActive.Genesis() [1]

Gives the genesis block header.

chainActive[chainActive.Height()] or chainActive.Tip() [2]

Gives the header for the most recent block in the active chain.

chainActive[chainActive.Height()-10]

Gives the block header for the block with 10 blocks built on top of it.

Use any of these CBlockIndex pointers as below to get the block.

CBlock block;
if (ReadBlockFromDisk(block, pindex)) {
    // do something
}


Where should I get rpcuser.py from? I am following the instructions in my bitcoin.conf file, it writes:

It is set at intialization time
# using the output from the script in share/rpcuser/rpcuser.py after providing a username:
#
# ./share/rpcuser/rpcuser.py alice

However, I can't finde any rpcuser folder or rpcuser.py file. Am I supposed to have them? Is this normal? I already ran

sudo apt-add-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoin-qt

So, if I don't have the file, where should I get it from? Does this mean my bitcoin installation is incomplete? I havent synced all the blockchain yet..

Anyway, any advice is welcome.

There is no rpcuser.py script anymore, it is now named rpcauth.py (the ppa may not be up to date). This file can be found in the Bitcoin Core source code repository: https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py


How is hash rate of mining hardware calculated The mining hardware does a double sha-256 hash of the header while mining.  Is each sha-256 operation counted when determining the hash rate or is the whole sha256(sha256(header)) counted as one hash?

Just to throw out some example numbers, if the hardware can do 300 Mhash/s is the hash rate 300 Mhash/s or is it 150 Mhash/s because two sha-256 operations are required for each attempt?

The sha256(sha256(header)) is commonly called the hash in the Bitcoin world. So the hash rate is the rate of sha256(sha256(header)) operations, not the rate of single sha256 operations. Otherwise it'd probably called a sharate or something similar :)


How can I access the mnemonic in the mobile copay wallet? I was encourage to download copay in my phone so that someone could give me 0.001 BTC. In that process I did not write down the 12 words. Is there a way to access them in the app? Thanks.

You should be able to view your mnemonic within the Android App under Settings > Bitcoin Wallet: Personal Wallet > Security: Backup.


how i can cancel a transaction in blockchain,info? I have two transaction of bitcoin that i sent about 12 hours ago now i want to cancel it or to confirm it how can i do it?

because the other part that i have sent my other bitcoins does not pay my money

2c4d2b4cae5613ff2fbab071a4804b25ac32ba0c65cf30a506c9b691a7ccdf63

e5ea6688bec80f31e431643580c1f5f13cdf52ddafd5ed6ee6ca483fee8c133e

There is no way of canceling a transaction once you publish it to the network.

At the moment there are many transactions (about 100k) waiting to be confirmed. This might take a while.

For now the best thing you can do is to wait.


Multi coin paper wallet generator? Is there a site where I can generate paper wallets for multiple cryptocurrency addresses?

I couldn't find a good one. So I made one:

Demo: https://xcubicle.github.io/memorypaperwallet/

Source: https://github.com/xcubicle/memorypaperwallet

Most paper wallet generators just generate bitcoin and derived coins. There wasn't one that generated non-btc ones like ethereum and monero. And the artwork is user changable too! Feedback welcomed.

enter image description here


What does "ASIC" mean? I stumbled on the terms "ASIC" and " ASIC Miner", what do they mean? Is this something related to special hardware?

ASIC or Application-specific integrated circuit is a type of circuit that has become very popular in the Bitcoin mining community.

wikipedia defines it as

  "An application-specific integrated circuit, or ASIC /ˈeɪsɪk/, is an integrated circuit (IC) customized for a particular use, rather than intended for general-purpose use."

Traditionally computer chips are made with variability of input in mind, meaning that a given chip should be able to do a wide range of things. Because Bitcoin miners only ever use their chips for Bitcoin mining, you can make chips that are really really fast if you make them solely with that purpose in mind.

This is how companies like butterfly labs can get such ridiculous speeds of up to 500 GH/s!


Is periodically transferring Bitcoin from an exchange to a private wallet cost effective? I'm new to this, I've read a lot about it and I've decided to start saving money on Bitcoin by buying a fixed amount every month.
I know it is safer to store my Bitcoin on a private wallet instead of having it on the exchange I'll use to buy. But I know that moving it from the exchange to the wallet will incur a blockchain fee.
It feels to my that by moving Bitcoin to my private wallet each month I'll be constantly paying and would be cheaper to just store it on the exchange.
What are your thoughts on this? What's the must cost effective way of moving it to my wallet? Will doing this once a month be as costly as doing it in larger amounts once a year?
I'm looking to hold for a long time.
Any advice will be much appreciated. Best.
PS: I've done my research before asking here but couldn't find a good answer.

But I know that moving it from the exchange to the wallet will incur a blockchain fee

There is a fee involved in all bitcoin transactions which goes to miners. However, withdrawal fees of most of the exchanges are not same as the fee used in bitcoin transaction for withdrawal. Most of these exchanges have fixed withdrawal fee like 0.005 BTC on Binance. Some don't have withdrawal fees like FTX (Maybe promotion and won't be free forever). Some exchanges allow you to set your own fee like Bitmex (Minimum fee changes according to mempool)
Spot exchanges also have their own fee structure for withdrawals. Peer to Peer exchange like HodlHodl uses 2 of 3 multisig so fees work differently and you don't keep bitcoin on exchange ever: https://hodlhodl.com/pages/faq

What's the must cost effective way of moving it to my wallet?

There are different types of fees involved in exchanges. You will have to explore all options and see what works best for you. Also prefer using an exchange that supports withdrawal to segwit addresses, LN and Liquid. Layer 2 solutions have lower fees compared to on-chain transactions most of the times.
I am going to make a list of exchanges that support latest bitcoin technologies soon. Until then this link can be helpful for exchanges that support LN: https://ln.guide/docs/EXCHANGES.html


Is there a usable Namecoin e-wallet? Specifically, I need the easiest possible way to store Namecoins mined through merged mining, so the eWallet will have to deal well with generated transactions. Do any NMC eWallets actually exist? Do any of the exchanges deal well with generated transactions at receiving addresses?

I would recommend VirCurEx. You can use it as a wallet or trade between different currencies.


Vanitygen regular expression match Using regular expression match instead of prefix, is there a way to add a difficulty and probability check? Seems to only report keys/s and total keys tested.

There is no simple algorithm to estimate the difficulty. Doing that requires you to first determine the cardinality of the intersection between the regular language expressed by the input regular expression, and the set of all valid public keys.


Are transactions containing zero-value output accepted by miners? Would miners generally accept a transaction that has one of its output values set to zero? Can the acceptance in this case depend also on the scriptPubKey associated with the zeroed output?

Each miner (or mining pool) sets their own policy, but miners using Bitcoin Core 0.9.0 and later will, by default, mine OP_RETURN (null data) outputs with zero value.  They will not, by default, mine any other outputs with a value below the dust threshold, which is 1/3 as many satoshis as it would take to relay the output plus the corresponding input according to your node's relay fee policy.

For example, if your node's relay fee is 1000 satoshis per kilobyte, the output is a 36 byte P2PKH script, and the input that spends it is expected to be 148 bytes, then the minimum allowed value is 546 satoshis.

To learn more about the default Bitcoin Core rules, you want to check its IsStandard() function which determines what transactions it accepts into its memory pool.  Bitcoin Core will mine anything in its memory pool.  The rules have changed a lot over time, so here are a few different links:

Bitcoin Core 0.9.x latest rules
Bitcoin Core 0.10.x latest rules
Bitcoin Core development branch latest rules

(Note: the links above may not point to the right place if code gets moved around.  Just search the page displayed for "IsStandard".)


Who bears the transaction fee for settling HTLC in Lightning Network? Given a channel that exist between Alice and Bob, where Alice wants to transfer 0.0001 BTC to Bob. Alice makes HTLC payment to Bob contingent to the secret for the payment hash within a timelock of say 100 blocks. So now Alice and Bob will each have a copy of the commitment transaction. Suppose Alice decides to close the channel at the 50th block height by broadcasting her copy of commitment transaction which has two output: HTLC success and HTLC timeout. So she bears the transaction fee of the commitment transaction. Now Bob can immediately spend the HTLC success transaction by using the preimage of the payment hash and his signature. Now Bob in order to guarantee that his HTLC success transaction is prioritized, increases the transaction fee of HTLC success transaction (using Replace-by-fee). So is that Bob has to bear the cost of the increased transaction fee in order to spend his output?

Tl,;Dr answer:

The fees for the htlc are covered by whoever claims the output
The fees for the commitment tx are always covered by the party who opened the channel.

Sorry to say that but I believe there are many things wrongly stated in your question:

The fee for the commitment transaction is not necessarily paid by Alice even if she force closes the channel. The fee is always covered by the the person who has opened the channel. This is independent of who closes it and what type of close we have.
The commitment tx does not have two outputs htlc success and htlc timeout. It has 3 outputs: a) a relative timelocked to_local b) to_remote  c) the htlc output which has two conditions to be spent: one is the htlc success and the other one is htlc timeout tx. (note of course there could be more than 1 htlc output in the commitment tx if there are several htlcs in flight)

The fees for claiming the htlc output must necessarily be paid by the person who claims the output, since the funds go to them and noone else. (of course ln could have decided that they could have been taken from the commitment tx but I think this would have been a wired and unclean solution) So yes in your case they are paid by Bob.
Note that the htlc output is again a multisig Adress to enable the second stage htlc process. AFAIK this is necessary to decouple the relative timelocks of the commitment tx from the absolute timelocks of the htlcs. That being said as far as I understand the situation Bob isn't able to replace by fee the htlc success tx without getting signatures from Alice. (note that in commitment signed message there is one signature for the commitment tx to spend the funding TX and then a list of signatures for every htlc as the htlcs are in a musig Adress (this is also necessary to allow the penalty tx in case if broadcasting old state). Thus without Alice's help Bob cannot create a new htlc success tx. In the case of a force close we assume there is no help.


How to deal with the wallets with very small amount of Bitcoins? The scenario is: You have a wallet with only 0.0001 BTC or less. The amount is less than the transaction fee. You want to transfer the coins to another wallet in order to reduce the wallet size. How can this be done?

Thank you good people:)

Two ways:

Create a transaction with no fee and wait as long as it takes for it to confirm.
Aggregate several such accounts into a single wallet so you can combine them in a single transaction.

Neither way is likely to be worth the effort though, unless you have a large number of such accounts.


How to realistically mitigate miner heat Does anyone have a system for flushing the heat generated by their miner out of their house/office w/o letting in outside temp. I'm worried about the cost of cooling a miner in the south in August. I previously heard that antminer s7/s9 miners can operate in the ~135 degree f range. Also, if this is off topic for the forum let me know.

When people speak of electricity costs of mining, they are not just referring to the miner, itself.  They are also talking about the cost of cooling the miners.

Anyone who has worked in a datacenter knows that cooling is a major cost, if not the main cost.  This is why large scale datacenters are often built next to water sources; to cool the servers.  If you are running a miner, you need to keep the ambient temperature cool (air conditioning), and perhaps have heatsinks and water cooling systems on the miner, itself.

The cost of cooling a mining rig may make mining unprofitable, depending on the issue ambient temperature.


Why is it harder to generate addresses starting with 1s? Here's a table I got from bitcoin wiki.

They say:

  A special case, leading numbers 1 (one) is especially difficult.

But why?

An address has 1 + 20 + 4 bytes, which has a total of 200 bits. Each of the Base58 characters contain log_2 58 bits of information, which is approximately 5.858. If one created an address that has the public key hash 0000...00, the result would be a 5-6 character address, due to the checksum. To prevent this, Satoshi decided to add "1"s for each 0x00 byte in front of the address. Those "1"s each contain 8 bits of information instead of 5.85... As they carry more information, it's harder to find an address starting with those 1s.


In what sense does the security model of proof-of-stake require users to "log on to the internet every few months" This is primarily a question about something I heard Vitalik Buterin say in an interview the other day. (Unchained podcast's January 9, 2018 episode, at 34 minutes, 15 seconds) I quote:

  As far as the cons [of proof-of-stake], I would say the main one is that it is a different security model. It’s a different security model that basically says that, in order to securely authenticate the blockchain, you have to log on to the internet at least once every few months. And if you don’t do that, then in order to bootstrap yourself to the chain again you basically have to trust some group of people who have. And I think that in reality this is a totally fine security model because people basically already trust this security model for software updates.

I don't understand this quote. The way I understand it is that, regardless of proof-of-work (PoW) or proof-of-stake (PoS), a person has two choices: Run a full node, or run a "lite" node where you trust a third party node.

If you run a full node, you have to download all of the chain before you can create new transactions. If you run a lite node then your balance and transactions are dependent on the third party, but you don't have to wait to download the chain. It seems to be that way both for clients of both PoW and PoS blockchains. So I don't see how the consensus algorithm is relevant. The only explanation is that I'm completely misunderstanding the quote, so I'm hoping that someone can shed some light on my misunderstanding.

Note: This question is not asking if PoW is better or worse than PoS. I just want to understand the quote. Thank you.

What Vitalik is talking about is the Slasher algorithm that he designed which punishes the block signer if he attempts to create a fork in the blockchain. However the way that slasher works is that there will be basically a timeout; if a fork is detected during that timeout, the signer that created the fork loses his money. But after the timeout, he does not. This is so that he can actually spend the money at some point.

The problem with this is that once the timeout has passed, the signer can then create a fork without being punished. This is known as a long range fork. This fork, if it survives, can grow and, at some point, could be longer than what you have synced up to. In that case, because of how PoS works, you could end up switching to using the forked chain instead of the real chain. So to avoid that, you need to go online routinely to keep your blockchain up to date so that in the event of a long range fork, you are still using the correct blockchain.


Calculating exchange reserves/inflows/outflows I see that there are a few sites that provide analytics for this kind of data (here's one:
https://www.tokenanalyst.io/dashboard).
I'm wondering how these companies are able to track this information.  Are the addresses of major exchanges publicly known?  Do the exchanges publish or offer this data?

Most exchanges aren't publishing this data, some even trying to hide as much of it as possible, using separate wallets and trying to be smart about change progression.
A lot of the analytic companies are using repositories (examples:1, 2) of publicly known addresses to find out the wallet ownership.
But this isn't the most optimal solution when it comes to analytics, some blockchain analytic companies are actually applying as customers of these exchanges and trying to get on-chain activity, main addresses (so-called hotwallets) and marking wallets through common input clustering.


Needing to recover husband's bitcoin account My husband passed away a few weeks ago and he had a bitcoin account. Is there any way that I can recover that and transfer it?

I'm sorry for your loss.

If your husband is keeping bitcoin at a big name bitcoin exchange, you may want to contact the exchange administrator to inquire about the procedure.

If the bitcoin is outside an exchange, then accessing it requires knowing a very long password or a very large number, possibly starting with "0x" (meaning hexadecimal). It would probably be written somewhere on paper, but may also be hidden in a password-protected file or stored in a special USB or other crypto device.

If you have reason to believe your husband may have significant money in this, you should really find a knowledgeable friend whom you trust to help you find the access credentials for the money. Unless you are pretty tech savy yourself, you should strongly consider immediately selling the bitcoin for "real money".

On the other hand, if you have no evidence that your husband had money in bitcoin (other than, as you said, "a link that said Bitcoin") you may want to understand that there are a lot of people with interest in Bitcoin who do not hold a meaningful amount of Bitcoin.

Lastly, as said already, do not trust anyone on the internet. Do not give anyone any passwords or any numbers you do not fully understand until you get help from a knowledgeable friend or have educated yourself very carefully. It is extremely easy to steal Bitcoin, it is nearly instantaneous, and it is almost completely outside of legal protections.


What value does bitcoin add to the world? I don't understand the value of bitcoin mining other than to produce value for its owners.  What product is produced for the world?  Mining for coal produces coal to be used for energy production.  Mining for precious minerals provides metals for use in products all humanity can use.  What product does bitcoin mining produce?  I originally thought these computations the bitcoin miners were doing were solving some intractable math problem needed for some scientific usage, but as best as I can tell the math is for no other purpose than to generate value for the owner.

If you see bitcoin as a currency, mining is issuing new bitcoins. It is analogous to a central bank issuing (or printing) new currency.

  What product is produced for the world? Mining for coal produces coal to be used for energy production. Mining for precious minerals provides metals for use in products all humanity can use.

You could ask the same question to the central bank example. If The Fed issues $ 1 trillion what product is it producing for the world? The difference with bitcoin is that there is no central authority that chooses when to issue new currency but an algorithm and the issued currency instead of going to the banks in a form of loan, are given to the user who mines the next block.


How does a transaction using a Bitcoin payment code BIP 47 look like on the blockchain? Having that payment code addresses are untracable, how does a transaction look like in a block explorer if someone sends a payment to a reusable payment code?

BIP47 transactions look like any other transactions as far as inputs/outputs & fees are concerned. There is no difference.

Payments are not sent to the payment code itself but rather to addresses generated by the shared secret of both the sender's payment code and the receiver's payment code.

The only recognisable trace on the blockchain is the notification transaction, of one payment code to another, which includes an OP_RETURN. Notification transactions are done once for a sender to a receiver to initialise the payment "channel" and also permit any future restore of the wallet directly from the blockchain (in the event of lost metadata, for example).

https://github.com/bitcoin/bips/blob/master/bip-0047.mediawiki
https://github.com/SamouraiDev/BIP47_RPC


Dumping private keys from wallet.dat from command line (pywallet.py alternatives) I have somewhere in my hard disks some copies of old wallets which I need to analyse.

My idea was importing them into blockchain.info, but to do that apparently you need to dump them with pywallet.py, which is one of the worst pieces of software I've recently put my hands on.

Is there an alternative?

I.e. either one software which given (via command line) the full path of the file, will dump something that blockchain.info can import, or something that at least given a wallet (again, full path via command line) will dump all the private keys.

PS: this has to work for encrypted wallets too, asking the password either at runtime (would be better) or at the command line.

This is an old question but just to say that the dumpwallet command has been added to bitcoin core. This will give you all the private keys in a text format.


Lightning Network: asymmetry in the information tracked by each participant? In following paper, written by Christian Decker et al., there is a paragraph that is not clear to me.

eltoo: A Simple Layer2 Protocol for Bitcoin

  "The central idea of Lightning is to invalidate an old state by
  punishing the participant publishing it, and claiming all the funds in
  the channel. This however introduces an intrinsic asymmetry in the
  information tracked by each participant. The replaced states turn into
  toxic information as soon as they are replaced, and leaking that
  information may result in funds being stolen. The asymmetry also
  limits Lightning to two participants."

There are following points that are not clear to me:

(1) Does asymmetry mean the information tracked by each participant (payer and recipient) are NOT the same (or are NOT equal)?

(2) What is the reason of this asymmetry?

(3) What does "turn into toxic information" mean?

(4) The last sentence: "asymmetry also limits Lightning to two participants", Does it mean that we can expect a payment transaction can have more than two participants? since a payment logically has only two participants: a payer and a recipient.

When two channel participants open a channel or update it, they exchange commitment transactions. These commitment transactions allow each party to unilaterally close the channel.
The commitment transactions are asymmetric in that they lock the closing party's funds when broadcast, i.e. Alice's commitment transaction locks Alice's funds, Bob's commitment transaction locks Bob's funds. The counterparty's funds are immediately available for spending. The lock on the closing party's funds (the "breach remedy") gives the counterparty time to impound the closing party's funds via a "punishment transaction" if an outdated state was broadcast.

Commitment Transaction (via Elle Mouton): Alice's output to herself (to_local) in her commitment transaction is encumbered with a Revocable Sequence Maturity Contract (RSMC) which allows her to revoke the commitment transaction later, while the output to Bob (to_remote) is a simple send, vice versa for Bob's transaction.
When a payment is made in the channel and the channel is updated with new commitment transactions, the outdated channel state is revoked by revealing the secrets to spend the old commitment transactions (dB1 and dA1 in the graphic). This makes the old state "toxic" in the sense that (accidentally) using the outdated commitment transaction to close the channel will cost the closer all their funds in the channel.
Updating a channel to make a payment in the punishment-based channel setup requires a procedure with multiple roundtrips in a specific order to ensure that there is no disadvantageous intermittent state for either party. If it were possible to map this onto a multiparty setup, it would be extremely complex.
In Eltoo, commitment transactions are shared across the participants. Broadcasting an outdated state is corrected by overwriting it with the latest state. Since the channel state is symmetric, it is trivial to have channels with more than two parties. This could take e.g. the form of four parties creating a four-of-four multisig output to anchor a channel. Each party would have a balance in the channel which they could use to send funds to another channel participant, or other network participants. With Schnorr signatures and key aggregation, such channels would be extremely efficient as they could still fit in the size of a singlesig output. Practically, the number of participants would still be limited as any channel update would have to be agreed upon by every participant, and any one participant wanting to close the channel would close it for all. Possibly, this could be used as a liquidity pool or for channel factories among large players that can guarantee continuous availability.


How to get unspents for a specified bitcoin address? I want to access unspent data of a specific bitcoin address.

I am trying this command

bitcoin-cli -regtest listunspent "some bitcoin address"

But I am always getting an empty list. I am using local bitcoind server on windows 7.

What should I do or use any function for getting desired output ?

listunspent only displays information about addresses which are currently part of your wallet. Bitcoin Core does not maintain indexes of unspent outputs for addresses you do not own, and will simply return a blank set if you attempt to query for them.


Why BIP32 derive address does not match with BIP39? How is that the same xPub rsults different address in BIP32 and BIP39? :)

It doesn't. You read it wrong, first snippet shows you account key for m/44'/0'/0'/0 derivation path, second snippet for m/44. As the derivation paths are different - obviously the accounts' keys are different too.


Is there any "permissionless" blockchain "without a native coin"? We may certainly say that a "permissioned" blockchain cannot have a native coin (or cryptocurreny) since in permissioned blockchain we need a permission to be eligible to participate for transactions validation and so having a native coin in a permissioned blockchain is not meaningful.

However, on the other hand, can we say that having a native coin/cryptocurrency for a "permissionless" blockchain is crucial? Or is there any permissionless blockchain without native coin? In that case, how to ensure security and how to motivate miners/validators for participation in transactions validation?

Ripple is actually a permissioned "chain", even if we stretch what the definition of a chain is. It is run by validators and as far as I know, it is not permissionless (which I equate with "trustless").

I do not see a specific need for a permissionless network to have its own coin or token. It could in theory still be driven on top of an already-existing coin from another network. It depends alot on your proof-of-what algorithm. You could have a network that awards "miners" ETH for doing "work" even if your own network does not have its own native token, per se.


Mining new litecoin based altcoin. Internal Server Error 500 I apologise if I put this question in wrong place.

I created new altcoin based on litecoin source code.
All looks ok, wallet and wallet-qt are compiled and running.
However when I trying to mine using cpuminer (minerd) I getting 500 error.

I put this settings to *coin.conf file:

rpcuser=miner1
rpcpassword=some_password_here
rpcallowip=127.0.0.1
rcpport=9332
server=1
gen=0

Command for minerd:

minerd -a scrypt -o http://127.0.0.1:9332 -O miner1:some_password_here

Minerd output:

[2017-06-29 10:38:02] 1 miner threads started, using 'scrypt' algorithm.
[2017-06-29 10:38:02] HTTP request failed: The requested URL returned error: 500 Internal Server Error
[2017-06-29 10:38:02] json_rpc_call failed, retry after 30 seconds

What I'm doing wrong? Is there something else I have to do to "launch" my new crypto currency?

Thank you for your help.

The problem is that the Litecoin I used 0.8.4.7, does not have embedded mining software.

I ended up with two solutions:

Create mining pool and then:

connect nodes to each other
run the miner on my mining pool

Compile and run (-gen=1 option) old Litecoin node then connect to th
e other nodes one.


Estimate Fee returning -1 I updated the bitcoin node to version to 140200 on top of which one of my applications was running. There wasn't any issue with the flow of the application estimatefee RPC I get -1 for no matter what I give as the number of blocks. Also the alternate fee api estimatesmartfee returns negative values.
When I execute the same api on a node with version 140100 it gives me a positive result
How do I resolve this ?

-1 means "not enough information for an accurate estimation".

Try with a higher confirmation target.


What is the legal money range for a bitcoin transaction? What is the legal money range for a bitcoin transaction message ?
I am guessing that the lower limit is one satoshi but what about an upper limit aside from the maximum block size constraint ?

0 to 21 million BTC. (Yes, 0-BTC transactions are allowed as long as they have a fee.)


Where is Double hashing performed in Bitcoin? where in the Bitcoin Protocol is SHA256(SHA256(x)) performed and why?

Bitcoin uses double hashing almost everywhere it hashes in one of two variants:

RIPEMD160(SHA256(x)) called Hash160 which produces a 160 bit output

hashing the public key to generate part of a Bitcoin addresses

SHA256(SHA256(x)) called Hash256 which produces a 256 bit output

generating the checksum in a Bitcoin address
hashing the block in a merkle tree
linking transaction outputs and inputs
hash of the block header (and thus the proof of work and the link to the previous block)

It seems like Satoshi chose Hash256 whenever collisions are a problem, and Hash160 when only (multi target) second pre-images matter. This is consistent with a goal of achieving 128 bits of security.

You need a 2*n bit hash to achieve n bit collision resistance, and you need a t*n bit hash to achieve n bit second pre-image resistance. If we assume a conservative 4 billion targets, and a 128 bit security level, this leads to 256 bit hashes for collision resistance and 160 bit hashes for multi-target second-preimages.

So why does he hash twice? I suspect it's in order to prevent length-extension attacks.

SHA-2, like all Merkle-Damgard hashes suffers from a property called "length-extension". This allows an attacker who knows H(x) to calculate H(x||y) without knowing x. This is usually not a problem, but there are some uses where it totally breaks the security. The most relevant example is using H(k||m) as MAC, where an attacker can easily calculate a MAC for m||m'. I don't think Bitcoin ever uses hashes in a way that would suffer from length extensions, but I guess Satoshi went with the safe choice of preventing it everywhere.

To avoid this property, Ferguson and Schneier suggested using SHA256d = SHA256(SHA256(x)) which avoids length-extension attacks. This construction has some minor weaknesses (not relevant to bitcoin), so I wouldn't recommend it for new protocols, and would use HMAC with constant key, or truncated SHA512 instead.

Some related reading:

Hashing or encrypting twice to increase security? on crypto.SE
Cryptographic reasoning for double-hash? on bitcointalk


How Multisignature Wallets are affected in case of a hard-fork? In an event of forking, are there any special circumstances involving multisig wallets? I am asking this because Coinbase says they do not support forks and multisig wallets?

Below is a quote from the Coinbase site:

  Multisig vaults were originally introduced as a way for customers to
  manage their private keys and control their own security while still
  using the Coinbase interface. However, as Bitcoin forks become more
  commonplace, the complexity of multisig vaults makes it infeasible to
  support multisig withdrawals for each additional forked asset.

No, multisig addresses are not special in any way that is effected by forks. They are just like any other output on the blockchain.

The reason it is hard for Coinbase is because they need to implement support for signing and creating transactions for those forks which requires significant engineering effort. It's the same reason that they don't support every fork in the normal Coinbase wallet - it is difficult to implement such support so they won't.


Join a pool or create my own pool with my 500 PCs? I'm an internet provider for a village that doesn't have access to internet except through my service.

I thought about using my customers' PCs for mining and splitting the profits between us.

Each computer will vary from 50-100kh/s. So it will lead to more than 25000khs/s if combined in a pool mining.

Should I set up each computer to do SOLO mining, then each one sends me the blocks it mined, and I exchange them to USD and split the profits?

OR

Should I join a mining pool ex. http://www.wemineltc.com/ and add the computers as workers under my account name?

OR

Should I create my own pool and make them search together to find the blocks and have the blocks go directly to me?

If the 3rd option is the best, are there any simple tutorials on how to do it with the GUIminer Scrypt Alpha (so that the users don't have to be confused with the command lines stuff, and to make it automated with Windows startup)?

With that much hash power, I believe you could be better off creating your own mini-pool and putting those computers in it. In theory, solo mining will always give you more coins in the long term for pools always take a fee for their services. In practice, of course, you could be mining for years without ever finding a block, so it's more a matter of how much you can wait to see a return on your costs and investment: more constant payments but less gain in the long term, or the inverse.

This formula can aproximate how much time on average would elapse before you found a block - it depended on the difficulty level of the network and your hashing power. Have a look at it and decide if you can wait that much weeks/months with no yield in order to gain more in the end.

https://en.bitcoin.it/wiki/Difficulty#How_soon_might_I_expect_to_generate_a_block.3F


Firstly, the signed transaction and the base_transaction will not be identical, the base_transaction will not have the signature in it. But yes they will look very similar apart from that.

What you are looking at is a hex-encoded transaction. You can decode it to see what information it contains using the decoderawtransaction API https://chainquery.com/bitcoin-api/decoderawtransaction


Satoshi Nakamoto's Transaction Chain Diagram Hash Value In Satoshi Nakamoto's diagram:

The line coming from transaction block 1 and going the the "Hash" label in transaction block 2 appears to represent the hash of the entire transaction block (Owner 1's Public Key + Hash + Owner 0's Signature) rather than represent the Hash value shown in transaction block 1 (in which case the line should (technically) be attached to the Hash block rather than to the border of the transaction block). Can anyone confirm exactly how the Hash value shown is computed and whether or not it contains the previous owner's signature?

Can anyone confirm exactly how the Hash value shown is computed

By taking the raw data for the transaction (as in the bytes that are sent over the wire for the transaction) and passing it through a hash function. For Bitcoin, that is SHA-256 double (SHA-256 done twice).

  and whether or not it contains the previous owner's signature?

It depends. For simplicity's sake, you could say that it contains the previous owner's signature.

However, due to the activation of segwit, it does not always contain the signature. For segwit, the hash is not actually the hash of the entire transaction but rather parts of it that are non-segwit. Transactions that are non-segwit will have the signatures as part of the hashed data.


How to get private key from bitcoin wallet? My wallet just won't synchronize and I have 10 bitcoins there. I need to use blockchain but I cannot get my import key. Can anyone please help me?

Blockchain.info can create a new wallet from an existing Bitcoin.org client's wallet.dat with a simple Drag and Drop:

https://blockchain.info/wallet/import-wallet

The wallet.dat is in the data directory.


What if ISP's block port 8332? Hypothetically, if it were a well coordinated NSA-type shut down and ALL ISP's suddenly blocked port 8332 (major ones anyway), how would the Bitcoin system immediately handle it?

Bitcoin can be configured to handle any port for both peer-to-peer communication, as well as JSON RPCs. However, as Bitcoin clients do not encrypt their messages, it would still be fairly easy to filter out Bitcoin-related activities. One could then switch to using Bitcoin through TOR, or the developers could implement message encryption if needed be.


How to securely store Bitcoin server-side? I am working on a web application that needs to hold users Bitcoin for an extended amount of time (escrow-like scenario), and I was wondering what are some good steps/precautions and principles (dos & dont's) to do this securely. This is mostly in regards to security, so things like individual vs single server-side wallet etc. My thoughts thus far is that I probably should not have all the eggs in one basket, so something like generating a new random wallet per transaction server-side, and encrypt the private keys with a two-way algorithm before they are stored in the database, perhaps combined with user password so given the encryption function ENCRYPT(password,data) it would be: ENCRYPT(HASH(hard-coded password+user password+random salt+pepper),  private key).

The precautions you can take from an architerual point of view would be as follows:

The database storing the private keys or the seeds in case of HD wallets should be running on a separate instance and only accessible via the application server(AWS allows lots of configuration you can make in the virtual private cloud i.e. VPC to accomplish this).
The keys are encrpyted. As you mentioned some sort of 2 way encryption key needs to be maintained. Also it should be your motive to achieve minimal responsibiltiy in case of breaches. So encrypting private keys with users password is a good start. But storing plain text passwords in obviously stupid and so is getting it from the user over the network. https solves the over the network issue but plain text password itself is a point of failure. So you will have to come up with a different scheme where in you are unable to spend your users funds.
Going by the same minimisation of your risk approach, multisig would be the best  solution in this case. But this will require your users to be more active in the transaction process. Bitgo enforces multisig coupled with HD in a secure way to provide similar services.

In conclusion, HD wallets will reduce the number of keys you have to store, having a separate private key server instance and encrypting the private keys by the users passwords is a good way to start. Multisig would make things complicated for the user but would provide utmost security.


What programs, websites or other applications leverage Mt Gox's API? I'm looking for sample programs and apps that leverage Mt Gox and learning what they do. Is there such a list in existence?

Links to the appropriate BitcoinTalk or Wiki page would be more than sufficient as long as it's centralized.

Not sure of any official list but here are a few that I've found

Github Repos

bitfloor books
bitcoin-arbitrage
metabit
mtgox-node.js-client

Websites

bitcoin charts
bitinstant


How can I buy Bitcoins in the UK now that Blockchain.info has suspended its deposits? After blockchain.info suspended Pingit, there is no convenient way to buy a small quantity of bitcoins. Any other alternatives to acquire bitcoins (mining or working are out of the questions.)

I've heard a SEPA transfer will allow UK bank accounts holders to utilize European exchanges, unfortunately I am concerned about the legality of these exchanges (ie: who owns/runs the exchange, for example.) As such I would like the company to be based in the UK, where I have more protection if the transaction goes awry.

For small BTC purchases in the UK, https://localbitcoins.com/ (LocalBitcoins) is the only viable option right now that I know of.

There are other methods, mostly involving bank transfer arrangements, but be very careful to figure out how much you end up paying in total fees for it. It doesn't make much of a difference with large BTC orders, but for small amounts it's a fair % of costs.


How does Nextcoin convert 256-bit Curve25519 public keys into ~20 arabic numerals? Nextcoin seems to convert 256-bit Curve25519 256-bit public keys into "account numbers" that have only arabic numbers and seem to only have a length of 20.

How is that done?

Examples

In the Nextcoin forum, users leave their account numbers.

According to these lines an accountId seems to be...

int(sha256(publicKey(sha256(passphrase)))[7:0], 256)

...which translates to 256^8 accounts or roughly 2 * 10^19, which fits the idea of around 20 arabic numerals.

Given there are only 2^64 unique accountId and the birthday paradox, you can check this collision probability table (the 16 bytes/64 bits row). If each person in the world had a single Nextcoin account, the collision probability is greater than 75%! I'm sure this is the least of their problems.

This looks really amateurish. Really amateurish. Really, REALLY, REALLY amateurish. Stay away from this coin!


How to put pool name in a Bitcoin Block? If someone access blockchain.info, see blocks and Pool name who finded. I want know how sign this?

Thanks

Mining pools self-identify blocks they've created by putting an identifier into the freely choosable input space of the Coinbase transaction.


Why do some transactions take months to get into a block? This page at bitcoincharts shows a list of transactions that didn't get included in a block yet.  Many of them are from 2 or 3 months ago, even though they include a fee.  What's going on?  Why haven't they been included in a block already?

From what I have read about Bitcoin transaction confirmation (aka mining), a transaction may not be included in a block for any reason, but the most common is that the fee is too low for the size of the transaction. A higher fee increases the chance that the transaction will be included in a block by a miner. A transaction with no fee may eventually be confirmed, but it could take a long time to do so.

Certain transactions cannot be included in a block because they violate the Bitcoin protocol and will be discarded. Among others, these are transactions that attempt to spend more Bitcoin than is in an account and tranactions that try to double spend an accound balance. Transactions that depend on other transactions that have not been confirmed yet and are retained until either it is dropped because it would violate the Bitcoin protocol, or it is added to a confirmed transaction block.

(source: https://www.rugatu.com/questions/42/why-do-some-transactions-take-months-to-get-into-a-block)


Easiest way to buy Bitcoin from Montreal/Canada Apart bank wire is there a fastest/cheapest way to buy Bitcoin? I checked the map with the live seller but there is none in Montreal.

Thank's.

Deposit cash at a bank is a deposit method for CAVirtex.   TD or CIBC banks.  You don't need to have an account to deposit.

https://en.bitcoin.it/wiki/VirtEx

Update:

CaVirtEx no longer allows cash deposits at any bank. You now make a Bill Payment to an established Payee, and CaVirtEx credits your account about 2-3 days later.

https://www.cavirtex.com/news

There is a new service called harborly which allows you to buy and sell bitcoins in Canada directly with your bank account.

https://harbor.ly


p2pool.util.jsonrpc.NarrowError: -10 I'm attempting to run P2Pool locally on my other machine and getting this issue while running bitcoind:

2016-12-19 09:56:24.100000 p2pool (version unknown 7032706f6f6c2d7032706f6f6c2d39633662323130)
2016-12-19 09:56:24.100000
2016-12-19 09:56:24.100000 Testing bitcoind RPC connection to 'http://127.0.0.1:8332/' with username 'bitcoinrpc'...
Error getting work from bitcoind:
Traceback (most recent call last):
  File "c:\Python27\lib\site-packages\twisted\internet\defer.py", line 651, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "c:\Python27\lib\site-packages\twisted\internet\defer.py", line 1355, in gotResult
    _inlineCallbacks(r, g, deferred)
  File "c:\Python27\lib\site-packages\twisted\internet\defer.py", line 1297, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "c:\Python27\lib\site-packages\twisted\python\failure.py", line 389, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
--- <exception caught here> ---
  File "C:\bitcoin\p2pool-p2pool-9c6b210\p2pool\util\deferral.py", line 41, in f
    result = yield func(*args, **kwargs)
  File "c:\Python27\lib\site-packages\twisted\internet\defer.py", line 1297, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "c:\Python27\lib\site-packages\twisted\python\failure.py", line 389, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "C:\bitcoin\p2pool-p2pool-9c6b210\p2pool\bitcoin\helper.py", line 53, in getwork
    work = yield go()
  File "c:\Python27\lib\site-packages\twisted\internet\defer.py", line 1297, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "c:\Python27\lib\site-packages\twisted\python\failure.py", line 389, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "C:\bitcoin\p2pool-p2pool-9c6b210\p2pool\util\jsonrpc.py", line 133, in _http_do
    raise Error_for_code(resp['error']['code'])(resp['error']['message'], resp['error'].get('data', None))
p2pool.util.jsonrpc.NarrowError: -10 Bitcoin is downloading blocks...

I know the last line indicates that the bitcoin block is still downloading but the bitcoin core gui indicates that I am up to date. I've tried shutting down the bitcoin client and restarting a couple of times with no luck.

I have no idea if I'm missing something obvious here or not.

So I found the reason behind the block downloading issue.

I had forgot to point to the block's data dir when running bitcoind. So instead of utilizing the block downloaded from the GUI it was downloading an entirely new block and using that one instead.


bitcoin-cli createrawtransaction and purpose of "scriptPubKey"? I am playing with P2SH on regtest and try to understand the logic of creating and signing tx with bitcoin daemon. I am on version 0.15.1, and try to create a tx.

The used  scriptPubKey results from a simple if/else/endif statement, not from a standard multisig approach. So I manually created the redeem script, and turned it into an address (beginning with "2"). I then created a transaction, that funds this address. Now I want to spend these funds. While creating the transaction, I discovered that the usage of "scriptPubKey" does not change anything in my output.

Example without "scriptPubKey":

bitcoin-cli -regtest createrawtransaction '''[{"txid":"'b5b67997f36627a461cd5ee1951aa775a68faa0c11c50b8f068ea1c7f4a9b087'","vout":'0'}]''' '''{"'mgpe9b44YYYbhDE1dbWosCSQDPYFkkoHjt'":'9.99995000'}'''
020000000187b0a9f4c7a18e068f0bc5110caa8fa675a71a95e15ecd61a42766f39779b6b50000000000ffffffff0178b69a3b000000001976a9140e507731ec9a94d454424f3ca65917a2abb45f4988ac00000000

Example with "scriptPubKey":

bitcoin-cli -regtest createrawtransaction '''[{"txid":"'b5b67997f36627a461cd5ee1951aa775a68faa0c11c50b8f068ea1c7f4a9b087'","vout":'0',"scriptPubKey":"'a914d53c738d730d8623eb2a070833599157beb3f6f687'"}]''' '''{"'mgpe9b44YYYbhDE1dbWosCSQDPYFkkoHjt'":'9.99995000'}'''
020000000187b0a9f4c7a18e068f0bc5110caa8fa675a71a95e15ecd61a42766f39779b6b50000000000ffffffff0178b69a3b000000001976a9140e507731ec9a94d454424f3ca65917a2abb45f4988ac00000000

The result is exactly the same. When the result is the same, what is the purpose of using this field as a parameter to "createrawtransaction"?

Currently, the create raw transaction method only uses the txid and vout parameters from that argument. You can view the relevant part of the source here.
For all practical purposes, you could pass in 00 for the scriptPubKey and still get the same result.


How can I tell if my Bitcoin-Qt wallet is protected with encryption? I am a new adopter of Bitcoins, forgive the ignorance. (note these are test transactions)

I am using the Bitcoin qt client and I am very confused and think I have done something wrong.

I have two computers A and B both with Bitcoin qt client on. I have made wallets on both computers.
After launching Bitcoin qt client for the first time on computer A I created two addresses using the 'new address' button. I then clicked 'Encrypt Wallet' and entered a passcode. Note I only did this process once, even though I created two addresses.
I then transfered two test transactions to the wallet on computer A from Bitstamp. These came through as:

http://i.stack.imgur.com/2ziI6.jpg

(don't know if anything looks wrong in that picture?)

I then tried my first ever test transaction and sent it to the address I created on computer B (I have never encrypted this wallet).
To my surprise this sent, even though I didn't have to enter any kind of passcode on computer A? Plus my address on computer B isn't even encrypted?
Does that mean anyone can use the funds I have in my wallet on computer A, without my passcode?
The status of the transaction on computer B is also,  8 confirmations? Is this a sign of a mistake. Also the 'from' is marked as unknown - is this important?
There is also no lock icon on my QT client, which I have been told there should be if the wallet has been encrypted?

I'm confused, please advise. Sorry for my ignorance, I am not a technically minded person but trying to adopt bit coins.

If you encrypt your wallet, it will also be encrypted for all addresses your ever create.
Bitcoin qt will ask you for every transaction you made for the password.

  Does that mean anyone can use the funds I have in my wallet on computer A, without my passcode?

At this moment yes, try to encrypt it again, maybe you made a misstake?

  The status of the transaction on computer B is also, 8 confirmations? Is this a sign of a mistake. Also the 'from' is marked as unknown - is this important?

A confirmation means, that you transaction was successful added to a block and is processed.
Some markets or platforms need a certain number of confirmations.
Your payment is normal confirmed after 1 confirmation.

  There is also no lock icon on my QT client, which I have been told there should be if the wallet has been encrypted?

Yes, there should be a "lock" icon on the right bottom. Try to encrypt your wallet again is it possible.


If I held fiat currency, instead BTC, on MT Gox, would I get paid sooner/more? If I held currency on Mt. Gox, but not actually bitcoins, am I in a different situation to those who held bitcoins? For example, if I had $700 AUD but 0 BTC. I can't get any information regarding this online and do not think contacting Mt. Gox would be helpful (nor possible).

Related, but concerned about BTC held in Mt. Gox rather than fiat: I have/had 31 bitcoins on MtGox; What are my options now?

Thanks

Unfortunately you are in the same boat as all the people that had BTC at Mt.Gox. Think about it positively, you are now part of a club of people that all had their money stolen / lost.

If you are keen to try and get your money back, keep checking in at http://www.reddit.com/r/mtgoxinsolvency. But if you are taking this route, prepare to be really patient.

Here is the latest update from the above reddit thread.

  LAST UPDATE: 3 JANUARY 2015 11:00 AM GMT

  NOTE: Progress is slow nowadays, so this current state of affairs sticky thread should be up to date.

  A note on recovering funds: From announcement dated 26 November 2014:

  The deadline for filing the proof of claims of bankruptcy in these bankruptcy proceedings is set as May 29, 2015, and we plan to disclose the necessary information one or two months prior to the said deadline. The bankruptcy trustee will make effort to ensure that creditors around the world have a reasonable period of time in which to file proofs of claim.

  Important dates: From announcement dated July 24th 2014:

  Period for filing proofs of bankruptcy claims: By May 29, 2015

  Date and time for investigation of claims: September 9, 2015, 1:30 pm.


What is a Stratum "mining.set_difficulty" command for? On the Stratum protocol the server may issue the following notification:

{ "id": null, "method": "mining.set_difficulty", "params": [2]}

What is this difficulty used for? from my understanding the the difficulty is sent with the mining job as an encoded difficulty.

Source:
https://slushpool.com/help/manual/stratum-protocol

The command is telling the miner not to send shares below the requested difficulty. If they were to send every difficulty 1 share for example, many pieces of hardware would be attempting to send hundreds of thousands of results a second. It’s simply flood control, and the only reason to send block shares at all (that are too low of a difficulty to be a block) is to prove to the remote stratum server that you’re doing work worth paying.

Many pools clamp at a lower bound of many tens of thousands of difficulty as of 2017, and many pieces of hardware aren’t even able to produce blocks with a lower difficulty than that. The miner really only needs to send share proofs every few minutes at most for the remote pool to have a reasonable confidence that they are mining at a particular speed for payout purposes.


JSON with price AND daily change? May be someone could point me towards a public API with Bitcoin price AND 24h change? Like $7'602 +2.3%?

All APIs I've found (like coindesk's) only contain price, not change :(

You can calculate the change yourself. The coinbase API (not a recommendation, just an example) has and endpoint for 24-hour stats (https://api.pro.coinbase.com/products/BTC-USD/stats)

{
open: "7674.24000000",
high: "7810.99000000",
low: "7490.00000000",
volume: "14477.94427039",
last: "7694.56000000",
volume_30day: "479763.13996598"
}

Last price minus the open price equals the 24 hour gain. Divide the gain by the open to get the decimal percentage.


What is the differences in Bitcoin derivative products such as perpetual vs futures? I see on some crypto exchanges, they offer Bitcoin perpetual orders and futures orders. What are the differences when compared to each other and vs margin orders.

Futures are derivative instruments used to lock in a price of a security at a predetermined future date and price. The price that you buy a future indicate the price of what Bitcoin would be say 3 months from today, also known as the expiry of the contract. However, if investors would like to trade on the current price, the only option available to them is to physically buy Bitcoins. But the biggest disadvantage with this method is that you need to put in higher capital as compared to buying a futures contract. Moreover, futures contracts have to be rolled over as they come close to expiry.

Perpetual contracts are future contracts that do not expire. The price of perpetual contracts closely mimics that of the average spot price of Bitcoin on different exchanges. The cash settlement of a futures contract is: spot price at expiry - futures price (as you can take the physical delivery of asset at expiry and sell in the open market). Thus if the perpetual contract trades at a premium to the spot price of Bitcoin, the longs of the contract will need to make funding payments to the shorts. This will make the contract less attractive to longs and more attractive to shorts thereby pushing the contract price back down to the level of the spot price. The opposite happens if the perpetual trades at a discount to the spot price. This is the reason perpetual contract closely mimics Bitcoin price (after adjusting for trading costs).

Perpetual contracts are very similar to margin orders as you need not post the entire buying amount. You need to keep certain amount as collateral. If you keep 20% of the buying amount as collateral than you have 5x leverage. The advantage over futures is that they track the spot price and they prevent the hassle of rollovers.


How does this OpenCL BTC private-key cracker work? Is it a real threat to bitcoins? I am specifically referring to this over at bitcointalk.org.

The general consensus I gathered from reading the thread is that this is not a hoax. There seems to be a group of generated bitcoin addresses that can be considered weak where its private key can be recovered in a reasonable amount of time. There's currently no known way to determine if a given btc address is weak or not.

What is not clear to be me is how it is able to accomplish this. What is the basic idea behind this attack that allows it to even work? Explain it to me like I was 5, if possible. Is this is a potential break of the ECC algorithm?

I hope this post by Greg Maxwell is convincing enough: https://bitcointalk.org/index.php?topic=421842.msg4809012#msg4809012

Unless your private key is generated by a weak random number generator, there is no need to worry. It effectively takes around 10^42 operations to crack a 256-bit elliptic curve private key.

He's using names of some well-known algorithms for solving the discrete logarithm problem (which is what you must do to find the private key from a public key in our case). They are significantly faster than a brute force search, but cannot break the limit posted above.

The explanation seems to boil down to "we pick some keys to start with, and if yours is close to any of them, we'll find it quickly". That shouldn't surprise anyone. The odds of being "close" to any of the keys someone chooses to start with are astronomically small however. Even being able to try millions or billions of keys per second will not change that.


Understanding GreenAddress nLocktime/recovery transactions What I understand is that Greenaddress locks a recovery transaction to be spend 90 days in the future. Whats the advantage in doing this?
Why not creating a recovery transaction without nLocktime?

When using a multisig Green Address wallet your funds are locked in a 2-of-2 multisig account, i.e. if you want to spend money from that account you need both your signature and Green Address' signature. This is done so that Green Address can guarantee that you will not try to double spend money from that account. This allows Green Address to grant you instant confirmation transactions. However, this means that in case Green Address goes down, or stops functioning in any way, your funds are locked in the multisig account for good. To mitigate this problem, Green Address generates and signs a transaction that unlocks your funds after 90 days. This means that, in case Green Address disappears, after 90 days you can broadcast that transaction and get your funds back. The reason why nLocktime is used is that if Green Address gave you a transaction without nLocktime, you would be able to spend the money in the multisig account at any time. This would not allow Green Address to guarantee that you do not try to double spend your funds when performing a transaction from that account, hence making Green Address not able to allow you instant confirmation transactions. In this way, instead, Green Address can guarantee that you will not double spend from that account for the next 90 days, hence granting you instant confirmation transactions.


How long would it take a large computer to crack a private key? I am doing a presentation on Bitcoins and I was looking for some calculations to make people feel safe about the private key encryption.  Please first answer, how long in bytes the private key is, then how many combinations of numbers it will contain, and then what is the fastest computer or network of supercomputers and how long it would take to crack a private key using that computer.  I think the result would be very educational based on my own calculations.  Thank you.

how long in bytes the private key is

32 bytes, or 256 bits

  then how many combinations of numbers it will contain

There are 2^256 different private keys.  That's a little larger than a 1 followed by 77 zeroes.

  what is the fastest computer or network of supercomputers

At its peak around August 2011, the Bitcoin network was checking 15 trillion sha256 hashes per second.  (See http://bitcoin.sipa.be/)

  how long it would take to crack a private key using that computer

If we assume it takes the same time to run an ECDSA operation as it takes to check an sha256 hash (it takes much longer), and we use an optimisation that allows us to only need 2^128 ECDSA operations, then the time needed can be calculated:

>>> pow(2,128) / (15 * pow(2,40)) / 3600 / 24 / 365.25 / 1e9 / 1e9
0.6537992112229596

It's 0.65 billion billion years.

That's a very conservative estimate for the time taken to break one single Bitcoin address.

Edit: it was pointed out that computers tend to get exponentially faster over time, according to Moore's Law.  Assuming computing speed doubles every year (Moore's law says 2 years, but we'll err on the side of caution), then in 59 years it'll only take 1.13 years. So your coins are safe for the next 60 years without a change to the algorithms used to protect the blockchain. However, I would expect the algorithms to be changed long before it's feasible to break the protection they provide.


How to generate or add balance in my btc testnet address I am trying to add btc testnet, I have read that these following sites offers testnet btc but upon checking their servers were down
https://bcoin.io/
https://bitpay.com/insight/#/ALL/mainnet/home
https://api.bitcore.io/api/BTC/testnet/
Is there any other platform or way I can add balance in my testnet address so I can try transferring and viewing transactions in test mode?

https://xmr.to has discontinued their service so this will not work anymore: https://xmr.to/blog/job-done
This workaround involves exchanging XMR(stagenet) to BTC(testnet). Everything is free and you get XMR(stagenet) from step 2 mentioned below. Questions and answers involving altcoins are offtopic on https://bitcoin.stackexchange.com however other bitcoin testnet faucets aren't working, so it's just a workaround to solve the problem and get free testnet bitcoin in few minutes
I always use this faucet and it works for me. Tried before posting this answer and got 0.05 tBTC in this transaction: https://blockstream.info/testnet/tx/86b2ae07645d664085a52e7474dac531e9b8c5790028162a7be9383a955fea33

Go to https://test.xmr.to/ and enter bitcoin address to receive testnet coins with amount less than 0.1

Proceed to next step, copy XMR address from payment instructions, open https://community.xmr.to/faucet/stagenet/ in another tab and paste the XMR address you copied earlier.

Click "submit" and if you don't see any error, tBTC will be sent to your address in few minutes

You can also share your testnet address with the question. If this faucet doesn't work I can send you small amount for testing or maybe someone else.


where is index value or hexa value of bitcoin in source code? Registered coin types
These are the default registered coin types for usage in level 2 of BIP44 described in chapter "Coin type" above.
All these constants are used as hardened derivation.
index   hexa    coin
0   0x80000000  Bitcoin
1   0x80000001  Bitcoin Testnet

where we can find index, hexa of bitcoin for BIP44 ? how to calculate it ?

https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Registered coin types
These are the registered coin types for usage in level 2 of BIP44 described in chapter "Coin type".
All these constants are used as hardened derivation.

index
hexa
symbol
coin

0
0x80000000
BTC
Bitcoin

1
0x80000001

Testnet (all coins)

2
0x80000002
LTC
Litecoin

3
0x80000003
DOGE
Dogecoin

4
0x80000004
RDD
Reddcoin

5
0x80000005
DASH
Dash (ex Darkcoin)

6
0x80000006
PPC
Peercoin

...
....
....
...

99999997
0x85f5e0fd
EQ
EQ

99999998
0x85f5e0fe
FLUID
Fluid Chains

99999999
0x85f5e0ff
QKC
QuarkChain

Coin types will be added only if there is a wallet implementing BIP-0044 for desired coin.