-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cw 649 rbf improvements opt in #1772
base: main
Are you sure you want to change the base?
Conversation
cw_bitcoin/lib/electrum_wallet.dart
Outdated
if (utxo.utxo.isP2tr()) { | ||
return key.signTapRoot(txDigest, sighash: sighash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was accidentally removed during a merge. I’ve restored it to handle Taproot signing
cw_bitcoin/lib/electrum_wallet.dart
Outdated
@@ -1543,14 +1543,17 @@ abstract class ElectrumWalletBase extends WalletBase< | |||
final bundle = await getTransactionExpanded(hash: txId); | |||
final outputs = bundle.originalTransaction.outputs; | |||
|
|||
final changeAddresses = walletAddresses.allAddresses.where((element) => element.isHidden); | |||
final receiverAmount = outputs.isNotEmpty ? outputs[0].amount.toInt() : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it has multiple outputs?
why not just use outputs.fold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Receiver amount is what the receiver should get, not just the sum of all outputs. I’ve improved this to sum outputs that aren’t change outputs, as using the first output isn’t reliable
int deduction = (outputAmount - _dustAmount >= remainingFee) | ||
? remainingFee | ||
: outputAmount - _dustAmount; | ||
|
||
outputs[i] = BitcoinOutput( | ||
address: outputs[i].address, value: BigInt.from(outputAmount - deduction)); | ||
address: output.address, value: BigInt.from(outputAmount - deduction)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we keep the output with the dust amount?
why not just check if the outputAmount - remainingFee > _dustAmount
then simply deduct the remaining fee from the output and break
else, then deduct the whole output amount from remainingFee and remove the whole output, and decrement the variable i
i.e
if (outputAmount - remainingFee > _dustAmount) {
_remainingFee = 0;
outputs[i] = BitcoinOutput(
address: output.address, value: BigInt.from(outputAmount - remainingFee));
break;
} else {
_remainingFee -= outputAmount;
outputs.remove(i);
i--;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve double-checked, and if I remove the output completely, I get the error “Sum value of utxo not spending” in some cases because the transaction becomes unbalanced—the inputs no longer equal the outputs plus the fee.
Issue Number (if Applicable): Fixes #
Description
Please include a summary of the changes and which issue is fixed / feature is added.
Pull Request - Checklist