From 8d411a16a77b64ed34369475d4307ce68f16867c Mon Sep 17 00:00:00 2001 From: yanmaani Date: Wed, 23 Jun 2021 12:00:00 +0000 Subject: [PATCH] fixup! rpc: Add name_autoregister RPC --- src/wallet/rpcnames.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wallet/rpcnames.cpp b/src/wallet/rpcnames.cpp index 6263293fb6..8c4672f55a 100644 --- a/src/wallet/rpcnames.cpp +++ b/src/wallet/rpcnames.cpp @@ -601,6 +601,16 @@ name_autoregister() // TODO: Mark all inputs unspendable. + for (auto input : mtx.vin) + pwallet->LockCoin(input.prevout); + + CTransactionRef txr = MakeTransactionRef(mtx); + pwallet->CommitTransaction(txr, {}, {}); + + pwallet->AddToWallet(txr, /* confirm */ {}, /* update_wtx */ nullptr, /* fFlushOnClose */ true); + // If the transaction is not added to the wallet, the inputs will continue to + // be considered spendable, causing us to double-spend the most preferable input if delegating. + const bool queued_ok = pwallet->WriteQueuedTransaction(mtx.GetHash(), mtx); if (!queued_ok) throw JSONRPCError(RPC_WALLET_ERROR, "Error queueing transaction");