Code formatting
This commit is contained in:
parent
b1fbd26bcf
commit
2b6c700644
5 changed files with 152 additions and 186 deletions
|
|
@ -384,8 +384,7 @@ const int8_t charset_rev[128] = {
|
||||||
-1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1,
|
-1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1,
|
||||||
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1,
|
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1,
|
||||||
-1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1,
|
-1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1,
|
||||||
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1
|
1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1};
|
||||||
};
|
|
||||||
|
|
||||||
/** Concatenate two byte arrays. */
|
/** Concatenate two byte arrays. */
|
||||||
bytes cat(bytes x, const bytes &y) {
|
bytes cat(bytes x, const bytes &y) {
|
||||||
|
|
@ -422,8 +421,7 @@ uint32_t polymod(const bytes &values) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Expand a HRP for use in checksum computation. */
|
/** Expand a HRP for use in checksum computation. */
|
||||||
bytes bech32_expand_hrp(const std::string& hrp)
|
bytes bech32_expand_hrp(const std::string &hrp) {
|
||||||
{
|
|
||||||
bytes ret;
|
bytes ret;
|
||||||
ret.reserve(hrp.size() + 90);
|
ret.reserve(hrp.size() + 90);
|
||||||
ret.resize(hrp.size() * 2 + 1);
|
ret.resize(hrp.size() * 2 + 1);
|
||||||
|
|
@ -450,8 +448,7 @@ bytes bech32_checksum(const std::string &hrp, const bytes &values) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verify a checksum. */
|
/** Verify a checksum. */
|
||||||
bool bech32_verify_checksum(const std::string& hrp, const bytes& values)
|
bool bech32_verify_checksum(const std::string &hrp, const bytes &values) {
|
||||||
{
|
|
||||||
// PolyMod computes what value to xor into the final values to make the checksum 0. However,
|
// PolyMod computes what value to xor into the final values to make the checksum 0. However,
|
||||||
// if we required that the checksum was 0, it would be the case that appending a 0 to a valid
|
// if we required that the checksum was 0, it would be the case that appending a 0 to a valid
|
||||||
// list of values would result in a new valid list. For that reason, Bech32 requires the
|
// list of values would result in a new valid list. For that reason, Bech32 requires the
|
||||||
|
|
@ -524,8 +521,7 @@ bool convertbits(bytes &out, const bytes &in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Encode a SegWit address. */
|
/** Encode a SegWit address. */
|
||||||
std::string segwit_addr_encode(const std::string& hrp, uint8_t witver, const bytes& witprog)
|
std::string segwit_addr_encode(const std::string &hrp, uint8_t witver, const bytes &witprog) {
|
||||||
{
|
|
||||||
bytes enc;
|
bytes enc;
|
||||||
enc.push_back(witver);
|
enc.push_back(witver);
|
||||||
convertbits<8, 5, true>(enc, witprog);
|
convertbits<8, 5, true>(enc, witprog);
|
||||||
|
|
@ -534,22 +530,19 @@ std::string segwit_addr_encode(const std::string& hrp, uint8_t witver, const byt
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Decode a SegWit address. */
|
/** Decode a SegWit address. */
|
||||||
bytes segwit_addr_decode(const std::string& addr)
|
bytes segwit_addr_decode(const std::string &addr) {
|
||||||
{
|
|
||||||
bytes dec = bech32_decode(addr);
|
bytes dec = bech32_decode(addr);
|
||||||
if (dec.size() < 1)
|
if (dec.size() < 1)
|
||||||
FC_THROW("Invalid bech32 address ${a}", ("a", addr));
|
FC_THROW("Invalid bech32 address ${a}", ("a", addr));
|
||||||
bytes conv;
|
bytes conv;
|
||||||
if (!convertbits<5, 8, false>(conv, bytes(dec.begin() + 1, dec.end())) ||
|
if (!convertbits<5, 8, false>(conv, bytes(dec.begin() + 1, dec.end())) ||
|
||||||
conv.size() < 2 || conv.size() > 40 || dec[0] > 16 || (dec[0] == 0 &&
|
conv.size() < 2 || conv.size() > 40 || dec[0] > 16 || (dec[0] == 0 && conv.size() != 20 && conv.size() != 32)) {
|
||||||
conv.size() != 20 && conv.size() != 32)) {
|
|
||||||
FC_THROW("Invalid bech32 address ${a}", ("a", addr));
|
FC_THROW("Invalid bech32 address ${a}", ("a", addr));
|
||||||
}
|
}
|
||||||
return conv;
|
return conv;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string p2wsh_address_from_redeem_script(const bytes& script, bitcoin_network network)
|
std::string p2wsh_address_from_redeem_script(const bytes &script, bitcoin_network network) {
|
||||||
{
|
|
||||||
// calc script hash
|
// calc script hash
|
||||||
fc::sha256 sh = fc::sha256::hash(reinterpret_cast<const char *>(&script[0]), script.size());
|
fc::sha256 sh = fc::sha256::hash(reinterpret_cast<const char *>(&script[0]), script.size());
|
||||||
bytes wp(sh.data(), sh.data() + sh.data_size());
|
bytes wp(sh.data(), sh.data() + sh.data_size());
|
||||||
|
|
@ -766,8 +759,7 @@ bytes add_signatures_to_unsigned_tx(const bytes &unsigned_tx, const std::vector<
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_weighted_multisig_address(const std::vector<std::pair<std::string, uint64_t> > &public_keys)
|
std::string get_weighted_multisig_address(const std::vector<std::pair<std::string, uint64_t>> &public_keys) {
|
||||||
{
|
|
||||||
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
||||||
for (auto p : public_keys)
|
for (auto p : public_keys)
|
||||||
key_data.push_back(std::make_pair(fc::ecc::public_key::from_base58(p.first), p.second));
|
key_data.push_back(std::make_pair(fc::ecc::public_key::from_base58(p.first), p.second));
|
||||||
|
|
@ -775,8 +767,7 @@ std::string get_weighted_multisig_address(const std::vector<std::pair<std::strin
|
||||||
return p2wsh_address_from_redeem_script(redeem_script);
|
return p2wsh_address_from_redeem_script(redeem_script);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes get_weighted_multisig_redeem_script(std::vector<std::pair<std::string, uint64_t> > public_keys)
|
bytes get_weighted_multisig_redeem_script(std::vector<std::pair<std::string, uint64_t>> public_keys) {
|
||||||
{
|
|
||||||
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
||||||
for (auto p : public_keys)
|
for (auto p : public_keys)
|
||||||
key_data.push_back(std::make_pair(fc::ecc::public_key::from_base58(p.first), p.second));
|
key_data.push_back(std::make_pair(fc::ecc::public_key::from_base58(p.first), p.second));
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,7 @@ struct btc_in {
|
||||||
btc_in(btc_in &&) = default;
|
btc_in(btc_in &&) = default;
|
||||||
btc_in &operator=(const btc_in &) = default;
|
btc_in &operator=(const btc_in &) = default;
|
||||||
|
|
||||||
btc_in(const std::string& txid, uint32_t out, uint32_t sequence = 0xffffffff)
|
btc_in(const std::string &txid, uint32_t out, uint32_t sequence = 0xffffffff) {
|
||||||
{
|
|
||||||
prevout.n = out;
|
prevout.n = out;
|
||||||
prevout.hash = fc::uint256(txid);
|
prevout.hash = fc::uint256(txid);
|
||||||
// reverse hash due to the different from_hex algo in bitcoin
|
// reverse hash due to the different from_hex algo in bitcoin
|
||||||
|
|
@ -108,8 +107,7 @@ struct btc_out {
|
||||||
|
|
||||||
btc_out(const std::string &address, uint64_t amount) :
|
btc_out(const std::string &address, uint64_t amount) :
|
||||||
nValue(amount),
|
nValue(amount),
|
||||||
scriptPubKey(lock_script_from_pw_address(address))
|
scriptPubKey(lock_script_from_pw_address(address)) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nValue;
|
int64_t nValue;
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
#include <graphene/chain/sidechain_transaction_object.hpp>
|
#include <graphene/chain/sidechain_transaction_object.hpp>
|
||||||
#include <graphene/chain/son_wallet_object.hpp>
|
#include <graphene/chain/son_wallet_object.hpp>
|
||||||
#include <graphene/chain/son_wallet_withdraw_object.hpp>
|
#include <graphene/chain/son_wallet_withdraw_object.hpp>
|
||||||
#include <graphene/peerplays_sidechain/sidechain_net_manager.hpp>
|
|
||||||
#include <graphene/peerplays_sidechain/bitcoin_utils.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin_utils.hpp>
|
||||||
|
#include <graphene/peerplays_sidechain/sidechain_net_manager.hpp>
|
||||||
#include <graphene/utilities/key_conversion.hpp>
|
#include <graphene/utilities/key_conversion.hpp>
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
@ -352,7 +352,6 @@ void peerplays_sidechain_plugin_impl::son_processing() {
|
||||||
process_withdrawals();
|
process_withdrawals();
|
||||||
|
|
||||||
complete_signing();
|
complete_signing();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include <graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp>
|
|
||||||
#include <graphene/peerplays_sidechain/bitcoin_utils.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin_utils.hpp>
|
||||||
|
#include <graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
#include <fc/network/ip.hpp>
|
#include <fc/network/ip.hpp>
|
||||||
|
|
||||||
#include <graphene/chain/account_object.hpp>
|
#include <graphene/chain/account_object.hpp>
|
||||||
#include <graphene/chain/protocol/son_wallet.hpp>
|
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
|
#include <graphene/chain/protocol/son_wallet.hpp>
|
||||||
#include <graphene/chain/sidechain_address_object.hpp>
|
#include <graphene/chain/sidechain_address_object.hpp>
|
||||||
#include <graphene/chain/sidechain_transaction_object.hpp>
|
#include <graphene/chain/sidechain_transaction_object.hpp>
|
||||||
#include <graphene/chain/son_info.hpp>
|
#include <graphene/chain/son_info.hpp>
|
||||||
|
|
@ -628,9 +628,7 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
|
||||||
son_pubkeys_bitcoin.push_back(
|
son_pubkeys_bitcoin.push_back(
|
||||||
make_pair(
|
make_pair(
|
||||||
si.sidechain_public_keys.at(sidechain_type::bitcoin),
|
si.sidechain_public_keys.at(sidechain_type::bitcoin),
|
||||||
si.total_votes
|
si.total_votes));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string address = create_weighted_multisignature_wallet(son_pubkeys_bitcoin);
|
string address = create_weighted_multisignature_wallet(son_pubkeys_bitcoin);
|
||||||
|
|
@ -686,8 +684,7 @@ static bool has_enough_signatures(const bitcoin_transaction_object &tx_object) {
|
||||||
return !has_empty;
|
return !has_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler_bitcoin::process_signing()
|
void sidechain_net_handler_bitcoin::process_signing() {
|
||||||
{
|
|
||||||
const auto &idx = plugin.database().get_index_type<proposal_index>().indices().get<by_id>();
|
const auto &idx = plugin.database().get_index_type<proposal_index>().indices().get<by_id>();
|
||||||
vector<proposal_id_type> proposals;
|
vector<proposal_id_type> proposals;
|
||||||
for (const auto &proposal : idx) {
|
for (const auto &proposal : idx) {
|
||||||
|
|
@ -703,8 +700,7 @@ void sidechain_net_handler_bitcoin::process_signing()
|
||||||
auto it = tx_object.signatures.find(son_id);
|
auto it = tx_object.signatures.find(son_id);
|
||||||
if (it == tx_object.signatures.end())
|
if (it == tx_object.signatures.end())
|
||||||
continue;
|
continue;
|
||||||
if (it->second.empty())
|
if (it->second.empty()) {
|
||||||
{
|
|
||||||
bitcoin_transaction_sign_operation op;
|
bitcoin_transaction_sign_operation op;
|
||||||
son_object s_obj = plugin.get_son_object(son_id);
|
son_object s_obj = plugin.get_son_object(son_id);
|
||||||
op.payer = s_obj.son_account;
|
op.payer = s_obj.son_account;
|
||||||
|
|
@ -726,8 +722,7 @@ void sidechain_net_handler_bitcoin::process_signing()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler_bitcoin::complete_signing()
|
void sidechain_net_handler_bitcoin::complete_signing() {
|
||||||
{
|
|
||||||
const auto &idx = plugin.database().get_index_type<bitcoin_transaction_index>().indices().get<by_processed>();
|
const auto &idx = plugin.database().get_index_type<bitcoin_transaction_index>().indices().get<by_processed>();
|
||||||
const auto &idx_range = idx.equal_range(false);
|
const auto &idx_range = idx.equal_range(false);
|
||||||
std::for_each(idx_range.first, idx_range.second,
|
std::for_each(idx_range.first, idx_range.second,
|
||||||
|
|
@ -781,8 +776,7 @@ std::string sidechain_net_handler_bitcoin::send_transaction(const std::string &t
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sidechain_net_handler_bitcoin::sign_and_send_transaction_with_wallet ( const std::string& tx_json )
|
std::string sidechain_net_handler_bitcoin::sign_and_send_transaction_with_wallet(const std::string &tx_json) {
|
||||||
{
|
|
||||||
if (!wallet_password.empty()) {
|
if (!wallet_password.empty()) {
|
||||||
bitcoin_client->walletpassphrase(wallet_password, 60);
|
bitcoin_client->walletpassphrase(wallet_password, 60);
|
||||||
}
|
}
|
||||||
|
|
@ -810,8 +804,7 @@ std::string sidechain_net_handler_bitcoin::sign_and_send_transaction_with_wallet
|
||||||
return reply_str;
|
return reply_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_address, const vector<son_info>& from_sons, const std::string& to_address)
|
void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string &from_address, const vector<son_info> &from_sons, const std::string &to_address) {
|
||||||
{
|
|
||||||
uint64_t fee_rate = bitcoin_client->estimatesmartfee();
|
uint64_t fee_rate = bitcoin_client->estimatesmartfee();
|
||||||
uint64_t min_fee_rate = 1000;
|
uint64_t min_fee_rate = 1000;
|
||||||
fee_rate = std::max(fee_rate, min_fee_rate);
|
fee_rate = std::max(fee_rate, min_fee_rate);
|
||||||
|
|
@ -839,24 +832,21 @@ void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_add
|
||||||
tx.nVersion = 2;
|
tx.nVersion = 2;
|
||||||
tx.nLockTime = 0;
|
tx.nLockTime = 0;
|
||||||
std::vector<uint64_t> amounts;
|
std::vector<uint64_t> amounts;
|
||||||
for(const auto& utx: unspent_utxo)
|
for (const auto &utx : unspent_utxo) {
|
||||||
{
|
|
||||||
tx.vin.push_back(btc_in(utx.txid_, utx.out_num_));
|
tx.vin.push_back(btc_in(utx.txid_, utx.out_num_));
|
||||||
amounts.push_back(uint64_t(utx.amount_ * 100000000.0));
|
amounts.push_back(uint64_t(utx.amount_ * 100000000.0));
|
||||||
}
|
}
|
||||||
tx.vout.push_back(btc_out(to_address, uint64_t((total_amount - min_amount) * 100000000.0)));
|
tx.vout.push_back(btc_out(to_address, uint64_t((total_amount - min_amount) * 100000000.0)));
|
||||||
|
|
||||||
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
||||||
for(auto si: from_sons)
|
for (auto si : from_sons) {
|
||||||
{
|
|
||||||
fc::ecc::public_key pk = si.signing_key;
|
fc::ecc::public_key pk = si.signing_key;
|
||||||
key_data.push_back(std::make_pair(pk, si.total_votes));
|
key_data.push_back(std::make_pair(pk, si.total_votes));
|
||||||
}
|
}
|
||||||
std::sort(key_data.begin(), key_data.end(),
|
std::sort(key_data.begin(), key_data.end(),
|
||||||
[](std::pair<fc::ecc::public_key, uint64_t> p1, std::pair<fc::ecc::public_key, uint64_t> p2) {
|
[](std::pair<fc::ecc::public_key, uint64_t> p1, std::pair<fc::ecc::public_key, uint64_t> p2) {
|
||||||
return (p1.second > p2.second);
|
return (p1.second > p2.second);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
bytes from_redeem_script = generate_redeem_script(key_data);
|
bytes from_redeem_script = generate_redeem_script(key_data);
|
||||||
|
|
||||||
bitcoin_transaction_send_operation op;
|
bitcoin_transaction_send_operation op;
|
||||||
|
|
@ -866,16 +856,12 @@ void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_add
|
||||||
tx.to_bytes(op.unsigned_tx);
|
tx.to_bytes(op.unsigned_tx);
|
||||||
// add signatures
|
// add signatures
|
||||||
std::set<son_id_type> plugin_sons = plugin.get_sons();
|
std::set<son_id_type> plugin_sons = plugin.get_sons();
|
||||||
for(auto si: from_sons)
|
for (auto si : from_sons) {
|
||||||
{
|
if (plugin_sons.find(si.son_id) != plugin_sons.end()) {
|
||||||
if (plugin_sons.find(si.son_id) != plugin_sons.end())
|
|
||||||
{
|
|
||||||
fc::ecc::private_key k = plugin.get_private_key(si.son_id);
|
fc::ecc::private_key k = plugin.get_private_key(si.son_id);
|
||||||
std::vector<bytes> signatures = signatures_for_raw_transaction(op.unsigned_tx, amounts, from_redeem_script, k);
|
std::vector<bytes> signatures = signatures_for_raw_transaction(op.unsigned_tx, amounts, from_redeem_script, k);
|
||||||
op.signatures[si.son_id] = signatures;
|
op.signatures[si.son_id] = signatures;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
op.signatures[si.son_id];
|
op.signatures[si.son_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -966,30 +952,26 @@ std::string sidechain_net_handler_bitcoin::transfer_withdrawal_from_primary_wall
|
||||||
tx.nLockTime = 0;
|
tx.nLockTime = 0;
|
||||||
tx.hasWitness = true;
|
tx.hasWitness = true;
|
||||||
std::vector<uint64_t> amounts;
|
std::vector<uint64_t> amounts;
|
||||||
for(const auto& utxo: unspent_utxo)
|
for (const auto &utxo : unspent_utxo) {
|
||||||
{
|
|
||||||
tx.vin.push_back(btc_in(utxo.txid_, utxo.amount_));
|
tx.vin.push_back(btc_in(utxo.txid_, utxo.amount_));
|
||||||
amounts.push_back(uint64_t(utxo.amount_ * 100000000.0));
|
amounts.push_back(uint64_t(utxo.amount_ * 100000000.0));
|
||||||
}
|
}
|
||||||
tx.vout.push_back(btc_out(swwo.withdraw_address, swwo.withdraw_amount.value));
|
tx.vout.push_back(btc_out(swwo.withdraw_address, swwo.withdraw_amount.value));
|
||||||
if((total_amount - min_amount) > 0.0)
|
if ((total_amount - min_amount) > 0.0) {
|
||||||
{
|
|
||||||
tx.vout.push_back(btc_out(pw_address, (total_amount - min_amount) * 100000000.0));
|
tx.vout.push_back(btc_out(pw_address, (total_amount - min_amount) * 100000000.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto from_sons = obj->sons;
|
auto from_sons = obj->sons;
|
||||||
|
|
||||||
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
std::vector<std::pair<fc::ecc::public_key, uint64_t>> key_data;
|
||||||
for(auto si: from_sons)
|
for (auto si : from_sons) {
|
||||||
{
|
|
||||||
fc::ecc::public_key pk = si.signing_key;
|
fc::ecc::public_key pk = si.signing_key;
|
||||||
key_data.push_back(std::make_pair(pk, si.total_votes));
|
key_data.push_back(std::make_pair(pk, si.total_votes));
|
||||||
}
|
}
|
||||||
std::sort(key_data.begin(), key_data.end(),
|
std::sort(key_data.begin(), key_data.end(),
|
||||||
[](std::pair<fc::ecc::public_key, uint64_t> p1, std::pair<fc::ecc::public_key, uint64_t> p2) {
|
[](std::pair<fc::ecc::public_key, uint64_t> p1, std::pair<fc::ecc::public_key, uint64_t> p2) {
|
||||||
return (p1.second > p2.second);
|
return (p1.second > p2.second);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
bytes from_redeem_script = generate_redeem_script(key_data);
|
bytes from_redeem_script = generate_redeem_script(key_data);
|
||||||
|
|
||||||
bitcoin_transaction_send_operation op;
|
bitcoin_transaction_send_operation op;
|
||||||
|
|
@ -999,16 +981,12 @@ std::string sidechain_net_handler_bitcoin::transfer_withdrawal_from_primary_wall
|
||||||
tx.to_bytes(op.unsigned_tx);
|
tx.to_bytes(op.unsigned_tx);
|
||||||
// add signatures
|
// add signatures
|
||||||
std::set<son_id_type> plugin_sons = plugin.get_sons();
|
std::set<son_id_type> plugin_sons = plugin.get_sons();
|
||||||
for(auto si: from_sons)
|
for (auto si : from_sons) {
|
||||||
{
|
if (plugin_sons.find(si.son_id) != plugin_sons.end()) {
|
||||||
if (plugin_sons.find(si.son_id) != plugin_sons.end())
|
|
||||||
{
|
|
||||||
fc::ecc::private_key k = plugin.get_private_key(si.son_id);
|
fc::ecc::private_key k = plugin.get_private_key(si.son_id);
|
||||||
std::vector<bytes> signatures = signatures_for_raw_transaction(op.unsigned_tx, amounts, from_redeem_script, k);
|
std::vector<bytes> signatures = signatures_for_raw_transaction(op.unsigned_tx, amounts, from_redeem_script, k);
|
||||||
op.signatures[si.son_id] = signatures;
|
op.signatures[si.son_id] = signatures;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
op.signatures[si.son_id];
|
op.signatures[si.son_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1032,13 +1010,13 @@ std::string sidechain_net_handler_bitcoin::transfer_withdrawal_from_primary_wall
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler_bitcoin::publish_btc_tx(const bitcoin_transaction_object &tx_object)
|
void sidechain_net_handler_bitcoin::publish_btc_tx(const bitcoin_transaction_object &tx_object) {
|
||||||
{
|
|
||||||
std::vector<std::vector<bytes>> signatures;
|
std::vector<std::vector<bytes>> signatures;
|
||||||
signatures.resize(tx_object.signatures.size());
|
signatures.resize(tx_object.signatures.size());
|
||||||
std::transform(tx_object.signatures.begin(), tx_object.signatures.end(),
|
std::transform(tx_object.signatures.begin(), tx_object.signatures.end(),
|
||||||
signatures.begin(), [](const std::pair<son_id_type, std::vector<bytes>>& p) { return p.second; }
|
signatures.begin(), [](const std::pair<son_id_type, std::vector<bytes>> &p) {
|
||||||
);
|
return p.second;
|
||||||
|
});
|
||||||
bytes signed_tx = add_signatures_to_unsigned_tx(tx_object.unsigned_tx, signatures, tx_object.redeem_script);
|
bytes signed_tx = add_signatures_to_unsigned_tx(tx_object.unsigned_tx, signatures, tx_object.redeem_script);
|
||||||
bitcoin_client->sendrawtransaction(fc::to_hex((const char *)&signed_tx[0], signed_tx.size()));
|
bitcoin_client->sendrawtransaction(fc::to_hex((const char *)&signed_tx[0], signed_tx.size()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue