Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
f23048a0
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f23048a0
编写于
8月 31, 2017
作者:
K
Kevin Heifner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add get_required_keys to eosd
上级
50bf83a6
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
48 addition
and
10 deletion
+48
-10
libraries/chain/include/eos/chain/chain_controller.hpp
libraries/chain/include/eos/chain/chain_controller.hpp
+1
-1
plugins/chain_api_plugin/chain_api_plugin.cpp
plugins/chain_api_plugin/chain_api_plugin.cpp
+1
-0
plugins/chain_plugin/chain_plugin.cpp
plugins/chain_plugin/chain_plugin.cpp
+23
-0
plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp
...ns/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp
+17
-1
plugins/wallet_plugin/include/eos/wallet_plugin/wallet_manager.hpp
...allet_plugin/include/eos/wallet_plugin/wallet_manager.hpp
+1
-2
plugins/wallet_plugin/wallet_manager.cpp
plugins/wallet_plugin/wallet_manager.cpp
+0
-1
tests/tests/wallet_tests.cpp
tests/tests/wallet_tests.cpp
+5
-5
未找到文件。
libraries/chain/include/eos/chain/chain_controller.hpp
浏览文件 @
f23048a0
...
...
@@ -164,7 +164,7 @@ namespace eos { namespace chain {
* @return Subset of candidateKeys whose private keys should be used to sign transaction
* @throws fc::exception if candidateKeys does not contain all required keys
*/
flat_set
<
public_key_type
>
get_required_keys
(
const
SignedTransaction
&
trx
,
const
flat_set
<
public_key_type
>&
candidateKeys
)
const
;
flat_set
<
public_key_type
>
get_required_keys
(
const
SignedTransaction
&
trx
,
const
flat_set
<
public_key_type
>&
candidateKeys
)
const
;
bool
_push_block
(
const
signed_block
&
b
);
...
...
plugins/chain_api_plugin/chain_api_plugin.cpp
浏览文件 @
f23048a0
...
...
@@ -54,6 +54,7 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RO_CALL
(
get_table_rows
),
CHAIN_RO_CALL
(
abi_json_to_bin
),
CHAIN_RO_CALL
(
abi_bin_to_json
),
CHAIN_RO_CALL
(
get_required_keys
),
CHAIN_RW_CALL
(
push_block
),
CHAIN_RW_CALL
(
push_transaction
),
CHAIN_RW_CALL
(
push_transactions
)
...
...
plugins/chain_plugin/chain_plugin.cpp
浏览文件 @
f23048a0
...
...
@@ -12,6 +12,8 @@
#include <eos/native_contract/balance_object.hpp>
#include <eos/native_contract/genesis_state.hpp>
#include <eos/utilities/key_conversion.hpp>
#include <fc/io/json.hpp>
#include <fc/variant.hpp>
...
...
@@ -322,5 +324,26 @@ read_only::abi_bin_to_json_result read_only::abi_bin_to_json( const read_only::a
return
result
;
}
read_only
::
get_required_keys_result
read_only
::
get_required_keys
(
const
get_required_keys_params
&
params
)
const
{
flat_set
<
public_key_type
>
available_keys
;
available_keys
.
reserve
(
params
.
available_keys_wif
.
size
());
for
(
const
auto
&
k
:
params
.
available_keys_wif
)
{
available_keys
.
emplace
(
public_key_type
(
k
));
}
auto
pretty_input
=
db
.
transaction_from_variant
(
params
.
transaction
);
auto
required_keys_set
=
db
.
get_required_keys
(
pretty_input
,
available_keys
);
get_required_keys_result
result
;
result
.
required_keys_wif
.
reserve
(
required_keys_set
.
size
());
for
(
const
auto
&
k
:
required_keys_set
)
{
result
.
required_keys_wif
.
emplace_back
(
k
.
operator
std
::
string
());
}
return
result
;
}
}
// namespace chain_apis
}
// namespace eos
plugins/chain_plugin/include/eos/chain_plugin/chain_plugin.hpp
浏览文件 @
f23048a0
...
...
@@ -7,6 +7,8 @@
#include <eos/database_plugin/database_plugin.hpp>
#include <boost/container/flat_set.hpp>
namespace
fc
{
class
variant
;
}
namespace
eos
{
...
...
@@ -14,8 +16,10 @@ namespace eos {
using
std
::
unique_ptr
;
using
namespace
appbase
;
using
chain
::
Name
;
using
fc
::
optional
;
using
chain
::
uint128_t
;
using
chain
::
public_key_type
;
using
fc
::
optional
;
using
boost
::
container
::
flat_set
;
namespace
chain_apis
{
struct
empty
{};
...
...
@@ -93,6 +97,16 @@ public:
abi_bin_to_json_result
abi_bin_to_json
(
const
abi_bin_to_json_params
&
params
)
const
;
struct
get_required_keys_params
{
fc
::
variant
transaction
;
vector
<
string
>
available_keys_wif
;
};
struct
get_required_keys_result
{
vector
<
string
>
required_keys_wif
;
};
get_required_keys_result
get_required_keys
(
const
get_required_keys_params
&
params
)
const
;
struct
get_block_params
{
string
block_num_or_id
;
...
...
@@ -276,3 +290,5 @@ FC_REFLECT( eos::chain_apis::read_only::abi_json_to_bin_params, (code)(action)(a
FC_REFLECT
(
eos
::
chain_apis
::
read_only
::
abi_json_to_bin_result
,
(
binargs
)(
required_scope
)(
required_auth
)
)
FC_REFLECT
(
eos
::
chain_apis
::
read_only
::
abi_bin_to_json_params
,
(
code
)(
action
)(
binargs
)
)
FC_REFLECT
(
eos
::
chain_apis
::
read_only
::
abi_bin_to_json_result
,
(
args
)(
required_scope
)(
required_auth
)
)
FC_REFLECT
(
eos
::
chain_apis
::
read_only
::
get_required_keys_params
,
(
available_keys_wif
)
)
FC_REFLECT
(
eos
::
chain_apis
::
read_only
::
get_required_keys_result
,
(
required_keys_wif
)
)
plugins/wallet_plugin/include/eos/wallet_plugin/wallet_manager.hpp
浏览文件 @
f23048a0
...
...
@@ -60,8 +60,7 @@ public:
/// @return A list of wallet names with " *" appended if the wallet is unlocked.
std
::
vector
<
std
::
string
>
list_wallets
();
/// @return A list of unlocked wallet names and their private keys.
/// Wallet name entry followed by private key entries.
/// @return A list of private keys from all unlocked wallets in wif format.
std
::
vector
<
std
::
string
>
list_keys
();
/// Locks all the unlocked wallets.
...
...
plugins/wallet_plugin/wallet_manager.cpp
浏览文件 @
f23048a0
...
...
@@ -78,7 +78,6 @@ std::vector<std::string> wallet_manager::list_keys() {
std
::
vector
<
std
::
string
>
result
;
for
(
const
auto
&
i
:
wallets
)
{
if
(
!
i
.
second
->
is_locked
())
{
result
.
emplace_back
(
i
.
first
);
const
auto
&
keys
=
i
.
second
->
list_keys
();
for
(
const
auto
&
i
:
keys
)
{
result
.
emplace_back
(
i
.
second
);
...
...
tests/tests/wallet_tests.cpp
浏览文件 @
f23048a0
...
...
@@ -85,14 +85,14 @@ BOOST_AUTO_TEST_CASE(wallet_manager_test)
BOOST_CHECK
(
!
pw
.
empty
());
BOOST_CHECK_EQUAL
(
0
,
pw
.
find
(
"PW"
));
// starts with PW
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_wallets
().
size
());
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_keys
().
size
());
// wallet name only
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
// no keys
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
!=
std
::
string
::
npos
);
wm
.
lock
(
"test"
);
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
==
std
::
string
::
npos
);
wm
.
unlock
(
"test"
,
pw
);
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
!=
std
::
string
::
npos
);
wm
.
import_key
(
"test"
,
key1
);
BOOST_CHECK_EQUAL
(
2
,
wm
.
list_keys
().
size
());
// name and key
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_keys
().
size
());
auto
keys
=
wm
.
list_keys
();
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
key1
)
!=
keys
.
cend
());
wm
.
import_key
(
"test"
,
key2
);
...
...
@@ -102,14 +102,14 @@ BOOST_AUTO_TEST_CASE(wallet_manager_test)
wm
.
lock
(
"test"
);
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
wm
.
unlock
(
"test"
,
pw
);
BOOST_CHECK_EQUAL
(
3
,
wm
.
list_keys
().
size
());
BOOST_CHECK_EQUAL
(
2
,
wm
.
list_keys
().
size
());
wm
.
lock_all
();
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
BOOST_CHECK
(
wm
.
list_wallets
().
at
(
0
).
find
(
"*"
)
==
std
::
string
::
npos
);
auto
pw2
=
wm
.
create
(
"test2"
);
BOOST_CHECK_EQUAL
(
2
,
wm
.
list_wallets
().
size
());
BOOST_CHECK_EQUAL
(
1
,
wm
.
list_keys
().
size
());
// wallet name only
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
wm
.
import_key
(
"test2"
,
key3
);
keys
=
wm
.
list_keys
();
BOOST_CHECK
(
std
::
find
(
keys
.
cbegin
(),
keys
.
cend
(),
key1
)
==
keys
.
cend
());
...
...
@@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(wallet_manager_test)
optional_private_key
=
utilities
::
wif_to_key
(
key3
);
BOOST_CHECK
(
find
(
pks
.
cbegin
(),
pks
.
cend
(),
optional_private_key
->
get_public_key
())
!=
pks
.
cend
());
BOOST_CHECK_EQUAL
(
5
,
wm
.
list_keys
().
size
());
BOOST_CHECK_EQUAL
(
3
,
wm
.
list_keys
().
size
());
wm
.
set_timeout
(
chrono
::
seconds
(
0
));
BOOST_CHECK_EQUAL
(
0
,
wm
.
list_keys
().
size
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录