Skip to content

Commit

Permalink
merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Array Mac committed Feb 14, 2019
2 parents ec957d2 + a8b00fd commit 79ba94a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions keychain_lib/include/keychain_lib/keychain_commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,25 +529,44 @@ struct keychain_command<command_te::sign_hex> : keychain_command_base
auto iter = [&it, &signatures]() { assert(it < signatures.end()); return *it++;};
for (auto& a : trx_info.vins)
{
auto sig = iter().hex();
auto sig_b = iter();
auto sig = sig_b.hex();
std::string r =sig.substr(0, 64), s = sig.substr(64, 64);

trx += a.txid;
ss.str("");
ss << std::setw(8) << ntohl(a.output_id);
trx += ss.str();
ss.str("");
uint8_t script_len = 0x6a, pushdata_sig = 0x47, header=0x30, sig_length=0x44, integer=2, r_length=0x20,
s_length=0x20, sig_hash_code=1, pushdata_pubkey=0x21;
if (sig_b[0] & 0x80)
{
script_len++;
pushdata_sig++;
sig_length++;
r_length++;
r.insert(0, "00");
}
if (sig_b[32] & 0x80)
{
script_len++;
pushdata_sig++;
sig_length++;
s_length++;
s.insert(0, "00");
}
// script_len + signature DER-encoded + pub_key
ss << std::setw(2) << ((int) script_len)
<< std::setw(2) << ((int) pushdata_sig)
<< std::setw(2) << ((int) header)
<< std::setw(2) << ((int) sig_length)
<< std::setw(2) << ((int) integer)
<< std::setw(2) << ((int) r_length)
<< sig.substr(0, 64)
<< r
<< std::setw(2) << ((int) integer)
<< std::setw(2) << ((int) s_length)
<< sig.substr(64, 64)
<< s
<< std::setw(2) << ((int) sig_hash_code)
<< std::setw(2) << ((int) pushdata_pubkey)
<< "03"+ dev::toPublic(private_key).hex().substr(0,64);
Expand Down

0 comments on commit 79ba94a

Please sign in to comment.