diff --git a/demo/App.config b/demo/App.config index f4a192a..963a31a 100644 --- a/demo/App.config +++ b/demo/App.config @@ -44,6 +44,14 @@ + + + + + + + + diff --git a/src/BitcoinLib/BitcoinLib.csproj b/src/BitcoinLib/BitcoinLib.csproj index 9663317..e5474f1 100644 --- a/src/BitcoinLib/BitcoinLib.csproj +++ b/src/BitcoinLib/BitcoinLib.csproj @@ -43,6 +43,8 @@ + + @@ -118,6 +120,8 @@ + + diff --git a/src/BitcoinLib/CoinParameters/Base/CoinParameters.cs b/src/BitcoinLib/CoinParameters/Base/CoinParameters.cs index ce6f1db..db16f71 100644 --- a/src/BitcoinLib/CoinParameters/Base/CoinParameters.cs +++ b/src/BitcoinLib/CoinParameters/Base/CoinParameters.cs @@ -8,6 +8,7 @@ using BitcoinLib.Services.Coins.Base; using BitcoinLib.Services.Coins.Bitcoin; using BitcoinLib.Services.Coins.Cryptocoin; +using BitcoinLib.Services.Coins.Dash; using BitcoinLib.Services.Coins.Dogecoin; using BitcoinLib.Services.Coins.Litecoin; using BitcoinLib.Services.Coins.Sarcoin; @@ -219,6 +220,45 @@ public CoinParameters(ICoinService coinService, #endregion + #region Dash + + else if (coinService is DashService) + { + if (!IgnoreConfigFiles) + { + DaemonUrl = ConfigurationManager.AppSettings.Get("Dash_DaemonUrl"); + DaemonUrlTestnet = ConfigurationManager.AppSettings.Get("Dash_DaemonUrl_Testnet"); + RpcUsername = ConfigurationManager.AppSettings.Get("Dash_RpcUsername"); + RpcPassword = ConfigurationManager.AppSettings.Get("Dash_RpcPassword"); + WalletPassword = ConfigurationManager.AppSettings.Get("Dash_WalletPassword"); + } + + CoinShortName = "DASH"; + CoinLongName = "Dash"; + IsoCurrencyCode = "DASH"; + + TransactionSizeBytesContributedByEachInput = 148; + TransactionSizeBytesContributedByEachOutput = 34; + TransactionSizeFixedExtraSizeInBytes = 10; + + FreeTransactionMaximumSizeInBytes = 1000; + FreeTransactionMinimumOutputAmountInCoins = 0.0001M; + FreeTransactionMinimumPriority = 57600000; + FeePerThousandBytesInCoins = 0.0001M; + MinimumTransactionFeeInCoins = 0.001M; + MinimumNonDustTransactionAmountInCoins = 0.0000543M; + + TotalCoinSupplyInCoins = 18900000; + EstimatedBlockGenerationTimeInMinutes = 2.7; + BlocksHighestPriorityTransactionsReservedSizeInBytes = 50000; + + BaseUnitName = "Duff"; + BaseUnitsPerCoin = 100000000; + CoinsPerBaseUnit = 0.00000001M; + } + + #endregion + #region Agnostic coin (cryptocoin) else if (coinService is CryptocoinService) diff --git a/src/BitcoinLib/CoinParameters/Dash/DashConstants.cs b/src/BitcoinLib/CoinParameters/Dash/DashConstants.cs new file mode 100644 index 0000000..10a38a3 --- /dev/null +++ b/src/BitcoinLib/CoinParameters/Dash/DashConstants.cs @@ -0,0 +1,18 @@ +using BitcoinLib.CoinParameters.Base; + +namespace BitcoinLib.CoinParameters.Dash +{ + public static class DashConstants + { + public sealed class Constants : CoinConstants + { + public readonly ushort CoinReleaseHalfsEveryXInYears = 7; + public readonly ushort DifficultyIncreasesEveryXInBlocks = 34560; + public readonly uint OneDashInDuffs = 100000000; + public readonly decimal OneDuffInDash = 0.00000001M; + public readonly decimal OneMicrodashInDash = 0.000001M; + public readonly decimal OneMillidashInDash = 0.001M; + public readonly string Symbol = "DASH"; + } + } +} \ No newline at end of file diff --git a/src/BitcoinLib/CoinParameters/Dash/IDashConstants.cs b/src/BitcoinLib/CoinParameters/Dash/IDashConstants.cs new file mode 100644 index 0000000..c2c6e87 --- /dev/null +++ b/src/BitcoinLib/CoinParameters/Dash/IDashConstants.cs @@ -0,0 +1,7 @@ +namespace BitcoinLib.CoinParameters.Dash +{ + public interface IDashConstants + { + DashConstants.Constants Constants { get; } + } +} \ No newline at end of file diff --git a/src/BitcoinLib/Services/Coins/Dash/DashService.cs b/src/BitcoinLib/Services/Coins/Dash/DashService.cs new file mode 100644 index 0000000..4aa4197 --- /dev/null +++ b/src/BitcoinLib/Services/Coins/Dash/DashService.cs @@ -0,0 +1,33 @@ +using BitcoinLib.CoinParameters.Dash; +using BitcoinLib.RPC.Specifications; + +namespace BitcoinLib.Services.Coins.Dash +{ + public class DashService : CoinService, IDashService + { + public DashService(bool useTestnet = false) : base(useTestnet) + { + } + + public DashService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword) + : base(daemonUrl, rpcUsername, rpcPassword, walletPassword) + { + } + + public DashService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, + short rpcRequestTimeoutInSeconds) + : base(daemonUrl, rpcUsername, rpcPassword, walletPassword, rpcRequestTimeoutInSeconds) + { + } + + /// + public string SendToAddress(string dashAddress, decimal amount, string comment = null, string commentTo = null, + bool subtractFeeFromAmount = false, bool useInstantSend = false, bool usePrivateSend = false) + { + return _rpcConnector.MakeRequest(RpcMethods.sendtoaddress, dashAddress, amount, comment, commentTo, + subtractFeeFromAmount, useInstantSend, usePrivateSend); + } + + public DashConstants.Constants Constants => DashConstants.Constants.Instance; + } +} \ No newline at end of file diff --git a/src/BitcoinLib/Services/Coins/Dash/IDashService.cs b/src/BitcoinLib/Services/Coins/Dash/IDashService.cs new file mode 100644 index 0000000..d3765ed --- /dev/null +++ b/src/BitcoinLib/Services/Coins/Dash/IDashService.cs @@ -0,0 +1,32 @@ +using BitcoinLib.CoinParameters.Dash; +using BitcoinLib.Services.Coins.Base; + +namespace BitcoinLib.Services.Coins.Dash +{ + public interface IDashService : ICoinService, IDashConstants + { + /// + /// Send an amount to a given address. + /// + /// The dash address to send to. + /// The amount in DASH to send. eg 0.1. + /// + /// A comment used to store what the transaction is for. This is not part of the transaction, + /// just kept in your wallet. + /// + /// + /// A comment to store the name of the person or organization to which you're sending the + /// transaction. This is not part of the transaction, just kept in your wallet. + /// + /// + /// The fee will be deducted from the amount being sent. The recipient will receive + /// less amount of Dash than you enter in the amount field. + /// + /// Send this transaction as InstantSend. + /// Use anonymized funds only. + /// The transaction id. + string SendToAddress(string dashAddress, decimal amount, string comment = null, + string commentTo = null, bool subtractFeeFromAmount = false, bool useInstantSend = false, + bool usePrivateSend = false); + } +} \ No newline at end of file diff --git a/src/BitcoinLib/Services/RpcServices/RpcService/RpcService.cs b/src/BitcoinLib/Services/RpcServices/RpcService/RpcService.cs index 20b8634..34efd20 100644 --- a/src/BitcoinLib/Services/RpcServices/RpcService/RpcService.cs +++ b/src/BitcoinLib/Services/RpcServices/RpcService/RpcService.cs @@ -18,7 +18,7 @@ namespace BitcoinLib.Services // Implementation of API calls list, as found at: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list (note: this list is often out-of-date so call "help" in your bitcoin-cli to get the latest signatures) public partial class CoinService : ICoinService { - private readonly IRpcConnector _rpcConnector; + protected readonly IRpcConnector _rpcConnector; public CoinService() {