Skip to content

Commit

Permalink
fix: throw insufficient balance when btc utxo is not enough
Browse files Browse the repository at this point in the history
  • Loading branch information
slient-coder committed Jan 5, 2024
1 parent 8e0645b commit 873f349
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ export class WalletController extends BaseController {
btcUtxos = await this.getBTCUtxos();
}

if (btcUtxos.length == 0) {
throw new Error('Insufficient balance.');
}

const { psbt, toSignInputs } = await txHelpers.sendBTC({
btcUtxos: btcUtxos,
tos: [{ address: to, satoshis: amount }],
Expand Down Expand Up @@ -749,6 +753,11 @@ export class WalletController extends BaseController {
if (!btcUtxos) {
btcUtxos = await this.getBTCUtxos();
}

if (btcUtxos.length == 0) {
throw new Error('Insufficient balance.');
}

const { psbt, toSignInputs } = await txHelpers.sendAllBTC({
btcUtxos: btcUtxos,
toAddress: to,
Expand Down Expand Up @@ -798,6 +807,10 @@ export class WalletController extends BaseController {
btcUtxos = await this.getBTCUtxos();
}

if (btcUtxos.length == 0) {
throw new Error('Insufficient balance.');
}

const { psbt, toSignInputs } = await txHelpers.sendInscription({
assetUtxo,
btcUtxos,
Expand Down Expand Up @@ -851,6 +864,10 @@ export class WalletController extends BaseController {
btcUtxos = await this.getBTCUtxos();
}

if (btcUtxos.length == 0) {
throw new Error('Insufficient balance.');
}

const { psbt, toSignInputs } = await txHelpers.sendInscriptions({
assetUtxos,
btcUtxos,
Expand Down Expand Up @@ -1415,6 +1432,11 @@ export class WalletController extends BaseController {
if (!btcUtxos) {
btcUtxos = await this.getBTCUtxos();
}

if (btcUtxos.length == 0) {
throw new Error('Insufficient balance.');
}

const { psbt, toSignInputs } = await txHelpers.sendAtomicalsNFT({
assetUtxo,
btcUtxos,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/RBFBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function RBFBar({ onChange }: { onChange: (val: boolean) => void }) {
return (
<Row justifyBetween>
<Tooltip
title={`A feature that allows the transaction to be replaced.`}
title={`A feature allows the transaction to be replaced.`}
overlayStyle={{
fontSize: fontSizes.xs
}}>
Expand Down

0 comments on commit 873f349

Please sign in to comment.