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
walletProxy
WalletProxy- 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
assetId
stringThe asset id
cancellationToken
CancellationTokenA 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
tradeId
stringThe trade id of the offer
secure
boolThis will create a transaction that includes coins that were offered
fee
ulongFee (in units of mojos)
cancellationToken
CancellationTokenA 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
secure
boolassetId
stringcancelAll
boolbatchSize
intbatchFee
ulongcancellationToken
CancellationTokenA 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
offer
stringThe bech32 encoded offer hex
cancellationToken
CancellationTokenA 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
launcherIdsAndMojoAmounts
IDictionary<string, long>The set of wallet ids and amounts (in mojo) representing the offer
minCoinAmount
ulong?maxCoinAmount
ulong?validateOnly
boolOnly validate the offer contents. Do not create.
driver
IDictionary<string, string>Additional data about the puzzle
solver
IDictionary<string, string>reusePuzhash
bool?fee
ulongFee (in units of mojos)
cancellationToken
CancellationTokenA 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
walletIdsAndMojoAmounts
IDictionary<uint, long>The set of wallet ids and amounts (in mojo) representing the offer
minCoinAmount
ulong?maxCoinAmount
ulong?validateOnly
boolOnly validate the offer contents. Do not create.
driver
IDictionary<string, string>Additional data about the puzzle
solver
IDictionary<string, string>reusePuzhash
bool?fee
ulongFee (in units of mojos)
cancellationToken
CancellationTokenA 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
offer
OfferSummarySummary of the offer to create
minCoinAmount
ulong?maxCoinAmount
ulong?validateOnly
boolOnly validate the offer contents. Do not create.
driver
IDictionary<string, string>Additional data about the puzzle
solver
IDictionary<string, string>reusePuzhash
bool?fee
ulongFee (in units of mojos)
cancellationToken
CancellationTokenA 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
cancellationToken
CancellationTokenA 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
tradeId
stringThe trade id of the offer
fileContents
boolIndicator as to whether to return the offer contents. Offer will be empty if this is false.
cancellationToken
CancellationTokenA 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
offer
stringThe bech32 encoded offer hex
advanced
boolcancellationToken
CancellationTokenA 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
excludeMyOffers
boolDo not include my offers in the result set
excludeTakenOffers
boolDo not include taken offers in the result set
includeCompleted
boolDo not include completed offers in the result set
sortKey
stringField to sort results by
reverse
boolReverse the sort order of the results
fileContents
boolInclude the offer value in the result
cancellationToken
CancellationTokenA 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
start
intthe start index of offers (zero based)
end
intThe end index of offers
excludeMyOffers
boolDo not include my offers in the result set
excludeTakenOffers
boolDo not include taken offers in the result set
includeCompleted
boolDo not include completed offers in the result set
sortKey
stringField to sort results by
reverse
boolReverse the sort order of the results
fileContents
boolInclude the offer value in the result
cancellationToken
CancellationTokenA 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
cancellationToken
CancellationTokenA 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
cancellationToken
CancellationTokenA 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
offer
stringsolver
IDictionary<string, object>minCoinAmount
ulong?maxCoinAmount
ulong?reusePuzhash
bool?fee
ulongFee (in units of mojos)
cancellationToken
CancellationToken