change info added to signed tx data

This commit is contained in:
moneroexamples 2016-10-24 09:51:53 +08:00
parent f340e7f0b1
commit ee1305b993
2 changed files with 24 additions and 6 deletions

View file

@ -1572,7 +1572,7 @@ namespace xmreg {
if (strncmp(decoded_raw_tx_data.c_str(), SIGNED_TX_PREFIX, magiclen) != 0) if (strncmp(decoded_raw_tx_data.c_str(), SIGNED_TX_PREFIX, magiclen) != 0)
{ {
cout << "The data is neigther unsigned nor signed tx!" << endl; cout << "The data is neither unsigned nor signed tx!" << endl;
return string( "The data is neither unsigned nor signed tx!"); return string( "The data is neither unsigned nor signed tx!");
} }
@ -1616,12 +1616,25 @@ namespace xmreg {
destination_addresses.push_back( destination_addresses.push_back(
mstch::map { mstch::map {
{"dest_address", get_account_address_as_str(testnet, a_dest.addr)}, {"dest_address" , get_account_address_as_str(testnet, a_dest.addr)},
{"dest_amount" , fmt::format("{:0.12f}", XMR_AMOUNT(a_dest.amount))} {"dest_amount" , fmt::format("{:0.12f}", XMR_AMOUNT(a_dest.amount))},
{"is_this_change" , false}
} }
); );
} }
// get change address and amount info
if (ptx.construction_data.change_dts.amount > 0)
{
destination_addresses.push_back(
mstch::map {
{"dest_address" , get_account_address_as_str(testnet, ptx.construction_data.change_dts.addr)},
{"dest_amount" , fmt::format("{:0.12f}", XMR_AMOUNT(ptx.construction_data.change_dts.amount))},
{"is_this_change" , true}
}
);
};
tx_context.insert({"dest_infos", destination_addresses}); tx_context.insert({"dest_infos", destination_addresses});
// get reference to inputs array created of the tx // get reference to inputs array created of the tx
@ -1632,8 +1645,8 @@ namespace xmreg {
{ {
mstch::map& output_map = boost::get<mstch::map>(outputs.at(i)); mstch::map& output_map = boost::get<mstch::map>(outputs.at(i));
//cout << boost::get<string>(output_map["out_pub_key"]) <<", " << address_amounts.at(i) << endl; cout << boost::get<string>(output_map["out_pub_key"])
//cout << boost::get<string>(output_map["out_pub_key"]) << endl; <<", " << boost::get<string>(output_map["amount"]) << endl;
} }
// get public keys of real outputs // get public keys of real outputs

View file

@ -93,7 +93,12 @@
{{#txs}} {{#txs}}
<h5> <h5>
{{#dest_infos}} {{#dest_infos}}
Send {{dest_amount}} to {{dest_address}}<br/> {{^is_this_change}}
Send {{dest_amount}} to {{dest_address}}<br/>
{{/is_this_change}}
{{#is_this_change}}
Change {{dest_amount}} back to {{dest_address}}<br/>
{{/is_this_change}}
{{/dest_infos}} {{/dest_infos}}
</h5> </h5>
{{>tx_details}} {{>tx_details}}