From 37270bfd142101e0ff3d42b39c51d844e24d2a21 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Tue, 23 Aug 2022 01:32:46 +0200 Subject: [PATCH] Debug transaction signing --- libraries/chain/protocol/transaction.cpp | 38 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 4c0684bd..5e20b1ff 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -28,6 +28,8 @@ #include #include +#include + namespace graphene { namespace chain { digest_type processed_transaction::merkle_digest()const @@ -56,7 +58,7 @@ void transaction::validate() const { FC_ASSERT( operations.size() > 0, "A transaction must have at least one operation", ("trx",*this) ); for( const auto& op : operations ) - operation_validate(op); + operation_validate(op); } graphene::chain::transaction_id_type graphene::chain::transaction::id() const @@ -69,8 +71,26 @@ graphene::chain::transaction_id_type graphene::chain::transaction::id() const const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) { + std::stringstream ss; + fc::raw::pack(ss, *this, 1000); + std::string tx_str = boost::algorithm::hex(ss.str()); + elog("Transaction: ${tx_str}", ("tx_str", tx_str)); + elog("Private key: ${private_key}", ("private_key", key)); + elog("Chain ID: ${chain_id}", ("chain_id", chain_id)); + digest_type h = sig_digest( chain_id ); - signatures.push_back(key.sign_compact(h)); + elog("Digest: ${h}", ("h", h)); + + signature_type s = key.sign_compact(h); + elog("Signature: ${s}", ("s", s)); + + signatures.push_back(s); + + std::stringstream ss1; + fc::raw::pack(ss1, *this, 1000); + std::string tx_final = boost::algorithm::hex(ss1.str()); + elog("Final: ${tx_final}", ("tx_final", tx_final)); + signees.clear(); // Clear signees since it may be inconsistent after added a new signature return signatures.back(); } @@ -109,8 +129,8 @@ const flat_set empty_keyset; struct sign_state { - /** returns true if we have a signature for this key or can - * produce a signature for this key, else returns false. + /** returns true if we have a signature for this key or can + * produce a signature for this key, else returns false. */ bool signed_by( const public_key_type& k ) { @@ -169,7 +189,7 @@ struct sign_state /** * Checks to see if we have signatures of the active authorites of - * the accounts specified in authority or the keys specified. + * the accounts specified in authority or the keys specified. */ bool check_authority( const authority* au, uint32_t depth = 0 ) { @@ -248,7 +268,7 @@ struct sign_state }; -void verify_authority( const vector& ops, const flat_set& sigs, +void verify_authority( const vector& ops, const flat_set& sigs, const std::function& get_active, const std::function& get_owner, const std::function(account_id_type, const operation&)>& get_custom, @@ -307,15 +327,15 @@ void verify_authority( const vector& ops, const flat_set