0

I am new to Bitcoin and Blockchain, and Blockcypher..

I am trying to use Blockcypher APIs to create (and sign) and send a transaction (on testnet). The request i provide has 1 input and 1 output, but the response i receive has 2 inputs/outputs/tosign 50% of the time.. Why would this be? Thanks

Sample Request:

Posting to https://api.blockcypher.com/v1/btc/test3/txs/new?token=XXXXXXXX

{
    "double_spend": false,
    "inputs": [{
        "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"]
    }],
    "outputs": [{
        "value": 2,
        "addresses": ["tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"]
    }]
}

Response:

{
    "tx": {
        "hash": "b520ccb4b9ab96075c3cf1a91b0c7710a22332f0bb4d25409bcf9693a35477dd",
        "block_height": -1,
        "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD", "tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"],
        "total": 55000,
        "fees": 30000,
        "relayed_by": "35.226.46.118",
        "received": "2021-07-22T10:19:47.853381661Z",
        "ver": 1,
        "vin_sz": 2,
        "vout_sz": 2,
        "confirmations": 0,
        "preference": "high",
        "double_spend": false,
        "inputs": [{
            "prev_hash": "34e749b34cc75b996e7b28638cc4648958942b046bf9961837af7ab0046e53d1",
            "output_index": 0,
            "output_value": 10000,
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }, {
            "prev_hash": "106ad632e2474e683b2180181c1b911bc4d5727db5ab341ee8aded3b78fb2da7",
            "output_index": 1,
            "output_value": 75000,
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }],
        "outputs": [{
            "value": 2,
            "script": "00144e537472b30a412b474cd6b20b6b397a216ef94f",
            "addresses": ["tb1qfefhgu4npfqjk36v66eqk6ee0gska720j09nvr"],
            "script_type": "pay-to-witness-pubkey-hash"
        }, {
            "value": 54998,
            "script": "76a91471b6e0ce39475cbe5cd43966f5c7eb80a886952088ac",
            "addresses": ["mqtDjKw8wCyPBvk61NfkgmNFZDwHvCJTUD"],
            "script_type": "pay-to-pubkey-hash"
        }]
    },
    "tosign": ["c0859bbf0f964af14c01d9ff2da9e5254279d02c5c75c902e3a8180db6bb67e5", "91a6c5b3003047c0af81348f12867918ebc4efd70f3ff1a5ee9e4566bf361de8"],
    "signatures": [],
    "pubkeys": []
}

Thanks

3
  • Without actually studying your data, it seems to me that as Its possible for an address to have multiple UTXOs and for a transaction amount to require using two of those, the second output would be change -- does this make sense to you? Jul 22, 2021 at 10:47
  • Nope :) Not really, but there a few things for me to go on there thanks. What would be great to understand in short term is if this response is valid (sure it is) and that i can proceed with signing.
    – Damo
    Jul 22, 2021 at 10:50
  • Also, if u had a min to look at data, that would REALLY help me. The only thing i can deduce, is that the second output has a value of 2, which maps to my requested value. Not sure what other amounts relate to. Thanks
    – Damo
    Jul 22, 2021 at 10:52

1 Answer 1

1

Not sure what other amounts relate to.

    "total": 55000,

The amount being transferred to outputs in this transaction

    "fees": 30000,

The difference between total input amounts and total output amounts.

Note that the above two values sum to 85000.

        "output_value": 10000,

An amount associated with one UTXO with the specified spending address

        "output_value": 75000,

An amount associated with a second UTXO with the specified spending address

Note that the above two values sum to 85000.

        "value": 2,

The amount you specified be sent to the destination address

        "value": 54998,

The remainder of the 55000 ("total", see above) being returned as change.

1
  • Thats fantastic!! Thanks for stepping thru that
    – Damo
    Jul 22, 2021 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.