Skip to content

Commit

Permalink
various rpc help and return fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Jul 11, 2017
1 parent 0e7d8db commit 1e1366b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ UniValue gettxout(const JSONRPCRequest& request)
" \"confirmations\" : n, (numeric) The number of confirmations\n"
" \"value\" : x.xxx, (numeric) The transaction value in " + CURRENCY_UNIT + "\n"
" \"amountcommitment\": \"hex\", (string) the output's value commitment, if blinded\n"
" \"asset\": \"hex\", (string) the output's asset type, if unblinded\n"
" \"assetcommitment\": \"hex\", (string) the output's asset commitment, if blinded\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"code\", (string) \n"
" \"hex\" : \"hex\", (string) \n"
Expand Down Expand Up @@ -962,6 +964,12 @@ UniValue gettxout(const JSONRPCRequest& request)
} else {
ret.push_back(Pair("amountcommitment", HexStr(coins.vout[n].nValue.vchCommitment)));
}
if (coins.vout[n].nAsset.IsExplicit()) {
ret.push_back(Pair("asset", HexStr(coins.vout[n].nAsset.vchCommitment)));
} else {
ret.push_back(Pair("assetcommitment", HexStr(coins.vout[n].nAsset.vchCommitment)));
}

UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
ret.push_back(Pair("scriptPubKey", o));
Expand Down
13 changes: 5 additions & 8 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,19 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
if (!issuance.IsNull()) {
UniValue issue(UniValue::VOBJ);
issue.push_back(Pair("assetBlindingNonce", issuance.assetBlindingNonce.GetHex()));
issue.push_back(Pair("assetEntropy", issuance.assetEntropy.GetHex()));
CAsset asset;
CAsset token;
uint256 entropy;
if (issuance.assetBlindingNonce.IsNull()) {
GenerateAssetEntropy(entropy, txin.prevout, issuance.assetEntropy);
issue.push_back(Pair("assetEntropy", HexStr(entropy)));
CalculateAsset(asset, entropy);
CalculateReissuanceToken(token, entropy, issuance.nAmount.IsCommitment());
issue.push_back(Pair("isreissuance", false));
issue.push_back(Pair("token", token.GetHex()));
}
else {
issue.push_back(Pair("assetEntropy", issuance.assetEntropy.GetHex()));
issue.push_back(Pair("isreissuance", true));
CalculateAsset(asset, issuance.assetEntropy);
}
Expand All @@ -162,9 +163,9 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
if (txout.nValue.IsExplicit())
if (txout.nValue.IsExplicit()) {
out.push_back(Pair("value", ValueFromAmount(txout.nValue.GetAmount())));
else {
} else {
int exp;
int mantissa;
uint64_t minv;
Expand All @@ -180,6 +181,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
out.push_back(Pair("ct-exponent", exp));
out.push_back(Pair("ct-bits", mantissa));
}
out.push_back(Pair("amountcommitment", HexStr(txout.nValue.vchCommitment)));
}
const CConfidentialAsset& asset = txout.nAsset;
if (asset.IsExplicit()) {
Expand All @@ -189,11 +191,6 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
}

const CConfidentialValue& amount = txout.nValue;
if (amount.IsExplicit()) {
out.push_back(Pair("value", amount.GetAmount()));
} else if (amount.IsCommitment()) {
out.push_back(Pair("amountcommitment", HexStr(amount.vchCommitment)));
}
out.push_back(Pair("n", (int64_t)i));
UniValue o(UniValue::VOBJ);
ScriptPubKeyToJSON(txout.scriptPubKey, o, true);
Expand Down
11 changes: 6 additions & 5 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)

if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error(
"getreceivedbyaddress \"address\" ( minconf )\n"
"getreceivedbyaddress \"address\" ( minconf assetlabel )\n"
"\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n"
"\nArguments:\n"
"1. \"address\" (string, required) The bitcoin address for transactions.\n"
Expand Down Expand Up @@ -2041,7 +2041,7 @@ UniValue gettransaction(const JSONRPCRequest& request)

if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error(
"gettransaction \"txid\" ( include_watchonly )\n"
"gettransaction \"txid\" ( include_watchonly assetlabel )\n"
"\nGet detailed information about in-wallet transaction <txid>\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
Expand Down Expand Up @@ -2621,7 +2621,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)

if (request.fHelp || request.params.size() > 1)
throw runtime_error(
"getwalletinfo\n"
"getwalletinfo ( assetlabel )\n"
"Returns an object containing various wallet state info.\n"
"1. \"assetlabel\" (string, optional) Hex asset id or asset label for balance. \"*\" retrieves all known asset balances.\n"
"\nResult:\n"
Expand Down Expand Up @@ -2730,10 +2730,11 @@ UniValue listunspent(const JSONRPCRequest& request)
" \"amount\" : x.xxx, (numeric) the transaction output amount in " + CURRENCY_UNIT + "\n"
" \"asset\": \"hex\" (string) the asset id for this output\n"
" \"assetcommitment\": \"hex\" (string) the asset commitment for this output\n"
" \"assetlabel\":\"<assetlabel>\", (string) Asset label for asset type if set.\n"
" \"confirmations\": n, (numeric) The number of confirmations\n"
" \"amountcommitment\": \"hex\", (string) the output's value commitment, if blinded\n"
" \"blinder\": \"blind\" (string) The value blinding factor used for a confidential output (or \"\")\n"
" \"assetblinder\": \"blind\"(string) The asset blinding factor used for a confidential output (or \"\")\n"
" \"blinder\": \"blind\" (string) The value blinding factor used for a confidential output\n"
" \"assetblinder\": \"blind\"(string) The asset blinding factor used for a confidential output\n"
" \"redeemScript\": n (string) The redeemScript if scriptPubKey is P2SH\n"
" \"spendable\": xxx, (bool) Whether we have the private keys to spend this output\n"
" \"solvable\": xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n"
Expand Down

0 comments on commit 1e1366b

Please sign in to comment.