fix(sweep): Added button to sweep DEX offers

This commit is contained in:
Chris Troutner
2025-03-22 05:37:44 -07:00
parent 2766867b26
commit b0487d78e9
+49
View File
@@ -101,6 +101,32 @@ const SweepWif = (props) => {
} }
} }
const handleCancelCounterOffers = async () => {
try {
console.log(`Executing handleCancelCounterOffers()`)
// Set modal initial state
// setShowModal(true)
// setHideSpinner(false)
// setStatusMsg('')
// Get the keypair that holds Counter Offer UTXOs.
const bchDexLib = appData.dexLib
const keyPair = await bchDexLib.take.util.getKeyPair(1)
const wif = keyPair.wif
// console.log(`WIF: ${wif}`)
// Sweep the private key holding the Counter Offer UTXOs.
setWifToSweep(wif)
await handleSweep()
} catch (err) {
console.error('Error in handleCancelCounterOffers(): ', err)
}
}
// Modal component // Modal component
const getModal = () => ( const getModal = () => (
<Modal show={showModal} size='lg' onHide={() => setShowModal(false)}> <Modal show={showModal} size='lg' onHide={() => setShowModal(false)}>
@@ -178,6 +204,29 @@ const SweepWif = (props) => {
</Button> </Button>
</Col> </Col>
</Row> </Row>
<br />
<br />
<hr />
<Row>
<Col>
<p>
When a Buy order is created, the coins (UTXO) to pay for it are
moved to a secondary address. Clicking the button below will
sweep those funds back into this main wallet. This will also
cancel/invalidate all open Counter Offers that you've created.
</p>
</Col>
</Row>
<Row style={{ textAlign: 'center' }}>
<Col>
<Button onClick={handleCancelCounterOffers}>
Sweep DEX Trading Wallet
</Button>
</Col>
</Row>
</Container> </Container>
{showModal && getModal()} {showModal && getModal()}
</> </>