Merge branch 'master' into bitshares
This commit is contained in:
commit
7aa33928f8
7 changed files with 192 additions and 3 deletions
|
|
@ -83,6 +83,11 @@ namespace graphene { namespace db {
|
|||
return T( *this );
|
||||
}
|
||||
|
||||
explicit operator std::string() const
|
||||
{
|
||||
return fc::to_string(space()) + "." + fc::to_string(type()) + "." + fc::to_string(instance());
|
||||
}
|
||||
|
||||
uint64_t number;
|
||||
};
|
||||
|
||||
|
|
@ -173,8 +178,9 @@ struct reflector<graphene::db::object_id<SpaceID,TypeID,T> >
|
|||
|
||||
inline void to_variant( const graphene::db::object_id_type& var, fc::variant& vo )
|
||||
{
|
||||
vo = fc::to_string(var.space()) + "." + fc::to_string(var.type()) + "." + fc::to_string(var.instance());
|
||||
vo = std::string( var );
|
||||
}
|
||||
|
||||
inline void from_variant( const fc::variant& var, graphene::db::object_id_type& vo )
|
||||
{ try {
|
||||
vo.number = 0;
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ struct signed_block_with_info : public signed_block
|
|||
|
||||
block_id_type block_id;
|
||||
public_key_type signing_key;
|
||||
vector< transaction_id_type > transaction_ids;
|
||||
};
|
||||
|
||||
struct vesting_balance_object_with_info : public vesting_balance_object
|
||||
|
|
@ -1449,7 +1450,7 @@ FC_REFLECT( graphene::wallet::worker_vote_delta,
|
|||
)
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::wallet::signed_block_with_info, (graphene::chain::signed_block),
|
||||
(block_id)(signing_key) )
|
||||
(block_id)(signing_key)(transaction_ids) )
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::wallet::vesting_balance_object_with_info, (graphene::chain::vesting_balance_object),
|
||||
(allowed_withdraw)(allowed_withdraw_time) )
|
||||
|
|
|
|||
|
|
@ -73,6 +73,19 @@ namespace graphene { namespace wallet {
|
|||
|
||||
namespace detail {
|
||||
|
||||
struct operation_result_printer
|
||||
{
|
||||
public:
|
||||
operation_result_printer( const wallet_api_impl& w )
|
||||
: _wallet(w) {}
|
||||
const wallet_api_impl& _wallet;
|
||||
typedef std::string result_type;
|
||||
|
||||
std::string operator()(const void_result& x) const;
|
||||
std::string operator()(const object_id_type& oid);
|
||||
std::string operator()(const asset& a);
|
||||
};
|
||||
|
||||
// BLOCK TRX OP VOP
|
||||
struct operation_printer
|
||||
{
|
||||
|
|
@ -2396,7 +2409,13 @@ std::string operation_printer::operator()(const T& op)const
|
|||
op_name.erase(0, op_name.find_last_of(':')+1);
|
||||
out << op_name <<" ";
|
||||
// out << "balance delta: " << fc::json::to_string(acc.balance) <<" ";
|
||||
out << payer.name << " fee: " << a.amount_to_pretty_string( op.fee );
|
||||
out << payer.name << " fee: " << a.amount_to_pretty_string( op.fee );
|
||||
operation_result_printer rprinter(wallet);
|
||||
std::string str_result = result.visit(rprinter);
|
||||
if( str_result != "" )
|
||||
{
|
||||
out << " result: " << str_result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
std::string operation_printer::operator()(const transfer_from_blind_operation& op)const
|
||||
|
|
@ -2470,6 +2489,21 @@ std::string operation_printer::operator()(const asset_create_operation& op) cons
|
|||
return fee(op.fee);
|
||||
}
|
||||
|
||||
std::string operation_result_printer::operator()(const void_result& x) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string operation_result_printer::operator()(const object_id_type& oid)
|
||||
{
|
||||
return std::string(oid);
|
||||
}
|
||||
|
||||
std::string operation_result_printer::operator()(const asset& a)
|
||||
{
|
||||
return _wallet.get_asset(a.asset_id).amount_to_pretty_string(a);
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
|
|
@ -3938,6 +3972,9 @@ signed_block_with_info::signed_block_with_info( const signed_block& block )
|
|||
{
|
||||
block_id = id();
|
||||
signing_key = signee();
|
||||
transaction_ids.reserve( transactions.size() );
|
||||
for( const processed_transaction& tx : transactions )
|
||||
transaction_ids.push_back( tx.id() );
|
||||
}
|
||||
|
||||
vesting_balance_object_with_info::vesting_balance_object_with_info( const vesting_balance_object& vbo, fc::time_point_sec now )
|
||||
|
|
|
|||
|
|
@ -27,3 +27,8 @@ install( TARGETS
|
|||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
add_executable( convert_address convert_address.cpp )
|
||||
|
||||
target_link_libraries( convert_address
|
||||
PRIVATE graphene_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
|
|
|
|||
52
programs/genesis_util/change_asset_symbol.py
Executable file
52
programs/genesis_util/change_asset_symbol.py
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
|
||||
def dump_json(obj, out, pretty):
|
||||
if pretty:
|
||||
json.dump(obj, out, indent=2, sort_keys=True)
|
||||
else:
|
||||
json.dump(obj, out, separators=(",", ":"), sort_keys=True)
|
||||
return
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Change an asset's symbol with referential integrity")
|
||||
parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)")
|
||||
parser.add_argument("-i", "--input", metavar="IN", default="-", help="input filename (default: stdin)")
|
||||
parser.add_argument("-f", "--from", metavar="PREFIX", default="", help="initial prefix")
|
||||
parser.add_argument("-t", "--to", metavar="PREFIX", default="", help="new prefix")
|
||||
parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output")
|
||||
opts = parser.parse_args()
|
||||
|
||||
if opts.input == "-":
|
||||
genesis = json.load(sys.stdin)
|
||||
else:
|
||||
with open(opts.input, "r") as f:
|
||||
genesis = json.load(f)
|
||||
|
||||
frum = opts.__dict__["from"] # from is a language keyword and cannot be an attribute name
|
||||
|
||||
for asset in genesis["initial_assets"]:
|
||||
if asset["symbol"] == frum:
|
||||
asset["symbol"] = opts.to
|
||||
|
||||
for balance in genesis["initial_balances"]:
|
||||
if balance["asset_symbol"] == frum:
|
||||
balance["asset_symbol"] = opts.to
|
||||
|
||||
for vb in genesis["initial_vesting_balances"]:
|
||||
if balance["asset_symbol"] == frum:
|
||||
balance["asset_symbol"] = opts.to
|
||||
|
||||
if opts.output == "-":
|
||||
dump_json( genesis, sys.stdout, opts.pretty )
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
with open(opts.output, "w") as f:
|
||||
dump_json( genesis, f, opts.pretty )
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
23
programs/genesis_util/convert_address.cpp
Normal file
23
programs/genesis_util/convert_address.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
/**
|
||||
* Convert BTC / PTS addresses to a Graphene address.
|
||||
*/
|
||||
|
||||
#include <graphene/chain/pts_address.hpp>
|
||||
#include <graphene/chain/protocol/address.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace graphene::chain;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// grab 0 or more whitespace-delimited PTS addresses from stdin
|
||||
std::string s;
|
||||
while( std::cin >> s )
|
||||
{
|
||||
std::cout << std::string( address( pts_address( s ) ) ) << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
65
programs/genesis_util/generate_account_patch.py
Executable file
65
programs/genesis_util/generate_account_patch.py
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def dump_json(obj, out, pretty):
|
||||
if pretty:
|
||||
json.dump(obj, out, indent=2, sort_keys=True)
|
||||
else:
|
||||
json.dump(obj, out, separators=(",", ":"), sort_keys=True)
|
||||
return
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Generate a patch file that adds init accounts")
|
||||
parser.add_argument("-o", "--output", metavar="OUT", default="-", help="output filename (default: stdout)")
|
||||
parser.add_argument("-a", "--accounts", metavar="ACCOUNTS", default="-", help="file containing name, balances to create")
|
||||
parser.add_argument("-p", "--pretty", action="store_true", default=False, help="pretty print output")
|
||||
parser.add_argument("-s", "--secret", metavar="SECRET", default=None, help="private key generation secret")
|
||||
opts = parser.parse_args()
|
||||
|
||||
if opts.secret is None:
|
||||
sys.stderr.write("missing required parameter --secret\n")
|
||||
sys.stderr.flush()
|
||||
sys.exit(1)
|
||||
|
||||
with open(opts.accounts, "r") as f:
|
||||
accounts = json.load(f)
|
||||
|
||||
initial_accounts = []
|
||||
initial_balances = []
|
||||
for e in accounts:
|
||||
name = e["name"]
|
||||
owner_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "owner-"+name]).decode("utf-8")
|
||||
active_str = subprocess.check_output(["programs/genesis_util/get_dev_key", opts.secret, "active-"+name]).decode("utf-8")
|
||||
owner = json.loads(owner_str)
|
||||
active = json.loads(active_str)
|
||||
initial_accounts.append({
|
||||
"name" : name,
|
||||
"owner_key" : owner[0]["public_key"],
|
||||
"active_key" : active[0]["public_key"],
|
||||
"is_lifetime_member" : True,
|
||||
})
|
||||
for bal in e.get("balances", []):
|
||||
bal = dict(bal)
|
||||
bal["owner"] = active[0]["address"]
|
||||
initial_balances.append(bal)
|
||||
result = {
|
||||
"append" : {
|
||||
"initial_accounts" : initial_accounts },
|
||||
}
|
||||
if len(initial_balances) > 0:
|
||||
result["append"]["initial_balances"] = initial_balances
|
||||
|
||||
if opts.output == "-":
|
||||
dump_json( result, sys.stdout, opts.pretty )
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
with open(opts.output, "w") as f:
|
||||
dump_json( result, f, opts.pretty )
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue