From baf5be5c137f87b41895fa94ddf8c7ca7d6cf739 Mon Sep 17 00:00:00 2001 From: erqan Date: Thu, 29 Sep 2016 18:33:10 +0300 Subject: [PATCH 1/3] enables readding a group key by --- src/twister.cpp | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/twister.cpp b/src/twister.cpp index 2627631c..2be6bce1 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -1206,34 +1206,33 @@ string getGroupAliasByKey(const string &privKey) void registerNewGroup(const string &privKey, const string &desc, const string &member, const string &invitedBy, int64_t utcTime, int k) { string groupAlias = getGroupAliasByKey(privKey); - if( !groupAlias.length() ) { - CBitcoinSecret vchSecret; - bool fGood = vchSecret.SetString(privKey); - if (!fGood) { - printf("registerGroupMember: Invalid private key\n"); - return; - } - CKey key = vchSecret.GetKey(); - CPubKey pubkey = key.GetPubKey(); - CKeyID vchAddress = pubkey.GetID(); - { - LOCK(pwalletMain->cs_wallet); - if (pwalletMain->HaveKey(vchAddress)) { - // already exists? reuse same alias (trying to fix inconsistency wallet x groups) - groupAlias = pwalletMain->mapKeyMetadata[vchAddress].username; - if( !groupAlias.length() || groupAlias.at(0) != '*' ) { - printf("registerGroupMember: Invalid group alias '%s' from wallet\n", groupAlias.c_str()); - return; - } - } else { - groupAlias = getRandomGroupAlias(); - } - pwalletMain->mapKeyMetadata[vchAddress] = CKeyMetadata(GetTime(), groupAlias); - if (!pwalletMain->AddKeyPubKey(key, pubkey)) { - printf("registerGroupMember: Error adding key to wallet\n"); + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(privKey); + if (!fGood) { + printf("registerGroupMember: Invalid private key\n"); + return; + } + CKey key = vchSecret.GetKey(); + CPubKey pubkey = key.GetPubKey(); + CKeyID vchAddress = pubkey.GetID(); + { + LOCK(pwalletMain->cs_wallet); + if (pwalletMain->HaveKey(vchAddress)) { + // already exists? reuse same alias (trying to fix inconsistency wallet x groups) + groupAlias = pwalletMain->mapKeyMetadata[vchAddress].username; + if( !groupAlias.length() || groupAlias.at(0) != '*' ) { + printf("registerGroupMember: Invalid group alias '%s' from wallet\n", groupAlias.c_str()); return; } + } else if (!groupAlias.length()) { + groupAlias = getRandomGroupAlias(); + } + + pwalletMain->mapKeyMetadata[vchAddress] = CKeyMetadata(GetTime(), groupAlias); + if (!pwalletMain->AddKeyPubKey(key, pubkey)) { + printf("registerGroupMember: Error adding key to wallet\n"); + return; } } From f0af136a5de56517cedddfd736caf63ad2324116 Mon Sep 17 00:00:00 2001 From: erqan Date: Tue, 4 Oct 2016 16:56:24 +0300 Subject: [PATCH 2/3] import group key with creategroup --- src/twister.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/twister.cpp b/src/twister.cpp index 2be6bce1..26922c11 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -3865,19 +3865,26 @@ Object getLibtorrentSessionStatus() Value creategroup(const Array& params, bool fHelp) { - if (fHelp || params.size() != 1) + if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "creategroup \n" - "Create a new key pair for group chat and add it to wallet\n" - "Hint: use groupcreate to invite yourself\n" + "creategroup []\n" + "Create (if is omited) a new key pair for group chat and add it to wallet\n" + "Or import the given into wallet\n" + "Hint: use newgroupinvite to invite yourself\n" "Returns the group alias"); string strDescription = params[0].get_str(); + string privKey; - RandAddSeedPerfmon(); - CKey secret; - secret.MakeNewKey(true); - string privKey = CBitcoinSecret(secret).ToString(); + if (params.size() == 2) + privKey = params[1].get_str(); + else + { + RandAddSeedPerfmon(); + CKey secret; + secret.MakeNewKey(true); + privKey = CBitcoinSecret(secret).ToString(); + } string noMember; registerNewGroup(privKey, strDescription, noMember, noMember, GetTime(), -1); From 23786984b7734f0ec05d74fcf81a68a7dba4c69c Mon Sep 17 00:00:00 2001 From: erqan Date: Wed, 5 Oct 2016 15:08:00 +0300 Subject: [PATCH 3/3] version bumping --- src/clientversion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clientversion.h b/src/clientversion.h index 31eaf527..f4fc4927 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -8,7 +8,7 @@ // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 -#define CLIENT_VERSION_REVISION 37 +#define CLIENT_VERSION_REVISION 38 #define CLIENT_VERSION_BUILD 0 // Set to true for release, false for prerelease or test build