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?

Recent Questions – Bitcoin Stack Exchange

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:

  1. Find the biggest possible address and convert it to bigint.
  2. 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.
  3. 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?

Recent Questions – Bitcoin Stack Exchange

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?

Recent Questions – Bitcoin Stack Exchange

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.

Recent Questions – Bitcoin Stack Exchange

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)

Recent Questions – Bitcoin Stack Exchange