Skip to content

Commit 2efa9b8

Browse files
author
minium
committed
Added another createrawtransaction command prototype
1 parent 9f687df commit 2efa9b8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/bitcoinapi/bitcoinapi.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ string BitcoinAPI::sendrawtransaction(const string& hexString, bool highFee) {
11431143
return result.asString();
11441144
}
11451145

1146-
11471146
string BitcoinAPI::createrawtransaction(const vector<txout_t>& inputs, const map<string,double>& amounts) {
11481147
string command = "createrawtransaction";
11491148
Value params, result;
@@ -1171,6 +1170,33 @@ string BitcoinAPI::createrawtransaction(const vector<txout_t>& inputs, const map
11711170
return result.asString();
11721171
}
11731172

1173+
string BitcoinAPI::createrawtransaction(const vector<txout_t>& inputs, const map<string,string>& amounts) {
1174+
string command = "createrawtransaction";
1175+
Value params, result;
1176+
1177+
Value vec(Json::arrayValue);
1178+
for(vector<txout_t>::const_iterator it = inputs.begin(); it != inputs.end(); it++){
1179+
Value val;
1180+
txout_t tmp = (*it);
1181+
1182+
val["txid"] = tmp.txid;
1183+
val["vout"] = tmp.n;
1184+
1185+
vec.append(val);
1186+
}
1187+
1188+
Value obj(Json::objectValue);
1189+
for(map<string,double>::const_iterator it = amounts.begin(); it != amounts.end(); it++){
1190+
obj[(*it).first] = (*it).second;
1191+
}
1192+
1193+
params.append(vec);
1194+
params.append(obj);
1195+
result = sendcommand(command, params);
1196+
1197+
return result.asString();
1198+
}
1199+
11741200
signrawtransaction_t BitcoinAPI::signrawtransaction(const string& rawTx, const vector<signrawtxin_t> inputs) {
11751201
string command = "signrawtransaction";
11761202
Value params, result;

src/bitcoinapi/bitcoinapi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class BitcoinAPI
141141
std::string sendrawtransaction(const std::string& hexString, bool highFee);
142142

143143
std::string createrawtransaction(const std::vector<txout_t>& inputs, const std::map<std::string, double>& amounts);
144+
std::string createrawtransaction(const std::vector<txout_t>& inputs, const std::map<std::string, std::string>& amounts);
145+
144146
signrawtransaction_t signrawtransaction(const std::string& rawTx, const std::vector<signrawtxin_t> inputs = std::vector<signrawtxin_t>());
145147
signrawtransaction_t signrawtransaction(const std::string& rawTx, const std::vector<signrawtxin_t> inputs, const std::vector<std::string>& privkeys, const std::string& sighashtype = "ALL");
146148

0 commit comments

Comments
 (0)