Skip to content

Commit

Permalink
fix: fix brc-20 sendby signing transaction before finalising then bro…
Browse files Browse the repository at this point in the history
…adcasting, closes #4635
  • Loading branch information
pete-watters committed Dec 8, 2023
1 parent 8b1be50 commit 5aa7c3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { BitcoinChooseFee } from '@app/features/bitcoin-choose-fee/bitcoin-choos
import { useValidateBitcoinSpend } from '@app/features/bitcoin-choose-fee/hooks/use-validate-bitcoin-spend';
import { UtxoResponseItem } from '@app/query/bitcoin/bitcoin-client';
import { useBrc20Transfers } from '@app/query/bitcoin/ordinals/brc20/use-brc-20';
import { useSignBitcoinTx } from '@app/store/accounts/blockchain/bitcoin/bitcoin.hooks';

import { useSendBitcoinAssetContextState } from '../../family/bitcoin/components/send-bitcoin-asset-container';

Expand All @@ -41,6 +42,7 @@ export function BrcChooseFee() {
const navigate = useNavigate();
const { amount, recipient, tick, utxos } = useBrc20ChooseFeeState();
const generateTx = useGenerateUnsignedNativeSegwitSingleRecipientTx();
const signTx = useSignBitcoinTx();
const { selectedFeeType, setSelectedFeeType } = useSendBitcoinAssetContextState();
const { initiateTransfer } = useBrc20Transfers();
const { feesList, isLoading } = useBitcoinFeesList({
Expand Down Expand Up @@ -80,12 +82,15 @@ export function BrcChooseFee() {
);

if (!resp) return logger.error('Attempted to generate raw tx, but no tx exists');
const signedTx = await signTx(resp.psbt);

if (!signedTx) return logger.error('Attempted to sign tx, but no tx exists');
signedTx.finalize();

const { hex } = resp;
const feeRowValue = formFeeRowValue(feeRate, isCustomFee);
navigate(RouteUrls.SendBrc20Confirmation.replace(':ticker', tick), {
state: {
tx: hex,
tx: signedTx.hex,
orderId: id,
fee: feeValue,
serviceFee: charge.amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AccountGate } from '@app/routes/account-gate';
import { BroadcastError } from '../broadcast-error/broadcast-error';
import { ChooseCryptoAsset } from '../choose-crypto-asset/choose-crypto-asset';
import { SendContainer } from '../send-container';
import { Brc20SentSummary } from '../sent-summary/brc20-sent-symmary';
import { Brc20SentSummary } from '../sent-summary/brc20-sent-summary';
import { BtcSentSummary } from '../sent-summary/btc-sent-summary';
import { StxSentSummary } from '../sent-summary/stx-sent-summary';
import { RecipientAccountsDrawer } from './components/recipient-accounts-drawer/recipient-accounts-drawer';
Expand Down

0 comments on commit 5aa7c3c

Please sign in to comment.