Skip to content

Commit

Permalink
Making BitcoinCore classes obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jul 23, 2018
1 parent 39d9e99 commit c7080cc
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 9 deletions.
6 changes: 0 additions & 6 deletions NBitcoin.Tests/script_tests.cs
Expand Up @@ -254,12 +254,6 @@ public void PayToPubkeyHashTemplateDoNotCrashOnInvalidSig()
[Trait("UnitTest", "UnitTest")]
public void CanCompressScript()
{
//Testing some strange key
var txx = new Transaction("01000000016244e8baca71666b77677882f3451e9a83b2b9e5fec71128e6cfb7c95e04297700000000494830450220572d08a87f14917a016a8c70e473162a0edc5bc099f4395f4aaa1141c6800b07022100e7e3dbe9885c0e78725907a9b0cdc6083a3460735753686567fd8b68a0d3267f01ffffffff025e489800000000001976a9145ea25a1d1791557fe831b139fd1c7b089121919a88ac010000000000000043410431415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446ac00000000");
var coins = new BitcoinCore.Coins(txx, 0);
BitcoinSerializableExtensions.Clone(coins);
/////

var key = new Key(true);

//Pay to pubkey hash (encoded as 21 bytes)
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/BlockStore.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class BlockStore : Store<StoredBlock, Block>
{
public const int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
Expand Down
3 changes: 3 additions & 0 deletions NBitcoin/BitcoinCore/BlockUndo.cs
Expand Up @@ -14,6 +14,7 @@ namespace NBitcoin.BitcoinCore
* last output of the affected transaction, its metadata as well
* (coinbase or not, height, transaction version)
*/
[Obsolete]
public class TxInUndo : IBitcoinSerializable
{
public TxInUndo()
Expand Down Expand Up @@ -111,6 +112,7 @@ public void ReadWrite(BitcoinStream stream)
public class TxUndo : IBitcoinSerializable
{
// undo information for all txins
#pragma warning disable CS0612 // Type or member is obsolete
List<TxInUndo> vprevout = new List<TxInUndo>();
public List<TxInUndo> Prevout
{
Expand All @@ -119,6 +121,7 @@ public List<TxInUndo> Prevout
return vprevout;
}
}
#pragma warning restore CS0612 // Type or member is obsolete

#region IBitcoinSerializable Members

Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/BlockUndoStore.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class BlockUndoStore : Store<StoredItem<BlockUndo>, BlockUndo>
{
public BlockUndoStore(string folder, Network network)
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/CachedBlockProvider.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class CachedBlockProvider : IBlockProvider
{
public CachedBlockProvider(IBlockProvider inner)
Expand Down
5 changes: 5 additions & 0 deletions NBitcoin/BitcoinCore/Coins.cs
Expand Up @@ -3,6 +3,7 @@

namespace NBitcoin.BitcoinCore
{
[System.Obsolete]
public class Coins : IBitcoinSerializable
{
// whether transaction is a coinbase
Expand Down Expand Up @@ -83,6 +84,7 @@ private void Cleanup()

public int UnspentCount => Outputs.Count(c => !IsNull(c));

#pragma warning disable CS0612 // Type or member is obsolete
public bool Spend(int position, out TxInUndo undo)
{
undo = null;
Expand All @@ -91,6 +93,7 @@ public bool Spend(int position, out TxInUndo undo)
if(IsNull(Outputs[position]))
return false;
undo = new TxInUndo(Outputs[position].Clone());
#pragma warning restore CS0612 // Type or member is obsolete
Outputs[position] = NullTxOut;
Cleanup();
if(IsEmpty)
Expand All @@ -104,7 +107,9 @@ public bool Spend(int position, out TxInUndo undo)

public bool Spend(int position)
{
#pragma warning disable CS0612 // Type or member is obsolete
TxInUndo undo;
#pragma warning restore CS0612 // Type or member is obsolete
return Spend(position, out undo);
}

Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/CoinsView.cs
Expand Up @@ -7,6 +7,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class CoinsView
{
public CoinsView(NoSqlRepository index)
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/DataDirectory.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class DataDirectory
{
private readonly string _Folder;
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/IBlockProvider.cs
Expand Up @@ -6,6 +6,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public interface IBlockProvider
{
Block GetBlock(uint256 id, List<byte[]> searchedData);
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/IndexedBlockStore.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class IndexedBlockStore : IndexedStore<StoredBlock, Block>, IBlockProvider
{
private readonly BlockStore _Store;
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/IndexedBlockUndoStore.cs
Expand Up @@ -7,6 +7,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public class IndexedBlockUndoStore : IndexedStore<StoredItem<BlockUndo>, BlockUndo>
{
public IndexedBlockUndoStore(NoSqlRepository index, BlockUndoStore store)
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/IndexedStore.cs
Expand Up @@ -8,6 +8,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public abstract class IndexedStore<TStoredItem, TItem>
where TStoredItem : StoredItem<TItem>
where TItem : IBitcoinSerializable, new()
Expand Down
1 change: 1 addition & 0 deletions NBitcoin/BitcoinCore/Store.cs
Expand Up @@ -7,6 +7,7 @@

namespace NBitcoin.BitcoinCore
{
[Obsolete]
public abstract class Store<TStoredItem, TItem>
where TStoredItem : StoredItem<TItem>
where TItem : IBitcoinSerializable, new()
Expand Down
4 changes: 2 additions & 2 deletions NBitcoin/BitcoinCore/StoredBlock.cs
Expand Up @@ -261,17 +261,17 @@ protected override void ReadWriteItem(BitcoinStream stream, ref Block item)
#if !NOFILEIO
#pragma warning disable CS0612 // Type or member is obsolete
public static IEnumerable<StoredBlock> EnumerateFile(string file, uint fileIndex = 0, DiskBlockPosRange range = null)
#pragma warning restore CS0612 // Type or member is obsolete
{
return new BlockStore(Path.GetDirectoryName(file), Network.Main).EnumerateFile(file, fileIndex, range);
}
#pragma warning restore CS0612 // Type or member is obsolete

#pragma warning disable CS0612 // Type or member is obsolete
public static IEnumerable<StoredBlock> EnumerateFolder(string folder, DiskBlockPosRange range = null)
#pragma warning restore CS0612 // Type or member is obsolete
{
return new BlockStore(folder, Network.Main).EnumerateFolder(range);
}
#pragma warning restore CS0612 // Type or member is obsolete
#endif
}
}
3 changes: 2 additions & 1 deletion NBitcoin/StandardScripts.cs
@@ -1,5 +1,6 @@
using NBitcoin.BitcoinCore;
using NBitcoin.Policy;
using System;
using System.Linq;

namespace NBitcoin
Expand Down Expand Up @@ -55,7 +56,7 @@ private static bool IsStandardScriptSig(Script scriptSig, Script scriptPubKey)
// script can be anything; an attacker could use a very
// expensive-to-check-upon-redemption script like:
// DUP CHECKSIG DROP ... repeated 100 times... OP_1
//
[Obsolete]
public static bool AreInputsStandard(Transaction tx, CoinsView coinsView)
{
if(tx.IsCoinBase)
Expand Down

0 comments on commit c7080cc

Please sign in to comment.