Class TradeManager
API wrapper for those wallet RPC methods dealing with trades and offers
public sealed class TradeManager
- Inheritance
-
TradeManager
- Inherited Members
- Extension Methods
Constructors
TradeManager(WalletProxy)
API wrapper for those wallet RPC methods dealing with trades and offers
public TradeManager(WalletProxy walletProxy)
Parameters
walletProxyWalletProxy- API wrapper for those wallet RPC methods dealing with trades and offers
Properties
WalletProxy
public WalletProxy WalletProxy { get; init; }
Property Value
- WalletProxy
- API wrapper for those wallet RPC methods dealing with trades and offers
Methods
AssetIdToName(string, CancellationToken)
Get the CAT name from an asset id
public Task<(uint? WalletId, string Name)> AssetIdToName(string assetId, CancellationToken cancellationToken = default)
Parameters
assetIdstringThe asset id
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
CancelOffer(string, bool, ulong, CancellationToken)
Cancels an offer using a transaction
public Task<IEnumerable<TransactionRecord>> CancelOffer(string tradeId, bool secure, ulong fee = 0, CancellationToken cancellationToken = default)
Parameters
tradeIdstringThe trade id of the offer
secureboolThis will create a transaction that includes coins that were offered
feeulongFee (in units of mojos)
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<TransactionRecord>>
An awaitable Task
CancelOffers(bool, string, bool, int, ulong, CancellationToken)
Cancels multiple offers.
public Task<IEnumerable<TransactionRecord>> CancelOffers(bool secure, string assetId = "xch", bool cancelAll = false, int batchSize = 5, ulong batchFee = 0, CancellationToken cancellationToken = default)
Parameters
secureboolassetIdstringcancelAllboolbatchSizeintbatchFeeulongcancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<TransactionRecord>>
An awaitable Task
CheckOfferValidity(string, CancellationToken)
Checks the validity of an offer
public Task<(bool Valid, string Id)> CheckOfferValidity(string offer, CancellationToken cancellationToken = default)
Parameters
offerstringThe bech32 encoded offer hex
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
CreateOffer(IDictionary<string, long>, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)
Create an offer file from a set of id's in the form of wallet_id:amount
public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(IDictionary<string, long> launcherIdsAndMojoAmounts, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)
Parameters
launcherIdsAndMojoAmountsIDictionary<string, long>The set of wallet ids and amounts (in mojo) representing the offer
minCoinAmountulong?maxCoinAmountulong?validateOnlyboolOnly validate the offer contents. Do not create.
driverIDictionary<string, string>Additional data about the puzzle
solverIDictionary<string, string>reusePuzhashbool?feeulongFee (in units of mojos)
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>
An awaitable Task
CreateOffer(IDictionary<uint, long>, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)
Create an offer file from a set of id's in the form of wallet_id:amount
public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(IDictionary<uint, long> walletIdsAndMojoAmounts, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)
Parameters
walletIdsAndMojoAmountsIDictionary<uint, long>The set of wallet ids and amounts (in mojo) representing the offer
minCoinAmountulong?maxCoinAmountulong?validateOnlyboolOnly validate the offer contents. Do not create.
driverIDictionary<string, string>Additional data about the puzzle
solverIDictionary<string, string>reusePuzhashbool?feeulongFee (in units of mojos)
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>
An awaitable Task
CreateOffer(OfferSummary, ulong?, ulong?, bool, IDictionary<string, string>?, IDictionary<string, string>?, bool?, ulong, CancellationToken)
Create an offer file from a set of id's in the form of wallet_id:amount
public Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> CreateOffer(OfferSummary offer, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool validateOnly = false, IDictionary<string, string>? driver = null, IDictionary<string, string>? solver = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)
Parameters
offerOfferSummarySummary of the offer to create
minCoinAmountulong?maxCoinAmountulong?validateOnlyboolOnly validate the offer contents. Do not create.
driverIDictionary<string, string>Additional data about the puzzle
solverIDictionary<string, string>reusePuzhashbool?feeulongFee (in units of mojos)
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<(OfferRecord Offer, TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)>
An awaitable Task
GetCATList(CancellationToken)
Get the default list of CATs
public Task<IEnumerable<CATInfo>> GetCATList(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<CATInfo>>
A list of CATs
GetOffer(string, bool, CancellationToken)
Retrieves an offer
public Task<OfferRecord> GetOffer(string tradeId, bool fileContents = false, CancellationToken cancellationToken = default)
Parameters
tradeIdstringThe trade id of the offer
fileContentsboolIndicator as to whether to return the offer contents. Offer will be empty if this is false.
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<OfferRecord>
The OfferRecord
GetOfferSummary(string, bool, CancellationToken)
Retrieves the summary of an offer
public Task<OfferSummary> GetOfferSummary(string offer, bool advanced = false, CancellationToken cancellationToken = default)
Parameters
offerstringThe bech32 encoded offer hex
advancedboolcancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<OfferSummary>
The summary of the offer
GetOffers(bool, bool, bool, string?, bool, bool, CancellationToken)
Get the list of offers
public Task<IEnumerable<OfferRecord>> GetOffers(bool excludeMyOffers = false, bool excludeTakenOffers = false, bool includeCompleted = false, string? sortKey = null, bool reverse = false, bool fileContents = false, CancellationToken cancellationToken = default)
Parameters
excludeMyOffersboolDo not include my offers in the result set
excludeTakenOffersboolDo not include taken offers in the result set
includeCompletedboolDo not include completed offers in the result set
sortKeystringField to sort results by
reverseboolReverse the sort order of the results
fileContentsboolInclude the offer value in the result
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<OfferRecord>>
A list of OfferRecords
GetOffers(int, int, bool, bool, bool, string?, bool, bool, CancellationToken)
Get the list of offers
public Task<IEnumerable<OfferRecord>> GetOffers(int start, int end, bool excludeMyOffers = false, bool excludeTakenOffers = false, bool includeCompleted = false, string? sortKey = null, bool reverse = false, bool fileContents = false, CancellationToken cancellationToken = default)
Parameters
startintthe start index of offers (zero based)
endintThe end index of offers
excludeMyOffersboolDo not include my offers in the result set
excludeTakenOffersboolDo not include taken offers in the result set
includeCompletedboolDo not include completed offers in the result set
sortKeystringField to sort results by
reverseboolReverse the sort order of the results
fileContentsboolInclude the offer value in the result
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<OfferRecord>>
A list of OfferRecords
GetOffersCount(CancellationToken)
Retrieves the number of offers.
public Task<(int Total, int MyOffersCount, int TakenOffersCount)> GetOffersCount(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<(int Total, int MyOffersCount, int TakenOffersCount)>
The number of offers
GetStrayCats(CancellationToken)
Get a list of all unacknowledged CATs.
public Task<IEnumerable<Token>> GetStrayCats(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to allow the call to be cancelled
Returns
- Task<IEnumerable<Token>>
The list of Tokens
TakeOffer(string, IDictionary<string, object>?, ulong?, ulong?, bool?, ulong, CancellationToken)
Takes an offer
public Task<(TradeRecord Trade, IEnumerable<TransactionRecord> Transactions)> TakeOffer(string offer, IDictionary<string, object>? solver = null, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool? reusePuzhash = null, ulong fee = 0, CancellationToken cancellationToken = default)
Parameters
offerstringsolverIDictionary<string, object>minCoinAmountulong?maxCoinAmountulong?reusePuzhashbool?feeulongFee (in units of mojos)
cancellationTokenCancellationToken