# Tag: calculate

## How to Calculate Bitcoin's Next Price Move

Crypto markets are breaking out to all-time highs. The total market cap of all crypto assets, which includes **Bitcoin**, now totals $ 165 billion, a 150 …

Google Alert – bitcoin

## How to calculate fee per kb

Here is my code in bitcoinj:

` Transaction tempTx = new Transaction(params); tempTx.addOutput(Coin.valueOf(utxoSend.b_amount), address2); for(UTXO utxo : utxoSend.b_utxo) { TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash()); tempTx.addSignedInput(outPoint, utxo.getScript(), key, Transaction.SigHash.ALL, true); } long msgSize = tempTx.getMessageSize(); long fee = (long)Math.ceil((msgSize*BTC_DEFAULT_FEE)/1000); //Prepare transaction Transaction tx = new Transaction(params); tx.addOutput(Coin.valueOf(utxoSend.b_amount-fee), address2); for(UTXO utxo : utxoSend.b_utxo) { TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash()); tx.addSignedInput(outPoint, utxo.getScript(), key, Transaction.SigHash.ALL, true); } `

BTC_DEFAULT_FEE is 10000 satoshi per kb. And now tempTx message size is completly diffrent than tx message size. My question is how to calculate fee for this type of transaction when I have all inputs and outputs and specific fee per kb?

## Best way to calculate difficulty of generating specific vanity address?

I’m now working at small tool, which purpose is to calculate difficulty (like number of attempts) of getting vanity address, like vanitygen (https://github.com/samr7/vanitygen) does. I’ve read some materials (https://en.bitcoin.it/wiki/Vanitygen#Difficulty_of_finding_a_vanity) and now i’m wondering about exact algorithm of how such calculation must be proceeded. There is no precise answer in the article at bitcoin.it wiki, so a look through the sources of vanitygen and ended up with some very basic ideas:

- All addresses are in a nutshell base58 numbers which can be converted to biginteger if needed.
- There is one final “biggest” address (like biggest number in the end of some range)
- Vanity address is any address from the range of addresses (if we think about them as numbers), that starts with specific pattern.

So what is the best way of finding difficulty of getting specified vanity address? I ended up with such idea:

- Find the biggest possible address and convert it to bigint.
- Find addresses range for given vanity pattern. First of all find the biggest possible address in the range by adding z to the end of the pattern while it is smaller than biggest possible address. Then to get smallest address in range i decided to add 1 (base58 representation for 0) to the vanity patter and i failed to determine when i must stop. Clearly address could not be longer than 34 symbols, but when i must stop? I think that i must take length of the biggest address in the range and that will be the same length for the smallest. But please, correct me if i’m wrong.
- When we have range of addresses, we can calculate it’s length by subtracting smallest one from biggest one and then divide biggest possible address by range length and the result will be our difficulty.

So is it all correct? What shall i do when pattern starts with “1”?

What additional materials you can suggest to read?

## How to calculate the size of the blockchain?

I want to find the size of the blockchain data. I’ve been using this Linux command:

`du --exclude=index /home/me/.bitcoin/blocks/`

Is this the most accurate way to do it? And does dividing the result by 1024/1024 give the size of the blockchain in GBs?

Note:The`--exclude=index`

part excludes the blocks/index/ subfolder, which I’ve heard is extra metadata used for levelDB to make it faster to search through the blockchain. I just want to know the size of the blockchain data only, so does it make sense to omit this?

## How can calculate the blockchain amonut for transaction

how can blockchain calculate the transaction amount which is placed in the red or green button?if any one know solution please share your ideas.

## What is the formula used to calculate the value of bitcoin-cli estimatefees?

Studying the output of **bitcoin-cli estimatefees** as a black box, the formula at work seems to be a moving average calculated over the previous X blocks. I cannot deduce X, nor if it is a simple moving average or an exponential moving average.

QUESTION: what is the formula used to calculate the value of bitcoin-cli estimatefees?

Thanks in advance.

## How do I calculate expected earnings when mining a cryptocurrency?

If I have access to currency-specific variables/datasets for any cryptocurrency of choice (see below), how would I calculate which cryptocurrency (out of a fixed set of say 3-5 altcoins — SHA-256 and Scrypt only) would be most profitable to mine at a given time?

**Given:** *difficulty, hash rate (network), block count, block time, block reward, exchange rate, and exchange volume.*

To be more specific, I’m wondering what math would go into calculating Expected Earnings/(MH/sec) for each cryptocurrency with this data? I’m not not necessarily asking for something like http://www.coinwarz.com/cryptocurrency/ that takes your own device’s hash rate and power consumption:power cost ratio to determine individual profitability, I’m talking about a general calculation where the output is in the units ‘Expected Earnings/(MH/sec)’

(I’m not sure how complicated a calculation like this is, so I’m not asking for exact math or anything just where/how to start with a problem like this)

## Is there some sort of algorithm to calculate transaction speed?

I’m wondering if there’s a way that I can calculate how long it will take for a transaction of `x`

BTC paid a `y`

fee to get `z`

confirmations based on current difficulty