Skip to content

Added multi wallet support #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
85427c6
Added multi wallet support
bahadirbb Oct 1, 2018
0978e61
Merge branch 'master' of git://github.com/minium/bitcoin-api-cpp into…
bahadirbb Oct 2, 2018
14396f4
Merge branch 'minium-master'
bahadirbb Oct 2, 2018
7ff90c4
Added watchonly support to listsinceblock, added fee variable to tran…
bahadirbb Oct 11, 2018
7312bce
Added estimatesmartfee function
bahadirbb Oct 11, 2018
5181892
Initial functions for omni layer support
bahadirbb Oct 20, 2018
436a5db
Added initial omni layer functions
bahadirbb Oct 29, 2018
903c4dd
Added omni_send and omni_funded_sendall functions
bahadirbb Nov 3, 2018
deebe12
Fixed string to double conversions on omni calls
bahadirbb Nov 7, 2018
f756890
Added omni_funded_send command
bahadirbb Nov 9, 2018
da27281
Added omni_listpendingtransactions function, updated listunspent
bahadirbb Nov 20, 2018
e987ae8
Merge branch 'OMNI_SUPPORT'
bahadirbb Dec 21, 2018
716c51a
Added iswatchonly to validateaddress response
bahadirbb Jan 16, 2019
f5be950
Added omni_getwalletaddressbalances function
bahadirbb Jan 19, 2019
bf7fb0f
Merge branch 'OMNI_SUPPORT'
bahadirbb Jan 19, 2019
8d06585
Added getaddressinfo function
bahadirbb Jan 23, 2019
bb80e7d
Merge branch 'master' of https://github.com/bahadirbb/bitcoin-api-cpp
bahadirbb Jan 23, 2019
ddf4c55
Added omni_gettransaction method
bahadirbb Jan 26, 2019
8cabcdd
Updated omni_transaction struct
bahadirbb Feb 4, 2019
2fa4f7f
Used JsonValue references instead of copying
bahadirbb Feb 6, 2019
62eb42c
Removed unused variable
bahadirbb Feb 6, 2019
fa0248f
Fixed omni_listpendingtransactions deserialization bug
bahadirbb Feb 25, 2019
2273e60
Fixed omni_transaction parsing bug. added type checks
bahadirbb Feb 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added omni_listpendingtransactions function, updated listunspent
  • Loading branch information
bahadirbb committed Nov 20, 2018
commit da2728105d8f6bfd848e2d9737bcee618b7b5db8
54 changes: 50 additions & 4 deletions src/bitcoinapi/bitcoinapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,22 @@ string BitcoinAPI::sendmany(const string& fromaccount, const map<string,double>&
return result.asString();
}

vector<unspenttxout_t> BitcoinAPI::listunspent(int minconf, int maxconf) {
vector<unspenttxout_t> BitcoinAPI::listunspent(int minconf, int maxconf, const vector<string>& addresses) {

string command = "listunspent";
Value params, result;
vector<unspenttxout_t> ret;

params.append(minconf);
params.append(maxconf);
if (addresses.size() > 0) {
Value addressesParam(Json::arrayValue);
for(vector<string>::const_iterator it = addresses.begin(); it != addresses.end(); it++){
Value val;
addressesParam.append((*it));
}
params.append(addressesParam);
}
result = sendcommand(command, params);

for(ValueIterator it = result.begin(); it != result.end(); it++){
Expand All @@ -881,6 +890,11 @@ vector<unspenttxout_t> BitcoinAPI::listunspent(int minconf, int maxconf) {
return ret;
}

vector<unspenttxout_t> BitcoinAPI::listunspent(int minconf, int maxconf) {
std::vector<std::string> addresses;
return this->listunspent(minconf, maxconf, addresses);
}

vector<txout_t> BitcoinAPI::listlockunspent() {
string command = "listlockunspent";
Value params, result;
Expand Down Expand Up @@ -1037,6 +1051,7 @@ txsinceblock_t BitcoinAPI::listsinceblock(const string& blockhash, int target_co
Value val = (*it);
transactioninfo_t tmp;

tmp.involvesWatchonly = val["involvesWatchonly"].asBool();
tmp.account = val["account"].asString();
tmp.address = val["address"].asString();
tmp.category = val["category"].asString();
Expand Down Expand Up @@ -1394,7 +1409,7 @@ std::string BitcoinAPI::omni_send(const std::string& fromaddress, const std::str
params.append(fromaddress);
params.append(toaddress);
params.append(propertyid);
params.append(amount);
params.append(std::to_string(amount));

result = sendcommand(command, params);
return result.asString();
Expand All @@ -1408,7 +1423,7 @@ std::string BitcoinAPI::omni_funded_send(const std::string& fromaddress, const s
params.append(fromaddress);
params.append(toaddress);
params.append(propertyid);
params.append(amount);
params.append(std::to_string(amount));
params.append(feeaddress);

result = sendcommand(command, params);
Expand Down Expand Up @@ -1493,7 +1508,7 @@ std::vector<omni_transaction_t> BitcoinAPI::omni_listtransactions(const std::str
tmp.referenceaddress = val["referenceaddress"].asString();
tmp.ismine = val["ismine"].asBool();
tmp.confirmations = val["confirmations"].asInt();

tmp.propertyid = val["propertyid"].asInt();
tmp.fee = stod(val["fee"].asString());
tmp.blocktime = val["blocktime"].asUInt();
tmp.valid = val["valid"].asBool();
Expand All @@ -1510,7 +1525,38 @@ std::vector<omni_transaction_t> BitcoinAPI::omni_listtransactions(const std::str
}

return ret;
}

std::vector<omni_transaction_t> BitcoinAPI::omni_listpendingtransactions(const std::string& address)
{
string command = "omni_listpendingtransactions";
Value params, result;
vector<omni_transaction_t> ret;

params.append(address);
result = sendcommand(command, params);

for(ValueIterator it = result.begin(); it != result.end(); it++) {
omni_transaction_t tmp;
Value val = (*it);
tmp.txid = val["txid"].asString();
tmp.sendingaddress = val["sendingaddress"].asString();
tmp.referenceaddress = val["referenceaddress"].asString();
tmp.ismine = val["ismine"].asBool();
tmp.confirmations = val["confirmations"].asInt();
tmp.propertyid = val["propertyid"].asInt();
tmp.fee = stod(val["fee"].asString());
tmp.blocktime = val["blocktime"].asUInt();
tmp.version = val["version"].asInt();
tmp.type_int = val["type_int"].asInt();
tmp.type = val["type"].asString();

tmp.amount = stod(val["amount"].asString());

ret.push_back(tmp);
}

return ret;
}

#endif
2 changes: 2 additions & 0 deletions src/bitcoinapi/bitcoinapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BitcoinAPI
std::vector<omni_detailed_balance_t> omni_getwalletbalances(bool includewatchonly);
omni_balance_t omni_getbalance(const std::string& address, int propertyid);
std::vector<omni_transaction_t> omni_listtransactions(const std::string& txid = "*", int count = 10, int skip = 0, int startblock = 0, int endblock = 999999999);
std::vector<omni_transaction_t> omni_listpendingtransactions(const std::string& address = "");

#endif

Expand Down Expand Up @@ -127,6 +128,7 @@ class BitcoinAPI
utxosetinfo_t gettxoutsetinfo();

std::vector<unspenttxout_t> listunspent(int minconf = 1, int maxconf = 999999);
std::vector<unspenttxout_t> listunspent(int minconf, int maxconf, const std::vector<std::string>& addresses);
std::vector<txout_t> listlockunspent();
bool lockunspent(bool unlock, const std::vector<txout_t>& outputs);

Expand Down
2 changes: 2 additions & 0 deletions src/bitcoinapi/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
};

struct transactioninfo_t: accountinfo_t{
bool involvesWatchonly;
std::string address;
std::string category;
std::string blockhash;
Expand Down Expand Up @@ -248,6 +249,7 @@
std::string txid;
std::string sendingaddress;
std::string referenceaddress;
int propertyid;
bool ismine;
int confirmations;
double amount;
Expand Down