Prepare A UTXO-Based Transaction From HD Wallet (xPub, yPub, zPub)

Through the “Prepare a UTXO-based transaction from xPub” endpoint users can prepare a transaction for signing from all synced with Crypto APIs addresses for the specific xPub. This is based on the selectionStrategy and the addresses’ balances. In the case a user has an address not synced with Crypto APIs, it will not be included. This endpoint applies to all supported UTXO-based blockchain protocols, e.g. Bitcoin, Litecoin, etc.

Single Result - This endpoint returns only one single result. POST /blockchain-tools/{blockchain}/{network}/transactions/prepare-utxo-transaction

Path Parameters

  • Required
    blockchain string
    Example : bitcoin
    Possible Values : bitcoin
  • Required
    network string
    Example : testnet
    Possible Values : testnet mainnet

Query parameters

  • Optional
    context string

    In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. context is specified by the user.

    Example : yourExampleString

Request body schema application/json

  • Optional
    context string

    In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. context is specified by the user.

    Example : yourExampleString
  • Required
    data object
    • Required
      item object
      • Optional
        additionalData string

        Representation of the additional data.

        Example : yourAdditionalDataHere
      • Required
        fee object
        • Optional
          address string

          Represents the fee address

          Example : tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a
        • Optional
          exactAmount string

          Representation of the exact amount value

          Example : 0.00023
        • Optional
          priority string

          Represents the fee priority

          Example : standard
          Possible Values : slow standard fast
      • Optional
        locktime integer

        Represents the time at which a particular transaction can be added to the blockchain.

        Example : 1659001055
      • Optional
        prepareStrategy string

        Representation of the transaction's strategy type

        Example : minimize-dust
        Possible Values : none minimize-dust optimize-size
      • Required
        recipients array
        Items (object)

        Represents a list of recipient addresses with the respective amounts. In account-based protocols like Ethereum there is only one address in this list.

        • Required
          address string

          The address which receives this transaction. In UTXO-based protocols like Bitcoin there could be several senders while in account-based protocols like Ethereum there is always only one recipient.

          Example : tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a
        • Required
          amount string

          Represents the amount value

          Example : 0.00003
      • Optional
        replaceable boolean

        Representation of whether the transaction is replaceable

        Example : False
      • Required
        xpub string

        Defines the account extended publicly known key which is used to derive all child public keys.

        Example : tpubDCNoSqt3HF32yq8VU6mgapTuW1FzENZa3C5dKUF6WCQzubWz2nA1yxUhMQWkhhkD58Uc8YiuD8cmB3y5tihqAv4zT2GNyqKTNLchHJmsvt9

Response schema

200 400 401 402 403 409 415 422 429 500
HTTP Status Code: 200
Content-Type: application/json

The resource has been successfully submitted.

  • Object :

  • Required
    apiVersion string

    Specifies the version of the API that incorporates this endpoint.

    Example : 2021-03-20
  • Required
    requestId string

    Defines the ID of the request. The requestId is generated by Crypto APIs and it's unique for every request.

    Example : 601c1710034ed6d407996b30
  • Optional
    context string

    In batch situations the user can use the context to correlate responses with requests. This property is present regardless of whether the response was successful or returned as an error. context is specified by the user.

    Example : yourExampleString
  • Required
    data object
    • Required
      item object
      • Optional
        additionalData string

        Representation of the additional data

        Example : yourAdditionalDataHere
      • Required
        fee string

        When isConfirmed is True - Defines the amount of the transaction fee When isConfirmed is False - For ETH-based blockchains this attribute represents the max fee value.

        Example : 0.0000279
      • Optional
        feePerByte string

        Defines the fee per byte value

        Example : 0.00000014
      • Required
        locktime integer

        Represents the time at which a particular transaction can be added to the blockchain.

        Example : 1781965
      • Required
        replaceable boolean

        Representation of whether the transaction is replaceable

        Example : False
      • Required
        size integer

        Represents the total size of this transaction.

        Example : 243
      • Required
        vin array

        Represents the transaction inputs.

        • Required
          address string

          Representation of the address

          Example : tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a
        • Optional
          change integer

          Representation of the change value

          Example : 0
        • Optional
          derivationIndex integer

          Representation of the derivation index of the xpub address.

          Example : 1
        • Required
          outputIndex integer

          Representation of the output index

          Example : 1
        • Required
          satoshis integer

          Representation of the satoshis value

          Example : 10000
        • Required
          script string

          Representation of the script string

          Example : 00143bb907c4cd6457aeda7b84c2d7cb79e79a8b9632
        • Required
          sighash string

          Representation of the hash that should be signed.

          Example : 90cfeef03b2755586b8e81668d8009b16b34d48abf2968729892279222e8d893
        • Required
          transactionId string

          Represents the reference transaction identifier.

          Example : ff59ac56616ece7498e62c7f9f957cfdd50f6f2a74402058154e3022e7617bf2
      • Required
        vout array

        Represents the transaction outputs.

        • Required
          address string

          Representation of the address

          Example : tb1qvx3fynjuctk475vgecetfck005fxh699mflshv
        • Required
          satoshis integer

          Representation of the satoshis value

          Example : 3094
        • Required
          script string

          Representation of the script

          Example : 0014a3f1019940ce572681c43fd836db97036a85bc8f

Credits Cost : 50 Credits For 1 Result(s)

Try it out

Request Example

POST
https://rest.cryptoapis.io/blockchain-tools/bitcoin/testnet/transactions/prepare-utxo-transaction?context=yourExampleString
Headers
Content-Type: application/json
X-API-Key: my-api-key

Request Body
{
    "context": "yourExampleString",
    "data": {
        "item": {
            "additionalData": "yourAdditionalDataHere",
            "fee": {
                "address": "tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a",
                "exactAmount": "0.00023",
                "priority": "standard"
            },
            "locktime": 1659001055,
            "prepareStrategy": "minimize-dust",
            "recipients": [
                {
                    "address": "tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a",
                    "amount": "0.00003"
                }
            ],
            "replaceable": false,
            "xpub": "tpubDCNoSqt3HF32yq8VU6mgapTuW1FzENZa3C5dKUF6WCQzubWz2nA1yxUhMQWkhhkD58Uc8YiuD8cmB3y5tihqAv4zT2GNyqKTNLchHJmsvt9"
        }
    }
}

Response Example

{
    "apiVersion": "2021-03-20",
    "requestId": "601c1710034ed6d407996b30",
    "context": "yourExampleString",
    "data": {
        "item": {
            "additionalData": "yourAdditionalDataHere",
            "fee": "0.0000279",
            "feePerByte": "0.00000014",
            "locktime": 1781965,
            "replaceable": false,
            "size": 243,
            "vin": [
                {
                    "address": "tb1q8wus03xdv3t6aknmsnpd0jmeu7dgh93j34pj5a",
                    "change": 0,
                    "derivationIndex": 1,
                    "outputIndex": 1,
                    "satoshis": 10000,
                    "script": "00143bb907c4cd6457aeda7b84c2d7cb79e79a8b9632",
                    "sighash": "90cfeef03b2755586b8e81668d8009b16b34d48abf2968729892279222e8d893",
                    "transactionId": "ff59ac56616ece7498e62c7f9f957cfdd50f6f2a74402058154e3022e7617bf2"
                }
            ],
            "vout": [
                {
                    "address": "tb1qvx3fynjuctk475vgecetfck005fxh699mflshv",
                    "satoshis": 3094,
                    "script": "0014a3f1019940ce572681c43fd836db97036a85bc8f"
                }
            ]
        }
    }
}