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

RPC: Scanforunspent #1547

Merged
merged 5 commits into from
Oct 5, 2019

Conversation

iFoggz
Copy link
Member

@iFoggz iFoggz commented Oct 3, 2019

Another RPC tool mainly aimed at multisig. I recently added a consolidation tool for multisig addresses however I felt this tool is also needed for managing multisig utxos. This tool is designed for scanning of a specified address for unspent utxos. This can also be used on non-multisig addresses as well. This tool also offers exporting of data into txt or xml

This uses some of the code works of consolidation of multisig utxos.

Added:

  • Scan block range for any utxos linked to an address that are not spent.
  • Option to export to xml or txt file in -backupdir
  • Display results in rpc for ease of use.
  • I've tested this on both mainnet/testnet.
  • Use stringstream for faster building for exporting data.

here is a rpc output from test

scanforunspent 2N3tWtXU4azezQjXushYbkicq11xnkEufEw 1030000 1040000 true txt

[
[
{
"txid": "d5f7a9bd915e35f8d56189628f2a78764c8bb5dcb088fdca70d3f880699300b4",
"vout": 1,
"value": 71011.77755834
},
{
"txid": "54e35e53294678fee4c008c9bcda364b4609adedf64cc589eaf8fa14f953bdaf",
"vout": 0,
"value": 4136.15581166
}

@jamescowens @cyrossignol review and mention any changes or ask any questions
],
{
"Block Start": 1030000,
"Block End": 1040000,
"Total UTXO Count": 2,
"Total Value": 75147.93337000
}
]

Output of a xml file:

<?xml version="1.0" encoding="UTF-8"?>
<id>
  <tx1>
    <txid>d5f7a9bd915e35f8d56189628f2a78764c8bb5dcb088fdca70d3f880699300b4</txi$
    <vout>1</vout>
    <value>71011.77755834</value>
  </tx1>
  <tx2>
    <txid>54e35e53294678fee4c008c9bcda364b4609adedf64cc589eaf8fa14f953bdaf</txi$
    <vout>0</vout>
    <value>4136.15581166</value>
  </tx2>
</id>

Output of a txt file:

TXID / VOUT / Value
d5f7a9bd915e35f8d56189628f2a78764c8bb5dcb088fdca70d3f880699300b4 / 1 / 71011.77755834
54e35e53294678fee4c008c9bcda364b4609adedf64cc589eaf8fa14f953bdaf / 0 / 4136.15581166

This will make the ease of use for foundation easier as we will be able to keep track and maintain foundation utxos more efficiently and effectively.

@jamescowens
Copy link
Member

@cyrossignol Let's get this reviewed and merged today. I want to get this one done and also all of the stuff in the integrated_scraper_2 tracking PR, and then we are going to do an interim release.

Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

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

Looks good. Should we create a subdirectory under the walletbackups directory to store this stuff, or maybe a new directory under the data directory, since people may have automated sweep scripts that would get confused by files other than wallet/conf file backups?

@iFoggz
Copy link
Member Author

iFoggz commented Oct 3, 2019

that is possible to do. i'll honour the -backupdir and just make a subdirectory within that. what should we call it? walletbackups/rpc ?

@jamescowens
Copy link
Member

Perfect.

@jamescowens jamescowens self-requested a review October 3, 2019 21:21
Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Member

@cyrossignol cyrossignol left a comment

Choose a reason for hiding this comment

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

Since we're already building up the UTXO list in txres, we can support JSON export without much additional effort:

exportoutput << txres.write(2); // 2 = indent spacing

std::unordered_multimap<int64_t, std::pair<uint256, unsigned int>> uMultisig;

LOCK(cs_main);
{
Copy link
Member

Choose a reason for hiding this comment

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

Can we move the LOCK into the nested scope?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes i'll move in inward when i get back home

{
if (nType == 0)
{
exportoutput << spacing << "<tx" << nCount << ">\n";
Copy link
Member

@cyrossignol cyrossignol Oct 3, 2019

Choose a reason for hiding this comment

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

If we want to use XML for a machine-readable format, we may want to move nCount into a child element:

<tx>
  <num>1</num>
  ...
</tx>

...or an attribute:

<tx num="1">...</tx>

...or remove it altogether instead of appending it to the tag name. This prevents some XML parsers from logically grouping the <tx> items into a list structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

originally i wanted by but can't have numbers in main part of tag. i'll play around with this idea

Copy link
Member Author

Choose a reason for hiding this comment

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

num="1" doesnt do anything really but cleaner then <tx#> and probably better supported for xml parsers

…expected white space, and add id tag instead to xml
@jamescowens jamescowens added this to the Fern milestone Oct 5, 2019
@jamescowens jamescowens merged commit bd33058 into gridcoin-community:development Oct 5, 2019
jamescowens added a commit that referenced this pull request Oct 22, 2019
Added
 - Add testnet desktop launcher action for Linux #1516 (@caraka)
 - Shuffle vSideStakeAlloc if necessary to support sidestaking to more than 6 destinations #1532 (@jamescowens)
 - New Superblock format preparations for Fern #1526, #1542 (@jamescowens, @cyrossignol)
 - Multisigtools
   - Consolidate multisig unspent #1529 (@iFoggz)
   - Scanforunspent #1547 (@iFoggz)
   - consolidatemsunspent and scanforunspent bug fix #1561 (@iFoggz)
 - New banning misbehavior handling and Peers Tab on Debug Console #1537 (@jamescowens)
 - Reimplement getunconfirmedbalance rpc #1548 (@jamescowens)
 - Add CLI switch to display binary version #1553 (@cyrossignol)

Changed
 - Select smallest coins for contracts #1519 (@iFoggz)
 - Move some functionality from miner to SelectCoinsForStaking + Respect the coin reserve setting + Randomize UTXO order #1525 (@iFoggz)
 - For voting - if url does not contain http then add it #1531 (@iFoggz)
 - Backport newer serialization facilities from Bitcoin #1535 (@cyrossignol)
 - Refactor ThreadSocketHandler2() Inactivity checks #1538 (@iFoggz)
 - Update outdated checkpoints #1539 (@barton2526)
 - Change needed to build Gridcoin for OSX using homebrew #1540 (@Git-Jiro)
 - Optimize scraper traffic for expiring manifests #1542 (@jamescowens)
 - Move legacy neural vote warnings to debug log level #1560 (@cyrossignol)
 - Change banlist save interval to 5 minutes #1564 (@jamescowens)
 - Change default rpcconsole.ui window size to better support new Peers tab #1566 (@jamescowens)

Removed
 - Remove deprecated RSA weight and legacy kernel #1507 (@cyrossignol)

Fixed
 - Clean up compiler warnings #1521 (@cyrossignol)
 - Handle missing external CPID in client_state.xml #1530 (@cyrossignol)
 - Support boost 1.70+ #1533 (@iFoggz)
 - Fix diagnostics failed to make connection to NTP server #1545 (@Git-Jiro)
 - Install manpages in correct system location #1546 (@Git-Jiro)
 - Fix ability to show help and version without a config file #1553 (@cyrossignol)
 - Refactor QT UI variable names to be more consistent, Fix Difficulty default #1563 (@barton2526)
 - Fix two regressions in previous UI refactor #1565 (@barton2526)
 - Fix "Owed" amount in output of "magnitude" RPC method #1569 (@cyrossignol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants