text:
How to debug a long "0/unconfirmed" status in the bitcoin client?
When someone gets a status of "0/unconfirmed" on a transaction for a long time - what could he be doing wrong? What should he check to solve this?

Try running bitcoind from the command line with the -rescan option. It may be that your transaction was erroneous or a double-spend attempt and it only exists in your client. You could double-check the receiving address in blockexplorer to see if the transaction ever came through from the rest of the network's perspective. If this is a zero transaction fee transaction (or is just otherwise unlucky) it might still be in-queue to be included in a block. Bitcoin Charts has a list of in-queue transactions you can check as well.
Assuming blockexplorer sees the transaction, your client probably isn't downloading blocks and may not even be connected at all. Check that the block number in your client matches the block number at blockexplorer (or any of a number of other sites), check if your client has 0 connections. If you have no connections, try the troubleshooting steps from this question. Worst case scenario delete everything from the Bitcoin data folder except for wallet.dat and re-launch the client. Several hours later when you've finished downloading a fresh copy of the block chain, your 0/unconfirmed transaction will probably be resolved.

How about checking if you're at all connected to the network? You should probably verify you have at least a few connections, and that your most recent block number is up to date (perhaps you haven't run the client for some time, and downloading new blocks just takes time).

Good point. I've added this to my answer in the interest of completeness.

One common cause of this condition is manually forcing a zero transaction fee. If you force a zero transaction fee on a 'large' transaction (one that gathers Bitcoins from many other transactions or sends Bitcoins to many different sources) other nodes in the Bitcoin network will refuse to relay your transaction.
While there are some nodes that will relay all valid transactions, your client will only send the transaction out about once every half an hour or so. As a result, it can be a long time before, by sheer luck, your client happens to send the transaction to a node that's willing to relay it (that happens to be able to relay it to other nodes that are similarly willing).

When users are quick to close the client, the transaction being sent will not get re-broadcast if for some reason it didn't propagate sufficiently when the first attempt was made.
So before even trying anything -- leave the client up and running on a reliable connection for maybe an hour.  If it still stays at 0/unconfirmed, then other troubleshooting is warranted.

If a transaction has been unconfirmed for three days, clients will delete it. This generally happens when you force a zero transaction fee.

This far the bitcoins are so called send and my btc shows 0.00 in wallet
I did several deletes of the whole thing but the btc is not restored or in being send at all
I left it open about 4 hours after it downloaded but nothing changes the -3.7737 btc keeps showing on the right side
i did 2x bitcoind -rescan before but the download of the chain takes a long time as well
even the given stransaction id i could not find in the list
i redeleted the files now again but untill now nothing has changed

Is this an answer? A question? If you have a question, please ask it separately.


text:
Can I still claim the pre-fork BCH even though my current wallet balance is 0?
I had BTC before the BCH fork, but I forgot to claim the BCH and just spent all of the BTC on buying more BCH. Can I still claim the pre-fork BCH even though my wallet balance is now 0? It was stored in Electrum. Any advice is appreciated.

The BCH blockchain completely ignores anything that happened on the BTC chain after the fork.  That's what a fork means (given that there is replay protection).  So all that matters is what you had at the time of the fork, and what if anything you did on the BCH chain since then.  The fact that you spent the BTC is totally irrelevant.

Despite your bitcoin wallet balance being 0, your cash balance on the same address should be non-zero. Check that with a cash blockchain explorer and then import your private keys into a cash wallet to access the coins.

https://blockchair.com/ should be able to show you both your BTC and BCH balances for the same address.
If your address still has the BCH, make sure when claiming that you don't send it to a BTC address by mistake!

source: Stack Exchange

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

sort: votes


text:
Why are the fees for converting Ripple to Bitcoin so high?
So I've very recently gotten into cryptocurrencies and after making a bit of money on bitcoin, I decided to try an altcoin. I used Changelly to convert my bitcoins into XRP and the fees were very low. Then, a few hours later I tried to convert 180 XRP (41 USD) to bitcoin using the same method. The "estimated amount" I would get (as indicated on Changelly) was quite close to this 41 USD amount, so I went ahead and exchanged. When the transaction was approved however, I only received 29 USD!!!! Is there something I did wrong? Is this normal? Why are the fees so high? Please do keep in mind that I've only started investing a few weeks ago. Thanks a lot!

This is most likely explained by the high fees on bitcoin. These services still have to move the bitcoin from one wallet to another and you have to pay a fortune at this time, about $6- $19.  You didn't do anything wrong this is something that will be fixed on the #bitcoin chain once #segwit and Lightning Network are highly adopted.

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


text:
How to create VeChain X Node? (VEN/VET)
Let's say I have a required amount of VET to make an X Node. How do I create it?

I found an answer on their medium announcement page:


text:
Difference between Bitcoin versions 0.1 and 0.2
Does anybody know what the difference is between Bitcoin versions (0.1) and (0.2)?
I need to know this because I am doing a school project about the future of Bitcoin.

If you're interested in a list of changes to Bitcoin, look at these sources:

0.3.21 - current: https://bitcoin.org/en/version-history
0.1.0 - 0.3.20: https://en.bitcoin.it/wiki/Bitcoind#History_of_official_bitcoind_.28and_predecessor.29_releases
(Click on the reference to see the announcment/changelog.)

Good luck with your project!


text:
When a transaction is broadcast to the network, what is actually being sent?
When a transaction is broadcasted to the network, what is being sent? Is it a hash? if yes, is it going to be the hash of: previous transaction + public key of the receiver?

Client creates a new transaction, adds it to its memory pool
Client broadcasts an inv frame, which indicates that it has something in its memory pool, by giving the hash of the transaction to one or more connected peers
Peer receives inv frame, checks its own memory pool, it's not in there, so it sends a getdata frame back
Client receives a getdata frame for the transaction it just created, so it sends a tx with the entire transaction
Peer receives the tx, hashes it and puts it in the memory pool
Peer now has something new in the memory pool, and broadcasts an inv to all connected peers
Client gets an inv frame, notices that it's already in the memory pool, and ignores it
Another client gets the inv frame as well, getdata's it, stores the tx, sends inv, and repeat that until the entire network has the transaction.

References :

tx frame
inventory vector
getdata

Correct me if I'm wrong, but doesn't bitcoin only send the transaction to one peer if it originated the transaction?

@NickODell Perhaps, but that's implementation related, and not a network rule.

Thank you Tom, very clear explanation. However, I still have a question. Based on Satoshi paper http://bitcoin.org/bitcoin.pdf, the hash consists of the public key of the receiver too. I suppose that the public key is added in order to have different hashes?

(Disclaimer: I've never read the paper, I've only built a client.) The hash of a transaction is simply the entire transaction (tx) hashed (unlike blocks, which only have their headers hashed). This includes all the inputs and outputs.

how fast or how long does it take to broadcast the information to all peers? i mean when i'm mining, and somebody has already found a new block, how long would it take till i receive the information and start mining again on new block?

Reaching all peers can take a long time (maybe even up to an hour), as there are always a few edges on the network where it takes a lot longer. However, for most nodes it's a matter of seconds to maybe two minutes.


text:
Why doesn't Butterfly Labs use their ASIC machines for their own mining process?
Butterfly Labs produces ASIC hardware for bitcoin mining. I guess it is cheap for them to produce a 1500 Ghash/sec machine. They could have many of them for a very reduced price. Why, instead of selling them, do not they use them for their own mining so they get more money?

Any answer here will likely be speculative, but another important factor here is PR--Butterfly Labs' customers wouldn't be very happy if the company that made their ASICs was driving up difficulty before delivering them.  It would feel like BFL was skimming the cream from the top of their customers' profits.

@eMansipater actually, I disagree. RentFree's answer is pretty much a fact, no speculation.

They are choosing a less risky option.  By selling now, they get the price of the machine no matter what happens to the BitCoin economy.   They are defining their core competency as being in the hardware business not the cryptocurrency business.
The same could be said for people selling pickaxes during the Gold Rush.  Why not use the pickaxes to mine gold?  They got the money for the pickaxes up front, then they were out of the picture.  They didn't have to choose a place to prospect and worry about how long the gold would last. They chose to be in the pickaxe business not the mining business.  Incidentally, during the Gold Rush it was these peripheral entrepreneurs that made much more than your typical gold miner.

this "gold rush" example is a very good metaphor, but I think that nowadays it is much easier to switch on asic machines an try to get some bitcoins that before was to mine gold

That's what the miners that bought pick-axes thought, too, but many of them were wrong.

That being said, I would expect that many Butterfly employees are buying the hardware and doing their own mining

The greatest cost in mining is electricity: https://en.bitcoin.it/wiki/Power_Calc . If you sell the hardware, you recover your investment right away. If you use it for mining, it takes some time before you recover what you payed. It's like a taxi. The car is only a part of what brings the money. You need to drive it, pay the gas, be lucky and have clients... The car seller doesn't need to worry about that.

I agree with RentFree's answer, but another part of the answer is the cost of capital. ButterflyLabs did not have the cash on hand to build its ASIC design or to manufacture all of the rigs. That's why they had their pre-order process: collecting the money up front was the only way they could afford to build the rigs. (Once they had built them, of course, they could have defaulted on their promises and used the units to mine for themselves instead of delivering them. But that would have had long term consequences to their reputation. I don't think the question was really asking if they should commit fraud, just whether they should keep their design private.)
The question does raise the question of whether it would be possible for a different company other than BFL (say a private equity firm with deep pockets) might fund their own ASIC mining rig and not release it to the public. I wouldn't say it's impossible, but it does have several factors against it. Firstly, RentFree's answer: that a private ASIC design strategy would have a lot of inherent risk. But there's also the issue that much of the cost of building an ASIC rig is in the design of the chip. Once our hypothetic private equity firm has spent the money to design the chip, the margin on individual rigs would be fairly high. So, at that point, there would be little incentive for them to refuse to sell the rigs to others. (Even if it raised the mining difficulty for their private rigs.)
In short, while there is nothing to say the ButterflyLabs (or other ASIC manufacturers) might not use some of their rigs (or test rigs) for mining, the business model of these types of companies wouldn't work very well if they didn't sell the majority of their machines: the upfront capital costs are too high and the incremental profit margin is too tempting.

I Would not be surprised if they collect cash up front for many orders, create a production run which takes 30 days, mine the units for 30 days, and then deliver. That's how I would maximize profit. They take no risk, but having the consumers pay for the costs (and more), they then have many many machines to mine or "perform QA (Quality Analysis) to make sure they work correctly while profiting them. After that, they package the units and send them to the consumer. If there's a spike it bitcoin value, I'm guessing the "QA" takes longer while mining is more profitable.
Just a speculation, but being a business owner, and having run production runs and QA through factories all over the world, this just makes sense to me.

If you're going to do it for 30 days, why not 60? Why not keep them for a year, then sell them?

@JohnBensin If they keep the ASICs for one extra day, it costs their customers money - those customers could have had one more day of mining before those ASICs become obsolete. Would that lose them customers? I don't think so, if they could conceal what they were doing.

I believe it's primarily because at such a large leap forward the bitcoin network would fail. I've read for starters that if someone owned over 50% of the hashing power the network would be compromised, I don't know this to be true or otherwise, but what I do know is, Bitcoins have little value if no one is trading them because their value is based on trust. If one company drove up the difficulty and also had a large majority of the coins out there then people would lose interest in the bitcoin network and therefore they'd not have all that much value either another network would ultimately just replace it.

Gather too much hashing power in your hands, and you compromise the security of the Bitcoin network. If security of the network is compromised, the price of bitcoin falls through the floor, and no matter how much you can mine (or manipulate the network into giving you) you end up with millions of worthless bitcoins.
It's much smarter to distribute the hashing power between the users, keeping bitcoin price high, and earn cash for the product. With Bitcoin, as opposed to normal capitalist markets, monopoly is disastrous to the whole market including the monopoly owner, so any enterprise aware of approaching the status of monopoly will actively fight reaching it - for example, selling a part of their processing power.

Butterfly labs was / is a company that aims maximal profits.
Guess they source & evaluate all options to make the maximal profit.
I know major pool owners who are in direct conversation/collaboration with them, and as im aware they mine asic for a while now.

Just look at this charts http://bitcoindifficulty.com/ & http://blockchain.info/charts/hash-rate , it tells stories.
As stated above, butterfly labs has/had all options & time to evaluate the best strategy for maximal profit. Probably they took way more factors into account like bitcoin price, appreciation, acceptance, the option to sell another batch, development process etc.
And shipping asics is not same as shipping asics, they had all time to evaluate WHO to ship to depending on scenario.
Bottom line, its a cashcow money business and they will do anything to maximize profits either way.

If you watch the video on their website, there is a server room with racks and racks of networked miners so its possible that they are.  However, it also appears you can purchase processing power from them instead of the actual hardware.  The  network setup might be for that.

It's totally possible that they have used hardware which they sold to customers for their own mining operation.  Your gear may very well have gone to a warehouse somewhere for "testing".  Once there's very little value left they ship it.
It would be unethical and likely illegal but by far the most profitable thing to do in their position.  I would challenge BFL to prove they haven't done this by making their factory shipping manifests and bills of lading public.

They do mine. Hashrates tripled during the last four months, and so did the difficulty. While this tendency continues, the difficulty will keep on rising. When you get your ASIC device from them, you are only able to mine $10 with two Jalapenos in one month. No sooner, no later.

Just a thought. I'm not (yet) a miner but seen all the complaints in delivery time from BFL it makes me wonder if they really don't do some mining with the production units before delivering them. It seems normal a 6 month delivery time wait, what doesn't happen in any other kind of market...
Would you wait 6 months to by a standard electronic device?
That's the dark side of this business, and the main reason I don't get decided to invest here...

Consider also that BFL may be using the initial pre-order capital to invest in and use infrastructure prior to actually shipping.  Unless you are purchasing one of the really, really big rigs, by the time you get your ASIC miner, it will be relatively worthless.  Similar to what a cpumining is.
This is really a type of ponzi scheme.   Before you get angry at me for saying it, really think about it...
Soon, bitcoin mining will only be really profitable for those who really have infrastructure... or for the mildly curious who don't care about making profit.


text:
How long does it take for an exchange to send me bitcoins?
I'm not sure I understand all of the bitcoin storage options
I know there are bitcoin addresses and bitcoin wallets
what is the relationship of an address to a wallet? is a wallet mandatory and a given when talking about any bitcoin storage option?
if I had an account at a bitcoin exchange, how could I quickly move those coins from the exchange to the same wallet that I am using to dump the coins I mine?
I might not be asking the right questions, because I am not sure about the relationship between the various storage options of bitcoins (wallet, exchanges)
I would like to understand this

If you have the private key that relates to an address, then you can use that to instantly make transactions with bitcoins that are stored against that address.
However, most exchanges and online wallets provide you with a unique address without providing you with the private key for it. This is probably because they consolidate the bitcoins sent to all their addresses into a single address for the exchange, which helps them reduce transaction fees and also allows them to operate with a fractional reserve system.
In the case of a 3rd party controlling your bitcoins, you are at their mercy when it comes to the timeframe of the transaction.
There are some online wallet services that allow you to have the private key for your bitcoins, which gives you the ability to import the private key to your own client and spend your bitcoins. In that case, you have a good level of control over your bitcoins.
The relationship between addresses and a wallet: one wallet can hold many addresses, and can even hold bitcoins against hidden addresses that have received "change" from a previous transaction.

Wallets:

The Bitcoin.org client (e.g., Bitcoin-Qt) is a local wallet.
Most online services which provide a bitcoin account for you provide what is called a hosted (shared) EWallet.
Some online services provide a hybrid EWallet which acts like a local wallet but is accessible online.  Blockchain.info/wallet is an example of this.

When you use a hosted (shared) EWallet, you have no control over the funds.  When withdrawing you are simply placing a request and the provider's systems (which are usually automated) respond to the withdrawal request.
Generally when you withdraw from a hosted (shared) EWallet, the transaction is broadcast fairly quickly -- within seconds.  Because the provider might use a cold wallet for storage of most of the service's funds, it keeps a limited amount of coins in a hot wallet to serve withdrawal requests.  It can't know in advance how many will be requested, so the level is based on whatever the provider estimates are needed.
So it can occur that a withdrawal request cannot immediately be honored and that the hot wallet needs to be replenished with additional funds from the cold wallet.  That could take from under an hour or much longer, especially if the "keys" to perform that transfer are locked in a bank vault and unavailable until the next business day.


text:
When pool mining, how do I get paid?
Just for fun i decided to check out bit coins and do some mining. No visions of making millions or anything I just find the concept pretty cool. At any rate I have installed guiminer in windows and i have installed the bit coin wallet from the bitcoin site.
How do i get my address so that i can have someone send me funds and in the mining software how do i set it up so that it knows where to deposit funds? I have it up and running using btc guild pool but it has never asked me about how to send me bit coins.
I am confused i feel  like i am missing the most important piece of the puzzle.

You need to get a receiving address from the client (or from an e-wallet if you prefer) and copy and paste it into the address field against your account in BTCGuild.
Bear in mind that if you're using the Bitcoin-QT client there is a very long synchronisation process to wait for, though you may be able to get a receiving address before it completes (but you won't see any received bitcoins in your wallet until it's synchronised). Depending on your hardware and bandwidth, synchronisation may take several days to complete.
While there's no receiving address against your BTCGuild account, you'll just be accumulating bitcoins against your BTCGuild balance, so you aren't losing anything in the meantime.
Bear in mind that the "difficulty" level of mining for the network as a whole has risen to a very high level due to the arrival of highly efficient dedicated ASIC bitcoin mining hardware. This means mining on graphics cards is likely no longer profitable (depending on purchase and electricity costs) and CPU mining hasn't been profitable for a long time.

I spent pretty much all of last night reading up on this then came across litecoins. Would this be a better thing to "get into". Again from a mining point of view i am not investing "hard" currency on any of this beyond cpu/gpu cycles. I find it fun lol.

@Ominus, if you can earn a profit mining them, then the only reason I can think of not to would be your principles. My guess is that the Litecoin exchange rate is somewhat on the high side, so if you do it I'd recommend exchanging them to another currency quickly rather than hold them, but that's just my personal opinion. I did a little Litecoin mining myself at one point and exchanged them for BTC on vircurex. Some would consider it a waste of time, because much of Bitcoin's value is in its popularity; Litecoin doesn't have that.

Well I am new to this too, but already did research on it. The BitCoin client and Mining Client is two different software for two different purposes(They used to be same, I read it somewhere). The Bitcoin client is just for handling your wallet, safegaurding your private keys, creating public keys (aka receiving addresses). I'd suggest you to try an e-client for eg. BlockChain in beginning.
Mining is another thing where you lend your pc's computing power to Bitcoin blockchains in return of free Bitcoins. It really sucks out your processing power.
So in general you'll just need a BTC client which will generate a receiving address for you which you can paste on the site of the mining pool you're using for mining. You can generate different address for different pools (or senders), so that you can track who's sending how much.


text:
How does a miner perform hashing?
I'm trying to walk my way through the process by which a miner hashes.
Let's say the getwork request returns a data field of:
0000000244de6ceba49e1c8d438c0d8c584eefd9c8590545bfdfbf380000025c00000000fb3a091de1b4bbe5dc7acfe6bdacbc3fc3bb09bf1030adef8e2854db1b6ac42f5075c0051a057e08456c6f69000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000

As far as I understand, the first step is to calculate the midstate. To do this, we first take the first half of the data string:
0000000244de6ceba49e1c8d438c0d8c584eefd9c8590545bfdfbf380000025c00000000fb3a091de1b4bbe5dc7acfe6bdacbc3fc3bb09bf1030adef8e2854db

We then reverse the endianness of each 32-bit unsigned int (represented as 8 hex digits in the string), yielding:
02000000eb6cde448d1c9ea48c0d8c43d9ef4e58450559c838bfdfbf5c020000000000001d093afbe5bbb4e1e6cf7adc3fbcacbdbf09bbc3efad3010db54288e

Next we transform this into sixteen 32-bit unsigned ints:
33554432, 3949780548, 2367463076, 2349698115, 3656339032, 1157978568, 952098751, 1543634944, 0, 487144187, 3854284001, 3872357084, 1069329597, 3205086147, 4021104656, 3679725710

We then input this int array into SHA-256's internal function, with the second input being the eight 32-bit numbers given on page 13 of the SHA-256 specs.
The output of this preliminary hash yields the following eight 32-bit ints as our midstate:
3045448562, 361056177, 1940413978, 3803584651, 1661283772, 3478943551, 2906109005, 300125848

From this point on, I'm not sure how correct the steps are. Corrections are greatly appreciated!
Next, we look at the second half of the input string:
1b6ac42f5075c0051a057e08456c6f69000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000

Once again, we reverse the endianness, as everything is an 8-character hex string representing 32-bit unsigned ints:
2fc46a1b05c07550087e051a696f6c45800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280

Now, we break this up into sixteen 32-bit ints: 801401371, 96499024, 142476570, 1768909893, 2147483648, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 640
The fifth number (21474836481) should be the nonce, according to this description.
(Why isn't this nonce zero?)
Now, starting at the given nonce, we use the SHA-256 function to hash the sixteen 32-bit ints from the second half of the data, using the midstate as the other eight int inputs. This yields: 3993002029, 2278477219, 3977673643, 191934125, 2075691039, 4115259165, 601235791, 2598049038
Now, what do I use as inputs for the second hash function in the "double-hash"? Or did calculating the midstate count as the first hash computation?
And when the nonce overflows, should I submit another getwork request or wait until I've checked the nonces in the range of [0, original_nonce_value)? (Assuming my analysis that the given nonce is 21474836481 is correct?)
Lastly, if our target value from the getwork request is:
ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000

We need to switch the endianness of this value, yielding:
00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff

And then we convert this to eight 32-bit unsigned ints, yielding: 0, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295, 4294967295
And I believe after the second SHA-256 hash we should have eight 32-bit unsigned ints. Lastly, we should compare these eight output ints against our eight target ints (from left to right in the array, so comparing output[0] against the target's 0, then output[1] against 4294967295, etc.) and if our output is less than the target, we convert our eight int values to hex strings, switch the endianness, concatenate them in the same order (output[0]'s hex string is the first set of eight characters), and submit it back to the pool server in a getwork completion POST.
How much of this is correct, and where am I misinterpreting the protocol?
All help is appreciated; thanks so much!

Thanks for the edit! I was wondering how to do that formatting...

The following thread looks like it might be a more complete answer:
http://stackoverflow.com/questions/9245235/golang-midstate-sha-256-hash

This question is a complicated one, but I'll see what I can do to answer it. Also, I won't try tackling the issue of endianness, as in the case of Bitcoin it gives me a headache...
First, lets see what we have in a block header given to us by getwork. Lets take the Genesis Block for an example.
01000000 - version
0000000000000000000000000000000000000000000000000000000000000000 - prev block
3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A - merkle root
29AB5F49 - timestamp
FFFF001D - bits
00000000 - nonce (it will be set to 1DAC2B7C later)
00 - number of transactions (always 0, this is the block header)
0000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000 - padding

In order to calculate the midstate, we split the header into two parts that are accepted by SHA algorithm (64 bytes each):
0100000000000000000000000000000000000000000000000000000000000000000000003BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA
4B1E5E4A29AB5F49FFFF001D00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000

We load the first part into the SHA algorithm. We take save this state for later use (midstate) (sorry for lack of examples, but I don't have my hashing algorithms on hand). Then we load the second part into the SHA algorithm. We read the output, this is the first hash. We take that output, plug it back to a new input, and get its result. That is the second hash. Assuming we got the correct nonce (in our case - 1DAC2B7C), our result should look something like this:
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

and compare it to our target:
00000000ffff0000000000000000000000000000000000000000000000000000

Taken as a number, which is bigger? The target. This means that we have the correct nonce, and we can submit our full header as the result. Profit!
From what I understand, you tried to break up the resulting numbers too much, instead of operating on really big numbers like Bitcoin appears to be doing. Then again, endianness is also a big problem with the protocol and what not...
I hope this answers your problem.


text:
Is an unencrypted wallet secure if bitcoind is not accepting RPC calls?
I'm interested in setting up a P2Pool node (which requires running bitcoind) to run a little mining pool for myself. Before you ask, nope I'm not even trying to break even, I know I'll lose money on this. Just want to play around and get a feel for how these things work.
My question is: I hear over and over again that it's important to take security precautions with bitcoind and wallets, but I've had trouble teasing out exactly what those security precautions are. If I have bitcoind not accepting RPC calls (as is the default), is there any danger to using the out-of-the-box unencrypted wallet?
If the information helps, I'll probably run the node in EC2, and have a cron job that frequently transfers any bitcoins earned through mining into an account in an exchange so I can play around with that side of things as well (so I'm not worried about large sums of bitcoin building up in my bitcoind wallet).

Thanks for the edit; my question clarified itself as I was writing it and I forgot to change the title. :)

Turning off RPC will prevent that particular attack vector, but if the coins are on a machine connected to the internet, that's a lot of vulnerabilities and attack vectors to consider.
That said, if you're running a node on EC2, you're not going to generate enough bitcoins to be worth stealing. If the point is to figure out how everything works, I wouldn't worry about the bitcoins you'll be mining since it'll be so little (at most $10 per year).

I'm not interested in the money but I am interested in the security considerations. Could you elaborate on some of the vulnerabilities/attack vectors you mention?

Whether bitcoind is accepting RPC calls has very little bearing on whether it's secure. By default, bitcoind only accepts connections originating from the local computer. In most situations where an attacker can make connections to RPC, they would have the ability to look in your wallet folder and copy your wallet off. (There are a bunch of tricky exceptions to that. For example, it's possible to take away a user's SSH privileges without taking away their ability to use SSH port forwarding.)
Additionally, if you turn on RPC, bitcoin will generate a password for it which is too long to be guessed. (This password is different from wallet encryption.)
If your wallet was encrypted, then you wouldn't be able to use a cron script to automatically transfer your Bitcoins to your exchange account.
I would call leaving your wallet unencrypted an acceptable security risk.


text:
How do I list all unique scripts from blockchain?
How do I list all unique scripts in the block chain, and their count (n-times-used)?

If you are looking for actual input scripts then the answer is simple: if there are n outputs being claimed then there are exactly n distinct scripts that are used exactly once. This is because each script includes a signature for a particular output that is being claimed, and they should be unique (that is excluding random collision, which are extremely unlikely).
If you are looking for output scripts then the number of distinct scripts is likely to be the number of addresses that received an incoming transaction, as they contain the addresses that may claim the output.
This is ofcourse just for the standard transactions in which you put up a claiming condition by requiring a single signature from an address and then provide the matching signature when claiming it.
More interesting could be the number of distinct script formats. That is counting the unique types of scripts, for example by just replacing all signatures and hashes with a placeholder and then counting them.
As far as I know blockchain.info does not currently offer such a functionality, but they might be interested to include it.

Like this item, "scriptPubKey":"OP_DUP OP_HASH160 2d56f654aa5353bc05587a30e3f16e15cf7aaf99 OP_EQUALVERIFY OP_CHECKSIG"

That would be the second option, which would have a new script for each address that ever received an incoming transaction.


text:
Is there any useful documentation on using the MtGox API with node.js?
I have been looking for some help building a platform using node that works with the MtGox api. It seems easy to make request, but I am confused about how to pass a parameter.
Right now my code starts off like below. I can hit the server and get basic market data but I don't know how to do anything else....
request = require('request');

APIResponder = require('../libraries/apiresponder');

exports.market_data = function(req, res, next){
  request('https://mtgox.com/api/1/BTCUSD/ticker', function (err, response, body) {
    console.log(response);
    console.log(body);
    APIResponder.respond(res, response);
  });
};

The Bitcoin wiki has a nice example program:
var querystring = require('querystring'),
        https = require('https'),
        crypto = require('crypto');

function MtGoxClient(key, secret) {
        this.key = key;
        this.secret = secret;
}

MtGoxClient.prototype.query = function(path, args, callback) {
        var client = this;

        // if no args or invalid args provided, just reset the arg object
        if (typeof args != "object") args = {};

        // generate a nonce
        args['nonce'] = (new Date()).getTime() * 1000;
        // compute the post data
        var post = querystring.stringify(args);
        // compute the sha512 signature of the post data
        var hmac = crypto.createHmac('sha512', new Buffer(client.secret, 'base64'));
        hmac.update(post);

        // this is our query
        var options = {
                host: 'mtgox.com',
                port: 443,
                path: '/api/' + path,
                method: 'POST',
                agent: false,
                headers: {
                        'Rest-Key': client.key,
                        'Rest-Sign': hmac.digest('base64'),
                        'User-Agent': 'Mozilla/4.0 (compatible; MtGox node.js client)',
                        'Content-type': 'application/x-www-form-urlencoded',
                        'Content-Length': post.length
                }
        };

        // run the query, buffer the data and call the callback
        var req = https.request(options, function(res) {
                res.setEncoding('utf8');
                var buffer = '';
                res.on('data', function(data) { buffer += data; });
                res.on('end', function() { if (typeof callback == "function") { callback(JSON.parse(buffer)); } });
        });

        // basic error management
        req.on('error', function(e) {
                console.log('warning: problem with request: ' + e.message);
        });

        // post the data
        req.write(post);
        req.end();
};

var client = new MtGoxClient('mykey', 'mysecret');
client.query('1/BTCUSD/public/ticker', {}, function(json) {
        // do something
        console.log(json);
});

Here's documentation for the v1 API

Wanted to add to this, for the streaming/ws API the wiki links to a git repo from ralphtheninja, who has provided a library for a node.js readable stream for mtgox.
Basically it converts the stream to a node.js stream.Readable object.


text:
rpcallowip=192.168.0.* ?? invalid configuration
I recently downloaded bitcoin from github and changed the settings to allow for rpc.
This is how I have it:
rpcallowip=192.168.0.*

This does not work anymore.
However when running bitcoind, it complains that:
Error: Invalid -rpcallowip subnet specification: 192.168.0.*.
Valid are a single IP, a network/netmask or a network CIDR.

I'm not that familiar with networking.
Can someone tell me what a valid network/netmask or network/CIDR is for all addresses that could be in 192.168.0.*

You want to use 192.168.0.0/24. That's CIDR notation for 192.168.0.*.


text:
When I make a transaction, how is it broadcasted to other clients?
It's a really nooby question, and with no doubt asked before, but if someone could tell me
a)how are other clients found
b)how is the information send to them
(please explain in a simple way, because I haven't messed with the bitcoin protocol itself)

They're found using a gossip protocol.
Transactions are sent using this structure: https://en.bitcoin.it/wiki/Transactions

While these links probably answer the question, would you please put some more explanation here?

Other clients are not found using DHT. http://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other

sorry guys. answered this way back before even doing proper research on it :( - can't delete because it's accepted so I tried adding some more info.


text:
Will BTC value depend on their history?
It might seem that virgin coins will have higher value than older coins that have lot of exchange transactions that might make it more traceable.
Is there some prevision in the protocol for this effect?

There is none, and I don't think it will ever be significant. There is a gentleman's agreement that's part of what makes Bitcoin work that a Bitcoin is a Bitcoin is a Bitcoin.
You can have a few "rare Bitcoins" with extra value. I might pay extra to have one Bitcoin transferred to me directly from the coins in the genesis block, for example. But just like there can be a few rare dollar bills, a dollar only works as a medium of exchange if more or less, we all agree that a dollar is a dollar. A prime serial number is cool, but your grocery store can't care about that if it wants to do business.

As a side note, in some places, the value of dollars can change a lot depending on the kind of note. When I was in Rwanda, large bank notes (100$) had a much better exchange rate than small notes (5$). And that way true even in official exchange bureau (like Western Union). Strange, but true ...

Getting coins from the genesis coin would be so cool. I wonder who holds them now ... or whether Satoshi has them all.

Value is subjective - a bitcoin is worth whatever somebody will pay for it. But some might see extra value in, say, bitcoins that have been through some form of convoluted laundry process to hide their origin.

Or in freshly mined coins.


text:
which transactions does bitcoind validate?
which types of transactions does bitcoind v0.10 perform checksig validation on?

blockchain transactions belonging to a wallet with known private key
blockchain transactions belonging to watch-only-wallet addresses
all transactions in the blockchain

my guesses for answers would be 1 - yes, 2 - yes, 3 - no. however i would like confirmation of this.

1, 2, 3, and 4: transaction seen on the network but not yet in a block

1, 2 and 3.
Transactions that arrive through inventory announcements on the network are validated completely by checking the form of the transaction for sanity, executing the script, checking signatures, ensuring that the outputs they are spending actually exist, and that the transaction doesn't end up making negative values anywhere. If they are accepted they are added to the nodes memory pool where they wait for inclusion in a block.

Additionally, non-consensus rules are applied to bare transactions known as IsStandard. On the production network only a small subset of transaction types are "standard", this includes P2SH (pay to script hash) and P2PKH (pay to pubkey hash, or an address), but not raw multisignature and other scripts. Transactions that do not pass are not accepted but relaying a non standard transaction is not a bannable offense.
After validation, IsMine is run to check if the nodes wallet (if it exists) has the keys which own these transactions, of it they have been added as a watching address, if they do they are marked as unconfirmed in the wallet file.

Transactions that arrive in a block are completely validated, along with the rest of the structure of the block. The proof of work is checked, the size and form of the block is checked, the merkle tree is validated to contain all the transactions it claims to and that it connects properly with the header. Every transaction is validated, same as if it had arrived from the network. If they are found to be invalid the entire block is thrown out and the peer who relayed the block is banned from connecting. If the block is valid, it is committed and written to the unspent outputs database, additional undo data is written to file if the accepted block is ever needed to be undone.

IsStandard does not apply here, any transaction that is valid is acceptable when it is included in a block.
IsMine is run to filter out any transactions relevant to the wallet or watch address (if present), and updates the wallet with confirmations if necessary.

i updated my question slightly. it might have been unclear that i was referring to blockchain transactions. anyway, i think this does not alter your answer. thanks for giving such a comprehensive response!

Transactions in the block chain would be the second portion, when transactions are received in a block. The term block chain just refers to many interlinking blocks so the answer applies cleanly to it as well.

are you sure about this actually? greg maxwell says in a talk i just watched that bitcoind "skips verifying signatures deep in the blockchain because it would take too long" https://youtu.be/Twynh6xIKUc?t=28m20s

What is being talked about there is unique to Bitcoin Core and only happens during the initial sync when checkpoints is not disabled in the configuration, once nodes are caught up to the most recent checkpoint they do the full blown verification for all content. It's an unfortunate and inelegant solution to the reality that ECDSA is nasty slow to verify on this sort of scale (much slower than to sign somewhat interestingly).

ah thanks. that's not obvious from his discussion. do you know if checkpoints are on by default? also does the node keep track of the block it has verified upto so it doesn't have to go from the start each time?

Yes checkpoints are on by default. The node only validates from where it left off, but it will roll back the chain slightly and re-validate some previous blocks in an attempt to catch chain state corruption. In current builds this is 288, but was previously 2500 in much older versions of the software. It can be altered with checkblocks, and the intensity can be altered with checklevel.


text:
rpc get hex not json
how can i get the hex output in bitcoin-rpc for blocks? i'm using python-bitcoinrpc.
in bitcoin-cli i can go:
$ bitcoin-cli getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 false
010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e362990101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000

but trying the same thing in bitcoinrpc gives a json output:
print rpc_connection.getblock("00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 false")
{u'merkleroot': u'0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098', u'nonce': 2573394689, u'previousblockhash': u'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', u'hash': u'00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048', u'version': 1, u'tx': [u'0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098'], u'chainwork': u'0000000000000000000000000000000000000000000000000000000200020002', u'height': 1, u'difficulty': Decimal('1.00000000'), u'nextblockhash': u'000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd', u'confirmations': 364412, u'time': 1231469665, u'bits': u'1d00ffff', u'size': 215}

getrawtransaction just works naturally this way:
$ print rpc_connection.getrawtransaction("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098")
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000

there seems to be some json on/off flag that is not well documented...

The second parameter of the RPC call is a boolean for decoding the results or not.
Setting this to False will return the hex encoded block.
hash = "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"
print rpc_connection.getblock(hash, False)


text:
Can double-spends be automated by malicious custom bitcoin clients?
Say a malicious mobile bitcoin client is created, programmed to quickly send two or more double-send transactions whenever a payment is made.
Is this an attack vector we should be concerned of?
What could be done in order protect against such an attack?

"rouge"? Maybe you mean "rogue", but then it's not the correct word anyway.

Thanks, I corrected to "rogue", and I think it means what I think it means - a dishonest, knavish person; scoundrel.

that's not what "rogue" mean in the context of Internet. You'd better use "fraudolent" or similar terms. "rogue" usually means a single cell or small group gone wild: related, but not exact.

"A Cornell University commission said yesterday that a graduate student in computer science, working alone, created the rogue program that produced havoc in nationwide computer networks last November" (source)

exactly, that was a program roaming free about the Internet causing pain. It is a term suited to viruses and similar wandering things, not to tools like yours.

let's agree on malicious? ;)

I touched on this a little in my answer to Is there a risk of double-spending when making a face-to-face transaction?.

@StephenGornick I added this question because I was interested in learning about what would happen if a mobile bitcoin client, specially crafted for performing double spends, was developed.

What could be done in order protect against such an attack?

Wait for N confirmations before accepting a payment as successful.

What happens if I have an Android app that broadcasts two transactions, spending the same input, to a different set of nodes whenever I pay for coffee? Only one of them will be mined into one of the next blocks, but does it mean I have to wait for ~10 minutes at the coffee shop?

@nivs exactly. Of course, for very small amounts that isn't important. In case it will ever be, that is fixed using third party services, similar to how debit cards work.

Using third party services (especially for processing small payments) breaks one of the most important benefits of bitcoin.

@nivs or you can wait 10 minutes, if you prefer.

@nivs With regards to the coffee shop situation, there still is some protection. I can look for that unconfirmed transaction. It isn't conclusive until its been mined and confirmed sufficiently, because a double spend could be hidingin an obscure part of the network and until the transaction is mined and confirmed it isn't 100% protected against that kind of deliberate double spend. But there are some risks with fiat currency as well (counterfeit, for example) and a vendor like a coffee shop will typically absorb those small risk in favor of customer convenience.

The coffee shop is also at risk that you'll run off without paying!  In the future, escrow services like nivs mentions will exist but very few places will use them, because if the transaction is big enough, you can wait 60 minutes, and if it's small, you'll trust the customer not to run away, same as today.

If you try to spend the same coins twice, proper clients won't accept the block as valid.  Read rules 9 and 14 here:
https://en.bitcoin.it/wiki/Protocol_rules#.22tx.22_messages
Double-spend could occur if the transaction history forks, but forks don't usually last very long.  Having 6 confirmations after the transaction should be sufficient.

I think the malicious attempts refers to 0/unconfirmed "race attack" and not any mining-related attack.


text:
What would a country adopting Bitcoins as official currency have to reinvent?
Let's say that a country decided to ditch their currency and go for Bitcoins. What would this country have to reinvent. The reason why I ask, is because I believe that if a tiny country was to adopt Bitcoins as their official currency, then this would remove all legal issues related to this currency, and hence would enable it to get adopted more widely.
Some of the issues that could require reinventing something could be in relation to:

Transparency requirements for the government to efficiently tackle

Black economy
VAT and general taxation fraud
Financing of terrorism

Ability to peg the currency to other currencies if this is judged as a good idea
Have an efficient banking system
Ability to fight deflation

Any other issues, which I have not thought about. Please note that you do not have to answer all these issues in any one answer, just one of them.

TL;DR:

In the first instance, my belief is that a government would have to
  create their own brand of Bitcoin (i.e. a new version of the
  blockchain) and use that to trade against other currencies. This is a
  useful move because the government retains control over their currency
  (they set the mining rules) and they don't suffer a wealth drain in
  the process.

In more detail, once a country (our mythical Seashell Island from the earlier draft) has decided that it wants to adopt Bitcoin as it's local currency the following timeline is likely to come into play:
Research into Bitcoin
At this time the government will need to look into what benefits and drawbacks Bitcoin is likely to bring to their economy. Assuming that they currently have a weak currency, then adopting Bitcoin early could be seen as a smart move since it gives them lower cost of entry into the Bitcoin marketplace.
Among the obvious advantages that Bitcoin brings with it are:

resistance to counterfeiting
resistance to inflation
easier to track than cash for traditional transactions types (i.e. not including private sales of high value private keys)

Some of the drawbacks are:

economy becomes vulnerable to loss of electricity/networking (true of all electronic transactions at present)
banks have a reduced regulatory role since transactions become largely anonymous
increased potential for anonymous transactions to take place in large amounts

This last drawback is perhaps the most serious since it allows for a vast amount of money to be moved in and out of the country without the knowledge of the government. Admittedly, this happens in the present system although due to the large physical size of cash it usually requires laundering of some kind (conversion to something precious).
However, government resources are significant and it is very hard to remain anonymous for long. Over time detailed statistics analysing transactions could be used by the police to pinpoint individuals reusing Bitcoin addresses. This process is made much easier by the existence of tools like blockexplorer.com and should be seen as an improvement over the existing traceability processes.
Setting up the necessary processes/contracts to obtain some form of Bitcoin
By this stage the government researchers will likely have determined that there are only a few feasible options to get hold of bitcoins (note the lowercase here):

set up their own mining pool (initially paying for it in their own currency) - unlikely
create a suitable contract with a mining pool to buy a large quantity of bitcoins (without including their own soon to be worthless currency - unlikely
encourage their citizens to go forth and buy bitcoins themselves and slowly drain the local currency into foreign hands then pull the plug on it (not exactly above board) - unlikely

Using any of the above approaches at this stage requires a significant transfer of wealth from the country into bitcoins and is probably the hardest part to get right. The problem is that there is no central authority who can control the supply of bitcoins exposing the country to the influence of the market. In the case of Euros, the exchange rate of the participating currencies was fixed well in advance after significant negotiation. When the time came to switch over nobody lost out because all the old currency was replaced with the new, which could be printed at will by the central bank.
It could be argued (by @David Perry for one) that some kind of intermediate value-store could be used, such as gold or silver. However, this still requires all of the country's wealth to be slowly converted to this value-store which will raise eyebrows among those folks selling it in exchange for a soon to be worthless currency. I'd welcome further discussion on this.
There is a significant danger that the country could be declared bankrupt in it's own currency before it is able to complete the operation.
EDIT to cover the most likely path by a government:

if a government made their own blockchain (e.g. SeashellCoin) then they could in theory use scripts to manage trades with Bitcoin.

This would permit a staged transition and essentially solves the value-store problem. The value of a Seashell would be fixed against their SeashellCoin equivalent (probably as 1:1). In my opinion, this is probably the most likely mechanism that a government could take. The government could decide upon their own inflation model, select a Version entry and then throw a supercomputer on the job for 5 minutes to generate a few million coins. Once that's done then they can take advantage of the blockchain approach and off they go.
Setting up the necessary legislation to make them legal tender locally
Once an adequate number of Bitcoins are, somehow, in the government coffers they can then make the announcement that all local debts can be paid in bitcoins and will be accepted by a court of law. This ratifies Bitcoins around the world (assuming the country is a recognised state) leading to a huge increase in the value of Bitcoins. It also opens the door to taxation in bitcoins which would largely operate in the same way as it did before.

Value Added Tax (VAT) (aka sales tax) would continue to be added to Bitcoin transactions by merchants who would then transfer the money to the government at regular intervals, overseen by accountants
Income tax would also stay the same
Accounts would have to be returned along with their transaction IDs to allow verification of truth
Standard statistical methods to detect fraud would remain (relies on most folks behaving themselves)

Managing the transition among the general population
Since it is the government driving this then they are likely to provide all necessary equipment to facilitate the transfer. This would include:

recommendations for mobile phone applications (probably not likely to make their own due to "backdoor" privacy concerns)
provision of Bitcoin Wallet Devices that offer tamperproof private keys and are essentially like smartphones for those that don't have mobile phones (see the original Fred)
provision of EPOS systems that are Bitcoin enabled

All of the above would probably occur via contracts with private companies.
Handled well, the transition to Bitcoin would be like introducing a new contactless payment system. They would still want to maintain a secure location for their bitcoins (most likely a government backed bank) and after a while it would just fade into the background.
Reaping the benefits to the economy afterwards
Much of the long term benefits would stem from

the decreased transaction friction within the existing legal and banking system
better fiscal policy since supply is limited leading to improved standards of living and quality of life
increased long term wealth as an early adopter to a global currency
greater transparency in accounting that can be easily verified
immunity to global currency crises

Just my 2 BTCs.

Answer does not take into account its open source, irrelevant points made, Adoption perception seems skewed for lack of a better word, unsure of what your trying to put across.

@MaxSan Thanks for the feedback. I'll have another crack at it - these were sort of a first draft of thoughts but I ran out of time.

Not a problem its a very difficult question and I think trying to answer them in such a way that is accurate and unbiased would be an awful difficul challenge.

Could seashell roll through an intermediate value-store? For example, in phase one all seashells are exchanged for gold/silver coins since they have a fairly stable value independent of the currency used, then in phase two gold is exchanged for bitcoins. Since the government can control the exchange rate for seashells/gold it can be handled much like the Euro was, and since gold has its own market value there wouldn't be a massive collapse when the exchanging for bitcoin begins. Seems logical to me, or have I missed something?

Fred doesn't have a mobile phone?  You've obviously never been to Seashell Island.

@eMansipater +1 'cos it made me laugh :-D

@David Perry I was considering the intermediate value-store but I stopped since I was concerned that it was just another indirection. Once the gold sellers realise that they're buying soon to be useless Seashells then they're in trouble once again. It's a problem of transfer of wealth.

Not if the gold sellers are the government. In the example of the EuroZone they were trading soon-to-be-worthless Finnish marks for Euros at a given exchange rate. There's certainly a loss, but it's unlikely that a government would get out of such a rollover without a substantial loss. Now if the Seashell were a currency in crisis (coughgreececough) then it might be worth the loss.

Just did a complete rewrite with a bit more cohesion and less storytelling. Off for a beer now.

@David Perry, they could use their own curreny to buy gold/silver yes. Then mint another 100 million "shellcoins" using the open source protocal. No extra would be able to be made and the value could be pegged at the amount of physical metal they hold.
There is no reason this would not be a suitable concept.

Excellent rewrite. I think it should be noted if the protocal was changed to hardwire a percentage transaction fee directly to the servers of the government the could eliminate the need to have any taxing systems. all transactions fees could be fed directly back into the country

Based on what I have read here, I cannot see any reason why a government would not, instead of adapting Bitcoins, would develop their own crypto-currency. This seems like a much cheaper option, and they would start off in complete control. But, if they created their own currency, I do not quite understand the purpose of making it a crypto-currency.

Thank you for updating your answer, I like the edited portion, but I still believe that the following section is unrealistic "Setting up the necessary contracts to purchase Bitcoins". A government would never purchase Bitcoins, nor set up any mining. The main reason for this is that they would influence the price of Bitcoins, while trying to purchase them, so they would not be able to calculate what the price would be to get enough Bitcoins. They would much rather start from scratch.

@David Yeah, purchasing bitcoins is very unlikely for a government (hence the extended discussion around it) but I feel it needs to remain in there for completeness. The best approach (that I'm currently aware of) for a government wanting to take advantage of the Bitcoin protocol for their own currency is for them to start mining their own.

Hardware wallets are on their way: http://www.bitcointrezor.com/

A nation State would never adopt Bitcoin willingly because the government would lose control over the ability to inflate the money supply.  Inflation is nothing more than a tax.  No government will ever willingly give up its primary means of stealing from the public.  The inflation tax is the most insidious and the easiest for government to get away with.  It is much more difficult to force people to hand over their money than it is to simply print new money.  Historical charts of US tax revenue show that no matter what rate the government sets taxes at, revenues always come in at around 20% of GDP.  This means that if the government wants to spend above 20% of GDP they must inflate the money supply as people will simply scam the tax system at higher rates.
Further, it would be ridiculous for any coercively funded government to implement its own version of Bitcoin that they retain control of, because once people found out that an identical open source currency system existed that had no inflation, they would use that system instead.  Once an economy has been restructured to use crypto-currencies, no one in their right mind would chose to use the government issued currency when they could use Bitcoins instead.
Thus, a State implementation of crypto-currency will never occur.  However, because Bitcoin has so many advantages over State issued currency and the fact that its exchange rates can not be controlled by a State, it is highly likely that over time Bitcoin will become the dominate global currency.  This is because taxation can be avoided with Bitcoins, which allows businesses to by-pass legal tender laws. According to Thier's law, in the absence of legal tender laws, good money will drive out bad money.

I could think very small countries (as Central American/Caribbean nations, or Southern Pacific island-nations) could very well adopt Bitcoin and benefit by doing so: most of them already use another nation's fiat currency, so they'd get independence of the other country's monetary policies. Plus they'd be more resistant to speculative attacks than if they went the route of printing their own (traditional) money...

The Lakota nation have just adopted a cryptocoin as their official currency - ex-professo created Mazacoin. Since they're surrounded by the USA and used US dollar for everything, most probably tribal govmnt. see it as a way to "claim" control and autonomy over their economy rather than surrendering it.

The most likely scenario in which a government would adopt Bitcoin is when their own currency is undergoing hyperinflation. As Gareth's answer points out, there would be no way to transfer the value of the old currency into Bitcoins. But if the currency had essentially no value anyway, it would not have to make that transition. In economies suffering hyperinflation, citizens typically switch to other currencies before their governments. Once the citizens have reached consensus that the old currency is worthless and privately switched to Bitcoins themselves, the government just has to agree to accept Bitcoins as payment, and the transition is complete.

Should Auroracoin's experiment succeed, Iceland will go thru just that transition in the next few months, citizens first, due to for both hyperinflation and oppressive monetary controls.

The short answer is that would have to reinvent bitcoin
In order for a country to adapt a new currency they have to abandon their old currency, this is done by making a law that transfers the value of the source currency to the new currency on a given date at a given rate (which may be decided on the day), but doing this is impossible with bitcoin since there isn't a central authority that can bless this sort of magic transaction as there was with the euro.
Basically they would have to invent a crypto currency that starts with the replacement of the source currency as it's seed.

I've edited my answer to include a more complete description of how a government can trade using their own Bitcoin blockchain so that the Bitcoin protocol stands.

This answer is simply wrong. They would face a lot of issues, but having to reinvent bitcoin isn't one of them. If they wanted, they could take the Bitcoin protocol, create a new blockchain, and pre-generate all coins. Checkout out @Gary's excellent answer.

There are other practical challenges a country need to face:
Before even starting the change, a government must convince people.
Old people here in Hungary still insist on using cash, and nobody can convince them to use bank cards: they got their salaries on the bank account and the first thing they do is going to the bank and withdraw the entire account as cash.
Also crypto-currencies require internet access. This means every people in the country must have some form of access to the internet to be able to transfer money between each other. So far no country in the world have 100% internet penetration. Here in Hungary the internet penetration is only 75%, this means 2.5 million don't have or don't wish to have access to the internet.
These people must be served by new system as well. Eg. they should make paper wallets that should be filled up by their employer.
People also need education. If you are careless it's rather easy to wipe off the private key of the current change address from your computer or smart phone and losing all the money.
Also in case of the paper wallets if someone can access their papers for a short time can take the money off from them without actually stealing the paper.
Authorities must find a way to track people's spendings. Banks nowadays must report the transactions to the tax authorities, so they can claim the right amount of tax. With bitcoin we are basically back the age of cash which is almost untrackable.
I have no idea how could they accomplish this.
The current Bitcoin system has a fixed money supply.
It doesn't address the problem of lost coins and hoarding.
Without some depreciation there is no incentive to actively exchange it.
So people instead will hoard it and use it as permanent store of value.
If we want active exchange then we should create a system that encodes some moderate inflation, that's large enough so people don't want store their savings in it, instead they exchange it and buy other financial assets to store value in.

I think the best countries suitable to adopt Bitcoin are the ones who are suffering from Hyper inflation (ie the government is inflating the money supply to offset bad economics or policies).  adoption would be informal, and would grow with grass roots much like those countries now adopt the USD as a safe haven.
The result would be cartelistic, like the invention of the wheel or the printing press or radio.  All financial interest in governing will be eroded, and true democracy for the people will emerge, like in the early Union of States, there will be no fiscal power in Politics.  There will be a lack of government funding, so the IMF and World Bank will lose their foot hold in reforming the country in there model, and a new more sustainable era will emerge.
Provided the adopting country had something to export that the international Bitcoin community wanted, the growth will spread and far sparse that of China on steroids.
The government that will evolve won't be centrally planned, the era of many to 1 and 1 to many communication will fade, it will be P2P many to many communication.
While Rick Falkvinge sees a future where there is a central governments providing social assistance, and people are liberated from involuntary tax and gain economic freedom, (http://bitcoinmedia.com/eurobit-rick-falkvinge-banks-the-fourth-victim-of-citizens-empowerment/ ) I mostly agree with his vision of change, but I think Bitcoin is a more radical technology. It will bring in a new kind of governance, that is not suitable for a centrally controlled monopoly. I see a new more just and equitable world (a type 1 civilization emerging).
So for that fundamental reason we now have a technology so powerful it will change the way we live, in just 10 years from now it will start. I don't want to suggest ways to change it to fit with our current political hierarchy, but use it as a disruptive technology and pave the way.


text:
What is bitcoin ID?
An answer on this page says that neither bitcoins nor satoshis have any identity. I then read that

You may consider a bitcoin to be "less-anonymous" when an attacker
  could feasibly find the true identity of a very recent owner of the
  bitcoin, perhaps because one of the bitcoin addresses was posted to a
  website, or because he knows some identifying information through
  other means.

As you see it mentions bitcoin addresses! These two statements seem to be in conflict, which is true?

The paragraph you copied from the Bitcoin wiki is imprecise.
Transactions result in transaction outputs that usually are associated with specific addresses. I.e. there is a balance of bitcoins associated with an address, that only can be spent by an order signed with the address' corresponding private key. The bitcoins itself are not identifiable, rather the path that they arrived through may be traceable.
As an example, let's assume there are two transactions:
Transaction 1: A --- 1 BTC ---> B
Transaction 2: B --- 1 BTC ---> C

A, B, and C are addresses in this case.

What the text from the wiki is trying to confer is that if somebody knew who owned address A, they might be able to force this person to tell them who owns the address B. This second Bitcoin user might then be forced to reveal the owner of address C.
However, the bitcoins itself do not have any identifiable footprint in the system, they merely exist in form of a transaction output's balance that may only be created through mining or the destruction of a previous balance.

Wait, which person? If A is exchange bank they may know the customer in person. But, B and C know only bitcoin wallets of each other. They do not know who are the persons. B donates to C. Ok, he knows the company he donates to. But, my question was noting more than about the about bitcoin identity, not person identity.

There is no way to identify wallets on the Bitcoin network. Wallet is merely an abstract term for the entirety of addresses owned by one user. And you are correct, it is possible that the owner of B does not know who owns the address C. Yet, certainly there must have been a motivation for the owner of B to send money to C.

Wallet is the worst word. It's not a Bitcoin wallet, it's more like a Bitcoin keychain

You can see addresses and transactions. But you can't get the owner of this address unless he or someone else is publishing the identity.
For example, this happend when the coins of silk road where seized: 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX.
Everyone can check where those coins went to from there on. Blockchain.info allows people to add a note to an address, to let others easily find those addresses.
Normaly people would not post their identity. So if you look into the blockchain and see someone send 1 BTC to someone else, you will never know which persons traded those coins. Therefore it's anonymous.

Addresses of what? Of the bitcoins? Do you see that I ask about addresses of bitcoins: can you identify concrete coin or not?

There is no coin-address. You can split one bitcoin in 100 mio fractional coins and merge them back together as you wish. If I would have received 1 BTC and send 0.5 to you, you can take 0.1 BTC and send 0.6 to someone else. Or you only send 0.4 to some else and save the last 0.1. This is a bit more complex than I just put it down, for more information there is a good wiki post: https://en.bitcoin.it/wiki/Transactions#Explanation

That is what I want to be the answer. Just explain what http://en.bitcoin.it/wiki/Anonymity had in mind saying bitcoin address?

It means the public address from which you send the coins(input) or where you send them to (output).


text:
Should mining.notify.merkle_branches contain the coinbase transaction or not?
Okay I'm working on a new pool-server though got a question.
I'm using litecoin testnet right now to test stuff and here's a getblocktemplate() response I get;
{
"result": {
    "version": 2,
    "previousblockhash": "8a39d544ae4f46bab42358baa72d338dc8d4ed764fc0cc578c16d339bb2aac4e",
    "transactions": [],
    "coinbaseaux": {
        "flags": "062f503253482f"
    },
    "coinbasevalue": 5000000000,
    "target": "0000014e2c000000000000000000000000000000000000000000000000000000",
    "mintime": 1399898893,
    "mutable": [
        "time",
        "transactions",
        "prevblock"
    ],
    "noncerange": "00000000ffffffff",
    "sigoplimit": 20000,
    "sizelimit": 1000000,
    "curtime": 1399898982,
    "bits": "1e014e2c",
    "height": 271882
},
"error": null,
"id": 1

}
As you can see it doesn't contain any transactions.
So while building my mining.notify structure, should my merkle_branches contain the coinbase transaction (generation transaction) I created or not?
From here my notification should be similar to this;
job_id = "b3ba"
prevhash = "7dcf1304b04e79024066cd9481aa464e2fe17966e19edf6f33970e1fe0b60277"
coinb1 = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff270362f401062f503253482f049b8f175308"
coinb2 = "0d2f7374726174756d506f6f6c2f000000000100868591052100001976a91431482118f1d7504daf1c001cbfaf91ad580d176d88ac00000000"
Merklebranches = [
    "57351e8569cb9d036187a79fd1844fd930c1309efcd16c46af9bb9713b6ee734",
    "936ab9c33420f187acae660fcdb07ffdffa081273674f0f41e6ecc1347451d23"
    ]
version = "00000002"
nbits = "1b44dfdb"
ntime = "53178f9b"
clean_jobs = true// Not required for block, just for completeness

But as I got 0 transactions from litecoin-testnet network to carry, my resulting json would not contain any merkle_branches.
So should I include the coinbase transaction I generated?

getblocktemplate() takes an array of capabilities as argument, what are you passing there?

{"coinbasetxn", "workid", "coinbase/append"}


text:
Can I send message inside the transactions script?
I would like to send transactions with messages as described in the wiki. In Transaction with slightly changed script is never relayed, someone answered that non-standard transactions are not relaid by the client. I was wondering if this will affect this type of transactions.
Also, I would like to know if there is a source code that implement this functionality. I need to send small data (SHA256) as a digital signature that can be view by all the peers in the network and is associated to this specific transaction.
Thank you very much and your help is very appreciated

You will find that non-standard transactions are very hard to get into the block chain. Instead, encode the additional information as accounts and send a single satoshi to each account needed to convey your message. That way, you can use standard transactions.
Transaction 28ccf29cfcc9f82d42793db770e7c7894d61ccf3d18299f34bda2e54415da287 is a particularly silly example of this.

If you don't want to throw away the coins to phantom addresses you can encode the message in the transferred amount: https://gist.github.com/1625828 . The link is the example for BTCsg (http://btcmsg.com/), but there are other ways.

You can, but you shouldn't. Bitcoin transactions should only contain the information needed for the world to verify your transaction. Anything else is essentially private information between the sender and the receiver, and would be useless bloat to the block chain (making it more expensive to maintain for everyone).
That doesn't mean you can't have messages attached to transactions at all, of course. The problem is that there is no easy way to communicate between sender and receiver right now, apart from via the block chain (which works, but as a means of communication it is slow, inefficient, expensive and unreliable). The payment protocol currently being worked on (see the current draft, or the mailing list archives) should solve this very neatly, as it supports transaction metadata that does not become part of the resulting Bitcoin transaction.

Thank you for the comments. This is part of my thesis proposal. I'm actually testing using testnet-in-a-box. The purpose of this is to allow linking virtual payment to real life transactions for non-repudiation purposes.

Yes, you can now store up to 80 bytes via an additional, special output:
https://bitcoinfoundation.org/blog/?p=290


text:
Is there a point where bitcoin mining will not be profitable?
A lot of news accounts are pointing out that bitcoin mining is getting more difficult over time, murch even said recently in chat its getting "exponentially harder". I am not sure if that is the case, but has anyone studied the economics and difficulty/hardness of bitcoin mining over spans of time? it appears clearly & by design to be subject to "diminishing marginal returns".
Is there a forecast when bitcoin mining will reach "break-even" level & be exactly as expensive as the hardware/energy required to mine it?
I am looking for quantitative/scientific analysis where possible. By the way, its a completely separate question of whether this would mean that bitcoin is no longer usable as a currency. (To me that is very likely not the case.)

found this similar question why does mining profitability trend to zero

It's a fact that difficulty is increasing over time, and dramatically so.  You only need to consult a chart of the last nine months of hash rate v. difficulty to determine that for yourself.
The question of whether it will reach break-even (zero returns) is more difficult.  People around the world have different inputs to the cost side of the equation.  For example, the power cost in Hawaii is quite a bit higher than the power cost in Washington state, and could be quite different still from some other location.
I'm sure you've seen the various calculators around.  They can't predict the future, they can only produce an anticipated result for a specific set of assumptions as inputs. Whether mining is profitable depends on your assumptions for the future (bitcoin price, difficulty increase, power costs, mining efficiency, date when miner goes operational, etc.)
Demand for mining hardware is still robust and I think the primary reason is that actual cost inputs vary (electricity, etc), and people have different views on the other inputs required for the profitability equation. Some people will be wrong.
I mine today, but my 30 g/hash equipment is long past it's prime. Not sure that I'm ready to sign up for the current arms race.

It's already here. At present, you're simply not going to be able to mine Bitcoin with consumer grade hardware. Even with ASICs, you're still looking at returns that would have been laughable just a year ago. You're better off mining something like Mint or Aurora, or Doge, and turning them in for Bitcoins. Just my 2400 satoshis.

ok, right. the pt of the question is that given trends (incl eg even rate of moores law not outpacing bitcoin mining difficulty) maybe even "professional grade" hardware will not be profitable in the foreseeable future.

If you buy new hardware now it will be unprofitable.  Predicted difficulty increase means that hardware cost plus electricity won't even be covered.  The only people who are making anything now are those with hardware already, those with cheap/free electricity (that someone somewhere is paying for) and of course the people who sell mining hardware.

First miners to get a new, improved ASIC see an enormous boost in their profits in the first few days. But as more people receive theirs and put them to work, difficulty raises rapidly until everyone is just recovering costs rather than profiting: only the first people to use a new ASIC model actually make money off of it.

All of the above answers are incorrect.
Bitcoin mining will always be profitable, for as long as there are transactions to be confirmed there will always be utility in "mining," even beyond year ~2140 when all bitcoins are thought to have been mined.
Alternatively, I agree with above re: BTC difficulty rendering all but commercial mining operations or cloudpools etc profitable being here, now. When I think about how, to date, the most reputable mining company (as far as I'm aware) is Terraminer I'm taken aback by the state of mining. After having shipped 1000 pre-orders for their 2TH mining rigs, we saw them weeks postponed from original promised date, and with all of them under-clocking at just 1.7TH at BEST!
Couple this trend, that of mining companies falling far below expectation, even farther behind promised schedule, being "new" seems like a fairy tale all things considered --- with the knowledge that every single miner is "tested" before it is shipped it's not hard to see why they have consistently sucked.
Tera chose to ship their models, at a time where bitcoin's $ value was decreasing steadily.  Perhaps if it had not been dealt a huge blow at the hands of Gox, they would have withheld shipments for several more weeks. Perhaps they would not ship out at all if they price again skyrocketed to $2000.
It is somewhat scary to think that all of these channels are dirtied with the stain of avarice, corrupted absolutely by cut throat companies who are almost never releasing anything earth shattering without getting their own bang out of the product first.
The bitcoin market and it's miners are forever inextricably linked due to their necessity in confirming transactions, in securing the network. The ties between them are tainted unfortunately.
I can't imagine any really profitable mining equipment being sold ... at all ... until key measures are put in place to level the mining field.

"utility" is not the same as "profit". dont fully understand the bitcoin architecture but it appears there could be a point where it is unprofitable to mine new bitcoins but the computational effort/overhead reqd to run existing network will continue/be maintained, maybe based on a small transaction tax by large providers or something. as for "avarice"/"corruption" it appears what you describe is just a basic aspect of capitalism (long predating bitcoin), nothing more sinister than that....

The OP didn't ask whether you would still be able to receive btc after all the coins were mined. Everyone understands transaction fees. He asked whether mining is/would be profitable, which is a debatable point.

Please note that the order of answers is configurable and in two of the three settings it changes over time (depending on votes and edits), so "above" is not a useful description of other answers in relation to your one.

Terraminers were not profitable at all. At 1.7TH, with the 17 amps of power draw, and at $6000/box and being shipped mid april.... totally burned. The day ours arrived cointerra announced they'd sell the same box for $4700... in-stock shipment. That they pre-mined those machines is pretty much a foregone conclusion... now they are dumping stock. And even after all they, they are the best deal in town.... ie: unprofitable at best.


text:
Is Bitcoin a mesh network?
Considering following definition, can we say that bitcoin is a mesh network?

A mesh network uses a network topology in which each node (called a mesh node) relays data for the network. All nodes cooperate in the distribution of data in the network. http://en.wikipedia.org/wiki/Mesh_networking

It broadcasts blocks and transactions using a logical mesh network, but that shouldn't be confused with physical mesh network proposals.

What I mean is I think we can consider bitcoin network to have a mesh topology.

@Nur Okay... is that a question?

The question was above

Bitcoin is meant to be a redundant and cooperative network.  Everyone feeds everyone data.  So in a way, sure.


text:
Decode transaction
I get this output from gettransaction:
{
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"version" : 1,
"time" : 1392083602,
"locktime" : 0,
"vin" : [
{
"txid" : "f56aaf54ccd5e6f1a5aa7d79f413c8b528151464ccc05b42c334ba3abcfec3a9",
"vout" : 0,
"scriptSig" : {
"asm" : "30450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb001 03edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c",
"hex" : "4830450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb0012103edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 232306.19497700,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 fd4c23e37c3e35db14b045e1657c821696ffd774 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914fd4c23e37c3e35db14b045e1657c821696ffd77488ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"MvL5PPHRz9PMHiwToAzXi7aptRrxZ9GLJY"
]
}
},
{
"value" : 3777.33695900,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 8c0634d7a07bd4041b4651c7b98ade93ca11e951 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9148c0634d7a07bd4041b4651c7b98ade93ca11e95188ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"Mk19FdAUVMSp7MM5dWRPnA9Nvj6bjMaFmH"
]
}
}
],
"blockhash" : "000000000448d9bf8021c78b6eeb1182a2cc2281185870111e094e4278ea27b4",
"confirmations" : 45591,
"txntime" : 1392083602,
"time" : 1392083613
}

How can I decode it into something like this with Perl? I need it to export database to MySQL.
Output:
wallet1 0.123 BTC
wallet2 0.5 BTC
Input:
wallet3 0.4 BTC
wallet4 0.222 BTC
Fees: 0.001 BTC

There is an open source implementation of block explorer that supports MySQL databases it is called Bitcoin-abe.  This also works with other cryptocurrencies besides BTC you can find it and the source code at https://github.com/bitcoin-abe/bitcoin-abe it is written in Python so it may or may not fit your requirements, you should also be aware that it may take a couple of days to parse a blockchain and be ready to view in a web browser.


text:
Does Ripple ever charge proportional transaction fees?
I spotted this sentence in WeExchange (a ripple gateway):

*: The ripple network may charge up to a 1% fee if you are withdrawing to an address that does not trust WeExchange for the amount.

What does it mean? Why can the fee reach 1%?

The network itself doesn't really ever charge proportional transaction fees. However, when you make a payment, that payment can take a path that can invoke any number of fees. These fees are charged by the individuals or companies who provide links in that path.
The four possible fees are:

Transfer fees: A transfer fee is a fee an IOU issuer can charge when their IOUs change hands. It is imposed by the issuer of the IOUs you hold. (This is one of the services your gateway can charge for.)
Quality fees: A quality fee is a fee someone who holds multiple IOUs can charge when you give them IOUs they consider less trustworthy in exchange for IOUs they consider more trustworthy. It is imposed by the entity that holds both IOUs. (This is a fee someone can charge if you use their liquidity to swap IOU issuers.)
Service fees: A service fee is a fee imposed on an IOU exchange in either direction as payment for the convenience of changing issuers. It is imposed by the entity that holds both IOUs. (This works the same as a quality fee except it can be charged in both directions and so doesn't necessarily reflect a change in quality.)
Exchange fees: An exchange fee is essentially the same as a service fee, but it can also occur when the currency is changed as well as the issuer.

When you form a transaction, the Ripple system finds the cheapest path taking these fees into account. Generally, the cost should be very close to the amount of money you are trying to deliver to the destination -- most of these fees are typically zero. If you hold IOUs from a gateway and are paying someone who trusts a gateway, these fees should total way under 1%.
These fees provide the incentive for people to provide liquidity and connectivity in the Ripple system. Competition should drive these fees to near zero for typical cases.
So, for example, if you hold IOUs for USD at two different gateways, you could offer to exchange between the two gateways at an exchange rate that makes you a modest profit. If you provide the best path between those gateways, then someone who holds IOUs from one gateway but needs to pay someone who only trusts the other gateway can take you up on your offer and you'll wind up imposing a fee on their transaction.
Ripple transactions can include multiple paths and a maximum amount to pay. At the instant the transaction is processed, the system will incrementally take from whichever path has the lowest cost. If the transaction cannot be completed at or below the specified maximum cost, it will return an error.
You might think it would be expensive to pay all these fees, but in practice, they'll be small or zero. Say you are at one exchange and you need to pay someone at another and the fee is high, say 1%. Someone with IOUs from both exchanges will see a profit opportunity -- just offer the IOUs at .9% instead. They can make money as the IOUs move back and forth and they won't have to do much. But then someone else will see an opportunity at .8% and so on. The price will get driven down to near zero unless there's some reason for the fee.
Some of these fees can apply in reverse and actually result in you paying less than the specified amount. If you're paying with IOUs that someone else needs, you may be able to give them the IOUs they want at a profit. So it could cost you $98 to pay me $100 if you hold IOUs that are needed and I'll accept IOUs you can get below face value.
The fees serve to cause transactions to do what people need done. If I have the "wrong" IOUs, I can just offer them in exchange for the IOUs I need at a good price and someone looking for the lowest fees will wind up fixing my problem for me. If I'm holding IOUs from someone I no longer trust, I just offer them at a discount and wait until they become someone else's cheapest path.
The 1% figure comes from the way WeExchange currently processes withdrawals from your exchange account to a Ripple account. If that Ripple account trusts WeExchange, they just issue that account IOUs. If not, some of the fees I mentioned above may be incurred. WeExchange currently will allow the withdrawal if it costs up to 1% more than the amount withdrawn. So if you order WeExchange to pay $100 to a Ripple account that won't take their IOUs, it may cost you more than $100 (up to $101) to do it. If it would cost more than that, WeExchange will report an error. (At least, this is my understanding. The details were relayed to me second hand and this is still subject to change.)

Wow, it seems you have a rather complicated system there.

I'm confused about #1 "Transfer Fees." You're saying that if I receive an IOU from a gateway, and I then transfer it to another third party, that I can be charged a fee? This makes no sense. Why should gateway IOUs changing hands between third parties incur a cost (above the XRP cost)?

@VinnieFalco: Yes, that's correct. Gateways can charge a fee for transferring their IOUs. Most currently charge a fee between .2% and .5%. Gateways charge a fee because they have costs associated with holding your money. We hope competition will bring those fees down (especially once interest rates go up), but people can charge whatever they want for the services they provide.

@DavidSchwarz: Okay, I get that there's costs associated with holding money but I don't see how those costs are proportional to the amount held, or how the costs are proportional to the number of times the IOUs are swapped by third parties.

@VinnieFalco: They're not. It's kind of like airlines charging more for tickets that don't have a weekend stay. It's a cost more in line with the value they provide than the costs they incur. Gateways can set this fee to zero if they don't think it's appropriate. Our model is to make things possible, not compel people to do things in a particular way. (I'm waiting for the first "virtual gateway" that brokers between gateways and sets the transfer fees for its own IOUs at or near zero.)


text:
What prevents bitcoin from breaking down in case of a "transaction attack"
Let's say that I want to kill Bitcoin by means of a transaction attack. What in the bitcoin system prevents the following approach:

I buy a limited number of bitcoin in the market.
Using a small number (say 50) physical computers all running bitcoin clients and accessing the net through proxies, I generate, say, 100.000 wallets - each with their own bitcoin addresses.
(Running a script on the computers) I start sending random amounts (mili-to nanobitcoin range) of bitcoin back and forth between all my 100.000 (or more) wallets - each at a very high frequency. Average flow of bitcoin between wallets average to zero.

This causes an explosion in the number of daily transactions (currently in 1,000-10,000/day) range to millions or billions of transactions.
This makes every block gigantic in size causing an explosion in the blockchain and causing widespread problems with blockchain verification, storage and (worse) synchronization => the network dies.

Can someone explain why bitcoin is immune to this kind of "transfer attack"?

Duplicate of http://bitcoin.stackexchange.com/questions/499/what-protection-does-bitcoin-have-against-denial-of-service-dos-attacks

@D.H. it is similar, but the answer to the other question doesn't address the issues with managing a huge blockchain after the flood.

Wouldn't all these transaction have such a low priority that they would not make it into the block chain? I think that was the point of requiring transaction fees for "smallish" transactions.

@nmat, the case of "transaction flooding" is covered in the other question and the way I read it the answer concludes that it would not be possible, hence no huge blockchain.

There are rules which make such kind of attack very costly to the attacker. Below are relevant rules from wiki, with updated transaction fee:
0.0005 BTC fee per kilobyte of transaction, but:

If the blocksize (size of all transactions currently waiting to be
included in a block) is less than 27 kB, transactions are free.
If the blocksize is more than 250 kB, transactions get increasingly
more expensive as the blocksize approaches the limit of 500 kB.
Sending a transaction when the blocksize is 400 kB will cost 5 times
the normal amount; sending when it's 499 kB will cost 500x, etc.

Let's say attacker publishes 499kB worth of transactions every block, this would be about 1000 transactions per block, 144000 per day. This is nowhere close to millions or billions, and besides it would cost him about 18000 BTC per day.
Source: Transaction fees

Your transactions will simply be ignored. They won't even be relayed across the network.
In order to fuel such an attack, you need old transaction outputs or you need to pay transaction fees. You can use each old transaction output at least once.
With small numbers of coins and no old coins in them, your transactions will be totally ignored unless you pay transaction fees.
It would take only a few hours before all major mining pools switched over to ignoring all transactions with no fees that didn't use coins at least a day old.