Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/coordinator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"@caravan/descriptors": "^0.1.1",
"@caravan/eslint-config": "*",
"@caravan/psbt": "*",
"@caravan/fees": "*",
"@caravan/typescript-config": "*",
"@caravan/wallets": "*",
"@emotion/react": "^11.10.6",
Expand Down
6 changes: 6 additions & 0 deletions apps/coordinator/src/actions/transactionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const SET_REQUIRED_SIGNERS = "SET_REQUIRED_SIGNERS";
export const SET_TOTAL_SIGNERS = "SET_TOTAL_SIGNERS";

export const SET_INPUTS = "SET_INPUTS";
export const SET_RBF = "SET_RBF";

export const ADD_OUTPUT = "ADD_OUTPUT";
export const SET_OUTPUT_ADDRESS = "SET_OUTPUT_ADDRESS";
Expand Down Expand Up @@ -114,6 +115,11 @@ export function setChangeAddressAction(value) {
};
}

export const setRBF = (enabled) => ({
type: SET_RBF,
value: enabled,
});

export function setChangeOutput({ value, address }) {
return (dispatch, getState) => {
const {
Expand Down
1 change: 1 addition & 0 deletions apps/coordinator/src/actions/walletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const WALLET_MODES = {
VIEW: 0,
DEPOSIT: 1,
SPEND: 2,
PENDING: 3,
};

export function updateDepositSliceAction(value) {
Expand Down
50 changes: 44 additions & 6 deletions apps/coordinator/src/components/ScriptExplorer/OutputsForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
InputAdornment,
Typography,
FormHelperText,
Switch,
FormControlLabel,
} from "@mui/material";
import InfoIcon from "@mui/icons-material/Info";
import { Speed } from "@mui/icons-material";
import AddIcon from "@mui/icons-material/Add";
import {
Expand All @@ -24,6 +27,7 @@ import {
setFee as setFeeAction,
finalizeOutputs as finalizeOutputsAction,
resetOutputs as resetOutputsAction,
setRBF as setRBFAction,
} from "../../actions/transactionActions";
import { updateBlockchainClient } from "../../actions/clientActions";
import { MIN_SATS_PER_BYTE_FEE } from "../Wallet/constants";
Expand Down Expand Up @@ -231,6 +235,11 @@ class OutputsForm extends React.Component {
setOutputAmount(1, outputAmount);
}

handleRBFToggle = () => {
const { setRBF, rbfEnabled } = this.props;
setRBF(!rbfEnabled);
};

render() {
const {
feeRate,
Expand All @@ -242,6 +251,7 @@ class OutputsForm extends React.Component {
inputs,
isWallet,
autoSpend,
rbfEnabled,
} = this.props;
const { feeRateFetchError } = this.state;
const feeDisplay = inputs && inputs.length > 0 ? fee : "0.0000";
Expand Down Expand Up @@ -281,7 +291,7 @@ class OutputsForm extends React.Component {
</Button>
</Grid>
</Grid>
<Grid item container spacing={gridSpacing}>
<Grid item container spacing={gridSpacing} alignItems="flex-end">
<Grid item xs={3}>
<Box mt={feeMt}>
<Typography
Expand Down Expand Up @@ -327,9 +337,6 @@ class OutputsForm extends React.Component {
</Typography>
</Grid>

<Grid item xs={4}>
<Box mt={feeMt}>&nbsp;</Box>
</Grid>
{!isWallet || (isWallet && !autoSpend) ? (
<Grid item xs={3}>
<Box mt={feeMt}>
Expand Down Expand Up @@ -357,10 +364,37 @@ class OutputsForm extends React.Component {
</Box>
</Grid>
) : (
""
<Grid item xs={3} />
)}

<Grid item xs={2} />
<Grid item xs={1} />
<Grid item xs={3}>
<Box
mt={feeMt}
display="flex"
flexDirection="column"
alignItems="flex-end"
>
<Tooltip title="Replace-By-Fee allows you to increase the fee later if needed">
<IconButton size="small">
<InfoIcon />
</IconButton>
</Tooltip>
<FormControlLabel
control={
<Switch
checked={rbfEnabled}
onChange={this.handleRBFToggle}
name="rbfToggle"
color="primary"
disabled={finalizedOutputs}
/>
}
label="Enable RBF"
labelPlacement="start"
/>
</Box>
</Grid>
</Grid>

<Grid item container spacing={gridSpacing}>
Expand Down Expand Up @@ -488,6 +522,8 @@ OutputsForm.propTypes = {
signatureImporters: PropTypes.shape({}).isRequired,
updatesComplete: PropTypes.bool,
getBlockchainClient: PropTypes.func.isRequired,
rbfEnabled: PropTypes.bool.isRequired,
setRBF: PropTypes.func.isRequired,
};

OutputsForm.defaultProps = {
Expand All @@ -504,6 +540,7 @@ function mapStateToProps(state) {
...state.client,
signatureImporters: state.spend.signatureImporters,
change: state.wallet.change,
rbfEnabled: state.spend.transaction.rbfEnabled,
};
}

Expand All @@ -515,6 +552,7 @@ const mapDispatchToProps = {
finalizeOutputs: finalizeOutputsAction,
resetOutputs: resetOutputsAction,
getBlockchainClient: updateBlockchainClient,
setRBF: setRBFAction,
};

export default connect(mapStateToProps, mapDispatchToProps)(OutputsForm);
4 changes: 4 additions & 0 deletions apps/coordinator/src/components/Wallet/WalletControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { setRequiredSigners as setRequiredSignersAction } from "../../actions/tr
import { MAX_FETCH_UTXOS_ERRORS, MAX_TRAILING_EMPTY_NODES } from "./constants";
import WalletDeposit from "./WalletDeposit";
import WalletSpend from "./WalletSpend";
import WalletPendingTransactions from "./WalletPendingTransactions";
import { SlicesTableContainer } from "../Slices";

class WalletControl extends React.Component {
Expand All @@ -41,6 +42,7 @@ class WalletControl extends React.Component {
<Tab label="Addresses" value={WALLET_MODES.VIEW} key={0} />,
<Tab label="Receive" value={WALLET_MODES.DEPOSIT} key={1} />,
<Tab label="Send" value={WALLET_MODES.SPEND} key={2} />,
<Tab label="Pending" value={WALLET_MODES.PENDING} key={3} />,
]}
</Tabs>
<Box mt={2}>{this.renderModeComponent()}</Box>
Expand All @@ -55,6 +57,8 @@ class WalletControl extends React.Component {
if (walletMode === WALLET_MODES.SPEND)
return <WalletSpend addNode={addNode} updateNode={updateNode} />;
if (walletMode === WALLET_MODES.VIEW) return <SlicesTableContainer />;
if (walletMode === WALLET_MODES.PENDING)
return <WalletPendingTransactions />;
}
const progress = this.progress();
return [
Expand Down
Loading