From 8c5def99093f825f512d688d3282e9db215d48d5 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Tue, 12 Feb 2019 20:26:25 -0800 Subject: [PATCH] Used SegWit address for keva_delete. --- src/wallet/rpckeva.cpp | 11 ++++------- test/functional/feature_keva.py | 7 +++++++ 2 files changed, 11 insertions(+), 7 deletions(-) mode change 100644 => 100755 test/functional/feature_keva.py diff --git a/src/wallet/rpckeva.cpp b/src/wallet/rpckeva.cpp index 8f6b696c6..91c4a1ce7 100644 --- a/src/wallet/rpckeva.cpp +++ b/src/wallet/rpckeva.cpp @@ -360,11 +360,10 @@ UniValue keva_delete(const JSONRPCRequest& request) CPubKey pubKeyReserve; const bool ok = keyName.GetReservedKey(pubKeyReserve, true); assert(ok); - bool usedKey = false; - CScript addrName; - usedKey = true; - addrName = GetScriptForDestination(pubKeyReserve.GetID()); + CScript redeemScript = GetScriptForDestination(WitnessV0KeyHash(pubKeyReserve.GetID())); + CScriptID scriptHash = CScriptID(redeemScript); + CScript addrName = GetScriptForDestination(scriptHash); const CScript kevaScript = CKevaScript::buildKevaDelete(addrName, nameSpace, key); @@ -374,9 +373,7 @@ UniValue keva_delete(const JSONRPCRequest& request) SendMoneyToScript(pwallet, kevaScript, &txIn, empty, KEVA_LOCKED_AMOUNT, false, wtx, coinControl); - if (usedKey) { - keyName.KeepKey(); - } + keyName.KeepKey(); UniValue obj(UniValue::VOBJ); obj.pushKV("txid", wtx.GetHash().GetHex()); diff --git a/test/functional/feature_keva.py b/test/functional/feature_keva.py old mode 100644 new mode 100755 index f0450740d..2b228a6f5 --- a/test/functional/feature_keva.py +++ b/test/functional/feature_keva.py @@ -92,5 +92,12 @@ class KevaTest(BitcoinTestFramework): response = self.nodes[0].keva_get(namespaceId, keyToDelete) assert(response['value'] == '') + self.log.info("Test reset the value after deleting") + newValue = 'This is the new value' + self.nodes[0].keva_put(namespaceId, keyToDelete, newValue) + self.nodes[0].generate(1) + response = self.nodes[0].keva_get(namespaceId, keyToDelete) + assert(response['value'] == newValue) + if __name__ == '__main__': KevaTest().main()