Skip to content
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

getspentzerocoinamount RPC call. #385

Merged
merged 1 commit into from
Nov 29, 2017

Conversation

whateverpal
Copy link

Accepts transaction hash and input index as parameters and returns amount of spent zerocoin input (if input is not zerocoin spend, returns -1).

Copy link

@presstab presstab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected for me. Few minor changes requested.

if (!input.scriptSig.IsZerocoinSpend())
return -1;

std::vector<char, zero_after_free_allocator<char> > dataTxIn;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can simplify this code:

libzerocoin::CoinSpend spend = TxInToZerocoinSpend(input);

dataTxIn.insert(dataTxIn.end(), input.scriptSig.begin() + 4, input.scriptSig.end());
CDataStream serializedCoinSpend(dataTxIn, SER_NETWORK, PROTOCOL_VERSION);
libzerocoin::CoinSpend spend(Params().Zerocoin_Params(), serializedCoinSpend);
return libzerocoin::ZerocoinDenominationToAmount(spend.getDenomination());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should return the formatted version of the value. Most people have a hard time figuring out pivtoshis.

CAmount nValue = libzerocoin::ZerocoinDenominationToAmount(spend.getDenomination());
return FormatMoney(nValue);

@whateverpal
Copy link
Author

Implemented requested changes

@PIVX-Project PIVX-Project added this to the 3.0.6 milestone Nov 20, 2017
Accepts transaction hash and input index as parameters and returns amount of spent zerocoin input (if input is not zerocoin spend, returns -1).
Return value in pivs, not pivtoshis.
@Fuzzbawls
Copy link
Collaborator

Rebased/Squashed into a single commit for merging

@Fuzzbawls Fuzzbawls merged commit 0c38407 into PIVX-Project:master Nov 29, 2017
Fuzzbawls added a commit that referenced this pull request Nov 29, 2017
0c38407 Add getspentzerocoinamount RPC call (whateverpal)

Tree-SHA512: 25222e480697db965cb762ff3ce26a28d3e07b3b03bfe0a7d82aeed40ca43ea7af81c827586896a82ab0cc02027e6ae2226ae73510b7ad49e17292099c2720da
@ghost ghost removed the review label Nov 29, 2017
Fuzzbawls pushed a commit to Fuzzbawls/PIVX that referenced this pull request Nov 29, 2017
Accepts transaction hash and input index as parameters and returns amount of spent zerocoin input (if input is not zerocoin spend, returns -1).
Return value in pivs, not pivtoshis.

Github-Merge: PIVX-Project#385
Rebased-From: 0c38407
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Feb 15, 2018
Accepts transaction hash and input index as parameters and returns amount of spent zerocoin input (if input is not zerocoin spend, returns -1).
Return value in pivs, not pivtoshis.

Github-Merge: PIVX-Project#385
Rebased-From: 0c38407
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Feb 20, 2018
Accepts transaction hash and input index as parameters and returns amount of spent zerocoin input (if input is not zerocoin spend, returns -1).
Return value in pivs, not pivtoshis.

Github-Merge: PIVX-Project#385
Rebased-From: 0c38407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants