virtual void edge( uint64_t value, const uint8_t *upTXHash, uint64_t outputIndex, const uint8_t *outputScript, uint64_t outputScriptSize, const uint8_t *downTXHash, uint64_t inputIndex, const uint8_t *inputScript, uint64_t inputScriptSize ) { if(dump) { uint8_t buf[1 + 2*kSHA256ByteSize]; toHex(buf, upTXHash); printf(" outputIndex = %" PRIu64 "\n", outputIndex); printf(" value = %.8f\n", value*1e-6); printf(" upTXHash = %s\n\n", buf); printf(" # challenge answer script, bytes=%" PRIu64 " (on downstream input) =\n", inputScriptSize); showScript(inputScript, inputScriptSize, 0, " "); printf(" ||\n"); printf(" VV\n"); printf(" # challenge script, bytes=%" PRIu64 " (on upstream output)=\n", outputScriptSize); showScript(outputScript, outputScriptSize, 0, " "); showScriptInfo(outputScript, outputScriptSize); valueIn += value; } }
// Called when an output has been fully parsed virtual void endOutput( const uint8_t *p, // Pointer to TX output raw data uint64_t value, // Number of satoshis on this output const uint8_t *txHash, // sha256 of the current transaction uint64_t outputIndex, // Index of this output in the current transaction const uint8_t *outputScript, // Raw script (challenge to would-be spender) carried by this output uint64_t outputScriptSize // Byte size of raw script ) { printf( "%svalue = %" PRIu64 " # %.08f\n", spaces, value, satoshisToNormaForm(value) ); printf("%sscript = '\n", spaces); showScript(outputScript, outputScriptSize, 0, (const char *)spaces); printf("%s'\n", spaces); showScriptInfo(outputScript, outputScriptSize, spaces); pop(); printf("%s}\n", spaces); ++outputId; }
virtual void startInput( const uint8_t *p ) { if(dump) { printf( " input[%" PRIu64 "] = {\n\n", nbInputs++ ); static uint256_t gNullHash; LOAD(uint256_t, upTXHash, p); LOAD(uint32_t, upOutputIndex, p); LOAD_VARINT(inputScriptSize, p); showScript(p, inputScriptSize, 0, " "); isGenTX = (0==memcmp(gNullHash.v, upTXHash.v, sizeof(gNullHash))); if(isGenTX) { uint64_t reward = getBaseReward(currBlock); printf(" generation transaction\n"); printf(" based on block height, reward = %.8f\n", satoshisToNormaForm(reward)); printf(" hex dump of coinbase follows:\n\n"); canonicalHexDump(p, inputScriptSize, " "); valueIn += reward; } } }
// Called when a TX input is encountered virtual void startInput( const uint8_t *p ) { printf( "%sinput%d = {\n", spaces, (int)inputId ); push(); static uint256_t gNullHash; LOAD(uint256_t, upTXHash, p); LOAD(uint32_t, upOutputIndex, p); LOAD_VARINT(inputScriptSize, p); printf("%sscript = '\n", spaces); pop(); showScript(p, inputScriptSize, 0, (const char *)spaces); push(); printf("%s'\n", spaces); p += inputScriptSize; LOAD(uint32_t, sequence, p); printf("%snsequence = %" PRIu32 "\n",spaces, sequence); isCoinBase = (0==memcmp(gNullHash.v, upTXHash.v, sizeof(gNullHash))); if(isCoinBase) { uint64_t value = getBaseReward(currBlock); printf("%sisCoinBase = true\n", spaces); printf( "%svalue = %" PRIu64 " # %.08f\n", spaces, value, satoshisToNormaForm(value) ); printf("%scoinBase = '\n", spaces); push(); canonicalHexDump( p, inputScriptSize, (const char *)spaces ); pop(); printf("%s'\n", spaces); } }
virtual void endOutput( const uint8_t *p, // Pointer to TX output raw data uint64_t value, // Number of satoshis on this output const uint8_t *txHash, // sha256 of the current transaction uint64_t outputIndex, // Index of this output in the current transaction const uint8_t *outputScript, // Raw script (challenge to would-be spender) carried by this output uint64_t outputScriptSize // Byte size of raw script ) { if(dump) { printf(" value = %.8f\n", satoshisToNormaForm(value)); printf(" challenge script, bytes=%" PRIu64 " :\n", outputScriptSize); showScript(outputScript, outputScriptSize, 0, " "); showScriptInfo(outputScript, outputScriptSize, (const uint8_t *)" "); printf(" }\n\n"); valueOut += value; } }
virtual void endOutput( const uint8_t *p, // Pointer to TX output raw data uint64_t value, // Number of satoshis on this output const uint8_t *txHash, // sha256 of the current transaction uint64_t outputIndex, // Index of this output in the current transaction const uint8_t *outputScript, // Raw script (challenge to would-be spender) carried by this output uint64_t outputScriptSize // Byte size of raw script ) { if(dump) { printf(" value = %.8f\n", value*1e-6); printf(" challenge script, bytes=%" PRIu64 " :\n", outputScriptSize); if(outputScriptSize == 0) { printf("\n proof of stake transaction: output[0] script empty\n"); isStakeTX = 1; } else { showScript(outputScript, outputScriptSize, 0, " "); showScriptInfo(outputScript, outputScriptSize); } printf(" }\n\n"); valueOut += value; } }
/** * Process OI Op Codes passed by controller */ void OpenInterface::handleOpCode(byte oc) { #ifdef DEBUG_SERIAL switch (oc) { case ('s'): oc = OC_SAFE; break; case ('d'): oc = OC_DIRECT_DRIVE; break; case ('g'): oc = OC_SENSORS; break; } #endif switch (oc) { case(OC_LOW_SIDE_DRIVERS): callCallbackWithOneByte(controlLsdOutputCallback); break; case(OC_LEDS): callCallbackWithThreeBytes(controlLedsCallback); break; case(OC_PWM_LOW_SIDE_DRIVERS): callCallbackWithThreeBytes(controlLsdPwmCallback); break; case(OC_DIGITAL_OUTPUTS): callCallbackWithOneByte(controlDigitalOutputCallback); break; case(OC_STREAM): stream(); break; case(OC_PAUSE_RESUME_STREAM): break; case(OC_SEND_IR): callCallbackWithOneByte(sendIrCallback); break; case(OC_SHOW_SCRIPT): showScript(); break; case(OC_WAIT_EVENT): callCallbackWithOneByte(waitEventCallback); break; case(OC_PLAY_SCRIPT): scriptPlay(); break; case(OC_SCRIPT): scriptSet(); break; case(OC_WAIT_ANGLE): if (waitAngleCallback) { waitAction(waitAngleCallback); } break; case(OC_WAIT_DISTANCE): if (waitDistanceCallback) { waitAction(waitDistanceCallback); } break; case(OC_WAIT_TIME): waitTime(); break; case(OC_DEMO): case(OC_SPOT): case(OC_COVER): case(OC_COVER_AND_DOCK): // These are all demo codes. Implement? break; case(OC_QUERY_LIST): queryList(); break; case (OC_START): sensor[OI_SENSOR_OI_MODE] = OI_MODE_PASSIVE; break; case (OC_BAUD): break; case (OC_CONTROL): case (OC_SAFE): sensor[OI_SENSOR_OI_MODE] = OI_MODE_SAFE; break; case (OC_SENSORS): getSensors(); break; case (OC_SONG): song(); break; case(OC_PLAY_SONG): songPlay(); break; case (OC_DIRECT_DRIVE): driveDirect(); break; case (OC_DRIVE): drive(); break; case (OC_FULL): sensor[OI_SENSOR_OI_MODE] = OI_MODE_FULL; break; } }