From f0af136a5de56517cedddfd736caf63ad2324116 Mon Sep 17 00:00:00 2001 From: erqan Date: Tue, 4 Oct 2016 16:56:24 +0300 Subject: [PATCH] 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);