How to verify locking and unlocking scripts? I've selected an arbitrary transaction id and retrieved its associated transaction details using the blockcypher explorer as follows:

from blockcypher import get_transaction_details
get_transaction_details('0db8ca471c0e0fd3ce6f24197d9a9cec9647fd3df5ab6aa2e174e0ea85949146')


The output is the following python dictionary

{'addresses': ['17uP1g6ppdKVonMQWJ2ojeUZ8r9AhH2tgf',
'19jaGQFE39oH71WdR1ZJjpajjnP8tWNZdv', '1PJwNGYympRP3kJ8hqkY2ayHDVHokrASrv'],
'block_hash':'0000000000000000032ba4f95d39b86b2cc24c27e3c0d3201070945faf890e0d',
'block_height': 419922,
'block_index': 1,
'confidence': 1,
'confirmations': 186323,
'confirmed': datetime.datetime(2016, 7, 9, 4, 3, tzinfo=tzutc()),
'double_spend': False,
 'fees': 311300,
 'hash':'0db8ca471c0e0fd3ce6f24197d9a9cec9647fd3df5ab6aa2e174e0ea85949146',
'inputs': [{'addresses': ['19jaGQFE39oH71WdR1ZJjpajjnP8tWNZdv'],
'age': 418553,
'output_index': 0,
'output_value': 44695270,
'prev_hash':'81b3bcc34490facea42a729ae166f599c7933501273010d0eb0c2a0efe190153',
'script': '483045022100e664861517c0ea91df7e4bde7001b7cda6b034a7f4c4c6e622b681a57bf72c4102207b02fa4046f6ca5c180aa60ee57e67fff4e82c09a7e60515b15a989cd4bd5d3a012103017e89c4294b1ca99533b424c367db4f18747c0cacad393e3fb103640bcdb2ce',
'script_type': 'pay-to-pubkey-hash',
'sequence': 4294967295}],
'outputs': [{'addresses': ['17uP1g6ppdKVonMQWJ2ojeUZ8r9AhH2tgf'],
'script': '76a9144bb8c253f24fa707f6796a0b3c542f78c94b4dcc88ac',
'script_type': 'pay-to-pubkey-hash',
'spent_by': '43a771f414804dcc5ef5b4a577961a1e694ce8f477b391da1a404a600a14c8e3',
'value': 18695900},
{'addresses': ['1PJwNGYympRP3kJ8hqkY2ayHDVHokrASrv'],
'script': '76a914f4b738bc3ee9ebad027381304b2b3e81a618a60488ac',
'script_type': 'pay-to-pubkey-hash',
'spent_by': '0ea2858001f752c4eb7d0bba88568e9dfb25cdcc76adab42bc1ccfbf27c8bda1',
'value': 25688070}],
'preference': 'high',
'received': datetime.datetime(2016, 7, 9, 3, 41, 4, 370000, tzinfo=tzutc()),
'relayed_by': '80.249.197.154:8333',
'size': 226,
'total': 44383970,
'ver': 1,
'vin_sz': 1,
'vout_sz': 2}


Now, from what I understand, the input script should be

&lt;sig&gt; &lt;PubKey&gt; 


and the output script should be  

DUP HASH160 &lt;PubKHash&gt; EQUALVERIFY CHECKSIG


In the above transaction details I see that there is one input script and two output scripts, which the blockcypher documentation says are raw hexadecimal encodings. However, when I put the encoding under the "scripts" fields into a hex decoder I get nothing that makes sense. My questions are:

1) How can I decode the strings in the "scripts" fields of the transaction details dictionary to see the actual scripts. When I do, will they follow the format I outlined above?

2) How can I verify that the unlocking (input) script, indeed works on the locked (output) scripts? Is that possible using only the transaction details I have generated above?
1) How can I decode the strings in the "scripts" fields of the transaction details dictionary to see the actual scripts. When I do, will they follow the format I outlined above?


Scripts are just raw bytes that follow a certain format that is somewhat explained here. In order to see it in the format you outlined (OP_DUP,...) you have to "decode" these bytes. Basically you start by reading the size of the entire script to know how many bytes should be read (when using an API that returns deserialized tx, you won't see this size). In this transaction the SignatureSCript size is 0x6b=107. Then start "interpreting" the script. To do that, you start by reading 1 byte, then based on that byte decide what to do next. For example in your SignatureScript the first byte is 0x48 (in the link above you see it in Constants table in the word column N/A), this value indicates size of a follow up data to be pushed onto the stack. So now you have a data push of size 0x48=72 bytes:  

&lt;3045022100e664861517c0ea91df7e4bde7001b7cda6b034a7f4c4c6e622b681a57bf72c4102207b02fa4046f6ca5c180aa60ee57e67fff4e82c09a7e60515b15a989cd4bd5d3a01&gt;


In this particular transaction, this happens to be a signature. Then read the next 1 byte which is 0x21 and just like above you have another data to push with size =33 that happens to be a public key:  

&lt;03017e89c4294b1ca99533b424c367db4f18747c0cacad393e3fb103640bcdb2ce&gt;


Do the same with other scripts. For instance for PubkeyScript the size of the script is 0x19=25 and the first byte in script is 0x76 (you'll find it under Stack) this value is OP_DUP (unlike previous two bytes, there is no follow up data to read, only an "action" to perform that is duplicating top stack item). Next byte is 0xa9=OP_HASH160 (find it under Crypto) and so on.


  2) How can I verify that the unlocking (input) script, indeed works on the locked (output) scripts? Is that possible using only the transaction details I have generated above?


You'll always need at least 2 transactions. 1 is the current one you have and want to verify, and the other is the transaction output it is spending. Here it is the transaction with txid 81b3bcc34490facea42a729ae166f599c7933501273010d0eb0c2a0efe190153and outIndex=0. Now you use the PubkeyScript of previous transaction from the corresponding index (locking script) with the SignatureScript of this transaction (unlocking script) together and perform each operation. See this example for each step.