diff --git a/src/chia-dotnet.tests/WalletTests.cs b/src/chia-dotnet.tests/WalletTests.cs
index cdc17ce2..deab2680 100644
--- a/src/chia-dotnet.tests/WalletTests.cs
+++ b/src/chia-dotnet.tests/WalletTests.cs
@@ -48,7 +48,7 @@ public async Task GetWalletBalance()
public async Task GetTransactions()
{
using var cts = new CancellationTokenSource(15000);
- var count = await _theWallet.GetTransactionCount(cts.Token);
+ var count = await _theWallet.GetTransactionCount(cancellationToken: cts.Token);
if (count == 0)
{
Assert.Inconclusive("no transactions");
@@ -66,7 +66,7 @@ public async Task GetTransactionsIncremental()
{
using var cts = new CancellationTokenSource(150000);
- var count = await _theWallet.GetTransactionCount(cts.Token);
+ var count = await _theWallet.GetTransactionCount(cancellationToken: cts.Token);
Assert.IsTrue(count > 4);
var transactions1 = await _theWallet.GetTransactions(start: 0, end: 2, cancellationToken: cts.Token);
@@ -117,7 +117,7 @@ public async Task GetTransactionCount()
{
using var cts = new CancellationTokenSource(15000);
- var count = await _theWallet.GetTransactionCount(cts.Token);
+ var count = await _theWallet.GetTransactionCount(cancellationToken: cts.Token);
Assert.IsNotNull(count);
}
diff --git a/src/chia-dotnet/CATWallet.cs b/src/chia-dotnet/CATWallet.cs
index 10dc9a71..24289ab3 100644
--- a/src/chia-dotnet/CATWallet.cs
+++ b/src/chia-dotnet/CATWallet.cs
@@ -78,11 +78,15 @@ public async Task SetName(string name, CancellationToken cancellationToken = def
///
/// The inner address for the spend
/// The amount to put in the wallet (in units of mojos)
- /// The fee to create the wallet (in units of mojos)
/// Optional list of byte string memos to include in the transaction
+ ///
+ ///
+ ///
+ ///
+ /// The fee to create the wallet (in units of mojos)
/// A token to allow the call to be cancelled
/// A
- public async Task Spend(string innerAddress, ulong amount, ulong fee, IEnumerable? memos = null, CancellationToken cancellationToken = default)
+ public async Task Spend(string innerAddress, ulong amount, IEnumerable? memos = null, ulong minCoinAmount = 0, ulong maxCoinAmount = 0, IEnumerable? excludeCoinAmounts = null, bool reusePuzhash = false, ulong fee = 0, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(innerAddress))
{
@@ -92,11 +96,18 @@ public async Task Spend(string innerAddress, ulong amount, ul
dynamic data = CreateWalletDataObject();
data.inner_address = innerAddress;
data.amount = amount;
+ data.min_coin_amount = minCoinAmount;
+ data.max_coin_amount = maxCoinAmount;
data.fee = fee;
+ data.reuse_puzhash = reusePuzhash;
if (memos != null)
{
data.memos = memos.ToList();
}
+ if (excludeCoinAmounts != null)
+ {
+ data.exclude_coin_ids = excludeCoinAmounts.ToList();
+ }
return await WalletProxy.SendMessage("cat_spend", data, "transaction", cancellationToken).ConfigureAwait(false);
}
diff --git a/src/chia-dotnet/Wallet.cs b/src/chia-dotnet/Wallet.cs
index 5321f73b..13f68715 100644
--- a/src/chia-dotnet/Wallet.cs
+++ b/src/chia-dotnet/Wallet.cs
@@ -122,42 +122,49 @@ public async Task> SelectCoins(ulong amount, IEnumerable
}
///
- /// Get the list of transactions
- ///
- /// Restrict results only to this address
- /// Field to sort results by
- /// Reverse the sort order of the results
- /// A token to allow the call to be cancelled
- /// A list of s
- public async Task> GetTransactions(string? toAddress = null, string? sortKey = null, bool reverse = false, CancellationToken cancellationToken = default)
- {
- var count = await GetTransactionCount(cancellationToken).ConfigureAwait(false);
- return await GetTransactions(0, count, toAddress, sortKey, reverse, cancellationToken).ConfigureAwait(false);
- }
-
- ///
- /// Get the list of transactions
+ /// Retrieves a list of transactions from a wallet.
///
/// the start index of transactions (zero based)
/// The end index of transactions (max of
/// Restrict results only to this address
/// Field to sort results by
/// Reverse the sort order of the results
+ ///
+ ///
/// A token to allow the call to be cancelled
- /// A list of s
- public async Task> GetTransactions(uint start, uint end, string? toAddress = null, string? sortKey = null, bool reverse = false, CancellationToken cancellationToken = default)
+ /// A list of
+ public async Task> GetTransactions(
+ string? toAddress = null,
+ TransactionTypeFilter? typeFilter = null,
+ bool reverse = false,
+ string? sortKey = null,
+ uint start = 0,
+ uint end = 50,
+ bool? confirmed = null,
+ CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.start = start;
data.end = end;
- data.to_address = toAddress;
- data.sort_key = sortKey;
data.reverse = reverse;
-
+ if (toAddress is not null)
+ {
+ data.to_address = toAddress;
+ }
+ if (sortKey is not null)
+ {
+ data.sort_key = sortKey;
+ }
+ if (typeFilter is not null)
+ {
+ data.type_filter = typeFilter;
+ }
+ if (confirmed is not null)
+ {
+ data.confirmed = confirmed;
+ }
return await WalletProxy.SendMessage>("get_transactions", data, "transactions", cancellationToken).ConfigureAwait(false);
}
-
-
///
/// Get the list of spendable coins
///
@@ -223,9 +230,14 @@ public async Task GetNextAddress(bool newAddress, CancellationToken canc
///
/// A token to allow the call to be cancelled
/// The number of transactions
- public async Task GetTransactionCount(CancellationToken cancellationToken = default)
+ public async Task GetTransactionCount(TransactionTypeFilter? typeFilter = null, CancellationToken cancellationToken = default)
{
- var response = await WalletProxy.SendMessage("get_transaction_count", CreateWalletDataObject(), cancellationToken).ConfigureAwait(false);
+ dynamic data = CreateWalletDataObject();
+ if (typeFilter is not null)
+ {
+ data.type_filter = typeFilter;
+ }
+ var response = await WalletProxy.SendMessage("get_transaction_count", data, cancellationToken).ConfigureAwait(false);
return response.count;
}
@@ -247,9 +259,23 @@ public async Task DeleteUnconfirmedTransactions(CancellationToken cancellationTo
/// The amount to send (in units of mojos)
/// Fee amount (in units of mojos)
/// Memos to go along with the transaction
+ /// /param>
+ /// /param>
+ /// /param>
+ /// /param>
+ /// /param>
/// A token to allow the call to be cancelled
/// The
- public async Task SendTransaction(string address, ulong amount, ulong fee, IEnumerable? memos = null, CancellationToken cancellationToken = default)
+ public async Task SendTransaction(string address,
+ ulong amount,
+ IEnumerable? memos = null,
+ IEnumerable? excludeCoinAmounts = null,
+ IEnumerable? excludeCoinsIds = null,
+ ulong minCoinAmount = 0,
+ ulong maxCoinAmount = 0,
+ bool resusePuzHash = false,
+ ulong fee = 0,
+ CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@@ -259,7 +285,18 @@ public async Task SendTransaction(string address, ulong amoun
dynamic data = CreateWalletDataObject();
data.address = address;
data.amount = amount;
+ data.min_coin_amount = minCoinAmount;
+ data.max_coin_amount = maxCoinAmount;
data.fee = fee;
+ data.reuse_puzhash = resusePuzHash;
+ if (excludeCoinAmounts is not null)
+ {
+ data.exclude_coin_amounts = excludeCoinAmounts.ToList();
+ }
+ if (excludeCoinsIds is not null)
+ {
+ data.exclude_coin_ids = excludeCoinsIds.ToList();
+ }
if (memos is not null)
{
data.memos = memos.ToList();
diff --git a/src/chia-dotnet/WalletProxy.cs b/src/chia-dotnet/WalletProxy.cs
index d2493c73..731d2fd3 100644
--- a/src/chia-dotnet/WalletProxy.cs
+++ b/src/chia-dotnet/WalletProxy.cs
@@ -621,16 +621,30 @@ public static async Task GetPoolInfo(Uri poolUri, CancellationToken ca
}
///
- /// Create but do not send a transaction
- ///
- /// Additions to the block chain
- /// Fee amount (in units of mojos)
- /// Coins to include
- /// Coins to announce
- /// Puzzles to announce
+ /// Creates and signs a transaction.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
/// A token to allow the call to be cancelled
/// The signed
- public async Task CreateSignedTransaction(IEnumerable additions, ulong fee, IEnumerable? coins = null, IEnumerable? coinAnnouncements = null, IEnumerable? puzzleAnnouncements = null, CancellationToken cancellationToken = default)
+ public async Task<(TransactionRecord SignedTx, IEnumerable SignedTxs)> CreateSignedTransaction(
+ IEnumerable additions,
+ IEnumerable? excludeCoinAmounts = null,
+ IEnumerable? excludeCoins = null,
+ IEnumerable? puzzleAnnouncements = null,
+ IEnumerable? coinAnnouncements = null,
+ IEnumerable? coins = null,
+ ulong minCoinAmount = 0,
+ ulong maxCoinAmount = 0,
+ ulong fee = 0,
+ CancellationToken cancellationToken = default)
{
if (additions is null)
{
@@ -640,19 +654,34 @@ public async Task CreateSignedTransaction(IEnumerable a
dynamic data = new ExpandoObject();
data.additions = additions.ToList();
data.fee = fee;
- if (coins is not null) // coins are optional
+ data.min_coin_amount = minCoinAmount;
+ data.max_coin_amount = maxCoinAmount;
+ if (excludeCoins is not null)
+ {
+ data.exclude_coins = excludeCoins.ToList();
+ }
+ if (excludeCoinAmounts is not null)
+ {
+ data.exclude_coin_amounts = excludeCoinAmounts.ToList();
+ }
+ if (coins is not null)
{
data.coins = coins.ToList();
}
- if (coinAnnouncements is not null) // coins are optional
+ if (coinAnnouncements is not null)
{
data.coin_announcements = coinAnnouncements.ToList();
}
- if (puzzleAnnouncements is not null) // coins are optional
+ if (puzzleAnnouncements is not null)
{
data.puzzle_announcements = puzzleAnnouncements.ToList();
}
- return await SendMessage("create_signed_transaction", data, "signed_tx", cancellationToken).ConfigureAwait(false);
+ var response = await SendMessage("create_signed_transaction", data, cancellationToken).ConfigureAwait(false);
+
+ return (
+ Converters.ToObject(response.signed_tx),
+ Converters.ToEnumerable(response.signed_txs)
+ );
}
///
@@ -800,5 +829,42 @@ public async Task DidFindLostDid(string coinId, CancellationToken cancel
data.coin_id = coinId;
return await SendMessage("did_find_lost_did", data, "latest_coin_id", cancellationToken).ConfigureAwait(false);
}
+ ///
+ /// Gets the current derivation index.
+ ///
+ /// A token to allow the call to be cancelled
+ ///
+ public async Task GetCurrentDerivationIndex(CancellationToken cancellationToken = default)
+ {
+ return await SendMessage("get_current_derivation_index", null, "index", cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Extends the current derivation index.
+ ///
+ ///
+ /// A token to allow the call to be cancelled
+ ///
+ public async Task ExtendDerivationIndex(uint index, CancellationToken cancellationToken = default)
+ {
+ dynamic data = new ExpandoObject();
+ data.index = index;
+ return await SendMessage("extend_derivation_index", data, "index", cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Retrieves the memo from a transaction.
+ ///
+ ///
+ /// A token to allow the call to be cancelled
+ ///
+ public async Task>>> GetTransactionMemo(string transactionId, CancellationToken cancellationToken = default)
+ {
+ dynamic data = new ExpandoObject();
+ data.transaction_id = transactionId;
+ var response = await SendMessage>>>("get_transaction_memo", data, cancellationToken).ConfigureAwait(false);
+
+ return response;
+ }
}
}