Is there an RPC to consolidate UTXOs?
RPC to consolidate UTXOs?
Yes, there is. Its name starts with “defrag”. However, I’m not sure that it is exactly equal to the consolidation in the app.
I see the app uses this code:
const result = await accountServices.defragmentNativeCoin(
MAX_FEE_PER_TX,
true,
account,
wallet,
accountServices.MAX_DEFRAGMENT_TXS,
);
And that function is defined here, with this params:
/**
* Create multiple tx to defragment all utxo in account
* @param {number} fee
* @param {boolean} isPrivacy
* @param {object} account
* @param {object} wallet
* @param {number} noOfTxs
* @returns {Promise<*>}
*/
As far as I can tell, noOfTxs
is always set to MAX_DEFRAGMENT_TXS = 3
, for what I can see in this line of code.
The app preforms tree consolidations at the same time, when you see the history of transactions for the PRV in your wallet. Then, I conclude that each consolidation consolidates 10 UTXOs. That’s also why the fee to consolidate is 0.0000003.
Thanks for your answer, @abduraman.
For now, there’s only one RPC to consolidate PRV, not yet for ptoken and here it is:
{
“jsonrpc”:“1.0”,
“method”:“defragmentaccount”,
“params”:[“private key”,
1000000000000, # defrag all UTXO which has value <= this number
-1, # transaction fee / kb, -1 means auto-fee
0], # privacy
“id”:1
}
Thanks! What is the difference between that one and defragmentaccountv2?
defrag v1 takes number (int) input while defrag v2 takes string input to avoid overflow