Bitcoin Forum
May 06, 2024, 05:13:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: « 1 ... 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 [59] 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 186 »
1161  Bitcoin / Development & Technical Discussion / Re: A bitcoin blockchain parser in a few hundred lines of C++ on: July 05, 2013, 08:01:36 PM
>>You run the script for the input and then run the script for the output.

Ok, I had previously asked in this thread how the input and output scripts related to each other and I did not get a clear answer.


In the transaction header there are (n1) input scripts and (n2) output scripts; how do I know which input script to run on the virtual-machine prior to running a particular output script?

Thanks,

John

In a given transaction they are unrelated.   For each TxIn you look at its OutPoint and go fetch the TxOut it references from a previous transaction in the block database.  You use that TxOut.  The TxOut in this Tx will be used as inputs in a future transaction (when the recipient spends the money)
1162  Bitcoin / Development & Technical Discussion / Re: A bitcoin blockchain parser in a few hundred lines of C++ on: July 05, 2013, 07:26:38 PM
You shouldn't be surprised there's no timestamps on transactions - that's the whole point of Bitcoin which is for a whole network of thousands of independent nodes to all agree on the ordering of transactions.   In essence, a transaction doesn't even really exist until it is included in a block.  Therefore, the block timestamp is when the TX became "real".  Everyone has different clocks and receives the tx in different orders and times.  The point of Bitcoin is for this network with no central authority to agree on which ones actually happened.

As for C++ code, go look at the Armory code base which had code that does exactly what you're looking for in the  cppForSWIG directory.  BlockUtils cppForSWIG.   Should be a function called parseEntireBlockchain of something like that.
1163  Bitcoin / Development & Technical Discussion / Re: Detailed information about datadir on: July 05, 2013, 01:36:43 AM
For example there are 30 blkxxxxxx files the first few are very large then most are 134MB.  The last one is smaller but that would make sense as it is the block file in progress.
Why 134MB?  Why roughly 2GB for the first two block files and then the third one breaks that pattern?

If you redownload the blockchain, they will be 134 MB.  But if your blockfiles were mostly downloaded prior to version 0.8, then it used a 2 GB blkfile size, and just kept them when they switched it in 0.8.

If you were to wipe the directory and redownload with 0.8+, it would be about 70 files of 134 MB each.  If you redownloaded with version 0.7 or prior, it would be 5 files of 2 GB each.
1164  Bitcoin / Development & Technical Discussion / Re: SIGHASH_WITHINPUTVALUE: Super-lightweight HW wallets and offline data on: July 04, 2013, 07:00:13 PM
Although it's a neat idea, it underestimates the blockchain bloat that comes with it.  If this became standard, and we had 1000 tx per block, that's potentially 1,000 extra UTXOs we wouldn't otherwise have.  Adding 1000 UTXOs per block would be pretty rough, and the total blockchain size would increase pretty dramatically in an effort to spend all those. 

No, OP_TRUE can be spent by anyone.  It implicitly means "pay to miner".  Ofc, some miners might not detect them and so it becomes pay to the first miner who finds them.

Oh, I understood that part, but I forgot about the part where they don't have to provide a large signature in order to spend it to themselves.  And I missed the part that they can mine all of them in a single transaction and produce only one extra output for themself.  Okay, it's kind of cool.
1165  Bitcoin / Development & Technical Discussion / Re: SIGHASH_WITHINPUTVALUE: Super-lightweight HW wallets and offline data on: July 04, 2013, 06:08:43 PM
I think there is another way to do this, but still need a soft-fork:

1. Define a new transaction version: valid only if total input amount = total output amount

2. Miner fee is sent to OP_TRUE

3. The rest will follow https://gist.github.com/gavinandresen/2355445

This has 2 bonus effect:

a. People using this type of transaction will not accidentally send a huge amount of transaction fee

b. In multi-parties contracts, people can define fee explicitly

The drawback is that would cost extra block space, so the transaction fee will be higher in long run

Comments?


Although it's a neat idea, it underestimates the blockchain bloat that comes with it.  If this became standard, and we had 1000 tx per block, that's potentially 1,000 extra UTXOs we wouldn't otherwise have.  Adding 1000 UTXOs per block would be pretty rough, and the total blockchain size would increase pretty dramatically in an effort to spend all those. 

It seems that you would end up with much more frequent "double-spends", for the same reason coinbase transactions require 100 blocks to become valid.  Miners could spend those fees immediately, meaning that orphaned blocks could lead to countless "accidental" double-spends.
1166  Bitcoin / Development & Technical Discussion / Re: A bitcoin blockchain parser in a few hundred lines of C++ on: July 04, 2013, 03:56:53 PM
The TxIns and TxOuts are independent.  Think of the network as containing a bunch of floating [unspent coins].  Each of those unspent TxOuts is like a bill (like $20 bill).  The TxIn is simply a reference to a particular bill with a signature proving you are authorized to spend it.  If you want to send someone 10 BTC, you need to collect enough bills (say, a 4 BTC bill/TxOut, a 2 BTC bill/TxOut, and a 7 BTC bill/TxOut).  10BTC output, and one output sending the remainder back to yourself (3 BTC).  

You can think of transactions as eating unspent TxOuts, and producing out new TxOuts (and you are authorizing the spending of the old TxOuts by the signatures in the TxIns). A transaction takes TxOuts of some ownership, and converts them into TxOuts of a new ownership.  You can split them or merge them in any quantity, as long as you have at least one TxIn (corresponding to a previous TxOut being eaten) and one new TxOut.

Here's a random picture I made a long time ago that attempts to illustrate it.  



The dotted lines for the TxIns illustrates that they are really kind of "transient" data.  They're simply for the network to see that you were authorized to move those coins, but in the far future, the old spent TxOuts, and the TxIns that moved them can all be pruned off.
1167  Bitcoin / Development & Technical Discussion / Re: Zerocoin when? on: July 04, 2013, 02:06:27 AM
And if someone is using them [P2SH] regularly, would they continue after the payment protocol is available? These things aren't really clear.

For reference, when Armory implements multi-sig and linked wallets, P2SH will become a staple.  It's not that there isn't use for them, it's that you need existing, mature wallet software to build on top of, and there just isn't a whole lot of options for that.  If I hadn't made such poor scalability decisions in Armory two years ago when it was started as a pet project, I probably would've done it by now...
1168  Bitcoin / Development & Technical Discussion / Re: Saving Transaction Outside of Network? on: July 04, 2013, 12:26:29 AM
I wouldn't say it's useless.  You could always create a transaction to someone (as Akka pointed out, it can be done with Armory), and then email it to them instead of broadcasting it.  Then it would be the same as writing a check from your bank checking account -- checks aren't guaranteed to have funds available to them, but if it's lost in the mail or the person moved (i.e. lost their wallet, etc), the coins never left your wallet.  

I had even thought about doing something like this in Armory as another kind of payment option.  

(1) Recipient gives the user his payment address.
(2) Sender, perhaps at a far later time doesn't know if that address is still valid, etc
(3) Sender creates a signed transaction and emails it to the recipient
(4) Recipient opens it in Armory and it says "This transaction sends 13.24 BTC to Wallet ABC" or "This transaction does not send coins to any wallet you own"
(5) Recipient presses "Broadcast" if they are happy with it.  Or replies with "this isn't valid, please use this address instead: ..."

It also makes MitM address swapping attack much less potent, because the person broadcasting is much more capable than the sender, of recognizing whether the transaction goes to their own wallet (edit: okay so this isn't actually true: because if the MitM can swap the addresses, he can probably also intercept the signed transaction and broadcast it himself... maybe only relevant if the tx is sent to the recipient through a different channel).  It also means that the recipient must actually act to broadcast the tx, which could be seen as actively acknowledging that payment was accepted.
1169  Bitcoin / Press / 2013-07-03 CBS News - Winklevoss trust will test Bitcoin security concerns on: July 03, 2013, 11:34:32 PM
http://www.cbsnews.com/8301-205_162-57592240/winklevoss-trust-will-test-bitcoin-security-concerns/

More discussion about the Winklevoss ETF, and then some educational discussion about Bitcoin... based on an interview with me!  Smiley

Quote
Will an investment trust push Bitcoin into the mainstream? Or will security fears leave growth of the "cryptocurrency" stagnant?

Bitcoin is a currency that exists in a digital form and is bought and sold using software operating over peer-to-peer networks. But it's also a technology platform that is built with an open-source code that has essentially de-centralized transactions.

Cameron and Tyler Winklevoss on Monday filed a proposal with the U.S. Securities and Exchange Commission to create a Bitcoin trust that will allow investors to purchase shares on a secondary exchange that is a variation on an exchange-traded fund (ETF), Bloomberg reports.

According to the New York Times, the Winklevoss brothers claim to own $11 million worth of Bitcoin as of April 11 -- making them the largest-known single shareholders of the currency.
1170  Bitcoin / Armory / Re: Armory - Discussion Thread on: July 03, 2013, 10:16:41 PM
I am using the example in extra/sample_armory_code.py to analyse a betting websites transactions much like the satoshidice example in there.

I think the job is simple. Only issue I have is that each time I run the code to debug what I have coded I have to wait 5mins for it to rescan the whole blockchain. Is there anyway I can when testing my code get it to just read one blk file or a few blocks?

It is just so every time there is a minor typo in my code I do not have to wait 5 mins to see if I have fixed it. It is driving me crazy!

Thanks

Hmm... good question.  I never bothered putting in something like that, because I always just used testnet if I needed to operate on less data.  I suppose you could create a temporary directory with just the first couple blk files and point your script to that using --satoshi-datadir, and then disable it when you're ready for the full blockchain.

1171  Bitcoin / Project Development / Re: Implementing “Ultimate blockchain compression & trust-free lite nodes” on: July 03, 2013, 10:15:03 PM
I know sipa was working on an optimized ECDSA verifier that would outperform SSL about 4x.  I don't know if he finished it (and got it into Bitcoin-Qt/bitcoind yet).

But I do remember that a single core of my i5-2500K did something like 200-500 ECDSA verifications per sec.  So with 4 cores that would be like 1000-2000/s.  And probably something like 5,000/sec when using sipa's optimization. 

However, it still doesn't change the fact that it's a couple orders of magnitude slower than hashing, which can execute about 15,000,000/s on the same hardware.  In the grand scheme of things, the address-indexed DB will not consume much time when implemented properly.  Each block only updates a couple MB of DB values which should take far less than a second, even with synchronous writes.
1172  Bitcoin / Armory / Re: Armory - Discussion Thread on: July 03, 2013, 09:53:35 PM
Had a chat with "Chenda" from CBS news this morning.  Apparently she used our conversation to write the whole last half of the CBS article! 

http://www.cbsnews.com/8301-205_162-57592240/winklevoss-trust-will-test-bitcoin-security-concerns/
1173  Bitcoin / Development & Technical Discussion / Re: A bitcoin blockchain parser in a few hundred lines of C++ on: July 03, 2013, 04:39:11 PM
Worrying about block validation is a whole new world you don't want to get into.  For now you can simply leverage the fact that if the block is in the blk*.dat files it is valid along with all the transactions in it.   As TierNolan said though, you'll probably have a few orphans in there, so you probably need your scanning code to either compute longest chain (which is a good exercise in itself) or just not assume that 100% of the blocks in those files are in the main chain.

For a first exercise, you don't need a full script evaluation engine.  Just program in enough to recognize common TxOut scripts and ignore the non - std scripts.  Although in terms of computing balances, it's kind of arbitrary... You can store every TxOut in a map<OutPoint, RawTxOut> and remove them as you see TxIns that spend them.  When you're done, you should have a map containing all unspent TxOuts on the network.

Also for your analysis of looking for dormant coins being spent, look up "bitcoin days destroyed"
1174  Bitcoin / Development & Technical Discussion / Re: A bitcoin blockchain parser in a few hundred lines of C++ on: July 02, 2013, 05:16:45 PM
I just wrote a bitcoin blockchain parser in a tiny code snippet.  This is implemented as just two source files, one header and one CPP, without any external dependencies.  This code snippet does not use any memory allocation, templates, containers, STL, Boost, or anything more complicated than 'fopen, fread, fclose'.

I wrote this mostly as a learning tool so I could understand the blockchain format myself.

While writing it I ran into a couple of minor issues.  One, is that sometimes a blockchain data file will just run out of data, the rest of the file containing zeros.  I don't know if this is normal or expected, but I treat it as an end-of-file condition.  

The other is that some blocks contain less data than is indicated by the block length; meaning that after all of the transactions are read in, the file pointer has not advanced as far as the 'block length' which was indicated.  I am going to assume this is normal and expected?

This code snippet parses my copy of the blockchain (9.2gb) in roughly 95 seconds; which I figured was pretty good; though I don't know what I have to compare to.

At any rate, if anyone finds this code snippet useful or just wants to better understand the data layout of the bitcoin blockchain you can find it here:

http://codesuppository.blogspot.com/2013/07/a-bitcoin-blockchain-parser-as-single.html

Feedback, bugfixes, suggestions, all welcome.

Thanks,

John



Being someone who wrote a blockchain parser from scratch (which is what Armory does on every load/rescan), I can tell you that everything about that is normal (except for the second point below).   And 95 seconds is pretty good.  It depends what else you're doing while you're scanning.  In my case, my code scans in about 150-240 seconds depending on HDD caching, but it's also identifying all the transaction scripts in order to search for coins that are related to my wallet (so I additionally parse and identify individual scripts and then do a lookup in a set<Address160> structure to see if it's relevant).

  • The zeros at the end of files are due to pre-allocation.  Since Bitcoin-Qt version 0.8, they now always allocate blk*.dat files in chunks of 16 MB to reduce disk thrashing.  i.e. if you keep appending to a file over and over again, the OS is forced to keep reallocating that space, or fragmenting it.  By preallocating with zero-padding, the number of disk reallocations are cut down dramatically
  • I'm not sure what would cause the numBytes field to be incorrect.  How often do you see it?  Do you have an example?

I think doing exactly what you did is one of the best ways to learn the ins and outs of Bitcoin.  If you want to do more, I recommend you pick some addresses and try adding code to watch for that address and accumulate its balance and spendable UTXOs.
1175  Bitcoin / Armory / Re: Armory - Discussion Thread on: June 29, 2013, 07:53:55 PM
Just a quick comment about progress:  No, it's not done yet.  But I am finally getting some time to do it.  And I'm doing it... slowly.

Now that Armory (and Bitcoin) is getting more serious, I decided I needed to adopt a more-serious testing framework for my code.  I mean, I have tests... thousands of lines of tests.  But they're not automated, and perhaps not as exhaustive as they should be.  Now seemed like a good time to do the upgrade, because I'm really tearing things up and putting them back together.   Again, it's one of those short-term-sacrifice-for-long-term-gain things.   Also, I'm writing a lot of new code that needs to be tested, and I wanted to start doing it "The Right Way."

So I recently started playing with GoogleTest.  In usual Google fashion, what they have made is super impressive.  They have produced a versatile, cross-platform, well-documented tool that is remarkably powerful yet stupid simple to use (once you get past the compiling issues).  In a day I've been able to translate a bunch of my tests into a GoogleTest setup.  And it's pretty.  It even times things for you.



That is all.  Back to my coding cave...
1176  Bitcoin / Armory / Re: Armory - Discussion Thread on: June 29, 2013, 03:14:41 PM
[Urgent]

I ran into a problem:

I created an offline transaction, signed it and broadcasted it. At the time of the broadcasting I had some internet connection problems and now the transaction shows up in my armory client with 0 confirmations but when I go to blockchain.info e.g. it doesn't show up. (At the time I  broadcasted it bitcoin-qt did not load all blocks but in the missing blocks there were not any with my wallet related transaction information).

After that I closed armory, restarted bitcoin-qt , loaded all blocks and startet armory again. In the hop it will try to broadcast my transaction again but so far nothing has changed.

I hope my funds are not lost in limba because it is a quite large amount for me.

What can I do now to get this transaction out?

Can this be an option?
 - Re import my watchonly wallet to get the transaction sorted out and simply make a new one?

Thank you very much!!!


Relax  The coins are not lost.  There is no way to lose to coins unless you sent them to the wrong address.  Worst case, they just get a little stuck Smiley

Close Armory and delete your mempool.bin file.  In windows:

C:\Users\<username>\AppData\Roaming\Armory\mempool.bin

or Linux

/home/<username>/.armory/mempool.bin.

Then restart both Armory and Bitcoin-Qt.  That should be it.
1177  Bitcoin / Armory / Re: How to send armory signed transaction without armory? on: June 28, 2013, 10:40:05 PM
(1) If you could not successfully broadcast a transaction despite being online, I need your help.  I've heard about a couple other people with this problem, and I need to narrow it down.  I suspect it may have to do with the more-recent versions of Bitcoin-Qt not liking certain signatures made by older versions of Armory.  If you have any more information about why it's not working, please let me know.  If it's that Armory can't even synchronize at all... well I know about that problem already (but since you got an unsigned transaction to be able to be signed, I suspect you did synchronize properly...)


(2) If you switch Armory to "Expert" usermode (might be in "Advanced" too, I don't know), on the window where you would normally broadcast your transaction, there's a button that says "Copy Final Tx (Hex)".  This should give you the raw transaction that can be plugged into any broadcast utility.  You're right that the raw text shown in the text box is not compatible with anything else, but the raw hex should be.  Let me know if that doesn't work.

1178  Bitcoin / Development & Technical Discussion / Re: Tying labels to individual tx's rather than just addresses on: June 28, 2013, 06:21:51 AM
Armory does exactly this.  It implements "comments" individually for addresses and transactions.  On the main window, you have a list of transactions.  You can double-click them and individually set the comment for that transaction.  If there is no transaction comment (tied to the tx ID), then it displays the address comment instead.  You can modify the address comments in the wallet properties address list the same way.
1179  Bitcoin / Development & Technical Discussion / Re: Reducing the chance of random reversal on: June 27, 2013, 11:18:17 PM
Oh I missed the part about no tx on each mini block.  So all this does is effectively eliminates the probability of one-block reversals.  Hmm, I'm not so much in favor of this direction.

My only point was that as your average confirm time moves closer to the header propagation time, you're dramatically increasing time spent by miners mining on forks.  Sure you don't get one-regular-confirmation reversals, but you'll end up with a totally fragmented network all working on different chains because most of the network can't get the longest chain in time to switch to it.    It may be that the header propagation times are, in fact, much smaller than 10s, in which case it wouldn't be so bad for the majority of the network. 

But consider a miner on a slow, high-latency connection.  If they have 10s latency to receive data, they would probably spend >50% of their time mining on forks.  Basically, they wouldn't be able to mine. 
1180  Bitcoin / Development & Technical Discussion / Re: Reducing the chance of random reversal on: June 27, 2013, 10:10:37 PM
I haven't fully thought it through, but don't forget that although a fork only takes 10 seconds to resolve in your scheme, forks happen a whole ton more often.  I don't know what all the terms add up to, but it wouldn't surprise me if this turned out to cause miners to spend more time mining on forks than less.  Especially as you lower that average-time-between-blocks closer to the average header propagation time.  I don't know what propagation times are, but if they were on average 30s to reach 99% of the network, you could have X% (X>10) of the network always mining on [soon-to-be] dead chains.    

At the very least it would lower the effective hashrate, making the network more vulnerable.  If you have 100 units of hashing power building one blockchain, an attacker needs 101 to outpace it.  If you have 4 groups of 25 units each mining on different forks, an attacker only need 26 to outpace it, even though the total network hashrate is the same.

Satoshi picked 10 minutes, because he was concerned about the network dynamics of slow block propagation and what dragons it would create.  He picked 10 minutes to be conservative, knowing that if it's long enough to absolutely be sure that propagation can happen reliably and consistently.  Though I don't have any links off-hand to previous discussions about that.  I'd be curious to re-read it myself.

Though, I'm going off on a tangent: your idea doesn't rely on 10s... it can be calibrated to whatever is "safe."  I do like the gist of the idea, since we already know that safety is basically a asymptotically increasing as the number of confirmations goes up, so if you can get the first couple confirmations out the door immediately 64 mini-confirmations would most definitely be better than 1 regular confirmation.
Pages: « 1 ... 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 [59] 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 186 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!