fix ethereumjs-tx rawTx object
196371
function(rawTx) {
  const rawTxMutation = Object.assign({}, rawTx);

  // fix rawTx gaslimit
  if (typeof rawTxMutation.gas !== 'undefined') {
    rawTxMutation.gasLimit = rawTxMutation.gas;
    delete rawTxMutation.gas;
  }

  // fix data by prefixing it with zero
  if (typeof rawTxMutation.data !== 'undefined'
      && rawTxMutation.data.slice(0, 2) !== '0x') {
    rawTxMutation.data = '0x' + rawTxMutation.data;
  }

  // return new mutated raw tx object
  return rawTxMutation;
}
1240616
function openOutputTransform(headers/*, data*/) {
  /*jshint validthis:true */
  var operation = this;

  var txid = headers.location.substring('/v1/transactions/'.length);

  if (operation.withState === true) {
    return new mlutil.Transaction(txid, operation.rawHeaders['set-cookie']);
  }

  return {txid: txid};
}
636518
function(providerObject) {
  const fixedProviderObject = Object.assign({}, providerObject);

  // object has signTransaction
  if (typeof fixedProviderObject.signTransaction !== 'undefined') {
    // store old sign transaction method
    const oldSignTransactionMethod = fixedProviderObject.signTransaction;

    // build new provider object signTransaciton method
    fixedProviderObject.signTransaction = function(rawTx, cb) {
      // fire old callback
      oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb);
    };
  }

  // return fixed provider object
  return fixedProviderObject;
}
434441
function TxPowerModeCharateristic(opts) {
	TxPowerModeCharateristic.super_.call(this, objectAssign({
		uuid: 'ee0c2087-8786-40ba-ab96-99b91ac981d8',
		properties: ['read', 'write'],
		sizeof: 1
	}, opts));

	this.removeAllListeners('beforeWrite');

	this.on('beforeWrite', function(data, res) {
		var err = Results.Success;
		var value = this.fromBuffer(data);
		if (data.length !== 1) {
			err = Results.InvalidAttributeLength;
		} else if (value < TxPowerMode.Lowest || value > TxPowerMode.High) {
			err = Results.WriteNotPermitted;
		}

		res(err);
	});
}
1323887
def make_tx(version, tx_ins, tx_outs, lock_time,
            expiry=None, value_balance=0, tx_shielded_spends=None,
            tx_shielded_outputs=None, tx_witnesses=None, tx_joinsplits=None,
            joinsplit_pubkey=None, joinsplit_sig=None, binding_sig=None):
    '''
    
    '''
    n = riemann.get_current_network_name()
    if 'decred' in n:
        return tx.DecredTx(
            version=utils.i2le_padded(version, 4),
            tx_ins=tx_ins,
            tx_outs=tx_outs,
            lock_time=utils.i2le_padded(lock_time, 4),
            expiry=utils.i2le_padded(expiry, 4),
            tx_witnesses=[tx_witnesses])
    if 'sprout' in n and tx_joinsplits is not None:
        return tx.SproutTx(
            version=version,
            tx_ins=tx_ins,
            tx_outs=tx_outs,
            lock_time=utils.i2le_padded(lock_time, 4),
            tx_joinsplits=tx_joinsplits if tx_joinsplits is not None else [],
            joinsplit_pubkey=joinsplit_pubkey,
            joinsplit_sig=joinsplit_sig)
    if 'overwinter' in n:
        return tx.OverwinterTx(
            tx_ins=tx_ins,
            tx_outs=tx_outs,
            lock_time=utils.i2le_padded(lock_time, 4),
            expiry_height=utils.i2le_padded(expiry, 4),
            tx_joinsplits=tx_joinsplits if tx_joinsplits is not None else [],
            joinsplit_pubkey=joinsplit_pubkey,
            joinsplit_sig=joinsplit_sig)
    if 'sapling' in n:
        return tx.SaplingTx(
            tx_ins=tx_ins,
            tx_outs=tx_outs,
            lock_time=utils.i2le_padded(lock_time, 4),
            expiry_height=utils.i2le_padded(expiry, 4),
            value_balance=utils.i2le_padded(value_balance, 8),
            tx_shielded_spends=(tx_shielded_spends
                                if tx_shielded_spends is not None else []),
            tx_shielded_outputs=(tx_shielded_outputs
                                 if tx_shielded_outputs is not None else []),
            tx_joinsplits=tx_joinsplits if tx_joinsplits is not None else [],
            joinsplit_pubkey=joinsplit_pubkey,
            joinsplit_sig=joinsplit_sig,
            binding_sig=binding_sig)
    flag = riemann.network.SEGWIT_TX_FLAG \
        if tx_witnesses is not None else None
    return tx.Tx(version=utils.i2le_padded(version, 4),
                 flag=flag,
                 tx_ins=tx_ins,
                 tx_outs=tx_outs,
                 tx_witnesses=tx_witnesses,
                 lock_time=utils.i2le_padded(lock_time, 4))
912855
def check_tx(self, raw_transaction):
        

        self.abort_if_abci_chain_is_not_synced()

        logger.debug('check_tx: %s', raw_transaction)
        transaction = decode_transaction(raw_transaction)
        if self.bigchaindb.is_valid_transaction(transaction):
            logger.debug('check_tx: VALID')
            return ResponseCheckTx(code=CodeTypeOk)
        else:
            logger.debug('check_tx: INVALID')
            return ResponseCheckTx(code=CodeTypeError)
915759
function RawDecoder(schema, opts) {
  opts = opts || {};

  var noDecode = !!opts.noDecode;
  stream.Duplex.call(this, {
    readableObjectMode: !noDecode,
    allowHalfOpen: false
  });

  this._type = types.createType(files.load(schema));
  this._tap = new Tap(new Buffer(0));
  this._writeCb = null;
  this._needPush = false;
  this._readValue = createReader(noDecode, this._type);
  this._finished = false;

  this.on('finish', function () {
    this._finished = true;
    this._read();
  });
}
1072723
function injectBytes(bs, leftPadding) {
        var p = leftPadding || 0;
        var address = scrypt_raw._malloc(bs.length + p);
        scrypt_raw.HEAPU8.set(bs, address + p);
        for (var i = address; i < address + p; i++) {
          scrypt_raw.HEAPU8[i] = 0;
        }
        return address;
      }
727165
def getrawtransaction(self, txid: str, decrypt: int=0) -> dict:
        ''''''

        q = 'getrawtransaction?txid={txid}&decrypt={decrypt}'.format(txid=txid, decrypt=decrypt)

        return cast(dict, self.api_fetch(q))
1362761
function getTransActionFromBase64String(base64String) {
  var bytesDecode = base64DecodeFromString(base64String);
  var transaction = Transaction.deserializeBinary(bytesDecode);
  //ToDo : ret is success
  return transaction;
}
188524
function Blockchain (connector, opts) {
  var self = this
  EventEmitter.call(self)

  opts = _.extend({
    networkName: 'livenet',
    txCacheSize: 100
  }, opts)

  self.connector = connector
  self.networkName = opts.networkName
  self.latest = {hash: util.zfill('', 64), height: -1}
  self._txCache = LRU({max: opts.txCacheSize, allowSlate: true})

  self._isSyncing = false
  self.on('syncStart', function () { self._isSyncing = true })
  self.on('syncStop', function () { self._isSyncing = false })
}
218224
function process_raw(token) {
	var token = escapeRegex(token);
	return {
		type: "raw",
		piece: token + "/",
		last: token + "/?"
	};
}
504223
def pushtx(tx_hex, coin_symbol='btc', api_key=None):
    '''
    
    '''

    assert is_valid_coin_symbol(coin_symbol)
    assert api_key, 'api_key required'

    url = _get_pushtx_url(coin_symbol=coin_symbol)

    logger.info(url)

    data = {'tx': tx_hex}

    params = {'token': api_key}

    r = requests.post(url, json=data, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS)
    return get_valid_json(r)
808255
function errorEnhancement(inputMessage) {
  var message = inputMessage; // eslint-disable-line
  var outputMessage = null; // eslint-disable-line

  // if the input message is an array or object
  if (inputMessage !== null
    && !isNaN(inputMessage)
    && typeof inputMessage !== 'string') {
    message = JSON.stringify(inputMessage);
  }

  // gauentee string convertion, null and other..
  message = String(message);

  // if message includes
  if (message.includes('Compiled contract not found')) {
    outputMessage = 'This could be due to a contract with the same name being compiled. Wafr doesnt allow two contracts with the same name. Look to see if any of your contracts have the same name.';
  }

  // if message includes
  if (message.includes('invalid JUMP')) {
    outputMessage = `This can be caused by many things. One main cause is a 'throw' flag being used somewhere in execution.

    This can be caused by:

    1. A 'throw' flag being used somewhere in execution (a function your calling)
    2. Sending ether to a contract which does not have the 'payable' modifier on the fallback:
        function () payable {}
    3. A send or transaction was out of gas
    `;
  }

  // if message includes
  if (message.includes('invalid opcode') || message.includes('invalid op code')) {
    outputMessage = 'This can be caused by a contract which compiles fine, but doesnt execute properly in the Ethereum Virtual Machine. Such as using a `0x0` as an address.';
  }

  // if message includes
  if (message.includes('out of gas')) {
    outputMessage = `This error can be due to various scenarios:

    1. A error caused somewhere in your contract
    2. An error with the EVM module (npm: 'ethereumjs-vm')
    3. An error caused by the wafr module
    4. An error with the node simulation module (npm: 'ethereumjs-testrpc')
    5. A wafr account actually being out of gas
    6. The 'payable' flag not being used on a contract your sending ether too (common)

    If you cannot resolve this issue with reasonable investigation,
    report the error at:

    http://github.com/SilentCicero/wafr/issues

    If you believe the error is caused by the test node infrastructure,
    report the error at:

    http://github.com/ethereumjs/testrpc

    If you believe the error is caused by the EVM module, report the error
    at:

    http://github.com/ethereumjs/ethereumjs-vm
    `;
  }

  // return output message
  return outputMessage;
}
175045
function (data, callback) {
    if (typeof txDataQueue != "undefined" || txInProgress) {
      if (txDataQueue === undefined)
        txDataQueue = "";
      txDataQueue += data;
      return callback();
    } else {
      txDataQueue = data;
    }

    function writeChunk() {
      var chunk;
      var CHUNKSIZE = 20;
      if (txDataQueue.length <= CHUNKSIZE) {
        chunk = txDataQueue;
        txDataQueue = undefined;
      } else {
        chunk = txDataQueue.substr(0, CHUNKSIZE);
        txDataQueue = txDataQueue.substr(CHUNKSIZE);
      }
      txInProgress = true;
      console.log("BT> Sending " + JSON.stringify(chunk));
      try {
        winnus.write(chunk);
        setTimeout(function() {
          txInProgress = false;
          if (txDataQueue)
            writeChunk();
        }, 20);
      } catch (e) {
        console.log("BT> ERROR " + e);
        txDataQueue = undefined;
      }
    }
    writeChunk();
    return callback();
  }
791120
def transform_attrib_for_ledger(txn):
        
        txn = deepcopy(txn)
        txn_data = get_payload_data(txn)
        attr_type, _, value = domain.parse_attr_txn(txn_data)
        if attr_type in [RAW, ENC]:
            txn_data[attr_type] = domain.hash_of(value) if value else ''

        return txn
1037764
async function sendTransaction (tx, options = {}) {
  const { waitMined, verify } = R.merge(this.Chain.defaults, options)
  // Verify transaction before broadcast
  if (this.verifyTxBeforeSend || verify) {
    const { validation, tx: txObject, txType } = await this.unpackAndVerify(tx)
    if (validation.length) {
      throw Object.assign(Error('Transaction verification error'), {
        code: 'TX_VERIFICATION_ERROR',
        errorData: { validation, tx: txObject, txType },
        txHash: tx
      })
    }
  }

  try {
    const { txHash } = await this.api.postTransaction({ tx })
    return waitMined ? { ...(await this.poll(txHash, options)), rawTx: tx } : { hash: txHash, rawTx: tx }
  } catch (e) {
    throw Object.assign(
      (new Error(e.message)),
      {
        rawTx: tx,
        verifyTx: () => this.unpackAndVerify(tx)
      }
    )
  }
}