Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
fix: argument order of constructRefundTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Jan 25, 2019
1 parent ecfc45e commit dbcbd62
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
7 changes: 5 additions & 2 deletions src/views/refund/refund.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ const Refund = ({
onPress={() => props.nextStage()}
loadingText={'Upload refund file'}
loadingStyle={classes.fileUpload}
loading={Object.keys(refundFile).length === 0}
loading={
Object.keys(refundFile).length === 0 ||
transactionHash === ''
}
/>
)}
/>
Expand All @@ -119,7 +122,7 @@ const Refund = ({
num={3}
render={() => (
<Controls
text={'Successfully completed refund!'}
text={'Try another Swap!'}
onPress={() => {
completeRefund();
goHome();
Expand Down
30 changes: 17 additions & 13 deletions src/views/refund/refundActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ export const startRefund = (
response.data.transactionHex
);

// TODO: refactor for new version of core library
// TODO: make sure the provided lockup transaction hash was correct and show more specific error if not
const refundTransaction = constructRefundTransaction(
ECPair.fromPrivateKey(getHexBuffer(refundFile.privateKey)),
redeemScript,
[
{
redeemScript,
txHash: lockupTransaction.getHash(),
keys: ECPair.fromPrivateKey(getHexBuffer(refundFile.privateKey)),
...detectSwap(redeemScript, lockupTransaction),
},
],
address.toOutputScript(destinationAddress, getNetwork(currency)),
refundFile.timeoutBlockHeight,
// TODO: make sure the provided lockup transaction hash was correct and show more specific error if not
{
txHash: lockupTransaction.getHash(),
...detectSwap(redeemScript, lockupTransaction),
},
address.toOutputScript(destinationAddress, getNetwork(currency))
1
);

const refundTransactionHex = refundTransaction.toHex();
Expand All @@ -103,11 +105,13 @@ export const startRefund = (
dispatch(setRefundTransaction(refundTransactionHex));
dispatch(setRefundTransactionHash(refundTransactionHash));

broadcastRefund(currency, refundTransactionHex, () => {
dispatch(refundResponse(true, response.data));
dispatch(
broadcastRefund(currency, refundTransactionHex, () => {
dispatch(refundResponse(true, response.data));

cb();
});
cb();
})
);
})
.catch(error => {
window.alert('Failed to refund swap');
Expand Down
2 changes: 1 addition & 1 deletion src/views/refund/refundReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as actionTypes from '../../constants/actions';
const initalState = {
isFetching: false,
refundFile: {},
transactionHash: null,
transactionHash: '',
destinationAddress: null,
refundTransaction: null,
refundTransactionHash: null,
Expand Down
19 changes: 9 additions & 10 deletions src/views/refund/steps/completeRefund.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ const StyledCompleteRefund = ({
}) => (
<View className={classes.wrapper}>
<FaCheckCircle size={240} className={classes.icon} />
<span className={classes.title}>Success!</span>
<p>Your refund transaction:</p>
<code className={classes.transaction}>{refundTransaction}</code>
<span className={classes.title}>
Refund transaction successfully broadcasted!
</span>
<p>
Your refund transaction hash: <br />
<code className={classes.transaction}>{refundTransactionHash}</code>
</p>

<p>
<a
className={classes.link}
target={'_blank'}
href={`https://chain.so/tx/LTCTEST/${refundTransactionHash}`}
>
{refundTransactionHash}
</a>
Raw transaction: <br />
<code className={classes.transaction}>{refundTransaction}</code>
</p>
</View>
);
Expand Down

0 comments on commit dbcbd62

Please sign in to comment.