-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
BTC RBF issue - did not use the original utxo #4149
Comments
Hi @jenbitcoin, you can have more control on UTXOs with BitcoinV2 protocol now. Lines 164 to 228 in 60ef068
The thing is that you can choose the UTXO selection pattern via Line 206 in 60ef068
It can be:
You can sort the UTXOs as you wish, and then use |
thank you, I will try it out. UPDATE: I tried this but for some reasons, it can't find the I tried to run this file in my local, and this is what I see. Am I missing something? 🤔 |
Describe the bug
The TrustWallet library chooses the best UTXO with bigger amount to spend. The issue happens when we want to replace a transaction. Example, the original input utxos are: [
utxo1 (1041 sats)
,utxo2 (2084 sats)
]and if we want to replace the transaction, and the original utxos are not enough to cover the new fee, we add another utxo [
utxo3 (5213 sats)
]When we send the original utxos + the new utxo to replace the transaction, the TW library chose the new utxo and disregard the original utxos. Which means, the app ended up creating a new transaction, not replacing the new one.
To Reproduce
BTC-1 sendAll amount to BTC-2 with [
utxo1 (1041 sats)
,utxo2 (2084 sats)
], but set the sequence to 4294967293.I want to replace, but there's no more balance, so I transfer more funds (5213 sats) to BTC-1.
After I received the new funds, replace the same transaction
send the original UTXOs + additional inputUTXO
[
utxo1 (1041 sats)
,utxo2 (2084 sats)
,utxo3 (5213 sats)
]Result:
The "replacement" transaction only used utxo3 (5213 sats) -- essentially creating a new transaction and not replacing the old one.
Expected behavior
Is there a way we can force the library to spend the original UTXO first to make sure the tx gets replaced.
Original Transaction:
[txId=
a874b98b8b634e18739db549090a175455cd6ebed91a614540b50ce12e4285eb
, txRaw=01000000028ab1d8fd56f7de55968624656ee8da22d0f5408e0f36fb144f0ce0106b6b1460000000006a47304402205976722a4cab5d00a720a179f985e95ed5eac6ccf9c664251529f8d1e0b1f76c02207605358cc6fb7bdc82d6e79741aaca76745104630152fe8fbd19e40da2fc78f5012103f854e8b00e451f78360744b72997b0ba44f1bbd9517c75d6857793f5ecabf67afdffffff508b85017432e126c79f1565186e78ed1a3fc7196f2e6ba66ae1d9ffe99aa651000000006b4830450221009f7cc41faf35402fd055ce3d95ce6e9357a966f320d6381f428f472e2ef5b27f02206874c622020551b28214f71c7f24ff712cd2dbfc76143cd9bb4ecfcb80ef2e41012103f854e8b00e451f78360744b72997b0ba44f1bbd9517c75d6857793f5ecabf67afdffffff0139080000000000001976a914f0c61800d9f659449fb00eeaba091bcd5ded578888ac00000000
, blockchain=BTC]Replaced Transaction:
[txId=
b1a56c835b1fcf5bb560c191d5a161e2c72c6dd576be98de42ed0a0e58bfa416
, txRaw=0100000001d2c9bb30e0365aca5a3c9a3293fee75f37d0c8f3f9b4c9e5b1cc4d52167ba106000000006b4830450221008dcbfd9875953b6c2e35c06acf6876988fba87dd71188d50f49f6784b2661d990220422f94458643fe596da9dfa1c6c0c6b6be280855d35ab28242420575fad9035e012103f854e8b00e451f78360744b72997b0ba44f1bbd9517c75d6857793f5ecabf67afdffffff0239080000000000001976a914f0c61800d9f659449fb00eeaba091bcd5ded578888ac7e090000000000001976a914c125b6c127ca853c5d4a73155f1d4ce525fbd55e88ac00000000
, blockchain=BTC]Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: