Implement chain-locked transactions
This commit is contained in:
parent
9f9c1e7895
commit
2e9876b557
27 changed files with 275 additions and 172 deletions
|
|
@ -140,6 +140,11 @@ namespace graphene { namespace app {
|
|||
return _db.get(global_property_id_type());
|
||||
}
|
||||
|
||||
chain_id_type database_api::get_chain_id()const
|
||||
{
|
||||
return _db.get_chain_id();
|
||||
}
|
||||
|
||||
dynamic_global_property_object database_api::get_dynamic_global_properties()const
|
||||
{
|
||||
return _db.get(dynamic_global_property_id_type());
|
||||
|
|
@ -1118,15 +1123,17 @@ namespace graphene { namespace app {
|
|||
|
||||
set<public_key_type> database_api::get_required_signatures( const signed_transaction& trx, const flat_set<public_key_type>& available_keys )const
|
||||
{
|
||||
return trx.get_required_signatures( available_keys,
|
||||
return trx.get_required_signatures( _db.get_chain_id(),
|
||||
available_keys,
|
||||
[&]( account_id_type id ){ return &id(_db).active; },
|
||||
[&]( account_id_type id ){ return &id(_db).owner; },
|
||||
_db.get_global_properties().parameters.max_authority_depth );
|
||||
}
|
||||
|
||||
bool database_api::verify_authority( const signed_transaction& trx )const
|
||||
bool database_api::verify_authority( const signed_transaction& trx )const
|
||||
{
|
||||
trx.verify_authority( [&]( account_id_type id ){ return &id(_db).active; },
|
||||
trx.verify_authority( _db.get_chain_id(),
|
||||
[&]( account_id_type id ){ return &id(_db).active; },
|
||||
[&]( account_id_type id ){ return &id(_db).owner; },
|
||||
_db.get_global_properties().parameters.max_authority_depth );
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include <graphene/time/time.hpp>
|
||||
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
#include <fc/smart_ref_impl.hpp>
|
||||
|
||||
|
|
@ -425,7 +426,7 @@ namespace detail {
|
|||
return trx_message( _chain_db->get_recent_transaction( id.item_hash ) );
|
||||
} FC_CAPTURE_AND_RETHROW( (id) ) }
|
||||
|
||||
virtual fc::sha256 get_chain_id()const override
|
||||
virtual chain_id_type get_chain_id()const override
|
||||
{
|
||||
return _chain_db->get_global_properties().chain_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/chain/protocol/types.hpp>
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
|
|
@ -82,6 +83,12 @@ namespace graphene { namespace app {
|
|||
* @brief Retrieve the current @ref global_property_object
|
||||
*/
|
||||
global_property_object get_global_properties()const;
|
||||
|
||||
/**
|
||||
* @brief Get the chain ID
|
||||
*/
|
||||
chain_id_type get_chain_id()const;
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current @ref dynamic_global_property_object
|
||||
*/
|
||||
|
|
@ -513,6 +520,7 @@ FC_API(graphene::app::database_api,
|
|||
(get_block)
|
||||
(get_transaction)
|
||||
(get_global_properties)
|
||||
(get_chain_id)
|
||||
(get_dynamic_global_properties)
|
||||
(get_accounts)
|
||||
(get_assets)
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
|||
uint32_t skip = get_node_properties().skip_flags;
|
||||
trx.validate();
|
||||
auto& trx_idx = get_mutable_index_type<transaction_index>();
|
||||
const chain_id_type& chain_id = get_chain_id();
|
||||
auto trx_id = trx.id();
|
||||
FC_ASSERT( (skip & skip_transaction_dupe_check) ||
|
||||
trx_idx.indices().get<by_trx_id>().find(trx_id) == trx_idx.indices().get<by_trx_id>().end() );
|
||||
|
|
@ -489,7 +490,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
|||
{
|
||||
auto get_active = [&]( account_id_type id ) { return &id(*this).active; };
|
||||
auto get_owner = [&]( account_id_type id ) { return &id(*this).owner; };
|
||||
trx.verify_authority( get_active, get_owner, get_global_properties().parameters.max_authority_depth );
|
||||
trx.verify_authority( chain_id, get_active, get_owner, get_global_properties().parameters.max_authority_depth );
|
||||
}
|
||||
|
||||
//Skip all manner of expiration and TaPoS checking if we're on block 1; It's impossible that the transaction is
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ decltype( chain_parameters::block_interval ) database::block_interval( )const
|
|||
return get_global_properties().parameters.block_interval;
|
||||
}
|
||||
|
||||
const chain_id_type& database::get_chain_id( )const
|
||||
{
|
||||
return get_global_properties().chain_id;
|
||||
}
|
||||
|
||||
const node_property_object& database::get_node_properties()const
|
||||
{
|
||||
return _node_property_object;
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ namespace graphene { namespace chain {
|
|||
|
||||
//////////////////// db_getter.cpp ////////////////////
|
||||
|
||||
const chain_id_type& get_chain_id()const;
|
||||
const asset_object& get_core_asset()const;
|
||||
const global_property_object& get_global_properties()const;
|
||||
const dynamic_global_property_object& get_dynamic_global_properties()const;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
#pragma once
|
||||
#include <fc/uint128.hpp>
|
||||
|
||||
#include <graphene/chain/protocol/chain_parameters.hpp>
|
||||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/chain/protocol/chain_parameters.hpp>
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/db/object.hpp>
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace graphene { namespace chain {
|
|||
// n.b. witness scheduling is done by witness_schedule object
|
||||
flat_set<account_id_type> witness_accounts; // updated once per maintenance interval
|
||||
|
||||
fc::sha256 chain_id;
|
||||
chain_id_type chain_id;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/chain/protocol/operations.hpp>
|
||||
|
||||
#include <numeric>
|
||||
|
|
@ -77,10 +78,12 @@ namespace graphene { namespace chain {
|
|||
vector<operation> operations;
|
||||
extensions_type extensions;
|
||||
|
||||
/// Calculate the digest for a transaction with an absolute expiration time
|
||||
/// Calculate the digest for a transaction
|
||||
digest_type digest()const;
|
||||
transaction_id_type id()const;
|
||||
void validate() const;
|
||||
/// Calculate the digest used for signature validation
|
||||
digest_type sig_digest( const chain_id_type& chain_id )const;
|
||||
|
||||
void set_expiration( fc::time_point_sec expiration_time );
|
||||
void set_reference_block( const block_id_type& reference_block );
|
||||
|
|
@ -115,10 +118,10 @@ namespace graphene { namespace chain {
|
|||
: transaction(trx){}
|
||||
|
||||
/** signs and appends to signatures */
|
||||
const signature_type& sign( const private_key_type& key );
|
||||
const signature_type& sign( const private_key_type& key, const chain_id_type& chain_id );
|
||||
|
||||
/** returns signature but does not append */
|
||||
signature_type sign( const private_key_type& key )const;
|
||||
signature_type sign( const private_key_type& key, const chain_id_type& chain_id )const;
|
||||
|
||||
/**
|
||||
* The purpose of this method is to identify some subset of
|
||||
|
|
@ -128,15 +131,18 @@ namespace graphene { namespace chain {
|
|||
* validation.
|
||||
*/
|
||||
set<public_key_type> get_required_signatures(
|
||||
const chain_id_type& chain_id,
|
||||
const flat_set<public_key_type>& available_keys,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH
|
||||
)const;
|
||||
|
||||
void verify_authority( const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH )const;
|
||||
void verify_authority(
|
||||
const chain_id_type& chain_id,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH )const;
|
||||
|
||||
/**
|
||||
* This is a slower replacement for get_required_signatures()
|
||||
|
|
@ -146,13 +152,14 @@ namespace graphene { namespace chain {
|
|||
*/
|
||||
|
||||
set<public_key_type> minimize_required_signatures(
|
||||
const chain_id_type& chain_id,
|
||||
const flat_set<public_key_type>& available_keys,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH
|
||||
) const;
|
||||
|
||||
flat_set<public_key_type> get_signature_keys()const;
|
||||
flat_set<public_key_type> get_signature_keys( const chain_id_type& chain_id )const;
|
||||
|
||||
vector<signature_type> signatures;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@
|
|||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
|
||||
digest_type processed_transaction::merkle_digest()const
|
||||
{
|
||||
return digest_type::hash(*this);
|
||||
digest_type::encoder enc;
|
||||
fc::raw::pack( enc, *this );
|
||||
return enc.result();
|
||||
}
|
||||
|
||||
digest_type transaction::digest()const
|
||||
|
|
@ -36,6 +37,15 @@ digest_type transaction::digest()const
|
|||
fc::raw::pack( enc, *this );
|
||||
return enc.result();
|
||||
}
|
||||
|
||||
digest_type transaction::sig_digest( const chain_id_type& chain_id )const
|
||||
{
|
||||
digest_type::encoder enc;
|
||||
fc::raw::pack( enc, chain_id );
|
||||
fc::raw::pack( enc, *this );
|
||||
return enc.result();
|
||||
}
|
||||
|
||||
void transaction::validate() const
|
||||
{
|
||||
FC_ASSERT( operations.size() > 0, "A transaction must have at least one operation", ("trx",*this) );
|
||||
|
|
@ -45,22 +55,25 @@ void transaction::validate() const
|
|||
|
||||
graphene::chain::transaction_id_type graphene::chain::transaction::id() const
|
||||
{
|
||||
digest_type::encoder enc;
|
||||
fc::raw::pack(enc, *this);
|
||||
auto hash = enc.result();
|
||||
auto h = digest();
|
||||
transaction_id_type result;
|
||||
memcpy(result._hash, hash._hash, std::min(sizeof(result), sizeof(hash)));
|
||||
memcpy(result._hash, h._hash, std::min(sizeof(result), sizeof(h)));
|
||||
return result;
|
||||
}
|
||||
|
||||
const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key)
|
||||
const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)
|
||||
{
|
||||
signatures.push_back(key.sign_compact(digest()));
|
||||
digest_type h = sig_digest( chain_id );
|
||||
signatures.push_back(key.sign_compact(h));
|
||||
return signatures.back();
|
||||
}
|
||||
signature_type graphene::chain::signed_transaction::sign(const private_key_type& key)const
|
||||
|
||||
signature_type graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const
|
||||
{
|
||||
return key.sign_compact(digest());
|
||||
digest_type::encoder enc;
|
||||
fc::raw::pack( enc, chain_id );
|
||||
fc::raw::pack( enc, *this );
|
||||
return key.sign_compact(enc.result());
|
||||
}
|
||||
|
||||
void transaction::set_expiration( fc::time_point_sec expiration_time )
|
||||
|
|
@ -234,9 +247,9 @@ void verify_authority( const vector<operation>& ops, const flat_set<public_key_t
|
|||
} FC_CAPTURE_AND_RETHROW( (ops)(sigs) ) }
|
||||
|
||||
|
||||
flat_set<public_key_type> signed_transaction::get_signature_keys()const
|
||||
flat_set<public_key_type> signed_transaction::get_signature_keys( const chain_id_type& chain_id )const
|
||||
{ try {
|
||||
auto d = digest();
|
||||
auto d = sig_digest( chain_id );
|
||||
flat_set<public_key_type> result;
|
||||
for( const auto& sig : signatures )
|
||||
{
|
||||
|
|
@ -250,10 +263,12 @@ flat_set<public_key_type> signed_transaction::get_signature_keys()const
|
|||
|
||||
|
||||
|
||||
set<public_key_type> signed_transaction::get_required_signatures( const flat_set<public_key_type>& available_keys,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion_depth )const
|
||||
set<public_key_type> signed_transaction::get_required_signatures(
|
||||
const chain_id_type& chain_id,
|
||||
const flat_set<public_key_type>& available_keys,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion_depth )const
|
||||
{
|
||||
flat_set<account_id_type> required_active;
|
||||
flat_set<account_id_type> required_owner;
|
||||
|
|
@ -261,7 +276,7 @@ set<public_key_type> signed_transaction::get_required_signatures( const flat_set
|
|||
get_required_authorities( required_active, required_owner, other );
|
||||
|
||||
|
||||
sign_state s(get_signature_keys(),get_active,available_keys);
|
||||
sign_state s(get_signature_keys( chain_id ),get_active,available_keys);
|
||||
s.max_recursion = max_recursion_depth;
|
||||
|
||||
for( const auto& auth : other )
|
||||
|
|
@ -283,13 +298,14 @@ set<public_key_type> signed_transaction::get_required_signatures( const flat_set
|
|||
}
|
||||
|
||||
set<public_key_type> signed_transaction::minimize_required_signatures(
|
||||
const chain_id_type& chain_id,
|
||||
const flat_set<public_key_type>& available_keys,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion
|
||||
) const
|
||||
{
|
||||
set< public_key_type > s = get_required_signatures( available_keys, get_active, get_owner, max_recursion );
|
||||
set< public_key_type > s = get_required_signatures( chain_id, available_keys, get_active, get_owner, max_recursion );
|
||||
flat_set< public_key_type > result( s.begin(), s.end() );
|
||||
|
||||
for( const public_key_type& k : s )
|
||||
|
|
@ -308,11 +324,13 @@ set<public_key_type> signed_transaction::minimize_required_signatures(
|
|||
return set<public_key_type>( result.begin(), result.end() );
|
||||
}
|
||||
|
||||
void signed_transaction::verify_authority( const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion )const
|
||||
void signed_transaction::verify_authority(
|
||||
const chain_id_type& chain_id,
|
||||
const std::function<const authority*(account_id_type)>& get_active,
|
||||
const std::function<const authority*(account_id_type)>& get_owner,
|
||||
uint32_t max_recursion )const
|
||||
{ try {
|
||||
graphene::chain::verify_authority( operations, get_signature_keys(), get_active, get_owner, max_recursion );
|
||||
graphene::chain::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, max_recursion );
|
||||
} FC_CAPTURE_AND_RETHROW( (*this) ) }
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ ${generated_file_banner}
|
|||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/egenesis/egenesis.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
namespace graphene { namespace egenesis {
|
||||
|
||||
using namespace graphene::chain;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <graphene/net/message.hpp>
|
||||
#include <graphene/net/peer_database.hpp>
|
||||
|
||||
#include <graphene/chain/protocol/chain_id.hpp>
|
||||
#include <graphene/chain/protocol/types.hpp>
|
||||
|
||||
#include <list>
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
namespace graphene { namespace net {
|
||||
|
||||
using fc::variant_object;
|
||||
using graphene::chain::chain_id_type;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
|
@ -108,7 +110,7 @@ namespace graphene { namespace net {
|
|||
*/
|
||||
virtual message get_item( const item_id& id ) = 0;
|
||||
|
||||
virtual fc::sha256 get_chain_id()const = 0;
|
||||
virtual chain_id_type get_chain_id()const = 0;
|
||||
|
||||
/**
|
||||
* Returns a synopsis of the blockchain used for syncing.
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ namespace graphene { namespace net { namespace detail {
|
|||
uint32_t& remaining_item_count,
|
||||
uint32_t limit = 2000) override;
|
||||
message get_item( const item_id& id ) override;
|
||||
fc::sha256 get_chain_id() const override;
|
||||
chain_id_type get_chain_id() const override;
|
||||
std::vector<item_hash_t> get_blockchain_synopsis(uint32_t item_type,
|
||||
const graphene::net::item_hash_t& reference_point = graphene::net::item_hash_t(),
|
||||
uint32_t number_of_blocks_after_reference_point = 0) override;
|
||||
|
|
@ -5163,7 +5163,7 @@ namespace graphene { namespace net { namespace detail {
|
|||
INVOKE_AND_COLLECT_STATISTICS(get_item, id);
|
||||
}
|
||||
|
||||
fc::sha256 statistics_gathering_node_delegate_wrapper::get_chain_id() const
|
||||
chain_id_type statistics_gathering_node_delegate_wrapper::get_chain_id() const
|
||||
{
|
||||
INVOKE_AND_COLLECT_STATISTICS(get_chain_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ typedef multi_index_container<
|
|||
|
||||
struct wallet_data
|
||||
{
|
||||
/** Chain ID this wallet is used with */
|
||||
chain_id_type chain_id;
|
||||
account_multi_index_type my_accounts;
|
||||
/// @return IDs of all accounts in @ref my_accounts
|
||||
vector<object_id_type> my_account_ids()const
|
||||
|
|
@ -211,7 +213,7 @@ class wallet_api_impl;
|
|||
class wallet_api
|
||||
{
|
||||
public:
|
||||
wallet_api(fc::api<login_api> rapi);
|
||||
wallet_api( const chain_id_type& chain_id, fc::api<login_api> rapi );
|
||||
virtual ~wallet_api();
|
||||
|
||||
bool copy_wallet_file( string destination_filename );
|
||||
|
|
@ -1191,7 +1193,6 @@ class wallet_api
|
|||
|
||||
std::map<string,std::function<string(fc::variant,const fc::variants&)>> get_result_formatters() const;
|
||||
|
||||
|
||||
fc::signal<void(bool)> lock_changed;
|
||||
std::shared_ptr<detail::wallet_api_impl> my;
|
||||
void encrypt_keys();
|
||||
|
|
@ -1207,6 +1208,7 @@ FC_REFLECT( graphene::wallet::blind_confirmation, (trx)(outputs) )
|
|||
FC_REFLECT( graphene::wallet::plain_keys, (keys)(checksum) )
|
||||
|
||||
FC_REFLECT( graphene::wallet::wallet_data,
|
||||
(chain_id)
|
||||
(my_accounts)
|
||||
(cipher_keys)
|
||||
(extra_keys)
|
||||
|
|
|
|||
|
|
@ -359,13 +359,21 @@ private:
|
|||
|
||||
public:
|
||||
wallet_api& self;
|
||||
wallet_api_impl( wallet_api& s, fc::api<login_api> rapi )
|
||||
wallet_api_impl( wallet_api& s, const chain_id_type& chain_id, fc::api<login_api> rapi )
|
||||
: self(s),
|
||||
_chain_id(chain_id),
|
||||
_remote_api(rapi),
|
||||
_remote_db(rapi->database()),
|
||||
_remote_net_broadcast(rapi->network_broadcast()),
|
||||
_remote_hist(rapi->history())
|
||||
{
|
||||
chain_id_type remote_chain_id = _remote_db->get_chain_id();
|
||||
if( remote_chain_id != _chain_id )
|
||||
{
|
||||
FC_THROW( "Remote server gave us an unexpected chain_id",
|
||||
("remote_chain_id", remote_chain_id)
|
||||
("chain_id", chain_id) );
|
||||
}
|
||||
init_prototype_ops();
|
||||
_remote_db->subscribe_to_objects( [=]( const fc::variant& obj )
|
||||
{
|
||||
|
|
@ -636,6 +644,10 @@ public:
|
|||
if( !_wallet.my_accounts.empty() )
|
||||
_remote_db->unsubscribe_from_objects(_wallet.my_account_ids());
|
||||
_wallet = fc::json::from_file( wallet_filename ).as< wallet_data >();
|
||||
if( _wallet.chain_id != _chain_id )
|
||||
FC_THROW( "Wallet chain ID does not match",
|
||||
("wallet.chain_id", _wallet.chain_id)
|
||||
("chain_id", _chain_id) );
|
||||
if( !_wallet.my_accounts.empty() )
|
||||
_remote_db->subscribe_to_objects([this](const fc::variant& v) {
|
||||
_wallet.update_account(v.as<account_object>());
|
||||
|
|
@ -815,7 +827,7 @@ public:
|
|||
{
|
||||
FC_ASSERT( false, "Malformed private key in _keys" );
|
||||
}
|
||||
tx.sign( *privkey );
|
||||
tx.sign( *privkey, _chain_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -938,7 +950,7 @@ public:
|
|||
{
|
||||
fc::optional< fc::ecc::private_key > privkey = wif_to_key( it->second );
|
||||
FC_ASSERT( privkey.valid(), "Malformed private key in _keys" );
|
||||
tx.sign( *privkey );
|
||||
tx.sign( *privkey, _chain_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1537,7 +1549,7 @@ public:
|
|||
{
|
||||
fc::optional<fc::ecc::private_key> privkey = wif_to_key( it->second );
|
||||
FC_ASSERT( privkey.valid(), "Malformed private key in _keys" );
|
||||
tx.sign( *privkey );
|
||||
tx.sign( *privkey, _chain_id );
|
||||
}
|
||||
/// TODO: if transaction has enough signatures to be "valid" don't add any more,
|
||||
/// there are cases where the wallet may have more keys than strictly necessary and
|
||||
|
|
@ -1901,6 +1913,7 @@ public:
|
|||
map<public_key_type,string> _keys;
|
||||
fc::sha512 _checksum;
|
||||
|
||||
chain_id_type _chain_id;
|
||||
fc::api<login_api> _remote_api;
|
||||
fc::api<database_api> _remote_db;
|
||||
fc::api<network_broadcast_api> _remote_net_broadcast;
|
||||
|
|
@ -2007,8 +2020,8 @@ void operation_printer::operator()(const asset_create_operation& op) const
|
|||
|
||||
namespace graphene { namespace wallet {
|
||||
|
||||
wallet_api::wallet_api(fc::api<login_api> rapi)
|
||||
: my(new detail::wallet_api_impl(*this, rapi))
|
||||
wallet_api::wallet_api(const chain_id_type& chain_id, fc::api<login_api> rapi)
|
||||
: my(new detail::wallet_api_impl(*this, chain_id, rapi))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -2628,7 +2641,7 @@ signed_transaction wallet_api::import_balance( string name_or_id, const vector<s
|
|||
auto tx = sign_transaction( trx, false );
|
||||
|
||||
for( auto a : required_addrs )
|
||||
tx.sign( keys[a] );
|
||||
tx.sign( keys[a], my->_chain_id );
|
||||
|
||||
// if the key for a balance object was the same as a key for the account we're importing it into,
|
||||
// we may end up with duplicate signatures, so remove those
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <graphene/app/api.hpp>
|
||||
#include <graphene/chain/protocol/protocol.hpp>
|
||||
#include <graphene/egenesis/egenesis.hpp>
|
||||
#include <graphene/utilities/key_conversion.hpp>
|
||||
#include <graphene/wallet/wallet.hpp>
|
||||
|
||||
|
|
@ -68,7 +69,8 @@ int main( int argc, char** argv )
|
|||
("rpc-tls-certificate,c", bpo::value<string>()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC")
|
||||
("rpc-http-endpoint,H", bpo::value<string>()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on")
|
||||
("daemon,d", "Run the wallet in daemon mode" )
|
||||
("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "wallet to load");
|
||||
("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "wallet to load")
|
||||
("chain-id", bpo::value<string>(), "chain ID to connect to");
|
||||
|
||||
bpo::variables_map options;
|
||||
|
||||
|
|
@ -123,8 +125,33 @@ int main( int argc, char** argv )
|
|||
|
||||
fc::path wallet_file( options.count("wallet-file") ? options.at("wallet-file").as<string>() : "wallet.json");
|
||||
if( fc::exists( wallet_file ) )
|
||||
wdata = fc::json::from_file( wallet_file ).as<wallet_data>();
|
||||
{
|
||||
wdata = fc::json::from_file( wallet_file ).as<wallet_data>();
|
||||
if( options.count("chain-id") )
|
||||
{
|
||||
// the --chain-id on the CLI must match the chain ID embedded in the wallet file
|
||||
if( chain_id_type(options.at("chain-id").as<std::string>()) != wdata.chain_id )
|
||||
{
|
||||
std::cout << "Chain ID in wallet file does not match specified chain ID\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( options.count("chain-id") )
|
||||
{
|
||||
wdata.chain_id = chain_id_type(options.at("chain-id").as<std::string>());
|
||||
std::cout << "Starting a new wallet with chain ID " << wdata.chain_id << " (from CLI)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
wdata.chain_id = graphene::egenesis::get_egenesis_chain_id();
|
||||
std::cout << "Starting a new wallet with chain ID " << wdata.chain_id << " (from egenesis)\n";
|
||||
}
|
||||
}
|
||||
|
||||
// but allow CLI to override
|
||||
if( options.count("server-rpc-endpoint") )
|
||||
wdata.ws_server = options.at("server-rpc-endpoint").as<std::string>();
|
||||
if( options.count("server-rpc-user") )
|
||||
|
|
@ -139,9 +166,10 @@ int main( int argc, char** argv )
|
|||
|
||||
auto remote_api = apic->get_remote_api< login_api >(1);
|
||||
edump((wdata.ws_user)(wdata.ws_password) );
|
||||
// TODO: Error message here
|
||||
FC_ASSERT( remote_api->login( wdata.ws_user, wdata.ws_password ) );
|
||||
|
||||
auto wapiptr = std::make_shared<wallet_api>(remote_api);
|
||||
auto wapiptr = std::make_shared<wallet_api>( wdata.chain_id, remote_api );
|
||||
wapiptr->set_wallet_filename( wallet_file.generic_string() );
|
||||
wapiptr->load_wallet_file();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE( two_node_network )
|
|||
db1->current_fee_schedule().set_fee( trx.operations.back() );
|
||||
|
||||
trx.set_expiration( db1->get_slot_time( 10 ) );
|
||||
trx.sign( nathan_key );
|
||||
trx.sign( nathan_key, db1->get_chain_id() );
|
||||
trx.validate();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -612,7 +612,12 @@ uint64_t database_fixture::fund(
|
|||
|
||||
void database_fixture::sign(signed_transaction& trx, const fc::ecc::private_key& key)
|
||||
{
|
||||
trx.sign( key );
|
||||
trx.sign( key, db.get_chain_id() );
|
||||
}
|
||||
|
||||
digest_type database_fixture::digest( const transaction& tx )
|
||||
{
|
||||
return tx.digest();
|
||||
}
|
||||
|
||||
const limit_order_object*database_fixture::create_sell_order(account_id_type user, const asset& amount, const asset& recv)
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ struct database_fixture {
|
|||
const witness_object& create_witness(const account_object& owner,
|
||||
const fc::ecc::private_key& signing_private_key = generate_private_key("null_key"));
|
||||
uint64_t fund( const account_object& account, const asset& amount = asset(500000) );
|
||||
digest_type digest( const transaction& tx );
|
||||
void sign( signed_transaction& trx, const fc::ecc::private_key& key );
|
||||
const limit_order_object* create_sell_order( account_id_type user, const asset& amount, const asset& recv );
|
||||
const limit_order_object* create_sell_order( const account_object& user, const asset& amount, const asset& recv );
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture )
|
|||
trx.operations.push_back( update_op );
|
||||
for( int i=0; i<int(create_op.owner.weight_threshold); i++)
|
||||
{
|
||||
trx.sign( *owner_privkey[i] );
|
||||
sign( trx, *owner_privkey[i] );
|
||||
if( i < int(create_op.owner.weight_threshold-1) )
|
||||
{
|
||||
GRAPHENE_REQUIRE_THROW(db.push_transaction(trx), fc::exception);
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@ BOOST_AUTO_TEST_CASE( recursive_accounts )
|
|||
sign(trx, parent2_key);
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx, database::skip_transaction_dupe_check ), fc::exception);
|
||||
trx.signatures.clear();
|
||||
trx.sign( parent2_key );
|
||||
trx.sign( grandparent_key );
|
||||
sign( trx, parent2_key );
|
||||
sign( trx, grandparent_key );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Attempt to transfer using parent2_key and grandparent_key" );
|
||||
PUSH_TX( db, trx, database::skip_transaction_dupe_check );
|
||||
|
|
@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
|
|||
trx.operations.push_back(op);
|
||||
set_expiration( db, trx );
|
||||
|
||||
trx.sign( init_account_priv_key );
|
||||
sign( trx, init_account_priv_key );
|
||||
const proposal_object& proposal = db.get<proposal_object>(PUSH_TX( db, trx ).operation_results.front().get<object_id_type>());
|
||||
|
||||
BOOST_CHECK_EQUAL(proposal.required_active_approvals.size(), 1);
|
||||
|
|
@ -356,13 +356,13 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
|
|||
pup.active_approvals_to_add.insert(nathan.id);
|
||||
|
||||
trx.operations = {pup};
|
||||
trx.sign( committee_key );
|
||||
sign( trx, committee_key );
|
||||
//committee may not add nathan's approval.
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
pup.active_approvals_to_add.clear();
|
||||
pup.active_approvals_to_add.insert(account_id_type());
|
||||
trx.operations = {pup};
|
||||
trx.sign( committee_key );
|
||||
sign( trx, committee_key );
|
||||
//committee has no stake in the transaction.
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
|
||||
|
|
@ -371,8 +371,8 @@ BOOST_AUTO_TEST_CASE( proposed_single_account )
|
|||
pup.active_approvals_to_add.insert(nathan.id);
|
||||
|
||||
trx.operations = {pup};
|
||||
trx.sign( nathan_key3 );
|
||||
trx.sign( nathan_key2 );
|
||||
sign( trx, nathan_key3 );
|
||||
sign( trx, nathan_key2 );
|
||||
|
||||
BOOST_CHECK_EQUAL(get_balance(nathan, core), nathan_start_balance.amount.value);
|
||||
PUSH_TX( db, trx );
|
||||
|
|
@ -407,25 +407,25 @@ BOOST_AUTO_TEST_CASE( committee_authority )
|
|||
sign(trx, committee_key);
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), graphene::chain::invalid_committee_approval );
|
||||
|
||||
auto sign = [&] { trx.signatures.clear(); trx.sign(nathan_key); };
|
||||
auto _sign = [&] { trx.signatures.clear(); sign( trx, nathan_key ); };
|
||||
|
||||
proposal_create_operation pop;
|
||||
pop.proposed_ops.push_back({trx.operations.front()});
|
||||
pop.expiration_time = db.head_block_time() + global_params.committee_proposal_review_period*2;
|
||||
pop.fee_paying_account = nathan.id;
|
||||
trx.operations = {pop};
|
||||
sign();
|
||||
_sign();
|
||||
|
||||
// The review period isn't set yet. Make sure it throws.
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx ), proposal_create_review_period_required );
|
||||
pop.review_period_seconds = global_params.committee_proposal_review_period / 2;
|
||||
trx.operations.back() = pop;
|
||||
sign();
|
||||
_sign();
|
||||
// The review period is too short. Make sure it throws.
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx ), proposal_create_review_period_insufficient );
|
||||
pop.review_period_seconds = global_params.committee_proposal_review_period;
|
||||
trx.operations.back() = pop;
|
||||
sign();
|
||||
_sign();
|
||||
proposal_object prop = db.get<proposal_object>(PUSH_TX( db, trx ).operation_results.front().get<object_id_type>());
|
||||
BOOST_REQUIRE(db.find_object(prop.id));
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ BOOST_AUTO_TEST_CASE( committee_authority )
|
|||
uop.key_approvals_to_add.emplace(6);
|
||||
*/
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(committee_key);
|
||||
sign( trx, committee_key );
|
||||
db.push_transaction(trx);
|
||||
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 0);
|
||||
BOOST_CHECK(db.get<proposal_object>(prop.id).is_authorized_to_execute(db));
|
||||
|
|
@ -467,7 +467,7 @@ BOOST_AUTO_TEST_CASE( committee_authority )
|
|||
uop.key_approvals_to_add.clear();
|
||||
uop.key_approvals_to_add.insert(committee_key.get_public_key()); // was 7
|
||||
trx.operations.back() = uop;
|
||||
trx.sign( committee_key);
|
||||
sign( trx, committee_key );
|
||||
// Should throw because the transaction is now in review.
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
|
||||
|
|
@ -530,7 +530,7 @@ BOOST_FIXTURE_TEST_CASE( fired_committee_members, database_fixture )
|
|||
uop.key_approvals_to_add.emplace(9);
|
||||
*/
|
||||
trx.operations.back() = uop;
|
||||
trx.sign(committee_key);
|
||||
sign( trx, committee_key );
|
||||
PUSH_TX( db, trx );
|
||||
BOOST_CHECK(pid(db).is_authorized_to_execute(db));
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture )
|
|||
pop.fee_paying_account = nathan.get_id();
|
||||
pop.expiration_time = db.head_block_time() + fc::days(1);
|
||||
trx.operations.push_back(pop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -618,7 +618,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture )
|
|||
uop.active_approvals_to_add.insert(nathan.get_id());
|
||||
uop.fee_paying_account = nathan.get_id();
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
|
||||
|
|
@ -627,9 +627,9 @@ BOOST_FIXTURE_TEST_CASE( proposal_two_accounts, database_fixture )
|
|||
|
||||
uop.active_approvals_to_add = {dan.get_id()};
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
GRAPHENE_REQUIRE_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
trx.sign(dan_key);
|
||||
sign( trx, dan_key );
|
||||
PUSH_TX( db, trx );
|
||||
|
||||
BOOST_CHECK(db.find_object(pid) == nullptr);
|
||||
|
|
@ -663,7 +663,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture )
|
|||
pop.fee_paying_account = nathan.get_id();
|
||||
pop.expiration_time = db.head_block_time() + fc::days(1);
|
||||
trx.operations.push_back(pop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -679,7 +679,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture )
|
|||
uop.proposal = prop.id;
|
||||
uop.active_approvals_to_add.insert(nathan.get_id());
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -687,7 +687,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture )
|
|||
|
||||
std::swap(uop.active_approvals_to_add, uop.active_approvals_to_remove);
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -700,7 +700,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_delete, database_fixture )
|
|||
dop.fee_paying_account = nathan.get_id();
|
||||
dop.proposal = pid;
|
||||
trx.operations.push_back(dop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
BOOST_CHECK(db.find_object(pid) == nullptr);
|
||||
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000);
|
||||
|
|
@ -739,7 +739,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture )
|
|||
pop.fee_paying_account = nathan.get_id();
|
||||
pop.expiration_time = db.head_block_time() + fc::days(1);
|
||||
trx.operations.push_back(pop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -755,7 +755,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture )
|
|||
uop.proposal = prop.id;
|
||||
uop.owner_approvals_to_add.insert(nathan.get_id());
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -763,7 +763,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture )
|
|||
|
||||
std::swap(uop.owner_approvals_to_add, uop.owner_approvals_to_remove);
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -777,7 +777,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_delete, database_fixture )
|
|||
dop.proposal = pid;
|
||||
dop.using_owner_authority = true;
|
||||
trx.operations.push_back(dop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
BOOST_CHECK(db.find_object(pid) == nullptr);
|
||||
BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 100000);
|
||||
|
|
@ -816,7 +816,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture )
|
|||
pop.fee_paying_account = nathan.get_id();
|
||||
pop.expiration_time = db.head_block_time() + fc::days(1);
|
||||
trx.operations.push_back(pop);
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -834,8 +834,8 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture )
|
|||
uop.key_approvals_to_add.insert(dan.active.key_auths.begin()->first);
|
||||
trx.operations.push_back(uop);
|
||||
set_expiration( db, trx );
|
||||
trx.sign(nathan_key);
|
||||
trx.sign(dan_key);
|
||||
sign( trx, nathan_key );
|
||||
sign( trx, dan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -844,8 +844,8 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture )
|
|||
std::swap(uop.key_approvals_to_add, uop.key_approvals_to_remove);
|
||||
trx.operations.push_back(uop);
|
||||
trx.expiration += fc::seconds(1); // Survive trx dupe check
|
||||
trx.sign(nathan_key);
|
||||
trx.sign(dan_key);
|
||||
sign( trx, nathan_key );
|
||||
sign( trx, dan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -854,8 +854,8 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture )
|
|||
std::swap(uop.key_approvals_to_add, uop.key_approvals_to_remove);
|
||||
trx.operations.push_back(uop);
|
||||
trx.expiration += fc::seconds(1); // Survive trx dupe check
|
||||
trx.sign(nathan_key);
|
||||
trx.sign(dan_key);
|
||||
sign( trx, nathan_key );
|
||||
sign( trx, dan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(!prop.is_authorized_to_execute(db));
|
||||
|
|
@ -865,7 +865,7 @@ BOOST_FIXTURE_TEST_CASE( proposal_owner_authority_complete, database_fixture )
|
|||
uop.owner_approvals_to_add.insert(nathan.get_id());
|
||||
trx.operations.push_back(uop);
|
||||
trx.expiration += fc::seconds(1); // Survive trx dupe check
|
||||
trx.sign(nathan_key);
|
||||
sign( trx, nathan_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
BOOST_CHECK(db.find_object(pid) == nullptr);
|
||||
|
|
@ -1003,7 +1003,7 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
|
|||
trx.operations.push_back( xfer_op );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Transfer signed by alice" );
|
||||
trx.sign(alice_key );
|
||||
sign( trx, alice_key );
|
||||
|
||||
flat_set<account_id_type> active_set, owner_set;
|
||||
vector<authority> others;
|
||||
|
|
@ -1018,13 +1018,13 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
|
|||
// Re-sign, now OK (sig is replaced)
|
||||
BOOST_TEST_MESSAGE( "Resign with Alice's Signature" );
|
||||
trx.signatures.clear();
|
||||
trx.sign( alice_key );
|
||||
sign( trx, alice_key );
|
||||
PUSH_TX( db, trx, skip );
|
||||
|
||||
trx.signatures.clear();
|
||||
trx.operations.pop_back();
|
||||
trx.sign( alice_key );
|
||||
trx.sign( charlie_key );
|
||||
sign( trx, alice_key );
|
||||
sign( trx, charlie_key );
|
||||
// Signed by third-party Charlie (irrelevant key, not in authority)
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, skip ), tx_irrelevant_sig );
|
||||
}
|
||||
|
|
@ -1054,7 +1054,7 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
|
|||
op.new_options->votes = flat_set<vote_id_type>{nathan_committee_member(db).vote_id};
|
||||
op.new_options->num_committee = 1;
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -1065,13 +1065,13 @@ BOOST_FIXTURE_TEST_CASE( voting_account, database_fixture )
|
|||
op.new_options->votes.insert(vikram_committee_member(db).vote_id);
|
||||
op.new_options->num_committee = 11;
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(vikram_private_key);
|
||||
sign( trx, vikram_private_key );
|
||||
// Fails because num_committee is larger than the cardinality of committee members being voted for
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
op.new_options->num_committee = 3;
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(vikram_private_key);
|
||||
sign( trx, vikram_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -1147,7 +1147,7 @@ BOOST_FIXTURE_TEST_CASE( get_required_signatures_test, database_fixture )
|
|||
) -> bool
|
||||
{
|
||||
//wdump( (tx)(available_keys) );
|
||||
set<public_key_type> result_set = tx.get_required_signatures( available_keys, get_active, get_owner );
|
||||
set<public_key_type> result_set = tx.get_required_signatures( db.get_chain_id(), available_keys, get_active, get_owner );
|
||||
//wdump( (result_set)(ref_set) );
|
||||
return result_set == ref_set;
|
||||
} ;
|
||||
|
|
@ -1261,7 +1261,7 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture )
|
|||
) -> bool
|
||||
{
|
||||
//wdump( (tx)(available_keys) );
|
||||
set<public_key_type> result_set = tx.get_required_signatures( available_keys, get_active, get_owner );
|
||||
set<public_key_type> result_set = tx.get_required_signatures( db.get_chain_id(), available_keys, get_active, get_owner );
|
||||
//wdump( (result_set)(ref_set) );
|
||||
return result_set == ref_set;
|
||||
} ;
|
||||
|
|
@ -1273,7 +1273,7 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture )
|
|||
) -> bool
|
||||
{
|
||||
//wdump( (tx)(available_keys) );
|
||||
set<public_key_type> result_set = tx.minimize_required_signatures( available_keys, get_active, get_owner );
|
||||
set<public_key_type> result_set = tx.minimize_required_signatures( db.get_chain_id(), available_keys, get_active, get_owner );
|
||||
//wdump( (result_set)(ref_set) );
|
||||
return result_set == ref_set;
|
||||
} ;
|
||||
|
|
@ -1292,9 +1292,9 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture )
|
|||
BOOST_CHECK( chk( tx, { alice_public_key, bob_public_key }, { alice_public_key, bob_public_key } ) );
|
||||
BOOST_CHECK( chk_min( tx, { alice_public_key, bob_public_key }, { alice_public_key } ) );
|
||||
|
||||
GRAPHENE_REQUIRE_THROW( tx.verify_authority( get_active, get_owner ), fc::exception );
|
||||
tx.sign( alice_private_key );
|
||||
tx.verify_authority( get_active, get_owner );
|
||||
GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner ), fc::exception );
|
||||
sign( tx, alice_private_key );
|
||||
tx.verify_authority( db.get_chain_id(), get_active, get_owner );
|
||||
}
|
||||
catch(fc::exception& e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
|
|||
db1.open(data_dir1.path(), make_genesis);
|
||||
database db2;
|
||||
db2.open(data_dir2.path(), make_genesis);
|
||||
BOOST_CHECK( db1.get_chain_id() == db2.get_chain_id() );
|
||||
|
||||
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
|
||||
for( uint32_t i = 0; i < 10; ++i )
|
||||
|
|
@ -258,7 +259,7 @@ BOOST_AUTO_TEST_CASE( fork_blocks )
|
|||
good_block = b;
|
||||
b.transactions.emplace_back(signed_transaction());
|
||||
b.transactions.back().operations.emplace_back(transfer_operation());
|
||||
b.sign(init_account_priv_key);
|
||||
b.sign( init_account_priv_key );
|
||||
BOOST_CHECK_EQUAL(b.block_num(), 14);
|
||||
GRAPHENE_CHECK_THROW(PUSH_BLOCK( db1, b ), fc::exception);
|
||||
}
|
||||
|
|
@ -309,7 +310,7 @@ BOOST_AUTO_TEST_CASE( undo_pending )
|
|||
cop.owner = authority(1, init_account_pub_key, 1);
|
||||
cop.active = cop.owner;
|
||||
trx.operations.push_back(cop);
|
||||
//trx.sign( init_account_priv_key );
|
||||
//sign( trx, init_account_priv_key );
|
||||
PUSH_TX( db, trx );
|
||||
|
||||
auto b = db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
|
||||
|
|
@ -348,6 +349,7 @@ BOOST_AUTO_TEST_CASE( switch_forks_undo_create )
|
|||
db2;
|
||||
db1.open(dir1.path(), make_genesis);
|
||||
db2.open(dir2.path(), make_genesis);
|
||||
BOOST_CHECK( db1.get_chain_id() == db2.get_chain_id() );
|
||||
|
||||
auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) );
|
||||
public_key_type init_account_pub_key = init_account_priv_key.get_public_key();
|
||||
|
|
@ -404,6 +406,7 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
|
|||
db2;
|
||||
db1.open(dir1.path(), make_genesis);
|
||||
db2.open(dir2.path(), make_genesis);
|
||||
BOOST_CHECK( db1.get_chain_id() == db2.get_chain_id() );
|
||||
|
||||
auto skip_sigs = database::skip_transaction_signatures | database::skip_authority_check;
|
||||
|
||||
|
|
@ -419,7 +422,7 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
|
|||
cop.owner = authority(1, init_account_pub_key, 1);
|
||||
cop.active = cop.owner;
|
||||
trx.operations.push_back(cop);
|
||||
trx.sign( init_account_priv_key );
|
||||
trx.sign( init_account_priv_key, db1.get_chain_id() );
|
||||
PUSH_TX( db1, trx, skip_sigs );
|
||||
|
||||
trx = decltype(trx)();
|
||||
|
|
@ -428,7 +431,7 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions )
|
|||
t.to = nathan_id;
|
||||
t.amount = asset(500);
|
||||
trx.operations.push_back(t);
|
||||
trx.sign( init_account_priv_key );
|
||||
trx.sign( init_account_priv_key, db1.get_chain_id() );
|
||||
PUSH_TX( db1, trx, skip_sigs );
|
||||
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db1, trx, skip_sigs ), fc::exception);
|
||||
|
|
@ -473,7 +476,7 @@ BOOST_AUTO_TEST_CASE( tapos )
|
|||
cop.owner = authority(1, init_account_pub_key, 1);
|
||||
cop.active = cop.owner;
|
||||
trx.operations.push_back(cop);
|
||||
trx.sign(init_account_priv_key);
|
||||
trx.sign( init_account_priv_key, db1.get_chain_id() );
|
||||
db1.push_transaction(trx);
|
||||
b = db1.generate_block(db1.get_slot_time(1), db1.get_scheduled_witness(1).first, init_account_priv_key, database::skip_nothing);
|
||||
trx.clear();
|
||||
|
|
@ -482,12 +485,12 @@ BOOST_AUTO_TEST_CASE( tapos )
|
|||
t.to = nathan_id;
|
||||
t.amount = asset(50);
|
||||
trx.operations.push_back(t);
|
||||
trx.sign(init_account_priv_key);
|
||||
trx.sign( init_account_priv_key, db1.get_chain_id() );
|
||||
//relative_expiration is 1, but ref block is 2 blocks old, so this should fail.
|
||||
GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception);
|
||||
set_expiration( db1, trx );
|
||||
trx.signatures.clear();
|
||||
trx.sign(init_account_priv_key);
|
||||
trx.sign( init_account_priv_key, db1.get_chain_id() );
|
||||
db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check);
|
||||
} catch (fc::exception& e) {
|
||||
edump((e.to_detail_string()));
|
||||
|
|
@ -619,19 +622,19 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture )
|
|||
GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), fc::exception );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Verify that double-signing causes an exception" );
|
||||
trx.sign(bob_private_key);
|
||||
trx.sign(bob_private_key);
|
||||
sign( trx, bob_private_key );
|
||||
sign( trx, bob_private_key );
|
||||
GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), tx_duplicate_sig );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Verify that signing with an extra, unused key fails" );
|
||||
trx.signatures.pop_back();
|
||||
trx.sign(generate_private_key("bogus"));
|
||||
sign( trx, generate_private_key("bogus" ));
|
||||
GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), tx_irrelevant_sig );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Verify that signing once with the proper key passes" );
|
||||
trx.signatures.pop_back();
|
||||
db.push_transaction(trx, 0);
|
||||
trx.sign(bob_private_key);
|
||||
sign( trx, bob_private_key );
|
||||
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
|
|
@ -663,15 +666,15 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture )
|
|||
get_account("init4").get_id(), get_account("init5").get_id(),
|
||||
get_account("init6").get_id(), get_account("init7").get_id()};
|
||||
trx.operations.push_back(uop);
|
||||
trx.sign(init_account_priv_key);
|
||||
sign( trx, init_account_priv_key );
|
||||
/*
|
||||
trx.sign(get_account("init1").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init2").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init3").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init4").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init5").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init6").active.get_keys().front(),init_account_priv_key);
|
||||
trx.sign(get_account("init7").active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init1" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init2" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init3" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init4" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init5" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init6" ).active.get_keys().front(),init_account_priv_key);
|
||||
sign( trx, get_account("init7" ).active.get_keys().front(),init_account_priv_key);
|
||||
*/
|
||||
db.push_transaction(trx);
|
||||
BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db));
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE( confidential_test )
|
|||
to_blind.outputs = {out2,out1};
|
||||
|
||||
trx.operations = {to_blind};
|
||||
trx.sign( dan_private_key );
|
||||
sign( trx, dan_private_key );
|
||||
db.push_transaction(trx);
|
||||
trx.signatures.clear();
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE( confidential_test )
|
|||
blind_tr.outputs = {out3,out4};
|
||||
blind_tr.validate();
|
||||
trx.operations = {blind_tr};
|
||||
trx.sign( owner2_key );
|
||||
sign( trx, owner2_key );
|
||||
db.push_transaction(trx);
|
||||
|
||||
BOOST_TEST_MESSAGE( "Attempting to double spend the same commitments" );
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE( cashback_test )
|
|||
op.owner = op.active; \
|
||||
op.fee = fees->calculate_fee(op); \
|
||||
trx.operations = {op}; \
|
||||
trx.sign( registrar_name ## _private_key); \
|
||||
sign( trx, registrar_name ## _private_key ); \
|
||||
actor_name ## _id = PUSH_TX( db, trx ).operation_results.front().get<object_id_type>(); \
|
||||
trx.clear(); \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ BOOST_AUTO_TEST_CASE( create_account_test )
|
|||
op.owner = auth_bak;
|
||||
|
||||
trx.operations.back() = op;
|
||||
trx.sign( init_account_priv_key);
|
||||
sign( trx, init_account_priv_key );
|
||||
trx.validate();
|
||||
PUSH_TX( db, trx, ~0 );
|
||||
|
||||
|
|
@ -1180,7 +1180,7 @@ BOOST_AUTO_TEST_CASE( witness_pay_test )
|
|||
trx.operations.push_back(uop);
|
||||
for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op);
|
||||
trx.validate();
|
||||
trx.sign(init_account_priv_key);
|
||||
sign( trx, init_account_priv_key );
|
||||
PUSH_TX( db, trx );
|
||||
auto pay_fee_time = db.head_block_time().sec_since_epoch();
|
||||
trx.clear();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_create )
|
|||
REQUIRE_THROW_WITH_VALUE(op, withdrawal_period_sec, 1);
|
||||
trx.operations.back() = op;
|
||||
}
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
db.push_transaction( trx );
|
||||
trx.clear();
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
|
@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test )
|
|||
set_expiration( db, trx );
|
||||
trx.clear();
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
|
||||
// would be legal on its own, but doesn't work because trx already withdrew
|
||||
|
|
@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test )
|
|||
trx.operations = {op};
|
||||
// make it different from previous trx so it's non-duplicate
|
||||
trx.expiration += fc::seconds(1);
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -169,14 +169,14 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test )
|
|||
op.amount_to_withdraw = asset(5);
|
||||
trx.operations.push_back(op);
|
||||
set_expiration( db, trx );
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
//Throws because nathan doesn't have the money
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
op.amount_to_withdraw = asset(1);
|
||||
trx.clear();
|
||||
trx.operations = {op};
|
||||
set_expiration( db, trx );
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_test )
|
|||
op.amount_to_withdraw = asset(5);
|
||||
trx.operations.push_back(op);
|
||||
set_expiration( db, trx );
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
//Throws because the permission has expired
|
||||
GRAPHENE_CHECK_THROW(PUSH_TX( db, trx ), fc::exception);
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_nominal_case )
|
|||
op.amount_to_withdraw = asset(5);
|
||||
trx.operations.push_back(op);
|
||||
set_expiration( db, trx );
|
||||
trx.sign(dan_private_key);
|
||||
sign( trx, dan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
// tx's involving withdraw_permissions can't delete it even
|
||||
// if no further withdrawals are possible
|
||||
|
|
@ -279,7 +279,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_update )
|
|||
REQUIRE_THROW_WITH_VALUE(op, authorized_account, account_id_type(0));
|
||||
REQUIRE_THROW_WITH_VALUE(op, period_start_time, db.head_block_time() - 50);
|
||||
trx.operations.back() = op;
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_delete )
|
|||
op.withdraw_from_account = get_account("nathan").id;
|
||||
set_expiration( db, trx );
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(generate_private_key("nathan"));
|
||||
sign( trx, generate_private_key("nathan" ));
|
||||
PUSH_TX( db, trx );
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds )
|
|||
op.issuer = nathan_id;
|
||||
op.new_feed_producers = {dan_id, ben_id, vikram_id};
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
generate_block(database::skip_nothing);
|
||||
}
|
||||
|
|
@ -393,7 +393,7 @@ BOOST_AUTO_TEST_CASE( feed_limit_test )
|
|||
op.asset_to_update = bit_usd.get_id();
|
||||
op.issuer = bit_usd.issuer;
|
||||
trx.operations = {op};
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
db.push_transaction(trx);
|
||||
|
||||
BOOST_TEST_MESSAGE("Checking current_feed is null");
|
||||
|
|
@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE( feed_limit_test )
|
|||
op.new_options.minimum_feeds = 3;
|
||||
trx.clear();
|
||||
trx.operations = {op};
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
db.push_transaction(trx);
|
||||
|
||||
BOOST_TEST_MESSAGE("Checking current_feed is not null");
|
||||
|
|
@ -431,7 +431,7 @@ BOOST_AUTO_TEST_CASE( witness_create )
|
|||
op.new_options->num_committee = std::count_if(op.new_options->votes.begin(), op.new_options->votes.end(),
|
||||
[](vote_id_type id) { return id.type() == vote_id_type::committee; });
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -541,7 +541,7 @@ BOOST_AUTO_TEST_CASE( global_settle_test )
|
|||
REQUIRE_THROW_WITH_VALUE(op, asset_to_settle, asset_id_type(100));
|
||||
REQUIRE_THROW_WITH_VALUE(op, issuer, account_id_type(2));
|
||||
trx.operations.back() = op;
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ BOOST_AUTO_TEST_CASE( worker_create_test )
|
|||
REQUIRE_THROW_WITH_VALUE(op, work_begin_date, db.head_block_time() - 10);
|
||||
REQUIRE_THROW_WITH_VALUE(op, work_end_date, op.work_begin_date);
|
||||
trx.operations.back() = op;
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test )
|
|||
op.owner = nathan_id;
|
||||
set_expiration( db, trx );
|
||||
trx.operations.push_back(op);
|
||||
trx.sign( nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.signatures.clear();
|
||||
REQUIRE_THROW_WITH_VALUE(op, amount, asset(1));
|
||||
|
|
@ -668,7 +668,7 @@ BOOST_AUTO_TEST_CASE( worker_pay_test )
|
|||
set_expiration( db, trx );
|
||||
REQUIRE_THROW_WITH_VALUE(op, amount, asset(501));
|
||||
trx.operations.back() = op;
|
||||
trx.sign( nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.signatures.clear();
|
||||
trx.clear();
|
||||
|
|
@ -701,7 +701,7 @@ BOOST_AUTO_TEST_CASE( refund_worker_test )
|
|||
REQUIRE_THROW_WITH_VALUE(op, work_begin_date, db.head_block_time() - 10);
|
||||
REQUIRE_THROW_WITH_VALUE(op, work_end_date, op.work_begin_date);
|
||||
trx.operations.back() = op;
|
||||
trx.sign( nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -774,7 +774,7 @@ BOOST_AUTO_TEST_CASE( burn_worker_test )
|
|||
REQUIRE_THROW_WITH_VALUE(op, work_begin_date, db.head_block_time() - 10);
|
||||
REQUIRE_THROW_WITH_VALUE(op, work_end_date, op.work_begin_date);
|
||||
trx.operations.back() = op;
|
||||
trx.sign( nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
trx.clear();
|
||||
}
|
||||
|
|
@ -1025,14 +1025,14 @@ BOOST_AUTO_TEST_CASE( assert_op_test )
|
|||
op.fee_paying_account = nathan_id;
|
||||
op.predicates.emplace_back(account_name_eq_lit_predicate{ nathan_id, "nathan" });
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
PUSH_TX( db, trx );
|
||||
|
||||
// nathan checks that his public key is not equal to the given value (fail)
|
||||
trx.clear();
|
||||
op.predicates.emplace_back(account_name_eq_lit_predicate{ nathan_id, "dan" });
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
sign( trx, nathan_private_key );
|
||||
GRAPHENE_CHECK_THROW( PUSH_TX( db, trx ), fc::exception );
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
|
@ -1068,6 +1068,9 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
|
||||
genesis_state.initial_accounts.emplace_back("n", n_key.get_public_key());
|
||||
|
||||
auto _sign = [&]( signed_transaction& tx, const private_key_type& key )
|
||||
{ tx.sign( key, db.get_chain_id() ); };
|
||||
|
||||
db.open(td.path(), [this]{return genesis_state;});
|
||||
const balance_object& balance = balance_id_type()(db);
|
||||
BOOST_CHECK_EQUAL(balance.balance.amount.value, 1);
|
||||
|
|
@ -1079,14 +1082,14 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.balance_to_claim = balance_id_type(1);
|
||||
op.balance_owner_key = x_key.get_public_key();
|
||||
trx.operations = {op};
|
||||
trx.sign(n_key);
|
||||
_sign( trx, n_key );
|
||||
// Fail because I'm claiming from an address which hasn't signed
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), fc::exception);
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), tx_missing_other_auth);
|
||||
trx.clear();
|
||||
op.balance_to_claim = balance_id_type();
|
||||
op.balance_owner_key = n_key.get_public_key();
|
||||
trx.operations = {op};
|
||||
trx.sign(n_key);
|
||||
_sign( trx, n_key );
|
||||
db.push_transaction(trx);
|
||||
|
||||
// Not using fixture's get_balance() here because it uses fixture's db, not my override
|
||||
|
|
@ -1112,8 +1115,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.balance_owner_key = v1_key.get_public_key();
|
||||
trx.clear();
|
||||
trx.operations = {op};
|
||||
trx.sign(n_key);
|
||||
trx.sign(v1_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v1_key );
|
||||
// Attempting to claim 1 from a balance with 0 available
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_invalid_claim_amount);
|
||||
|
||||
|
|
@ -1122,8 +1125,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.balance_owner_key = v2_key.get_public_key();
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v2_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v2_key );
|
||||
// Attempting to claim 151 from a balance with 150 available
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_invalid_claim_amount);
|
||||
|
||||
|
|
@ -1132,8 +1135,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.balance_owner_key = v2_key.get_public_key();
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v2_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v2_key );
|
||||
db.push_transaction(trx);
|
||||
BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 101);
|
||||
BOOST_CHECK_EQUAL(vesting_balance_2.balance.amount.value, 300);
|
||||
|
|
@ -1141,8 +1144,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.total_claimed.amount = 10;
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v2_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v2_key );
|
||||
// Attempting to claim twice within a day
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
|
||||
|
||||
|
|
@ -1156,8 +1159,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.balance_owner_key = v1_key.get_public_key();
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v1_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v1_key );
|
||||
db.push_transaction(trx);
|
||||
BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr);
|
||||
BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 601);
|
||||
|
|
@ -1167,8 +1170,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.total_claimed.amount = 10;
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v2_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v2_key );
|
||||
// Attempting to claim twice within a day
|
||||
GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often);
|
||||
|
||||
|
|
@ -1180,8 +1183,8 @@ BOOST_AUTO_TEST_CASE( balance_object_test )
|
|||
op.total_claimed = vesting_balance_2.balance;
|
||||
trx.operations = {op};
|
||||
trx.signatures.clear();
|
||||
trx.sign(n_key);
|
||||
trx.sign(v2_key);
|
||||
_sign( trx, n_key );
|
||||
_sign( trx, v2_key );
|
||||
db.push_transaction(trx);
|
||||
BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr);
|
||||
BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 901);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE( serialization_raw_test )
|
|||
auto packed = fc::raw::pack( trx );
|
||||
signed_transaction unpacked = fc::raw::unpack<signed_transaction>(packed);
|
||||
unpacked.validate();
|
||||
BOOST_CHECK( trx.digest() == unpacked.digest() );
|
||||
BOOST_CHECK( digest(trx) == digest(unpacked) );
|
||||
} catch (fc::exception& e) {
|
||||
edump((e.to_detail_string()));
|
||||
throw;
|
||||
|
|
@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE( serialization_json_test )
|
|||
fc::variant packed(trx);
|
||||
signed_transaction unpacked = packed.as<signed_transaction>();
|
||||
unpacked.validate();
|
||||
BOOST_CHECK( trx.digest() == unpacked.digest() );
|
||||
BOOST_CHECK( digest(trx) == digest(unpacked) );
|
||||
} catch (fc::exception& e) {
|
||||
edump((e.to_detail_string()));
|
||||
throw;
|
||||
|
|
@ -79,6 +79,4 @@ BOOST_AUTO_TEST_CASE( json_tests )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ BOOST_AUTO_TEST_CASE( override_transfer_test )
|
|||
BOOST_TEST_MESSAGE( "Require throwing without signature" );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), tx_missing_active_auth );
|
||||
BOOST_TEST_MESSAGE( "Require throwing with dan's signature" );
|
||||
trx.sign( dan_private_key );
|
||||
sign( trx, dan_private_key );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), tx_missing_active_auth );
|
||||
BOOST_TEST_MESSAGE( "Pass with issuer's signature" );
|
||||
trx.signatures.clear();
|
||||
trx.sign( sam_private_key );
|
||||
sign( trx, sam_private_key );
|
||||
PUSH_TX( db, trx, 0 );
|
||||
|
||||
BOOST_REQUIRE_EQUAL( get_balance( dan, advanced ), 900 );
|
||||
|
|
@ -117,11 +117,11 @@ BOOST_AUTO_TEST_CASE( override_transfer_test2 )
|
|||
BOOST_TEST_MESSAGE( "Require throwing without signature" );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), fc::exception);
|
||||
BOOST_TEST_MESSAGE( "Require throwing with dan's signature" );
|
||||
trx.sign( dan_private_key );
|
||||
sign( trx, dan_private_key );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), fc::exception);
|
||||
BOOST_TEST_MESSAGE( "Fail because overide_authority flag is not set" );
|
||||
trx.signatures.clear();
|
||||
trx.sign( sam_private_key );
|
||||
sign( trx, sam_private_key );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), fc::exception );
|
||||
|
||||
BOOST_REQUIRE_EQUAL( get_balance( dan, advanced ), 1000 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue