From 342114433488f32c8487182e059a514a5d234881 Mon Sep 17 00:00:00 2001 From: surangap Date: Thu, 8 Jul 2021 16:57:13 +0800 Subject: [PATCH] Interface`icx_claimdfchtlc` RPC (#406) * Added ICXOrderBook.claimDFCHTLC() function, testing and documentation * Refactored code. * Refactored code. * Refactored code. --- .../icxorderbook/claimDFCHTLC.test.ts | 191 ++++++++++++++++++ .../category/icxorderbook/icx_setup.ts | 41 +++- .../src/category/icxorderbook.ts | 38 +++- website/docs/jellyfish/api/icxorderbook.md | 20 ++ 4 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 packages/jellyfish-api-core/__tests__/category/icxorderbook/claimDFCHTLC.test.ts diff --git a/packages/jellyfish-api-core/__tests__/category/icxorderbook/claimDFCHTLC.test.ts b/packages/jellyfish-api-core/__tests__/category/icxorderbook/claimDFCHTLC.test.ts new file mode 100644 index 0000000000..7e36947d8f --- /dev/null +++ b/packages/jellyfish-api-core/__tests__/category/icxorderbook/claimDFCHTLC.test.ts @@ -0,0 +1,191 @@ +import { ContainerAdapterClient } from '../../container_adapter_client' +import { MasterNodeRegTestContainer } from '@defichain/testcontainers' +import { + ICXClaimDFCHTLCInfo, ICXDFCHTLCInfo, ICXEXTHTLCInfo, ICXHTLCStatus, + ICXHTLCType, ICXListHTLCOptions +} from '../../../src/category/icxorderbook' +import { accountDFI, idDFI, accountBTC, ICXSetup, symbolDFI } from './icx_setup' +import { BigNumber, RpcApiError } from '../../../src' + +describe('ICXOrderBook.claimDFCHTLC', () => { + const container = new MasterNodeRegTestContainer() + const client = new ContainerAdapterClient(container) + const icxSetup = new ICXSetup(container, client) + + beforeAll(async () => { + await container.start() + await container.waitForReady() + await container.waitForBlock(1) + await icxSetup.createAccounts() + await icxSetup.createBTCToken() + await icxSetup.initializeTokensIds() + await icxSetup.mintBTCtoken(100) + await icxSetup.fundAccount(accountDFI, symbolDFI, 500) + await icxSetup.fundAccount(accountBTC, symbolDFI, 10) // for fee + await icxSetup.createBTCDFIPool() + await icxSetup.addLiquidityToBTCDFIPool(1, 100) + await icxSetup.setTakerFee(0.001) + }) + + afterAll(async () => { + await container.stop() + }) + + afterEach(async () => { + // enable this after #ain/583 + // await icxSetup.closeAllOpenOffers() + }) + + it('should claim DFC HTLC for DFI sell order', async () => { + const { createOrderTxId } = await icxSetup.createDFISellOrder('BTC', accountDFI, '037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941', new BigNumber(15), new BigNumber(0.01)) + const { makeOfferTxId } = await icxSetup.createDFIBuyOffer(createOrderTxId, new BigNumber(0.10), accountBTC) + const { DFCHTLCTxId } = await icxSetup.createDFCHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', 500) + await icxSetup.submitExtHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(0.10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', + '13sJQ9wBWh8ssihHUgAaCmNWJbBAG5Hr9N', '036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252', 15) + + const accountDFIBeforeClaim: Record = await client.call('getaccount', [accountDFI, {}, true], 'bignumber') + const accountBTCBeforeClaim: Record = await client.call('getaccount', [accountBTC, {}, true], 'bignumber') + // claim + const { txid: claimTxId } = await client.icxorderbook.claimDFCHTLC(DFCHTLCTxId, 'f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef') + await container.generate(1) + + // List htlc and check + const listHTLCOptions: ICXListHTLCOptions = { + offerTx: makeOfferTxId, + closed: true + } + const HTLCs: Record = await client.call('icx_listhtlcs', [listHTLCOptions], 'bignumber') + expect(Object.keys(HTLCs).length).toBe(4) // extra entry for the warning text returned by the RPC atm. + // we have a common field "type", use that to narrow down the record + if (HTLCs[claimTxId].type === ICXHTLCType.CLAIM_DFC) { + // ICXClaimDFCHTLCInfo cast + const ClaimHTLCInfo: ICXClaimDFCHTLCInfo = HTLCs[claimTxId] as ICXClaimDFCHTLCInfo + expect(ClaimHTLCInfo.dfchtlcTx).toStrictEqual(DFCHTLCTxId) + expect(ClaimHTLCInfo.seed).toStrictEqual('f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef') + } + + // check HTLC DFCHTLCTxId is in claimed status + if (HTLCs[DFCHTLCTxId].type === ICXHTLCType.DFC) { + // ICXDFCHTLCInfo cast + const DFCHTLCInfo: ICXDFCHTLCInfo = HTLCs[DFCHTLCTxId] as ICXDFCHTLCInfo + expect(DFCHTLCInfo.status).toStrictEqual(ICXHTLCStatus.CLAIMED) + } + + const accountDFIAfterClaim: Record = await client.call('getaccount', [accountDFI, {}, true], 'bignumber') + const accountBTCAfterClaim: Record = await client.call('getaccount', [accountBTC, {}, true], 'bignumber') + + // maker should get incentive + maker deposit and taker should get amount in DFCHTLCTxId HTLC - takerfee + expect(accountDFIAfterClaim[idDFI]).toStrictEqual(accountDFIBeforeClaim[idDFI].plus(0.010).plus(0.00250)) + expect(accountBTCAfterClaim[idDFI]).toStrictEqual(accountBTCBeforeClaim[idDFI].plus(10)) + }) + + it('should claim DFC HTLC with input utxos', async () => { + const { createOrderTxId } = await icxSetup.createDFISellOrder('BTC', accountDFI, '037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941', new BigNumber(15), new BigNumber(0.01)) + const { makeOfferTxId } = await icxSetup.createDFIBuyOffer(createOrderTxId, new BigNumber(0.10), accountBTC) + const { DFCHTLCTxId } = await icxSetup.createDFCHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', 500) + await icxSetup.submitExtHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(0.10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', + '13sJQ9wBWh8ssihHUgAaCmNWJbBAG5Hr9N', '036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252', 15) + + const accountDFIBeforeClaim: Record = await client.call('getaccount', [accountDFI, {}, true], 'bignumber') + const accountBTCBeforeClaim: Record = await client.call('getaccount', [accountBTC, {}, true], 'bignumber') + + // input utxos + const inputUTXOs = await container.fundAddress(accountBTC, 10) + // claim + const claimTxId = (await client.icxorderbook.claimDFCHTLC(DFCHTLCTxId, 'f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef', [inputUTXOs])).txid + await container.generate(1) + + const rawtx = await container.call('getrawtransaction', [claimTxId, true]) + expect(rawtx.vin[0].txid).toStrictEqual(inputUTXOs.txid) + expect(rawtx.vin[0].vout).toStrictEqual(inputUTXOs.vout) + + // List htlc and check + const listHTLCOptions: ICXListHTLCOptions = { + offerTx: makeOfferTxId, + closed: true + } + const HTLCs: Record = await client.call('icx_listhtlcs', [listHTLCOptions], 'bignumber') + expect(Object.keys(HTLCs).length).toBe(4) // extra entry for the warning text returned by the RPC atm. + // we have a common field "type", use that to narrow down the record + if (HTLCs[claimTxId].type === ICXHTLCType.CLAIM_DFC) { + // ICXClaimDFCHTLCInfo cast + const ClaimHTLCInfo: ICXClaimDFCHTLCInfo = HTLCs[claimTxId] as ICXClaimDFCHTLCInfo + expect(ClaimHTLCInfo.dfchtlcTx).toStrictEqual(DFCHTLCTxId) + expect(ClaimHTLCInfo.seed).toStrictEqual('f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef') + } + + // check HTLC DFCHTLCTxId is in claimed status + if (HTLCs[DFCHTLCTxId].type === ICXHTLCType.DFC) { + // ICXDFCHTLCInfo cast + const DFCHTLCInfo: ICXDFCHTLCInfo = HTLCs[DFCHTLCTxId] as ICXDFCHTLCInfo + expect(DFCHTLCInfo.status).toStrictEqual(ICXHTLCStatus.CLAIMED) + } + + const accountDFIAfterClaim: Record = await client.call('getaccount', [accountDFI, {}, true], 'bignumber') + const accountBTCAfterClaim: Record = await client.call('getaccount', [accountBTC, {}, true], 'bignumber') + + // maker should get incentive + maker deposit and taker should get amount in DFCHTLCTxId HTLC - takerfee + expect(accountDFIAfterClaim[idDFI]).toStrictEqual(accountDFIBeforeClaim[idDFI].plus(0.010).plus(0.00250)) + expect(accountBTCAfterClaim[idDFI]).toStrictEqual(accountBTCBeforeClaim[idDFI].plus(10)) + }) + + it('should return an error when try to claim DFC HTLC with invalid transaction id', async () => { + const { createOrderTxId } = await icxSetup.createDFISellOrder('BTC', accountDFI, '037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941', new BigNumber(15), new BigNumber(0.01)) + const { makeOfferTxId } = await icxSetup.createDFIBuyOffer(createOrderTxId, new BigNumber(0.10), accountBTC) + await icxSetup.createDFCHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', 500) + await icxSetup.submitExtHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(0.10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', + '13sJQ9wBWh8ssihHUgAaCmNWJbBAG5Hr9N', '036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252', 15) + + // claim with invalid DFC HTLC tx id "123" + const promise = client.icxorderbook.claimDFCHTLC('123', 'f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef') + await expect(promise).rejects.toThrow(RpcApiError) + await expect(promise).rejects.toThrow('RpcApiError: \'Test ICXClaimDFCHTLCTx execution failed:\ndfc htlc with creation tx 0000000000000000000000000000000000000000000000000000000000000123 does not exists!\', code: -32600, method: icx_claimdfchtlc') + + // claim with invalid DFC HTLC tx id "INVALID_DFC_HTLC_TX_ID" + const promise2 = client.icxorderbook.claimDFCHTLC('INVALID_DFC_HTLC_TX_ID', 'f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef') + await expect(promise2).rejects.toThrow(RpcApiError) + await expect(promise2).rejects.toThrow('RpcApiError: \'Test ICXClaimDFCHTLCTx execution failed:\ndfc htlc with creation tx 0000000000000000000000000000000000000000000000000000000000000000 does not exists!\', code: -32600, method: icx_claimdfchtlc') + }) + + it('should return an error when try to claim DFC HTLC with invalid seed', async () => { + const { createOrderTxId } = await icxSetup.createDFISellOrder('BTC', accountDFI, '037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941', new BigNumber(15), new BigNumber(0.01)) + const { makeOfferTxId } = await icxSetup.createDFIBuyOffer(createOrderTxId, new BigNumber(0.10), accountBTC) + const { DFCHTLCTxId } = await icxSetup.createDFCHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', 500) + await icxSetup.submitExtHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(0.10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', + '13sJQ9wBWh8ssihHUgAaCmNWJbBAG5Hr9N', '036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252', 15) + + // claim with invalid seed "INVALID_SEED" + const promise = client.icxorderbook.claimDFCHTLC(DFCHTLCTxId, 'INVALID_SEED') + await expect(promise).rejects.toThrow(RpcApiError) + await expect(promise).rejects.toThrow('RpcApiError: \'Test ICXClaimDFCHTLCTx execution failed:\nhash generated from given seed is different than in dfc htlc: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220!\', code: -32600, method: icx_claimdfchtlc') + }) + + // NOTE(surangap): Why this test is failing. should not be able to claim with arbitary utxos? + // it('should return an error when try to claim DFC HTLC with arbitary input utxos', async () => { + // const { createOrderTxId } = await icxSetup.createDFISellOrder('BTC', accountDFI, '037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941', new BigNumber(15), new BigNumber(0.01)) + // const { makeOfferTxId } = await icxSetup.createDFIBuyOffer(createOrderTxId, new BigNumber(0.10), accountBTC) + // const { DFCHTLCTxId } = await icxSetup.createDFCHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', 500) + // await icxSetup.submitExtHTLCForDFIBuyOffer(makeOfferTxId, new BigNumber(0.10), '957fc0fd643f605b2938e0631a61529fd70bd35b2162a21d978c41e5241a5220', + // '13sJQ9wBWh8ssihHUgAaCmNWJbBAG5Hr9N', '036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252', 15) + + // // input utxos + // const inputUTXOs = await container.fundAddress(await container.getNewAddress(), 10) + // // claim + // const promise = client.icxorderbook.claimDFCHTLC(DFCHTLCTxId, 'f75a61ad8f7a6e0ab701d5be1f5d4523a9b534571e4e92e0c4610c6a6784ccef', [inputUTXOs]) + // await expect(promise).rejects.toThrow(RpcApiError) + // await expect(promise).rejects.toThrow('RpcApiError: \'Test ICXSubmitEXTHTLCTx execution failed:\ntx must have at least one input from offer owner\', code: -32600, method: icx_submitexthtlc') + + // // List htlc and check + // const listHTLCOptions: ICXListHTLCOptions = { + // offerTx: makeOfferTxId, + // } + // const HTLCs: Record = await client.call('icx_listhtlcs', [listHTLCOptions], 'bignumber') + // expect(Object.keys(HTLCs).length).toBe(3) // extra entry for the warning text returned by the RPC atm. + // // check HTLC DFCHTLCTxId is still in OPEN status + // if (HTLCs[DFCHTLCTxId].type === ICXHTLCType.DFC) { + // // ICXDFCHTLCInfo cast + // const DFCHTLCInfo: ICXDFCHTLCInfo = HTLCs[DFCHTLCTxId] as ICXDFCHTLCInfo + // expect(DFCHTLCInfo.status).toStrictEqual(ICXHTLCStatus.OPEN) + // } + // }) +}) diff --git a/packages/jellyfish-api-core/__tests__/category/icxorderbook/icx_setup.ts b/packages/jellyfish-api-core/__tests__/category/icxorderbook/icx_setup.ts index 03b8df945f..430e7a105f 100644 --- a/packages/jellyfish-api-core/__tests__/category/icxorderbook/icx_setup.ts +++ b/packages/jellyfish-api-core/__tests__/category/icxorderbook/icx_setup.ts @@ -1,5 +1,8 @@ import { BigNumber } from '@defichain/jellyfish-api-core' -import { ICXOrder, ICXGenericResult, ICXOrderInfo, ICXOfferInfo, ICXOffer, ICXOrderStatus, ICXHTLCType, ICXHTLCStatus, HTLC, ICXClaimDFCHTLCInfo, ICXDFCHTLCInfo, ICXEXTHTLCInfo, ICXListHTLCOptions } from '../../../src/category/icxorderbook' +import { + ICXOrder, ICXGenericResult, ICXOrderInfo, ICXOfferInfo, ICXOffer, ICXOrderStatus, ICXHTLCType, ICXHTLCStatus, HTLC, + ICXClaimDFCHTLCInfo, ICXDFCHTLCInfo, ICXEXTHTLCInfo, ICXListHTLCOptions, ExtHTLC +} from '../../../src/category/icxorderbook' import { MasterNodeRegTestContainer } from '@defichain/testcontainers' import { createToken, mintTokens, accountToAccount } from '@defichain/testing' import { ContainerAdapterClient } from 'jellyfish-api-core/__tests__/container_adapter_client' @@ -182,7 +185,7 @@ export class ICXSetup { } } - // create and submits DFC HTLC for DFI buy order + // create and submits DFC HTLC for DFI buy offer async createDFCHTLCForDFIBuyOffer (makeOfferTxId: string, amount: BigNumber, hash: string, timeout: number): Promise<{DFCHTLC: HTLC, DFCHTLCTxId: string}> { const accountDFIBeforeDFCHTLC: Record = await this.client.call('getaccount', [accountDFI, {}, true], 'bignumber') // create DFCHTLC - maker @@ -213,4 +216,38 @@ export class ICXSetup { DFCHTLCTxId: DFCHTLCTxId } } + + // submits ExtHTLC for DFI buy offer + async submitExtHTLCForDFIBuyOffer (makeOfferTxId: string, amount: BigNumber, hash: string, htlcScriptAddress: string, ownerPubkey: string, timeout: number): Promise<{ExtHTLC: ExtHTLC, ExtHTLCTxId: string}> { + const accountBTCBeforeEXTHTLC = await this.client.call('getaccount', [accountBTC, {}, true], 'bignumber') + // submit EXT HTLC - taker + const ExtHTLC: ExtHTLC = { + offerTx: makeOfferTxId, + amount: amount, + hash: hash, + htlcScriptAddress: htlcScriptAddress, + ownerPubkey: ownerPubkey, + timeout: timeout + } + const ExtHTLCTxId = (await this.client.icxorderbook.submitExtHTLC(ExtHTLC)).txid + await this.container.generate(1) + + // List htlc + const listHTLCOptions: ICXListHTLCOptions = { + offerTx: makeOfferTxId + } + const HTLCs: Record = await this.client.call('icx_listhtlcs', [listHTLCOptions], 'bignumber') + expect(Object.keys(HTLCs).length).toBe(3) // extra entry for the warning text returned by the RPC atm. + expect((HTLCs[ExtHTLCTxId] as ICXEXTHTLCInfo).type).toStrictEqual(ICXHTLCType.EXTERNAL) + expect((HTLCs[ExtHTLCTxId] as ICXEXTHTLCInfo).status).toStrictEqual(ICXHTLCStatus.OPEN) + + const accountBTCAfterEXTHTLC = await this.client.call('getaccount', [accountBTC, {}, true], 'bignumber') + // should have the same balance as accountBTCBeforeEXTHTLC + expect(accountBTCAfterEXTHTLC).toStrictEqual(accountBTCBeforeEXTHTLC) + + return { + ExtHTLC: ExtHTLC, + ExtHTLCTxId: ExtHTLCTxId + } + } } diff --git a/packages/jellyfish-api-core/src/category/icxorderbook.ts b/packages/jellyfish-api-core/src/category/icxorderbook.ts index c8a5636c25..8290cb4e83 100644 --- a/packages/jellyfish-api-core/src/category/icxorderbook.ts +++ b/packages/jellyfish-api-core/src/category/icxorderbook.ts @@ -69,7 +69,7 @@ export class ICXOrderBook { * @param {UTXO[]} [utxos = []] Specific utxos to spend * @param {string} utxos.txid transaction Id * @param {number} utxos.vout The output number - * @return {Promise} Object indluding transaction id of the the transaction + * @return {Promise} Object including transaction id of the the transaction */ async closeOffer (offerTx: string, utxos: UTXO[] = []): Promise { return await this.client.call( @@ -92,7 +92,7 @@ export class ICXOrderBook { * @param {UTXO[]} [utxos = []] Specific utxos to spend * @param {string} utxos.txid transaction Id * @param {number} utxos.vout The output number - * @return {Promise} Object indluding transaction id of the the transaction + * @return {Promise} Object including transaction id of the the transaction */ async submitDFCHTLC (htlc: HTLC, utxos: UTXO[] = []): Promise { return await this.client.call( @@ -117,7 +117,7 @@ export class ICXOrderBook { * @param {UTXO[]} [utxos = []] Specific utxos to spend * @param {string} utxos.txid transaction Id * @param {number} utxos.vout The output number - * @return {Promise} Object indluding transaction id of the the transaction + * @return {Promise} Object including transaction id of the the transaction */ async submitExtHTLC (htlc: ExtHTLC, utxos: UTXO[] = []): Promise { return await this.client.call( @@ -129,11 +129,35 @@ export class ICXOrderBook { ) } + /** + * Claims a DFC HTLC + * + * @param {string} DFCHTLCTxId Transaction id of DFC HTLC transaction for which the claim is + * @param {string} seed Secret seed for claiming HTLC + * @param {UTXO[]} [utxos = []] Specific utxos to spend + * @param {string} utxos.txid transaction Id + * @param {number} utxos.vout The output number + * @return {Promise} Object including transaction id of the the transaction + */ + async claimDFCHTLC (DFCHTLCTxId: string, seed: string, utxos: UTXO[] = []): Promise { + const htlc = { + dfchtlcTx: DFCHTLCTxId, + seed: seed + } + return await this.client.call( + 'icx_claimdfchtlc', + [ + htlc, utxos + ], + 'bignumber' + ) + } + /** * Returns information about order or fillorder * * @param {string} orderTx Transaction id of createorder or fulfillorder transaction - * @return {Promise>} Object indluding details of the transaction. + * @return {Promise>} Object including details of the transaction. */ async getOrder (orderTx: string): Promise> { return await this.client.call( @@ -156,7 +180,7 @@ export class ICXOrderBook { * @param {string} [options.orderTx] Order txid to list all offers for this order * @param {number} [options.limit = 50] Maximum number of orders to return (default: 50) * @param {boolean} [options.closed] Display closed orders (default: false) - * @return {Promise>} Object indluding details of offers. + * @return {Promise>} Object including details of offers. */ async listOrders (options: { orderTx: string } & ICXListOrderOptions): Promise> @@ -169,7 +193,7 @@ export class ICXOrderBook { * @param {string} [options.orderTx] Order txid to list all offers for this order * @param {number} [options.limit = 50] Maximum number of orders to return (default: 50) * @param {boolean} [options.closed] Display closed orders (default: false) - * @return {Promise>} Object indluding details of orders and offers. + * @return {Promise>} Object including details of orders and offers. */ async listOrders (options?: ICXListOrderOptions): Promise> @@ -182,7 +206,7 @@ export class ICXOrderBook { * @param {string} [options.orderTx] Order txid to list all offers for this order * @param {number} [options.limit = 50] Maximum number of orders to return (default: 50) * @param {boolean} [options.closed] Display closed orders (default: false) - * @return {Promise>} Object indluding details of the transaction. + * @return {Promise>} Object including details of the transaction. */ async listOrders (options: ICXListOrderOptions = {}): Promise> { return await this.client.call( diff --git a/website/docs/jellyfish/api/icxorderbook.md b/website/docs/jellyfish/api/icxorderbook.md index 7524bb93e7..22b4867ad5 100644 --- a/website/docs/jellyfish/api/icxorderbook.md +++ b/website/docs/jellyfish/api/icxorderbook.md @@ -149,6 +149,26 @@ interface ICXGenericResult { } ``` +## claimDFCHTLC + +Claims a DFC HTLC + +```ts title="client.icxorderbook.claimDFCHTLC()" +interface icxorderbook { + claimDFCHTLC (DFCHTLCTxId: string, seed: string, utxos: UTXO[] = []): Promise +} + +interface UTXO { + txid: string + vout: number +} + +interface ICXGenericResult { + WARNING: string + txid: string +} +``` + ## getOrder Returns information about order or fillorder