Skip to content
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

Add canceltransaction RPC method #11536

Merged
merged 1 commit into from
Sep 25, 2023
Merged

Conversation

lontivero
Copy link
Collaborator

@lontivero lontivero commented Sep 21, 2023

This PR adds the canceltransaction RPC method which received the hash of the transaction to be cancelled and returns the raw transaction that cancels the previous tx.

$ curl -s --user rpcuser:rpcpassword \
--data-binary '{"jsonrpc":"2.0", "id":"curltext", "method":"canceltransaction", "params":["0f5cdf64a4138d7bbf95bdaf7b73619aae9137085edf69c057b18ff6dda1935f"]}' -H \
-- 'content-type: text/plain;' \
http://127.0.0.1:37128/TestNet%20Small/

010000000001015620b45c9625563e7fe9899407ce905c0b34d4b1edb373eca920e6ece172f06a0000000000fdffffff011b3e100000000000225120f2e947f2bbbad6a738fe6dcc96886291fc75d483e428dcd0fd7dc25fb7ebe4e00140f074f6f3e53ace8f4e60c25186661ba5a31159feb668d6a78e864815c398a8b317cc759971144cfbecc6ab122e3e3d9f91362b793bb9b48297894a1c2c26927200000000

This one and #11537 close: #11500

Copy link
Collaborator

@MarnixCroes MarnixCroes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tack 937e649

var mempoolStore = Global.BitcoinStore.TransactionStore.MempoolStore;
if (!mempoolStore.TryGetTransaction(txId, out var smartTransactionToCancel))
{
throw new NotSupportedException($"Unknown transaction {txId}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would ArgumentException be better? Or does throwing NotSupportedException lead to some interesting behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be. There is another issue to fix the error reporting code. I still don't know exactly how but I will take this there.

@@ -220,6 +220,23 @@ public async Task<object> SendTransactionAsync(PaymentInfo[] payments, OutPoint[
};
}

[JsonRpcMethod("canceltransaction")]
public string BuildCancelTransaction(uint256 txId, string password = "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note to self: This somewhat makes it look like we succeed in case the parameters are correct but it might still fail because the cancellation would be too expensive AFAIK. Not sure how expected that is but hopefully we will document it in the RPC documentation)

kiminuo
kiminuo previously approved these changes Sep 23, 2023
Copy link
Collaborator

@kiminuo kiminuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lontivero lontivero merged commit 25e6a48 into WalletWasabi:master Sep 25, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add RPC endpoints to accelerate and cancel transactions
3 participants