예제 #1
0
        public void CanReIndex()
        {
            var source = new BlockStore(@"data\blocks", Network.Main);
            var store  = CreateBlockStore("CanReIndexFolder");

            store.AppendAll(source.Enumerate(false).Take(100).Select(b => b.Item));


            var test      = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
            var reIndexed = test.ReIndex();

            Assert.Equal(100, reIndexed);
            int i = 0;

            foreach (var b in store.Enumerate(true))
            {
                var result = test.Get(b.Item.GetHash());
                Assert.Equal(result.GetHash(), b.Item.GetHash());
                i++;
            }
            Assert.Equal(100, i);

            var last = source.Enumerate(false).Skip(100).FirstOrDefault();

            store.Append(last.Item);

            reIndexed = test.ReIndex();
            Assert.Equal(1, reIndexed);

            reIndexed = test.ReIndex();
            Assert.Equal(0, reIndexed);
        }
예제 #2
0
        public void RunFullBlockTest()
        {
            var generator = new FullBlockTestGenerator(Network.Main);

            ValidationState validation = new ValidationState(Network.Main);
            validation.CheckMerkleRoot = false;
            validation.CheckProofOfWork = false;

            var scan =
                new ScanState(new PubKeyHashScanner(generator.CoinbaseKey.PubKey.ID),
                        new Chain(),
                        new Account(),
                        0);
            scan.CheckDoubleSpend = true;

            var mainChain = new Chain(Network.Main);
            var indexed = new IndexedBlockStore(new InMemoryNoSqlRepository(), CreateBlockStore());
            indexed.Put(Network.Main.GetGenesis());
            foreach(var test in generator.GetBlocksToTest(true, true).list.OfType<BlockAndValidity>())
            {
                indexed.Put(test.block);
                mainChain.GetOrAdd(test.block.Header);
                Assert.True(scan.Process(mainChain, indexed) == test.connects);
                //if(!)
                //{
                //	Assert.True(test.throwsException);
                //}
                Assert.Equal(test.heightAfterBlock, scan.Chain.Height);
                Assert.Equal(test.hashChainTipAfterBlock, scan.Chain.Tip.HashBlock);
                mainChain.SetTip(scan.Chain.Tip);
            }
        }
예제 #3
0
 public ScannerTester(string folderName)
 {
     TestUtils.EnsureNew(folderName);
     _FolderName = folderName;
     string index = Path.Combine(folderName, "Index.dat");
     _Index = new IndexedBlockStore(new SQLiteNoSqlRepository(index, true), new BlockStore(folderName, Network.TestNet));
 }
예제 #4
0
        /// <summary>
        /// Method populates index for faster block access.
        /// </summary>
        public void PrepareIndex(string datapath)
        {
            BlockStore store = new BlockStore(datapath, Network.Main);

            index = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
            index.ReIndex();
        }
예제 #5
0
        public void RunFullBlockTest()
        {
            var generator = new FullBlockTestGenerator(Network.Main);

            ValidationState validation = new ValidationState(Network.Main);

            validation.CheckMerkleRoot  = false;
            validation.CheckProofOfWork = false;

            var scan =
                new ScanState(new PubKeyHashScanner(generator.CoinbaseKey.PubKey.ID),
                              new Chain(),
                              new Account(),
                              0);

            scan.CheckDoubleSpend = true;

            var mainChain = new Chain(Network.Main);
            var indexed   = new IndexedBlockStore(new InMemoryNoSqlRepository(), CreateBlockStore());

            indexed.Put(Network.Main.GetGenesis());
            foreach (var test in generator.GetBlocksToTest(true, true).list.OfType <BlockAndValidity>())
            {
                indexed.Put(test.block);
                mainChain.TrySetTip(test.block.Header);
                Assert.True(scan.Process(mainChain, indexed) == test.connects);
                //if(!)
                //{
                //	Assert.True(test.throwsException);
                //}
                Assert.Equal(test.heightAfterBlock, scan.Chain.Height);
                Assert.Equal(test.hashChainTipAfterBlock, scan.Chain.Tip.HashBlock);
                mainChain.SetTip(scan.Chain.Tip);
            }
        }
예제 #6
0
        public ScannerTester(string folderName)
        {
            TestUtils.EnsureNew(folderName);
            _FolderName = folderName;
            string index = Path.Combine(folderName, "Index.dat");

            _Index = new IndexedBlockStore(new SQLiteNoSqlRepository(index, true), new BlockStore(folderName, Network.TestNet));
        }
예제 #7
0
        public void BenchmarkBlockIndexing()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            BlockStore        store   = new BlockStore(this.BlockStoreFolder, Network.PurpleMain);
            IndexedBlockStore indexed = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);

            indexed.ReIndex();
            watch.Stop();
            var time = watch.Elapsed;
        }
예제 #8
0
        public void BenchmarkBlockIndexing()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            BlockStore        store   = new BlockStore(@"E:\Bitcoin\blocks\", Network.Main);
            IndexedBlockStore indexed = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);

            indexed.ReIndex();
            watch.Stop();
            var time = watch.Elapsed;
        }
예제 #9
0
		public BlockRepository(IndexedBlockStore blockStore,
							   IndexedBlockStore headerStore)
		{
			if(blockStore == null)
				throw new ArgumentNullException("blockStore");
			if(headerStore == null)
				throw new ArgumentNullException("headerStore");
			if(blockStore == headerStore)
				throw new ArgumentException("The two stores should be different");
			_BlockStore = blockStore;
			_HeaderStore = headerStore;
		}
예제 #10
0
        public void IndexTheFullChain()
        {
            var store      = new BlockStore(TestDataLocations.BlockFolderLocation, Network.StratisMain);
            var indexStore = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
            var reindexed  = indexStore.ReIndex();

            Assert.Equal(103952, reindexed);

            ConcurrentChain chain = store.GetChain();

            foreach (ChainedBlock item in chain.ToEnumerable(false))
            {
                Block block = indexStore.Get(item.HashBlock);
                Assert.True(BlockValidator.CheckBlock(block));
            }
        }
예제 #11
0
        public void CanIndexBlock()
        {
            IndexedBlockStore index = CreateIndexedStore();

            foreach (StoredBlock block in StoredBlock.EnumerateFile(TestDataLocations.DataBlockFolder("blk0001.dat"), network:Network.StratisMain).Take(50))
            {
                index.Put(block.Item);
            }

            Block genesis = index.Get(uint256.Parse("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af"));

            Assert.NotNull(genesis);

            Block invalidBlock = index.Get(uint256.Parse("0x0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972ae"));

            Assert.Null(invalidBlock);
        }
예제 #12
0
        public static void CanCalculatePowPosCorrectly()
        {
            var store      = new BlockStore(TestDataLocations.BlockFolderLocation, Network.Main);
            var chain      = store.GetChain();
            var stakeChain = new MemoryStakeChain(Network.Main);
            var indexStore = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
            var reindexed  = indexStore.ReIndex();

            Assert.Equal(reindexed, 103952);

            foreach (var chainedBlock in chain.EnumerateAfter(chain.Genesis))
            {
                var block      = indexStore.Get(chainedBlock.HashBlock);
                var blockstake = new BlockStake(block);
                stakeChain.Set(chainedBlock.HashBlock, blockstake);

                Assert.True(stakeChain.CheckPowPosAndTarget(chainedBlock, blockstake, Network.Main));
            }
        }
예제 #13
0
        public void CanCalculateDifficulty()
        {
            var histories = File.ReadAllLines(TestDataLocations.DataFolder(@"targethistory.csv"));

            var store = new BlockStore(TestDataLocations.BlockFolderLocation, Network.Main);
            // todo: load the chain with a header only file
            ConcurrentChain chain = store.GetChain();

            var stakeChain = new MemoryStakeChain(Network.Main);
            var indexStore = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
            var reindexed  = indexStore.ReIndex();

            Assert.Equal(reindexed, 103952);

            var lastIndex = 0;

            foreach (var history in histories)
            {
                var height         = int.Parse(history.Split(',')[0]);
                var expectedTarget = new Target(new BigInteger(history.Split(',')[1].Trim(), 10));

                var chainedBlock = chain.GetBlock(height);
                for (int i = height; i > lastIndex; i--)
                {
                    var g     = chain.GetBlock(i);
                    var block = indexStore.Get(g.HashBlock);
                    stakeChain.Set(g.HashBlock, new BlockStake(block));
                }
                lastIndex = height;

                Assert.Equal(expectedTarget, chainedBlock.Header.Bits);
                var target = stakeChain.GetWorkRequired(chainedBlock, stakeChain.Get(chainedBlock.HashBlock), Network.Main.Consensus);
                //var target = chain.GetWorkRequired(Network.Main, height);
                Assert.Equal(expectedTarget, target);
            }
        }
예제 #14
0
        public static void Play()
        {
            //1,132

            //NodeServer server = new NodeServer(Network.Main);
            //server.RegisterPeerTableRepository(new SqLitePeerTableRepository("PeerCachePlay"));
            //server.BuildChain(new StreamObjectStream<ChainChange>(File.Open("MainChain.dat", FileMode.OpenOrCreate)));

            var from = new DateTimeOffset(new DateTime(2012, 12, 1));
            var to = new DateTimeOffset(new DateTime(2013, 1, 20));

            var chain = new Chain(new StreamObjectStream<ChainChange>(File.Open("MainChain.dat", FileMode.OpenOrCreate)));
            var blocks =
                chain.ToEnumerable(false)
                    .SkipWhile(c => c.Header.BlockTime < from)
                    .TakeWhile(c => c.Header.BlockTime < to)
                    .ToArray();

            //index.ReIndex();
            //Console.WriteLine("");

            BlockStore store = new BlockStore("E:\\Bitcoin\\blocks", Network.Main);
            IndexedBlockStore index = new IndexedBlockStore(new SQLiteNoSqlRepository("PlayIndex"), store);
            var target = Money.Parse("1100");
            var margin = Money.Parse("1");
            var dest = Network.CreateFromBase58Data<BitcoinAddress>("1FrtkNXastDoMAaorowys27AKQERxgmZjY");
            var en = new CultureInfo("en-US");

            FileStream fs = File.Open("logs", FileMode.Create);
            var writer = new StreamWriter(fs);
            writer.WriteLine("time,height,txid,value");

            var lines = from header in blocks
                        let block = index.Get(header.HashBlock)
                        from tx in block.Transactions
                        from txout in tx.Outputs
                        //where txout.ScriptPubKey.GetDestination() == dest.ID
                        where target - margin < txout.Value && txout.Value < target + margin
                        select new
                        {
                            Block = block,
                            Height = header.Height,
                            Transaction = tx,
                            TxOut = txout
                        };
            foreach(var line in lines)
            {
                writer.WriteLine(
                    line.Block.Header.BlockTime.ToString(en) + "," +
                    line.Height + "," +
                    line.Transaction.GetHash() + "," +
                    line.TxOut.Value.ToString());
            }
            writer.Flush();
            Process.Start(@"E:\Chocolatey\lib\notepadplusplus.commandline.6.4.5\tools\notepad++.exe", "\"" + new FileInfo(fs.Name).FullName + "\"");

            //foreach(var b in blocks)
            //{
            //	var block = index.Get(b.HashBlock);
            //	foreach(var tx in block.Transactions)
            //	{
            //		foreach(var txout in tx.Outputs)
            //		{
            //			var pa = new PayToPubkeyHashTemplate()
            //					.ExtractScriptPubKeyParameters(txout.ScriptPubKey);
            //			if(pa != null && pa == dest.ID)
            //			{
            //				if(target - margin < txout.Value && txout.Value < target + margin)
            //				{
            //					writer.WriteLine(b.Header.BlockTime.ToString(en) + "," + b.Height + "," + tx.GetHash() + "," + txout.Value.ToString());
            //				}
            //			}
            //		}
            //	}

            //}

            //They were purchased anonymously at a restaurant halfway between Sandwich, IL, and Chicago, in Naperville, IL, about the second week of December, 2012. Taxing my memory, the total was 1,132 + x(single digit).xxx... and immediately put in a freshly created InstaWallet bitcoin wallet. A couple/three days later I split the three accounts up into 1,000, 132, and x.xxx... wallets, always using InstaWallet while in my possession. Hope that helps with your plans.

            //var txt = File.ReadAllText("data/difficultyhistory.csv");
            //var lines = txt.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
            //StringBuilder builder = new StringBuilder();
            //foreach(var line in lines)
            //{
            //	var fields = line.Split(',');
            //	builder.AppendLine(fields[0] + "," + fields[2]);
            //}
            //File.WriteAllText("targethistory.csv",builder.ToString());
            ////PlaySplit();
            //var oo = new PubKey(TestUtils.ParseHex("02bbc9fccbe03de928fc66fcd176fbe69d3641677970c6f8d558aa72f72e35e0cb")).GetAddress(Network.TestNet);
            //RPCClient client = RPCClientTests.CreateRPCClient();

            ////https://tpfaucet.appspot.com/
            //var scan = new Key(TestUtils.ParseHex("cc411aab02edcd3bccf484a9ba5280d4a774e6f81eac8ebec9cb1c2e8f73020a"));
            //var addr = new BitcoinStealthAddress("waPYjXyrTrvXjZHmMGdqs9YTegpRDpx97H5G3xqLehkgyrrZKsxGCmnwKexpZjXTCskUWwYywdUvrZK7L2vejeVZSYHVns61gm8VfU", Network.TestNet);

            //var sender = new BitcoinSecret("cRjSUV1LqN2F8MsGnLE2JKfCP75kbWGFRroNQeXHC429jqVFgmW3", Network.TestNet);

            //using(var fs = File.Open("Data.txt", FileMode.Create))
            //{
            //	StreamWriter writer = new StreamWriter(fs);
            //	foreach(var c in client.ListUnspent())
            //	{
            //		var ephem = new Key();
            //		writer.WriteLine("---");
            //		writer.WriteLine("Ephem Private key : " + Encoders.Hex.EncodeData(ephem.ToBytes()));
            //		Transaction tx = new Transaction();
            //		tx.Version = 1;
            //		tx.AddInput(new TxIn(c.OutPoint));
            //		var pay = addr.CreatePayment(ephem);

            //		writer.WriteLine("Metadata hash : " + pay.Metadata.Hash);
            //		writer.WriteLine("Metadata script : " + pay.Metadata.Script);
            //		writer.WriteLine("Metadata Nonce : " + pay.Metadata.Nonce);
            //		writer.WriteLine("Metadata Ephem Key : " + pay.Metadata.EphemKey.ToHex());

            //		pay.AddToTransaction(tx, c.Amount);

            //		tx.SignAll(sender);

            //		client.SendRawTransaction(tx);

            //		fs.Flush();
            //	}

            //}

            //var p = new PubKey(Encoders.Hex.DecodeData("03b4e5d3cf889840c75f0dd02ebda946151bf37e56cb888c6002c2ae5288e56de7"));
            //var o = Network.CreateFromBase58Data("mvXf4sF4C1w5KgQyasbEWxqVyqbLNtVdnY");
            //var sender = new BitcoinSecret("cRjSUV1LqN2F8MsGnLE2JKfCP75kbWGFRroNQeXHC429jqVFgmW3", Network.TestNet).Key;
            ////var addr = secret.Key.PubKey.GetAddress(Network.TestNet); //mwdJkHRNJi1fEwHBx6ikWFFuo2rLBdri2h
            //
            //var receiver = new BitcoinStealthAddress("waPV5rHToBq3NoR7y5J9UdE7aUbuqJybNpE88Dve7WgWhEfvMrcuaSvF6tSQ3Fbe8dErL6ks8byJPcp3QCK2HHviGCSjg42VgMAPJb", Network.TestNet);

            //Key ephemKey = new Key(Encoders.Hex.DecodeData("9daed68ad37754305e82740a6252cf80765c36d29a55158b1a19ed29914f0cb1"));
            //var ephemKeyStr = Encoders.Hex.EncodeData(ephemKey.ToBytes());
            //var scanStr = Encoders.Hex.EncodeData(receiver.ScanPubKey.ToBytes());
            //var spendStr = Encoders.Hex.EncodeData(receiver.SpendPubKeys[0].ToBytes());

            //var payment = receiver.CreatePayment(ephemKey);
            //var tx = new Transaction();
            //tx.Version = 1;
            //tx.Inputs.Add(new TxIn(new OutPoint(new uint256("d65e2274f6fde9515a35655d54e79243d5a17355f6943d6c16a63083a8769ea3"), 1)));

            //payment.AddToTransaction(tx, Money.Parse("0.51"));

            //tx.Inputs[0].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptPubKey(sender.PubKey.GetAddress(Network.TestNet));
            //var hash = tx.Inputs[0].ScriptSig.SignatureHash(tx, 0, SigHash.All);
            //var sig = sender.Sign(hash);
            //tx.Inputs[0].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptSig(new TransactionSignature(sig, SigHash.All), sender.PubKey);

            //var result = Script.VerifyScript(tx.Inputs[0].ScriptSig, new Script("OP_DUP OP_HASH160 b0b594bb2d2ca509b817f27e9280f6471807af26 OP_EQUALVERIFY OP_CHECKSIG"), tx, 0);

            //var bytes = Encoders.Hex.EncodeData(tx.ToBytes());
            //var client = new NodeServer(Network.TestNet);

            //var node = client.GetNodeByEndpoint(new IPEndPoint(IPAddress.Parse("95.85.39.28"), 18333));
            //node.VersionHandshake();
            //node.SendMessage(new TxPayload(tx));
            ////var store = new BlockStore(@"E:\Bitcoin\blocks", Network.Main);
            ////foreach(var un in store.EnumerateFolder())
            ////{
            //	var expectedSize = un.Header.ItemSize;
            //	var actualSize = un.Item.GetSerializedSize();
            //}

            //var test = new IndexedBlockStore(new SQLiteNoSqlRepository("Play", true), new BlockStore(@"E:\Bitcoin\blocks", Network.Main));
            //test.ReIndex();
            //var i = 0;
            //Stopwatch watch = new Stopwatch();
            //watch.Start();
            //foreach(var b in test.Store.Enumerate(false, new DiskBlockPosRange(new DiskBlockPos(137,0))).Take(144))
            //{
            //	i++;
            //}
            //watch.Stop();
        }
예제 #15
0
        public void CanReIndex()
        {
            var source = new BlockStore(@"data\blocks", Network.Main);
            var store = CreateBlockStore("CanReIndexFolder");
            store.AppendAll(source.Enumerate(false).Take(100).Select(b => b.Item));

            var test = new IndexedBlockStore(new SQLiteNoSqlRepository("CanReIndex", true), store);
            var reIndexed = test.ReIndex();
            Assert.Equal(100, reIndexed);
            int i = 0;
            foreach(var b in store.Enumerate(true))
            {
                var result = test.Get(b.Item.GetHash());
                Assert.Equal(result.GetHash(), b.Item.GetHash());
                i++;
            }
            Assert.Equal(100, i);

            var last = source.Enumerate(false).Skip(100).FirstOrDefault();
            store.Append(last.Item);

            reIndexed = test.ReIndex();
            Assert.Equal(1, reIndexed);

            reIndexed = test.ReIndex();
            Assert.Equal(0, reIndexed);
        }
예제 #16
0
 public WalletTester([CallerMemberName] string name = null)
 {
     _Index = RepositoryTests.CreateIndexedStore(name);
     _Index.Put(Network.Main.GetGenesis());
 }
예제 #17
0
        public static void Play()
        {
            var tx2 = new Transaction("010000000188932931d6bc23d3182183ab5e9707980ab4aaf9db3c6d3be42e5c0ce783b0ba00000000844730440220100aaa46e8a4f9d4589f935f5457f263a911f3712ee50688732c1274face6bb30220155b48760fd6ffbc0842761db03d824954567e8cd499883318d1f1c705f7d4d7012103dccb6bd324ae3c60afb85d9a0e5f300284faf2d71c40dbb7732d8fa79ee930f71976a914edc80be0e4f342a54a4fbe6e31e8e58b6849972a88acffffffff02204e0000000000001976a91430a5d35558ade668b8829a2a0f60a3f10358327e88ac70110100000000001976a914edc80be0e4f342a54a4fbe6e31e8e58b6849972a88ac00000000");

            var oo = tx2.GetHash();


            var scriptPubKey             = new Script(Encoders.Hex.DecodeData("a91467c205a82218e3b1327095f1e10dd676c6ce09df87"));
            ScriptEvaluationContext eval = new ScriptEvaluationContext();

            var result = eval.VerifyScript(tx2.Inputs[0].ScriptSig, scriptPubKey, tx2, 0);



            CancellationTokenSource s1 = new CancellationTokenSource();
            CancellationTokenSource s2 = new CancellationTokenSource(TimeSpan.FromSeconds(1));

            try
            {
                Thread.Sleep(3000);
                CancellationTokenSource.CreateLinkedTokenSource(s1.Token, s2.Token).Token.ThrowIfCancellationRequested();
            }
            catch (OperationCanceledException ex)
            {
                bool a = s2.Token == ex.CancellationToken;
            }

            //1,132

            //NodeServer server = new NodeServer(Network.Main);
            //server.RegisterPeerTableRepository(new SqLitePeerTableRepository("PeerCachePlay"));
            //server.BuildChain(new StreamObjectStream<ChainChange>(File.Open("MainChain.dat", FileMode.OpenOrCreate)));

            var from = new DateTimeOffset(new DateTime(2012, 12, 1));
            var to   = new DateTimeOffset(new DateTime(2013, 1, 20));

            var chain  = new Chain(new StreamObjectStream <ChainChange>(File.Open("MainChain.dat", FileMode.OpenOrCreate)));
            var blocks =
                chain.ToEnumerable(false)
                .SkipWhile(c => c.Header.BlockTime < from)
                .TakeWhile(c => c.Header.BlockTime < to)
                .ToArray();

            //index.ReIndex();
            //Console.WriteLine("");


            BlockStore        store = new BlockStore("E:\\Bitcoin\\blocks", Network.Main);
            IndexedBlockStore index = new IndexedBlockStore(new SQLiteNoSqlRepository("PlayIndex"), store);
            var target = Money.Parse("1100");
            var margin = Money.Parse("1");
            var dest   = Network.CreateFromBase58Data <BitcoinAddress>("1FrtkNXastDoMAaorowys27AKQERxgmZjY");
            var en     = new CultureInfo("en-US");

            FileStream fs     = File.Open("logs", FileMode.Create);
            var        writer = new StreamWriter(fs);

            writer.WriteLine("time,height,txid,value");

            var lines = from header in blocks
                        let block = index.Get(header.HashBlock)
                                    from tx in block.Transactions
                                    from txout in tx.Outputs
                                    //where txout.ScriptPubKey.GetDestination() == dest.ID
                                    where target - margin < txout.Value && txout.Value < target + margin
                                    select new
            {
                Block       = block,
                Height      = header.Height,
                Transaction = tx,
                TxOut       = txout
            };

            foreach (var line in lines)
            {
                writer.WriteLine(
                    line.Block.Header.BlockTime.ToString(en) + "," +
                    line.Height + "," +
                    line.Transaction.GetHash() + "," +
                    line.TxOut.Value.ToString());
            }
            writer.Flush();
            Process.Start(@"E:\Chocolatey\lib\notepadplusplus.commandline.6.4.5\tools\notepad++.exe", "\"" + new FileInfo(fs.Name).FullName + "\"");

            //foreach(var b in blocks)
            //{
            //	var block = index.Get(b.HashBlock);
            //	foreach(var tx in block.Transactions)
            //	{
            //		foreach(var txout in tx.Outputs)
            //		{
            //			var pa = new PayToPubkeyHashTemplate()
            //					.ExtractScriptPubKeyParameters(txout.ScriptPubKey);
            //			if(pa != null && pa == dest.ID)
            //			{
            //				if(target - margin < txout.Value && txout.Value < target + margin)
            //				{
            //					writer.WriteLine(b.Header.BlockTime.ToString(en) + "," + b.Height + "," + tx.GetHash() + "," + txout.Value.ToString());
            //				}
            //			}
            //		}
            //	}

            //}

            //They were purchased anonymously at a restaurant halfway between Sandwich, IL, and Chicago, in Naperville, IL, about the second week of December, 2012. Taxing my memory, the total was 1,132 + x(single digit).xxx... and immediately put in a freshly created InstaWallet bitcoin wallet. A couple/three days later I split the three accounts up into 1,000, 132, and x.xxx... wallets, always using InstaWallet while in my possession. Hope that helps with your plans.



            //var txt = File.ReadAllText("data/difficultyhistory.csv");
            //var lines = txt.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries);
            //StringBuilder builder = new StringBuilder();
            //foreach(var line in lines)
            //{
            //	var fields = line.Split(',');
            //	builder.AppendLine(fields[0] + "," + fields[2]);
            //}
            //File.WriteAllText("targethistory.csv",builder.ToString());
            ////PlaySplit();
            //var oo = new PubKey(TestUtils.ParseHex("02bbc9fccbe03de928fc66fcd176fbe69d3641677970c6f8d558aa72f72e35e0cb")).GetAddress(Network.TestNet);
            //RPCClient client = RPCClientTests.CreateRPCClient();

            ////https://tpfaucet.appspot.com/
            //var scan = new Key(TestUtils.ParseHex("cc411aab02edcd3bccf484a9ba5280d4a774e6f81eac8ebec9cb1c2e8f73020a"));
            //var addr = new BitcoinStealthAddress("waPYjXyrTrvXjZHmMGdqs9YTegpRDpx97H5G3xqLehkgyrrZKsxGCmnwKexpZjXTCskUWwYywdUvrZK7L2vejeVZSYHVns61gm8VfU", Network.TestNet);

            //var sender = new BitcoinSecret("cRjSUV1LqN2F8MsGnLE2JKfCP75kbWGFRroNQeXHC429jqVFgmW3", Network.TestNet);


            //using(var fs = File.Open("Data.txt", FileMode.Create))
            //{
            //	StreamWriter writer = new StreamWriter(fs);
            //	foreach(var c in client.ListUnspent())
            //	{
            //		var ephem = new Key();
            //		writer.WriteLine("---");
            //		writer.WriteLine("Ephem Private key : " + Encoders.Hex.EncodeData(ephem.ToBytes()));
            //		Transaction tx = new Transaction();
            //		tx.Version = 1;
            //		tx.AddInput(new TxIn(c.OutPoint));
            //		var pay = addr.CreatePayment(ephem);

            //		writer.WriteLine("Metadata hash : " + pay.Metadata.Hash);
            //		writer.WriteLine("Metadata script : " + pay.Metadata.Script);
            //		writer.WriteLine("Metadata Nonce : " + pay.Metadata.Nonce);
            //		writer.WriteLine("Metadata Ephem Key : " + pay.Metadata.EphemKey.ToHex());

            //		pay.AddToTransaction(tx, c.Amount);

            //		tx.SignAll(sender);

            //		client.SendRawTransaction(tx);

            //		fs.Flush();
            //	}

            //}

            //var p = new PubKey(Encoders.Hex.DecodeData("03b4e5d3cf889840c75f0dd02ebda946151bf37e56cb888c6002c2ae5288e56de7"));
            //var o = Network.CreateFromBase58Data("mvXf4sF4C1w5KgQyasbEWxqVyqbLNtVdnY");
            //var sender = new BitcoinSecret("cRjSUV1LqN2F8MsGnLE2JKfCP75kbWGFRroNQeXHC429jqVFgmW3", Network.TestNet).Key;
            ////var addr = secret.Key.PubKey.GetAddress(Network.TestNet); //mwdJkHRNJi1fEwHBx6ikWFFuo2rLBdri2h
            //
            //var receiver = new BitcoinStealthAddress("waPV5rHToBq3NoR7y5J9UdE7aUbuqJybNpE88Dve7WgWhEfvMrcuaSvF6tSQ3Fbe8dErL6ks8byJPcp3QCK2HHviGCSjg42VgMAPJb", Network.TestNet);

            //Key ephemKey = new Key(Encoders.Hex.DecodeData("9daed68ad37754305e82740a6252cf80765c36d29a55158b1a19ed29914f0cb1"));
            //var ephemKeyStr = Encoders.Hex.EncodeData(ephemKey.ToBytes());
            //var scanStr = Encoders.Hex.EncodeData(receiver.ScanPubKey.ToBytes());
            //var spendStr = Encoders.Hex.EncodeData(receiver.SpendPubKeys[0].ToBytes());

            //var payment = receiver.CreatePayment(ephemKey);
            //var tx = new Transaction();
            //tx.Version = 1;
            //tx.Inputs.Add(new TxIn(new OutPoint(new uint256("d65e2274f6fde9515a35655d54e79243d5a17355f6943d6c16a63083a8769ea3"), 1)));

            //payment.AddToTransaction(tx, Money.Parse("0.51"));

            //tx.Inputs[0].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptPubKey(sender.PubKey.GetAddress(Network.TestNet));
            //var hash = tx.Inputs[0].ScriptSig.SignatureHash(tx, 0, SigHash.All);
            //var sig = sender.Sign(hash);
            //tx.Inputs[0].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptSig(new TransactionSignature(sig, SigHash.All), sender.PubKey);

            //var result = Script.VerifyScript(tx.Inputs[0].ScriptSig, new Script("OP_DUP OP_HASH160 b0b594bb2d2ca509b817f27e9280f6471807af26 OP_EQUALVERIFY OP_CHECKSIG"), tx, 0);

            //var bytes = Encoders.Hex.EncodeData(tx.ToBytes());
            //var client = new NodeServer(Network.TestNet);

            //var node = client.GetNodeByEndpoint(new IPEndPoint(IPAddress.Parse("95.85.39.28"), 18333));
            //node.VersionHandshake();
            //node.SendMessage(new TxPayload(tx));
            ////var store = new BlockStore(@"E:\Bitcoin\blocks", Network.Main);
            ////foreach(var un in store.EnumerateFolder())
            ////{
            //	var expectedSize = un.Header.ItemSize;
            //	var actualSize = un.Item.GetSerializedSize();
            //}

            //var test = new IndexedBlockStore(new SQLiteNoSqlRepository("Play", true), new BlockStore(@"E:\Bitcoin\blocks", Network.Main));
            //test.ReIndex();
            //var i = 0;
            //Stopwatch watch = new Stopwatch();
            //watch.Start();
            //foreach(var b in test.Store.Enumerate(false, new DiskBlockPosRange(new DiskBlockPos(137,0))).Take(144))
            //{
            //	i++;
            //}
            //watch.Stop();
        }
예제 #18
0
		public void BenchmarkBlockIndexing()
		{
			Stopwatch watch = new Stopwatch();
			watch.Start();
			BlockStore store = new BlockStore(@"E:\Bitcoin\blocks\", Network.Main);
			IndexedBlockStore indexed = new IndexedBlockStore(new InMemoryNoSqlRepository(), store);
			indexed.ReIndex();
			watch.Stop();
			var time = watch.Elapsed;
		}