Skip to content

Commit dd3de06

Browse files
author
minium
committed
Added decodescript command
1 parent fa12ffb commit dd3de06

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/bitcoinapi/bitcoinapi.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,27 @@ getrawtransaction_t BitcoinAPI::getrawtransaction(const string& txid, int verbos
10881088
return ret;
10891089
}
10901090

1091+
decodescript_t BitcoinAPI::decodescript(const std::string& hexString) {
1092+
string command = "decodescript";
1093+
Value params, result;
1094+
decodescript_t ret;
1095+
1096+
params.append(hexString);
1097+
result = sendcommand(command, params);
1098+
1099+
ret.assm = result["asm"].asString();
1100+
ret.reqSigs = result["reqSigs"].asInt();
1101+
ret.type = result["type"].asString();
1102+
ret.p2sh = result["p2sh"].asString();
1103+
1104+
for (ValueIterator it = result["addresses"].begin(); it != result["addresses"].end(); it++) {
1105+
Value val = (*it);
1106+
ret.addresses.push_back(val.asString());
1107+
}
1108+
1109+
return ret;
1110+
}
1111+
10911112
decoderawtransaction_t BitcoinAPI::decoderawtransaction(const string& hexString) {
10921113
string command = "decoderawtransaction";
10931114
Value params, result;

src/bitcoinapi/bitcoinapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class BitcoinAPI
137137

138138
/* === Low level calls === */
139139
getrawtransaction_t getrawtransaction(const std::string& txid, int verbose = 0);
140+
decodescript_t decodescript(const std::string& hexString);
140141
decoderawtransaction_t decoderawtransaction(const std::string& hexString);
141142
std::string sendrawtransaction(const std::string& hexString, bool highFee);
142143

src/bitcoinapi/types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@
134134
std::string hex;
135135
};
136136

137+
struct decodescript_t{
138+
std::string assm;
139+
std::string type;
140+
std::string p2sh;
141+
142+
int reqSigs;
143+
std::vector<std::string> addresses;
144+
};
137145

138146
/* decoderawtransaction return type */
139147
struct scriptSig_t{
@@ -173,6 +181,8 @@
173181
std::vector<vout_t> vout;
174182
};
175183

184+
185+
176186
/* getrawtransaction return type */
177187
struct getrawtransaction_t: decoderawtransaction_t{
178188
std::string hex;

0 commit comments

Comments
 (0)