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

Commit

Permalink
Merge pull request #68 from BoltzExchange/minor-fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
michael1011 authored Jan 26, 2019
2 parents 72b4885 + dbcbd62 commit cfd22c1
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 42 deletions.
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
11 changes: 6 additions & 5 deletions src/views/swap/swapActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ export const startListening = (dispatch, swapId, callback) => {
source.onmessage = event => {
const data = JSON.parse(event.data);

if (data.message.startsWith('Transaction confirmed:')) {
message = {
pending: false,
message: 'Confirmed!',
};
if (data.message.startsWith('Invoice paid:')) {
source.close();
callback();
} else if (data.message.startsWith('Transaction confirmed:')) {
message = {
pending: true,
message: 'Waiting for invoice to be paid...',
};
} else {
message = {
error: true,
Expand Down

0 comments on commit cfd22c1

Please sign in to comment.