Consolidate Unspents - Simple

Combine multiple smaller UTXOs into a single larger UTXO in one step. See the Guide.

  1. Use the simple flow to build, sign, and send a consolidation transaction all in one step. This uses BitGo Express or the JavaScript SDK to handle the entire process. You can configure parameters such as minValue, maxValue, minConfirms, and targetAddress to control which unspents the transaction consolidates and where it sends the result.

    Consolidating unspents is only available for self-custody wallets. Consolidation transactions for bitcoin automatically opt-in to acceleration using Replace-By-Fee (RBF).

    Prerequisites: Complete Get Started, Create Wallets, and Create Addresses.

    API Reference

// 1. Build, Sign, and Send Consolidation
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export WALLET_PASSPHRASE="<WALLET_PASSPHRASE>"
export XPRV="<YOUR_PRIVATE_KEY>"
export TARGET_ADDRESS="<DESIRED_TARGET_ADDRESS>"

curl -X POST \
  http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/consolidateunspents \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "walletPassphrase": "'"$WALLET_PASSPHRASE"'",
    "xprv": "'"$XPRV"'",
    "feeRate": null,
    "maxFeeRate": null,
    "maxFeePercentage": 0,
    "feeTxConfirmTarget": 0,
    "bulk": true,
    "minValue": "2000000",
    "maxValue": "2000000",
    "minHeight": 0,
    "minConfirms": 0,
    "enforceMinConfirmsForChange": true,
    "limit": 0,
    "numUnspentsToMake": 0,
    "targetAddress": "'"$TARGET_ADDRESS"'",
    "txFormat": "legacy"
}'
Response
// 1. Build, Sign, and Send Consolidation Response
{
  "transfer": {
    "coin": "btc",
    "id": "59cd72485007a239fb00282ed480da1f",
    "wallet": "59cd72485007a239fb00282ed480da1f",
    "enterprise": "59cd72485007a239fb00282ed480da1f",
    "txid": "b8a828b98dbf32d9fd1875cbace9640ceb8c82626716b4a64203fdc79bb46d26",
    "txidType": "transactionHash",
    "height": 0,
    "heightId": "string",
    "date": "2019-08-24T14:15:22Z",
    "confirmations": 0,
    "type": "send",
    "value": 0,
    "valueString": "2000000",
    "intendedValueString": "2000000",
    "baseValue": 0,
    "baseValueString": "2000000",
    "baseValueWithoutFees": 0,
    "baseValueWithoutFeesString": "2000000",
    "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,
    "coinSpecific": {},
    "sequenceId": "string",
    "entries": [
      {
        "address": "2NAUwNgXaoFj2VVnSEvNLGuez8CfdU2UCMZ",
        "wallet": "string",
        "value": 0,
        "valueString": "string",
        "isChange": true,
        "isPayGo": true,
        "token": "omg",
        "label": "string",
        "failed": true
      }
    ],
    "usersNotified": true,
    "label": "string",
    "replaces": [
      "string"
    ],
    "replacedBy": [
      "string"
    ]
  },
  "txid": "string",
  "tx": "string",
  "status": "signed"
}