Consolidate Unspents
Overview
You can consolidate unspents by taking multiple, smaller unspents and combining them into a single, larger unspent. This is useful for reducing the number of individual unspents that you need to manage. Additionally, some assets limit to the total number of unspents in a single transaction. Consolidating unspents can also reduce transaction fees, since the transaction size of single larger unspent is less than that of many smaller unspents. The opposite of consolidating unspents is to Fan Out Unspents.
Consolidation transactions follow the normal transaction flow, requiring signatures, approvals, and sending, as outlined in Wallets Overview.
All consolidation transactions for bitcoin automatically opt-in to acceleration using Replace-By-Fee (RBF). Should the transaction become stuck, you can follow up with an RBF transaction that includes a higher fee.
Prerequisites
Steps
1 2 3 4 5 6 7 8 9 10 11 12 13
let params = { numUnspentsToMake: 2, minValue: 100000, maxValue: 47000000, minHeight: 1, minConfirms: 2, limit: 100, walletPassphrase: 'secretpassphrase1a5df8380e0e30', }; wallet.consolidateUnspents(params).then(function (transactionInfo) { // print transaction info console.dir(transactionInfo); });
Step Result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
{ "transfer": { "coin": "btc", "id": "59cd72485007a239fb00282ed480da1f", "wallet": "59cd72485007a239fb00282ed480da1f", "enterprise": "59cd72485007a239fb00282ed480da1f", "txid": "b8a828b98dbf32d9fd1875cbace9640ceb8c82626716b4a64203fdc79bb46d26", "height": 0, "heightId": "string", "date": "2019-08-24T14:15:22Z", "type": "send", "value": 0, "valueString": "string", "baseValue": 0, "baseValueString": "string", "feeString": "string", "payGoFee": 0, "payGoFeeString": "string", "usd": 0, "usdRate": 0, "state": "confirmed", "tags": [ "59cd72485007a239fb00282ed480da1f" ], "history": [ { "date": "2019-08-24T14:15:22Z", "user": "59cd72485007a239fb00282ed480da1f", "action": "created", "comment": "string" } ], "comment": "string", "vSize": 0, "nSegwitInputs": 0, "coinSpecific": {}, "sequenceId": "string", "entries": [ { "address": "2NAUwNgXaoFj2VVnSEvNLGuez8CfdU2UCMZ", "wallet": "string", "value": 0, "valueString": "string", "isChange": true, "isPayGo": true, "token": "omg" } ], "usersNotified": true }, "txid": "string", "tx": "string", "status": "signed" }
Next
Sign the transaction.