01000000013dcd7d87904c9cb7f4b79f36b5a03f96e2e729284c09856238d5353e1182b00200000000 fd5d01004730440220762ce7bca626942975bfd5b130ed3470b9f538eb2ac120c2043b445709369628022051d73c80328b543f744aa64b7e9ebefa7ade3e5c716eab4a09b408d2c307ccd701483045022100abf740b58d79cab000f8b0d328c2fff7eb88933971d1b63f8b99e89ca3f2dae602203354770db3cc2623349c87dea7a50cee1f78753141a5052b2d58aeb592bcf50f014cc9524104a882d414e478039cd5b52a92ffb13dd5e6bd4515497439dffd691a0f12af9575fa349b5694ed3155b136f09e63975a1700c9f4d4df849323dac06cf3bd6458cd41046ce31db9bdd543e72fe3039a1f1c047dab87037c36a669ff90e28da1848f640de68c2fe913d363a51154a0c62d7adea1b822d05035077418267b1a1379790187410411ffd36c70776538d079fbae117dc38effafb33304af83ce4894589747aee1ef992f63280567f52f5ba870678b4ab4ff6c8ea600bd217870a8b4f1f09f3a8e8353aeffffffff0130d90000000000001976a914569076ba39fc4ff6a2291d9ea9196d8c08f9c7ab88ac00000000
puede decodificar por encima de tx en http://chainquery.com/bitcoin-api/decoderawtransaction
Desde bitcoin explorer, descubrí que la transacción anterior es 2-3 multisig tx. Entendí que la parte en negrita fd5d01
es la longitud del guión. su valor es de 349 Bytes. En un tx normal, dentro del ScriptSig, el primer byte que nos dice cuanto tiempo tiene la firma. seguido del tamaño del segundo elemento y luego el segundo elemento que es pubkey. Ahora, cómo identificar la cantidad de firmas involucradas en un tx multisig como el ejemplo anterior. Me refiero a cómo descubrió el explorador que es 2-3 multisig. En primer lugar ¿cómo identificar un multisig? ¿Y cuál es el significado de OP_0 al comienzo de scriptsig?
Como ha averiguado correctamente, el campo de longitud describe la siguiente longitud del script. Luego sigue el SigScript:
004730440220762CE7BCA626942975BFD5B130ED3470B9F538EB2AC120C2043B445709369628022051D73C80328B543F744AA64B7E9EBEFA7ADE3E5C716EAB4A09B408D2C307CCD701483045022100ABF740B58D79CAB000F8B0D328C2FFF7EB88933971D1B63F8B99E89CA3F2DAE602203354770DB3CC2623349C87DEA7A50CEE1F78753141A5052B2D58AEB592BCF50F014CC9524104A882D414E478039CD5B52A92FFB13DD5E6BD4515497439DFFD691A0F12AF9575FA349B5694ED3155B136F09E63975A1700C9F4D4DF849323DAC06CF3BD6458CD41046CE31DB9BDD543E72FE3039A1F1C047DAB87037C36A669FF90E28DA1848F640DE68C2FE913D363A51154A0C62D7ADEA1B822D05035077418267B1A1379790187410411FFD36C70776538D079FBAE117DC38EFFAFB33304AF83CE4894589747AEE1EF992F63280567F52F5BA870678B4AB4FF6C8EA600BD217870A8B4F1F09F3A8E8353AE
La secuencia de comandos comienza con un "0" hexadecimal, que compensa un "fallo por un error" muy temprano en las rutinas de ejecución de las rutinas checksig. Se extrajo demasiado elemento de la pila. Este "error" lleva tanto tiempo en el sistema, que todo el mundo se acostumbró a él, y eliminarlo requiere un enorme esfuerzo. Entonces se convirtió en una característica :-) Aún más, si hay tx, que tienen un tiempo de ejecución en el futuro, ya no funcionarían...
¿Cómo descubrió el explorador que es 2-3 multigrado? En primer lugar ¿cómo identificar un multisig?
El explorador encuentra esto en el script sig. Ahí están las dos firmas, y la parte para el multisig:
<sig1> <sig2> <length> OP2 <pubkey1> <pubkey2> <pubkey3> OP3 AE
para poder ver mejor, he decodificado un poco el script. Los signos comienzan con hex 0x47 o 0x48 y terminan con 0x01. Están codificados en ASN1-DER, lo que proporciona una vista de los campos R y S, y tienen información de longitud circundante. Después del segundo 0x01, sigue el campo de longitud, y luego el código OP multisig (0x02) y las 3 claves públicas.
00: OP_0, OP_FALSE: an empty array is pushed onto the stack.
<sig1>
47: OP_DATA_0x47: push hex 47 (decimal 71) bytes on stack
30: OP_SEQUENCE_0x30: type tag indicating SEQUENCE, begin sigscript
44: OP_LENGTH_0x44: length of R + S
02: OP_INT_0x02: type tag INTEGER indicating length
20: OP_LENGTH_0x20: this is SIG R (32 Bytes)
02: OP_INT_0x02: type tag INTEGER indicating length
20: OP_LENGTH_0x20: this is SIG S (32 Bytes)
01: OP_SIGHASHALL: this terminates the ECDSA signature (ASN1-DER structure)
<sig2>
48: OP_DATA_0x48: push hex 48 (decimal 72) bytes on stack
30: OP_SEQUENCE_0x30: type tag indicating SEQUENCE, begin sigscript
45: OP_LENGTH_0x45: length of R + S
02: OP_INT_0x02: type tag INTEGER indicating length
21: OP_LENGTH_0x21: this is SIG R (33 Bytes)
02: OP_INT_0x02: type tag INTEGER indicating length
20: OP_LENGTH_0x20: this is SIG S (32 Bytes)
01: OP_SIGHASHALL: this terminates the ECDSA signature (ASN1-DER structure)
4C: OP_PUSHDATA1: next byte is # of bytes that go onto stack
C9: OP_Int(0x01-0xff): 201 bytes onto the stack
52: OP_2: the number 2 is pushed onto stack
################### we go multisig ####################################
41: OP_DATA_0x41: uncompressed pub key (65 Bytes)
41: OP_DATA_0x41: uncompressed pub key (65 Bytes)
41: OP_DATA_0x41: uncompressed pub key (65 Bytes)
53: OP_3: the number 3 is pushed onto stack
################### 2-of-3 Multisig ###################################
AE: OP_CHECKMULTISIG: terminating multisig
Encontrará una muy buena explicación en el capítulo 6 "Transacciones" y 7 "Transacciones avanzadas y secuencias de comandos" del maravilloso libro de Andreas "Mastering Bitcoin", que también está disponible en línea.
lch
pebwindkraft