diff --git a/app/background/shakedex/service.js b/app/background/shakedex/service.js index 73e4e3e93..cd46b1fe0 100644 --- a/app/background/shakedex/service.js +++ b/app/background/shakedex/service.js @@ -22,7 +22,6 @@ import {app} from "electron"; import bdb from "bdb"; import { auctionSchema, - finalizeLockScheme, fulfillmentSchema, getFinalizeFromTransferTx, nameLockSchema, @@ -189,10 +188,20 @@ export async function transferCancel(nameLock, password) { const existing = await get( `${listingPrefix()}/${nameLock.name}/${nameLock.transferTxHash}`, ); - const {finalizeLock} = existing; + const { + tx: finalizeTx, + coin: finalizeCoin, + } = await getFinalizeFromTransferTx( + nameLock.transferTxHash, + nameLock.name, + nodeService, + ); + const cancelNameLock = await transferNameLockCancel(context, { - ...finalizeLock, - publicKey: Buffer.from(finalizeLock.publicKey, 'hex'), + ...nameLock, + finalizeTxHash: finalizeTx.hash, + finalizeOutputIdx: finalizeCoin.index, + publicKey: Buffer.from(nameLock.publicKey, 'hex'), privateKey: Buffer.from(decrypt(nameLock.encryptedPrivateKey, password), 'hex'), }); const {privateKey, ...cancelLockJSON} = cancelNameLock.toJSON(context); @@ -242,11 +251,10 @@ export async function finalizeCancel(nameLock, password) { export async function restoreOneListing(listing) { const {valid: auctionValid} = jsonSchemaValidate(listing.auction, auctionSchema); - const {valid: finalizeValid} = jsonSchemaValidate(listing.finalizeLock, finalizeLockScheme); const {valid: nameLockValid} = jsonSchemaValidate(listing.nameLock || {}, nameLockSchema); const {valid: paramsValid} = jsonSchemaValidate(listing.params, paramSchema); - if (!auctionValid || !finalizeValid || !nameLockValid || !paramsValid) { + if (!auctionValid || !nameLockValid || !paramsValid) { throw new Error('Invalid backup file schema'); } const {nameLock} = listing; diff --git a/app/ducks/exchange.js b/app/ducks/exchange.js index bf032cdc5..5b2c43cf6 100644 --- a/app/ducks/exchange.js +++ b/app/ducks/exchange.js @@ -475,8 +475,9 @@ export const launchExchangeAuction = (nameLock, overrideParams) => async (dispat try { const passphrase = await new Promise((resolve, reject) => dispatch(getPassphrase(resolve, reject))); - await shakedex.launchAuction(nameLock, passphrase, overrideParams); + await shakedex.launchAuction(nameLock, passphrase, overrideParams, true); } catch (e) { + console.log(e); dispatch({ type: LAUNCH_EXCHANGE_AUCTION_ERR, }); diff --git a/app/utils/shakedex.js b/app/utils/shakedex.js index d40dd357b..506e9b610 100644 --- a/app/utils/shakedex.js +++ b/app/utils/shakedex.js @@ -279,8 +279,10 @@ export async function getFinalizeFromTransferTx(transferTxHash, name, nodeClient finalizeOutputIdx = 0; for (let i = 0; i < finalizeTx.outputs.length; i++) { - if (finalizeTx.outputs[i].covenant.action === 'FINALIZE') { + const covenant = finalizeTx.outputs[i].covenant; + if (covenant.action === 'FINALIZE' && covenant.items[0] === nameHash) { finalizeOutputIdx = i; + continue; } }