From 19a9e2f4cca8310d6a1267119b108f8a9f4c6891 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 25 Apr 2019 18:38:26 +0300 Subject: [PATCH] Report `instantlock: true` for transactions locked via ChainLocks (#2877) * Report `instantlock: true` for transactions locked via ChainLocks Also introduce `instantlock_internal` to show the actual lock state. * Always show instantlock_internal --- doc/instantsend.md | 2 +- src/rpc/rawtransaction.cpp | 4 +++- src/wallet/rpcwallet.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/instantsend.md b/doc/instantsend.md index bea11735c0..fb3dcd5ac4 100644 --- a/doc/instantsend.md +++ b/doc/instantsend.md @@ -25,4 +25,4 @@ When a wallet InstantSend transaction is successfully locked a shell command pro #### RPC -Details pertaining to an observed "Transaction Lock" can also be retrieved through RPC. There is a boolean field named `instantlock` which indicates whether a given transaction is locked via InstantSend. This field is present in the output of some wallet RPC commands e.g. `listsinceblock`, `gettransaction` etc. as well as in the output of some mempool RPC commands e.g. `getmempoolentry` and a couple of others like `getrawmempool` (for `verbose=true` only). +Details pertaining to an observed "Transaction Lock" can also be retrieved through RPC. There is a boolean field named `instantlock` which indicates whether a given transaction is locked via InstantSend. This field is present in the output of some wallet RPC commands e.g. `listsinceblock`, `gettransaction` etc. as well as in the output of some mempool RPC commands e.g. `getmempoolentry` and a couple of others like `getrawmempool` (for `verbose=true` only). For blockchain based RPC commands `instantlock` will also say `true` if this transaction was locked via LLMQ based ChainLocks (for backwards compatibility reasons). diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 8ece8720fc..e6dd0d4cd6 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -201,7 +201,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) } bool fLocked = instantsend.IsLockedInstantSendTransaction(txid); bool fLLMQLocked = llmq::quorumInstantSendManager->IsLocked(txid); - entry.push_back(Pair("instantlock", fLocked || fLLMQLocked)); + entry.push_back(Pair("instantlock", fLocked || fLLMQLocked || chainLock)); + entry.push_back(Pair("instantlock_internal", fLocked || fLLMQLocked)); entry.push_back(Pair("chainlock", chainLock)); } @@ -269,6 +270,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request) " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" " \"instantlock\" : true|false, (bool) Current transaction lock state\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state\n" " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" "}\n" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e3760cce95..4eb4cc19aa 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -72,7 +72,8 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) chainlock = llmq::chainLocksHandler->HasChainLock(mapBlockIndex[wtx.hashBlock]->nHeight, wtx.hashBlock); } entry.push_back(Pair("confirmations", confirms)); - entry.push_back(Pair("instantlock", fLocked || fLLMQLocked)); + entry.push_back(Pair("instantlock", fLocked || fLLMQLocked || chainlock)); + entry.push_back(Pair("instantlock_internal", fLocked || fLLMQLocked)); entry.push_back(Pair("chainlock", chainlock)); if (wtx.IsCoinBase()) entry.push_back(Pair("generated", true)); @@ -1575,6 +1576,7 @@ UniValue listtransactions(const JSONRPCRequest& request) " 'receive' category of transactions. Negative confirmations indicate the\n" " transation conflicts with the block chain\n" " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions.\n" " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" " \"trusted\": xxx, (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n" @@ -1779,6 +1781,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) " \"confirmations\" : n, (numeric) The number of blockchain confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" " When it's < 0, it means the transaction conflicted that many blocks ago.\n" " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions.\n" " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" @@ -1880,6 +1883,7 @@ UniValue gettransaction(const JSONRPCRequest& request) " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" " 'send' category of transactions.\n" " \"instantlock\" : true|false, (bool) Current transaction lock state\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state\n" " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" " \"confirmations\" : n, (numeric) The number of blockchain confirmations\n" " \"blockhash\" : \"hash\", (string) The block hash\n"