Skip to content

Commit b3f9f30

Browse files
authored
fix(transfer): disable RBF for manual channel funding (#2294)
1 parent baee6f8 commit b3f9f30

File tree

8 files changed

+40
-67
lines changed

8 files changed

+40
-67
lines changed

src/screens/Settings/AddressViewer/index.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,8 @@ const AddressViewer = ({
644644
return;
645645
}
646646
updateSendTransaction({
647-
transaction: {
648-
...transactionRes.value,
649-
outputs: [{ address: receiveAddress.value, value: 0, index: 0 }],
650-
},
647+
...transactionRes.value,
648+
outputs: [{ address: receiveAddress.value, value: 0, index: 0 }],
651649
});
652650
dispatch(updateUi({ fromAddressViewer: true }));
653651
sendMax({

src/screens/Transfer/SpendingAmount.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const SpendingAmount = ({
6666
useCallback(() => {
6767
const setupTransfer = async (): Promise<void> => {
6868
await resetSendTransaction();
69-
await setupOnChainTransaction();
69+
await setupOnChainTransaction({ rbf: false });
7070
refreshBlocktankInfo().then();
7171
};
7272
setupTransfer();

src/screens/Wallets/Send/Amount.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ const Amount = ({ navigation }: SendScreenProps<'Amount'>): ReactElement => {
151151
return;
152152
}
153153
if (isMaxSendAmount && amount !== availableAmount) {
154-
updateSendTransaction({ transaction: { max: false } });
154+
updateSendTransaction({ max: false });
155155
}
156156

157157
if (!isMaxSendAmount && amount === availableAmount) {
158-
updateSendTransaction({ transaction: { max: true } });
158+
updateSendTransaction({ max: true });
159159
}
160160
}, [isMaxSendAmount, amount, availableAmount, transaction?.lightningInvoice]);
161161

src/store/actions/wallet.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,11 @@ export const getChangeAddress = async ({
319319
* @param {Partial<ISendTransaction>} transaction
320320
* @returns {Promise<Result<string>>}
321321
*/
322-
export const updateSendTransaction = ({
323-
transaction,
324-
}: {
325-
transaction: Partial<ISendTransaction>;
326-
}): Result<string> => {
322+
export const updateSendTransaction = (
323+
transaction: Partial<ISendTransaction>,
324+
): Result<string> => {
327325
const tx = getOnChainWalletTransaction();
328-
return tx.updateSendTransaction({
329-
transaction,
330-
});
326+
return tx.updateSendTransaction({ transaction });
331327
};
332328

333329
/**

src/store/utils/blocktank.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,13 @@ export const startChannelPurchase = async ({
282282
}
283283

284284
updateSendTransaction({
285-
transaction: {
286-
outputs: [
287-
{
288-
address: buyChannelData.payment.onchain.address,
289-
value: amountToSend,
290-
index: 0,
291-
},
292-
],
293-
},
285+
outputs: [
286+
{
287+
address: buyChannelData.payment.onchain.address,
288+
value: amountToSend,
289+
index: 0,
290+
},
291+
],
294292
});
295293

296294
const fees = getFeesStore().onchain;

src/utils/scanner.ts

+13-17
Original file line numberDiff line numberDiff line change
@@ -843,12 +843,10 @@ export const handleData = async ({
843843
sendNavigation.navigate('Amount');
844844

845845
updateSendTransaction({
846-
transaction: {
847-
label: message,
848-
outputs: [{ address: address, value: sats, index: 0 }],
849-
lightningInvoice: undefined,
850-
slashTagsUrl: slashTagsUrl,
851-
},
846+
label: message,
847+
outputs: [{ address: address, value: sats, index: 0 }],
848+
lightningInvoice: undefined,
849+
slashTagsUrl: slashTagsUrl,
852850
});
853851

854852
return ok({
@@ -884,17 +882,15 @@ export const handleData = async ({
884882
}
885883

886884
updateSendTransaction({
887-
transaction: {
888-
outputs: [
889-
{
890-
address: '',
891-
value: invoiceAmount,
892-
index: 0,
893-
},
894-
],
895-
lightningInvoice: lightningPaymentRequest,
896-
slashTagsUrl,
897-
},
885+
outputs: [
886+
{
887+
address: '',
888+
value: invoiceAmount,
889+
index: 0,
890+
},
891+
],
892+
lightningInvoice: lightningPaymentRequest,
893+
slashTagsUrl,
898894
});
899895

900896
return ok({

src/utils/wallet/transactions.ts

+9-25
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,14 @@ export const getTotalFee = ({
8989
});
9090
};
9191

92-
interface ICreateTransaction {
93-
selectedWallet?: TWalletName;
94-
selectedNetwork?: EAvailableNetwork;
95-
transactionData?: ISendTransaction;
96-
}
97-
9892
/**
9993
* Creates complete signed transaction using the transaction data store
10094
* @param {ISendTransaction} [transactionData]
10195
* @returns {Promise<Result<{id: string, hex: string}>>}
10296
*/
103-
export const createTransaction = async ({
104-
transactionData,
105-
}: ICreateTransaction = {}): Promise<Result<{ id: string; hex: string }>> => {
97+
export const createTransaction = async (
98+
transactionData?: ISendTransaction,
99+
): Promise<Result<{ id: string; hex: string }>> => {
106100
try {
107101
const transaction = getOnChainWalletTransaction();
108102
const createTxRes = await transaction.createTransaction({
@@ -690,10 +684,8 @@ export const updateSendAmount = ({
690684
}
691685

692686
updateSendTransaction({
693-
transaction: {
694-
outputs: [{ ...currentOutput, value: amount }],
695-
max,
696-
},
687+
outputs: [{ ...currentOutput, value: amount }],
688+
max,
697689
});
698690

699691
return ok('');
@@ -747,15 +739,11 @@ export const updateMessage = async ({
747739
if (max) {
748740
_transaction.outputs = [{ address, value: inputTotal - newFee, index }];
749741
//Update the tx value with the new fee to continue sending the max amount.
750-
updateSendTransaction({
751-
transaction: _transaction,
752-
});
742+
updateSendTransaction(_transaction);
753743
return ok('Successfully updated the message.');
754744
}
755745
if (totalNewAmount <= inputTotal) {
756-
updateSendTransaction({
757-
transaction: _transaction,
758-
});
746+
updateSendTransaction(_transaction);
759747
}
760748
return ok('Successfully updated the message.');
761749
};
@@ -816,11 +804,7 @@ const runCoinSelect = async ({
816804
fee: autoCoinSelectResponse.value.fee,
817805
inputs: autoCoinSelectResponse.value.inputs,
818806
};
819-
updateSendTransaction({
820-
selectedWallet,
821-
selectedNetwork,
822-
transaction: updatedTx,
823-
});
807+
updateSendTransaction(updatedTx);
824808
return ok('Successfully updated tx.');
825809
}
826810
return ok('No need to update transaction.');
@@ -913,7 +897,7 @@ export const broadcastBoost = async ({
913897
}
914898
const transaction = transactionDataResponse.value;
915899

916-
const rawTx = await createTransaction({});
900+
const rawTx = await createTransaction();
917901
if (rawTx.isErr()) {
918902
return err(rawTx.error.message);
919903
}

src/utils/wallet/transfer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ export const createFundedChannel = async ({
115115
const address = getAddressFromScriptPubKey(output_script, network);
116116

117117
updateSendTransaction({
118-
transaction: { outputs: [{ address, value: value_satoshis, index: 0 }] },
118+
rbf: false,
119+
outputs: [{ address, value: value_satoshis, index: 0 }],
119120
});
120121

121122
const createTxResult = await createTransaction();

0 commit comments

Comments
 (0)