mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
replace serValue/valuecommitment with amount(commitment)
This commit is contained in:
parent
fe39cf5599
commit
0e7d8db1d0
4 changed files with 23 additions and 18 deletions
|
|
@ -75,19 +75,19 @@ class WalletTest (BitcoinTestFramework):
|
|||
txid1 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
|
||||
txout1v0 = self.nodes[0].gettxout(txid1, 0)
|
||||
rawtx1 = self.nodes[0].getrawtransaction(txid1, 1)
|
||||
valuecommit1 = rawtx1["vout"][0]["serValue"]
|
||||
amountcommit1 = rawtx1["vout"][0]["amountcommitment"]
|
||||
assert_equal(txout1v0['confirmations'], 0)
|
||||
assert(not txout1v0['coinbase'])
|
||||
assert_equal(valuecommit1, txout1v0['valuecommitment'])
|
||||
assert_equal(amountcommit1, txout1v0['amountcommitment'])
|
||||
|
||||
|
||||
txid2 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
|
||||
txout2v0 = self.nodes[0].gettxout(txid2, 0)
|
||||
rawtx2 = self.nodes[0].getrawtransaction(txid2, 1)
|
||||
valuecommit2 = rawtx2["vout"][0]["serValue"]
|
||||
amountcommit2 = rawtx2["vout"][0]["amountcommitment"]
|
||||
assert_equal(txout2v0['confirmations'], 0)
|
||||
assert(not txout2v0['coinbase'])
|
||||
assert_equal(valuecommit2, txout2v0['valuecommitment'])
|
||||
assert_equal(amountcommit2, txout2v0['amountcommitment'])
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo("bitcoin")
|
||||
assert_equal(walletinfo['immature_balance'], 0)
|
||||
|
|
|
|||
|
|
@ -901,6 +901,7 @@ UniValue gettxout(const JSONRPCRequest& request)
|
|||
" \"bestblock\" : \"hash\", (string) the block hash\n"
|
||||
" \"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"
|
||||
" \"scriptPubKey\" : { (json object)\n"
|
||||
" \"asm\" : \"code\", (string) \n"
|
||||
" \"hex\" : \"hex\", (string) \n"
|
||||
|
|
@ -959,7 +960,7 @@ UniValue gettxout(const JSONRPCRequest& request)
|
|||
if (coins.vout[n].nValue.IsExplicit()) {
|
||||
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue.GetAmount())));
|
||||
} else {
|
||||
ret.push_back(Pair("valuecommitment", HexStr(coins.vout[n].nValue.vchCommitment)));
|
||||
ret.push_back(Pair("amountcommitment", HexStr(coins.vout[n].nValue.vchCommitment)));
|
||||
}
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true);
|
||||
|
|
|
|||
|
|
@ -145,12 +145,12 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
|||
if (issuance.nAmount.IsExplicit()) {
|
||||
issue.push_back(Pair("assetamount", ValueFromAmount(issuance.nAmount.GetAmount())));
|
||||
} else if (issuance.nAmount.IsCommitment()) {
|
||||
issue.push_back(Pair("assetvaluecommitment", HexStr(issuance.nAmount.vchCommitment)));
|
||||
issue.push_back(Pair("assetamountcommitment", HexStr(issuance.nAmount.vchCommitment)));
|
||||
}
|
||||
if (issuance.nInflationKeys.IsExplicit()) {
|
||||
issue.push_back(Pair("tokenamount", ValueFromAmount(issuance.nInflationKeys.GetAmount())));
|
||||
} else if (issuance.nInflationKeys.IsCommitment()) {
|
||||
issue.push_back(Pair("tokenvaluecommitment", HexStr(issuance.nInflationKeys.vchCommitment)));
|
||||
issue.push_back(Pair("tokenamountcommitment", HexStr(issuance.nInflationKeys.vchCommitment)));
|
||||
}
|
||||
in.push_back(Pair("issuance", issue));
|
||||
}
|
||||
|
|
@ -184,15 +184,15 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
|||
const CConfidentialAsset& asset = txout.nAsset;
|
||||
if (asset.IsExplicit()) {
|
||||
out.push_back(Pair("asset", asset.GetAsset().GetHex()));
|
||||
}
|
||||
else if (asset.IsCommitment()) {
|
||||
} else if (asset.IsCommitment()) {
|
||||
out.push_back(Pair("assetcommitment", HexStr(asset.vchCommitment)));
|
||||
}
|
||||
|
||||
{
|
||||
CDataStream ssValue(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssValue << txout.nValue;
|
||||
out.push_back(Pair("serValue", HexStr(ssValue.begin(), ssValue.end())));
|
||||
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);
|
||||
|
|
@ -258,12 +258,14 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
|
|||
" },\n"
|
||||
" \"sequence\": n (numeric) The script sequence number\n"
|
||||
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
|
||||
" \"issuance\" (object) Info on issuance\n"
|
||||
" }\n"
|
||||
" ,...\n"
|
||||
" ],\n"
|
||||
" \"vout\" : [ (array of json objects)\n"
|
||||
" {\n"
|
||||
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
|
||||
" \"amountcommitment\": \"hex\", (string) the output's value commitment, if blinded\n"
|
||||
" \"fee_value\" : x.xxx, (numeric) The fee value in " + CURRENCY_UNIT + "\n"
|
||||
" \"n\" : n, (numeric) index\n"
|
||||
" \"asset\" : \"hex\" (string) the asset id, if unblinded\n"
|
||||
|
|
@ -1043,6 +1045,7 @@ UniValue decoderawtransaction(const JSONRPCRequest& request)
|
|||
" },\n"
|
||||
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
|
||||
" \"sequence\": n (numeric) The script sequence number\n"
|
||||
" \"issuance\" (object) Info on issuance\n"
|
||||
" }\n"
|
||||
" ,...\n"
|
||||
" ],\n"
|
||||
|
|
|
|||
|
|
@ -2731,8 +2731,9 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|||
" \"asset\": \"hex\" (string) the asset id for this output\n"
|
||||
" \"assetcommitment\": \"hex\" (string) the asset commitment for this output\n"
|
||||
" \"confirmations\": n, (numeric) The number of confirmations\n"
|
||||
" \"serValue\": \"hex\", (string) the output's value commitment\n"
|
||||
" \"blinder\": \"blind\" (string) The blinding factor used for a confidential output (or \"\")\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"
|
||||
" \"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"
|
||||
|
|
@ -2846,9 +2847,9 @@ UniValue listunspent(const JSONRPCRequest& request)
|
|||
entry.push_back(Pair("confirmations", out.nDepth));
|
||||
entry.push_back(Pair("spendable", out.fSpendable));
|
||||
entry.push_back(Pair("solvable", out.fSolvable));
|
||||
CDataStream ssValue(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssValue << nValue;
|
||||
entry.push_back(Pair("serValue", HexStr(ssValue.begin(), ssValue.end())));
|
||||
if (out.tx->tx->vout[out.i].nValue.IsCommitment()) {
|
||||
entry.push_back(Pair("amountcommitment", HexStr(out.tx->tx->vout[out.i].nValue.vchCommitment)));
|
||||
}
|
||||
entry.push_back(Pair("blinder",out.tx->GetOutputBlindingFactor(out.i).ToString()));
|
||||
entry.push_back(Pair("assetblinder",out.tx->GetOutputAssetBlindingFactor(out.i).ToString()));
|
||||
results.push_back(entry);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue