diff --git a/MultiChainLib/Client/MultiChainClient.cs b/MultiChainLib/Client/MultiChainClient.cs index e4301d8..c7652ee 100644 --- a/MultiChainLib/Client/MultiChainClient.cs +++ b/MultiChainLib/Client/MultiChainClient.cs @@ -61,7 +61,7 @@ public Task> SendToAddressAsync(string address, string a { var theAmount = new Dictionary(); theAmount[assetName] = amount; - return this.ExecuteAsync("sendtoaddress", 0, address, theAmount, comment ?? string.Empty, + return this.ExecuteAsync("sendtoaddress", 0, address, theAmount, comment ?? string.Empty, commentTo ?? string.Empty); } @@ -72,7 +72,7 @@ public Task> SendWithMetadataFromAsync(string fromAddres return this.ExecuteAsync("sendwithmetadatafrom", 0, fromAddress, toAddress, theAmount, FormatHex(dataHex)); } - public Task> SendAssetToAddressAsync(string address, string assetName, decimal quantity, + public Task> SendAssetToAddressAsync(string address, string assetName, decimal quantity, int nativeAmount = 0, string comment = null, string commentTo = null) { return this.ExecuteAsync("sendassettoaddress", 0, address, assetName, quantity, nativeAmount, @@ -176,7 +176,7 @@ public Task>> ListPermissions(Bloc return this.ExecuteAsync>("listpermissions", 0, permissionsAsString); } - public Task> IssueAsync(string issueAddress, string assetName, int quantity, decimal units, + public Task> IssueAsync(string issueAddress, string assetName, int quantity, decimal units, decimal nativeAmount = 0, string comment = null, string commentTo = null, int startBlock = 0, int endBlock = 0) { return this.ExecuteAsync("issue", 0, issueAddress, assetName, quantity, units); /*, nativeAmount, comment, @@ -213,7 +213,7 @@ public Task> RevokeAsync(IEnumerable addresses, commentTo ?? string.Empty, startBlock, endBlock);*/ } - public Task> GrantFromAsync(string fromAddress, IEnumerable toAddresses, BlockchainPermissions permissions, decimal nativeAmount = 0M, + public Task> GrantFromAsync(string fromAddress, IEnumerable toAddresses, BlockchainPermissions permissions, decimal nativeAmount = 0M, string comment = null, string commentTo = null, int startBlock = 0, int endBlock = 0) { var stringifiedAddresses = this.StringifyValues(toAddresses); @@ -382,22 +382,32 @@ public Task> VerifyChainAsync(CheckBlockType type = CheckB return this.ExecuteAsync("verifychain", 0, (int)type, numBlocks); } - // not implemented -- contact us with specific implementation requirements and we'll implement this... - public Task> CreateRawTransactionAync() + public Task> CreateRawTransactionAync(IEnumerable txids = null, IEnumerable assets = null) { - throw new NotImplementedException("This operation has not been implemented."); + string amountstr = string.Empty; + dynamic flexible; + flexible = new System.Dynamic.ExpandoObject(); + var dictionary = (IDictionary)flexible; + if (assets != null) + { + foreach (var asset in assets) + { + dictionary.Add(asset.Address, asset.StringifyAmount()); + } + } + return this.ExecuteAsync("createrawtransaction", 0, txids, dictionary); } - // not implemented -- contact us with specific implementation requirements and we'll implement this... - public Task> SendRawTransactionAsync() + + public Task> SendRawTransactionAsync(string hex) { - throw new NotImplementedException("This operation has not been implemented."); + return this.ExecuteAsync("sendrawtransaction", 0, hex); } - // not implemented -- contact us with specific implementation requirements and we'll implement this... - public Task> SignRawTransactionAsync() + + public Task> SignRawTransactionAsync(string hex) { - throw new NotImplementedException("This operation has not been implemented."); + return this.ExecuteAsync("signrawtransaction", 0, hex); } public Task> PrioritiseTransactionAsync(string txId, decimal priority, int feeSatoshis) @@ -515,14 +525,75 @@ public Task> ListSinceBlockAsync(str return this.ExecuteAsync("listsinceblock", 0, hash, confirmations, watchOnly); } + public Task> PrepareLockUnspent(string address = null, IEnumerable amounts = null, bool _lock = true) + { + //multichain - cli testbc preparelockunspent '{"asset1":100,"asset2":20}' + + string amountstr = string.Empty; + dynamic flexible; + flexible = new System.Dynamic.ExpandoObject(); + var dictionary = (IDictionary)flexible; + if (amounts != null) + { + foreach (var amount in amounts) + { + dictionary.Add(amount.Name, amount.Qty); + } + } + if (address == null) + return this.ExecuteAsync("preparelockunspent", 0, dictionary, _lock); + + return this.ExecuteAsync("preparelockunspentfrom", 0, address, dictionary, _lock); + } + + + public Task> PrepareLockUnspent(IEnumerable amounts = null, bool _lock = true) + { + //multichain - cli testbc preparelockunspent '{"asset1":100,"asset2":20}' + + string amountstr = string.Empty; + dynamic flexible; + flexible = new System.Dynamic.ExpandoObject(); + var dictionary = (IDictionary)flexible; + if (amounts != null) + { + foreach (var amount in amounts) + { + dictionary.Add(amount.Name, amount.Qty); + } + } + + return this.ExecuteAsync("preparelockunspent", 0, dictionary, _lock); + } + + public Task> LockUnspent(bool unlock, IEnumerable unspentTxs = null) + { + + + return this.ExecuteAsync("lockunspent", 0, unlock, unspentTxs); + } + public Task>> ListUnspentAsync(int minConf = 1, int maxConf = 999999, IEnumerable addresses = null) { - return this.ExecuteAsync>("listunspent", 0, minConf, maxConf); + //multichain - cli testbc listunspent 1 999999[\"4Qk5zZJbJNRTjwVETGzyBbgCW5ePVt7j4vuXTc\"] + + StringBuilder builder = new StringBuilder(); + + foreach (var address in addresses) + { + if (builder.Length > 0) + builder.Append(","); + builder.Append(address); + } + builder.Insert(0, "["); + builder.Append("]"); + //return this.ExecuteAsync>("listunspent", 0, minConf, maxConf,addresses!=null?builder.ToString():string.Empty); + return this.ExecuteAsync>("listunspent", 0, minConf, maxConf, addresses ?? null); } - public Task>> ListLockUnspentAsync() + public Task>> ListLockUnspentAsync() { - return this.ExecuteAsync>("listlockunspent", 0); + return this.ExecuteAsync>("listlockunspent", 0); } public Task>> GetAddressesAsync() diff --git a/MultiChainLib/Model/AssetVout.cs b/MultiChainLib/Model/AssetVout.cs new file mode 100644 index 0000000..91a4b34 --- /dev/null +++ b/MultiChainLib/Model/AssetVout.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MultiChainLib +{ + public class AssetVout + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("issuetxid")] + public string IssueTxId { get; set; } + + [JsonProperty("assetref")] + public string AssetRef { get; set; } + + [JsonProperty("qty")] + public decimal Qty { get; set; } + + [JsonProperty("raw")] + public long Raw { get; set; } + } +} diff --git a/MultiChainLib/Model/CreateRawTransactionAmount.cs b/MultiChainLib/Model/CreateRawTransactionAmount.cs new file mode 100644 index 0000000..7ba0612 --- /dev/null +++ b/MultiChainLib/Model/CreateRawTransactionAmount.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MultiChainLib +{ + public class CreateRawTransactionAmount + { + public string Address { get; set; } + public Decimal Qty { get; set; } + + public CreateRawTransactionAmount() + { + } + + //"1DK3fuhpAqHWAvNtbWHqsyHYxUsK38N878t3nZ":qty, + public virtual object StringifyAmount() + { + return Qty; + } + } + + public class CreateRawTransactionAsset: CreateRawTransactionAmount + { + public string Name { get; set; } + public CreateRawTransactionAsset() { } + + //"1DK3fuhpAqHWAvNtbWHqsyHYxUsK38N878t3nZ":{"asset":qty}, + public override object StringifyAmount() + { + dynamic flexible; + flexible = new System.Dynamic.ExpandoObject(); + var dictionary = (IDictionary)flexible; + dictionary.Add(Name, Qty); + + return dictionary; + } + } +} diff --git a/MultiChainLib/Model/CreateRawTransactionTxIn.cs b/MultiChainLib/Model/CreateRawTransactionTxIn.cs new file mode 100644 index 0000000..8e582ef --- /dev/null +++ b/MultiChainLib/Model/CreateRawTransactionTxIn.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MultiChainLib +{ + public class CreateRawTransactionTxIn + { + [JsonProperty("txid")] + public string TxId { get; set; } + + [JsonProperty("vout")] + public int Vout { get; set; } + + + public CreateRawTransactionTxIn() + { + } + + + } +} diff --git a/MultiChainLib/Model/PrepareLockUnspentAmount.cs b/MultiChainLib/Model/PrepareLockUnspentAmount.cs new file mode 100644 index 0000000..a7bf8b3 --- /dev/null +++ b/MultiChainLib/Model/PrepareLockUnspentAmount.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MultiChainLib +{ + public class PrepareLockUnspentAmount + { + public string Name { get; set; } + public Decimal Qty { get; set; } + + public PrepareLockUnspentAmount() { } + public PrepareLockUnspentAmount(string name, decimal qty) { Name = name; Qty = qty; } + + public object StringifyAmount() + { + dynamic flexible; + flexible = new System.Dynamic.ExpandoObject(); + var dictionary = (IDictionary)flexible; + dictionary.Add(Name, Qty); + + return dictionary; + } + } +} diff --git a/MultiChainLib/Model/SignRawTransactionResponse.cs b/MultiChainLib/Model/SignRawTransactionResponse.cs new file mode 100644 index 0000000..f3c844b --- /dev/null +++ b/MultiChainLib/Model/SignRawTransactionResponse.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MultiChainLib +{ + public class SignRawTransactionResponse + { + [JsonProperty("hex")] + public string Hex { get; set; } + + [JsonProperty("complete")] + public bool Complete { get; set; } + + + public SignRawTransactionResponse() + { + } + } +} diff --git a/MultiChainLib/Model/TransactionVout.cs b/MultiChainLib/Model/TransactionVout.cs index f4a0487..4ba8bab 100644 --- a/MultiChainLib/Model/TransactionVout.cs +++ b/MultiChainLib/Model/TransactionVout.cs @@ -19,14 +19,14 @@ public class TransactionVout public ScriptPubKeyResponse ScriptPubKey { get; set; } [JsonProperty("assets")] - public List Assets { get; set; } + public List Assets { get; set; } [JsonProperty("permissions")] public List Permissions { get; set; } public TransactionVout() { - this.Assets = new List(); + this.Assets = new List(); this.Permissions = new List(); } } diff --git a/MultiChainLib/MultiChainLib.csproj b/MultiChainLib/MultiChainLib.csproj index e081a27..ca8f8e5 100644 --- a/MultiChainLib/MultiChainLib.csproj +++ b/MultiChainLib/MultiChainLib.csproj @@ -11,6 +11,10 @@ MultiChainLib v4.5.2 512 + SAK + SAK + SAK + SAK true @@ -54,10 +58,14 @@ + + + + @@ -75,6 +83,7 @@ + @@ -89,6 +98,7 @@ +