3
1
I am really confused and I am having trouble even asking this question in a coherent manner (as I am trying to describe things that other people have renamed multiple times in different instances) so please bear with me...
I am trying to build a transaction using each api I find so I am normalizing the structure of the response from each api call into
Bitcores expected format for the unspent outputs:
[
{
"address": "2Mwswt6Eih28xH8611fexpqKqJCLJMomveK",
"scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387",
"txid": "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
"vout": 1,
"amount": 1.0,
"confirmations":7
}
, { ... }
]
from: https://blog.bitpay.com/transactionbuilder/
But different apis are returning different parts of data
webbtc.com/address api unspent has only scriptPubKey
"scriptPubKey": "OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG"
whereas toshi.io api unspent has
"script":"OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG",
"script_hex":"76a914cba5f746dc1e41a932a7d38be7aba95944619ee888ac",
smartbit api has
"script_pub_key":{
"asm":"OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG",
"hex":"76a914cba5f746dc1e41a932a7d38be7aba95944619ee888ac"}
All the apis call these two things by different names and some apis include both/one/or-the-other
It would only make sense to present useful information in these apis So does it mean can I use the one with all the OP_ stuff for scriptPubKey in bitpay.com/transactionbuilder if the other is missing?
Why would they sometimes give me one and not the other?
I would have thought that if different apis give different bits of this info that maybe ether one could be used to build a transaction!?
For example I could strip away OP_DUP OP_HASH160 OP_EQUALVERIFY... anything beginning with OP_ (If the one with only the alpha numerical string isn't on its own i mean)
The thing that really confused me and is the main reason:
bitpay in their above example "scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387" is just a hex sring whereas webbtc have the exact same name "scriptPubKey": "OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG" but it has all the OP_ stuff in there
So with webbtc
"scriptPubKey"(this is protocol level script data!), Must I encrypt or sign the data with my private key in order to create the hex blob of the script? – Ben Muircroft – 2016-10-01T20:48:34.620Not you directly, that's the role of Bitpay's transaction builder. As long as you provide it the keys locking the outputs, it'll do all the signing needed to make the transaction valid. – alcio – 2016-10-01T21:30:57.557