Write p2pkh attenuation script to the given buffer.
@param {String} attenuation_string
@param {String} from_tx
@param {number} index
@param {String} address
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset
356047
function writeAttenuationScript(attenuation_string, from_tx, from_index, address, buffer, offset) {
    let attenuation_buffer = Buffer.from(attenuation_string.toString('hex'));
    offset += bufferutils.writeVarInt(buffer, 26 + attenuation_string.length + 40, offset);
    offset = buffer.writeUInt8(77, offset);
    offset = buffer.writeInt16LE(attenuation_string.length, offset);
    offset += attenuation_buffer.copy(buffer, offset);
    offset = buffer.writeUInt8(36, offset);
    let hash = Buffer.from((from_tx != undefined) ? from_tx : '0000000000000000000000000000000000000000000000000000000000000000', 'hex').reverse();
    let index = Buffer.from('ffffffff', 'hex');
    if (from_index != undefined)
        index.writeInt32LE(from_index, 0);
    offset += Buffer.concat([hash, index]).copy(buffer, offset);
    offset = buffer.writeUInt8(178, offset);
    offset = buffer.writeUInt8(OPS.OP_DUP, offset);
    offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
    //Write previous output address
    offset = buffer.writeUInt8(20, offset); //Address length
    offset += Buffer.from(base58check.decode(address, 'hex').data, 'hex').copy(buffer, offset);
    //Static transfer stuff
    offset = buffer.writeUInt8(OPS.OP_EQUALVERIFY, offset);
    offset = buffer.writeUInt8(OPS.OP_CHECKSIG, offset);
    return offset;
}
814584
def sendtoaddress(self, recv_addr, amount, comment=""):
        """"""
        return self.req("sendtoaddress", [recv_addr, amount, comment])
454011
function (txReceipt, addressToNameMap) {
    const oThis = this;

    var decodedEvents = [];

    // txReceipt is mandatory, return error if not present
    if (!txReceipt) {
      return responseHelper.error({
        internal_error_identifier: 'tx_receipt_not_found',
        api_error_identifier: 'receipt_not_found',
        error_config: basicHelper.fetchErrorConfig()
      });
    }

    // Transaction failed
    if (txReceipt.status && parseInt(txReceipt.status, 16) !== 1) {
      logger.error("Transaction failed as status is ", txReceipt);
      return responseHelper.error({
        internal_error_identifier: 'tx_receipt_status_failed',
        api_error_identifier: 'transaction_receipt_failed',
        error_config: basicHelper.fetchErrorConfig()
      });
    }

    // if block not mined, return error
    if (!txReceipt.blockNumber) {
      return responseHelper.error({
        internal_error_identifier: 'l_w_ld_1',
        api_error_identifier: 'receipt_not_found',
        error_config: basicHelper.fetchErrorConfig()
      });
    }

    var toAddr = txReceipt.to
      , contractName = oThis.getContractNameFor(toAddr, addressToNameMap);

    // if the address is a known address
    if (contractName && txReceipt.logs.length > 0) {
      var abiDecoder = require('abi-decoder')
        , relevantLogs = [];

      for (var i = 0; i < txReceipt.logs.length; i++) {
        const currContractName = oThis.getContractNameFor(txReceipt.logs[i].address, addressToNameMap)
          , currContractABI = coreAddresses.getAbiForContract(currContractName);

        // if contract name is null, continue to next log element.
        if (!currContractName) {
          continue;
        }

        // ABI not found for a contract for which name was recognized, hence error
        if (!currContractABI) {
          return responseHelper.error({
            internal_error_identifier: 'l_w_ld_2',
            api_error_identifier: 'abi_not_found_for_contract',
            error_config: basicHelper.fetchErrorConfig()
          });
        }

        // push the log element to relevant log array
        relevantLogs.push(txReceipt.logs[i]);
        abiDecoder.addABI(currContractABI);
      }

      if (relevantLogs.length > 0) {
        decodedEvents = abiDecoder.decodeLogs(relevantLogs);
      }
    }

    return responseHelper.successWithData({
      rawTransactionReceipt: txReceipt,
      formattedTransactionReceipt: {
        transactionHash: txReceipt.transactionHash,
        blockHash: txReceipt.blockHash,
        blockNumber: txReceipt.blockNumber,
        eventsData: decodedEvents,
        toAddress: toAddr,
        contractAddress: txReceipt.contractAddress || ''
      }
    });
  }
692025
public WrappedByteBuffer putIntAt(int index, int v) {
        _checkForWriteAt(index, 4);
        _buf.putInt(index, v);
        return this;
    }
1255461
function pton6(addr, dest, index = 0) {
  if (typeof addr !== 'string') {
    throw new TypeError('Argument 1 should be a string.')
  }

  if (addr.length <= 0) {
    einval()
  }

  const isbuffer = Buffer.isBuffer(dest)
  const endp = index + IPV6_OCTETS

  if (isbuffer) {
    if (endp > dest.length) {
      throw new Error('Too small target buffer.')
    }
  }

  const buf = isbuffer ? dest : Buffer.allocUnsafe(IPV6_OCTETS)

  let i = 0
  let colonp = null
  let seenDigits = 0
  let val = 0
  let curtok = 0
  let ch = 0

  if (addr[i] === ':') {
    if (addr.length >= 2 && addr[++i] !== ':') {
      einval()
    }
  }

  curtok = i

  while ((ch = i++) < addr.length) {
    const char = code(addr[ch])

    if (isDigit(char) || isLetter16(char)) {
      val <<= 4

      if (isDigit(char)) {
        val |= char - CHAR0
      } else if (isLetter16Low(char)) {
        val |= char - CHARa + 10
      } else if (isLetter16Up(char)) {
        val |= char - CHARA + 10
      }

      if (++seenDigits > 4) {
        einval()
      }
    } else if (char === CHARCOLON) {
      curtok = i

      // If it's second colon in pair.
      if (seenDigits === 0) {
        // Only one colon pair allowed.
        if (colonp !== null) {
          einval()
        }

        colonp = index
        continue
      } else if (i >= addr.length) {
        einval()
      }

      if (index + 2 > endp) {
        einval()
      }

      buf[index++] = (val >> 8) & 0xFF
      buf[index++] = val & 0xFF

      seenDigits = 0
      val = 0
    } else if (char === CHARPOINT) {
      pton4(addr.slice(curtok), buf, index)
      index += IPV4_OCTETS
      seenDigits = 0
      break
    } else {
      einval()
    }
  }

  // Handle last pair.
  if (seenDigits > 0) {
    if (index + 2 > endp) {
      einval()
    }

    buf[index++] = (val >> 8) & 0xFF
    buf[index++] = val & 0xFF
  }

  if (colonp !== null) {
    const n = index - colonp

    if (index === endp) {
      einval()
    }

    buf.copyWithin(endp - n, colonp, colonp + n)
    fill(buf, 0, colonp, endp - n)
  }

  return buf
}
442378
function (address, cb) {
          setupMultiserver()
          ms_client.client(coearseAddress(address), function (err, stream) {
            return err ? cb(err) : cb(null, setupRPC(stream, null, true))
          })
        }
1332585
public static Script createOutputScript(Address to) {
        if (to instanceof LegacyAddress) {
            ScriptType scriptType = to.getOutputScriptType();
            if (scriptType == ScriptType.P2PKH)
                return createP2PKHOutputScript(to.getHash());
            else if (scriptType == ScriptType.P2SH)
                return createP2SHOutputScript(to.getHash());
            else
                throw new IllegalStateException("Cannot handle " + scriptType);
        } else if (to instanceof SegwitAddress) {
            ScriptBuilder builder = new ScriptBuilder();
            // OP_0 <pubKeyHash|scriptHash>
            SegwitAddress toSegwit = (SegwitAddress) to;
            builder.smallNum(toSegwit.getWitnessVersion());
            builder.data(toSegwit.getWitnessProgram());
            return builder.build();
        } else {
            throw new IllegalStateException("Cannot handle " + to);
        }
    }
973996
public WrappedByteBuffer putAt(int index, byte v) {
        _checkForWriteAt(index, 1);
        _buf.put(index, v);
        return this;
    }
308905
@Override
  public int addressRemote(byte []buffer, int offset, int length)
  {
    return _socket.getRemoteAddress(buffer, offset, length);
  }
455616
function writeScriptLockedPayToPubKeyHash(address, locktime, buffer, offset) {
    let locktime_buffer = Buffer.from(locktime, 'hex');
    offset = buffer.writeUInt8(27 + locktime_buffer.length, offset); //Script length
    offset = buffer.writeUInt8(locktime_buffer.length, offset); //Length of locktime
    offset += locktime_buffer.copy(buffer, offset);
    offset = buffer.writeUInt8(OPS.OP_NUMEQUALVERIFY, offset);
    offset = buffer.writeUInt8(OPS.OP_DUP, offset);
    offset = buffer.writeUInt8(OPS.OP_HASH160, offset);
    //Write previous output address
    offset = buffer.writeUInt8(20, offset); //Address length
    offset += Buffer.from(base58check.decode(address, 'hex').data, 'hex').copy(buffer, offset);
    offset = buffer.writeUInt8(OPS.OP_EQUALVERIFY, offset);
    offset = buffer.writeUInt8(OPS.OP_CHECKSIG, offset);
    return offset;
}
1243131
function read(mode,callback) {
      if (spi === undefined) {return;};
      var txBuf = new Buffer([1,mode,0]);
      var rxBuf = new Buffer([0,0,0]);
      
      spi.transfer(txBuf,rxBuf,function(dev,buffer) {
        var value = ((buffer[1] & 3)<< 8) + buffer[2];
        callback(value);
      });
    }
819982
@Override
    public int transferTo(int index, WritableByteChannel channel) {
        rangeCheck(index);
        
        try {
            long address = getAddress(index);
            int segPos = _addressFormat.getOffset(address);
            int segInd = _addressFormat.getSegment(address);
            
            // no data found
            if(segPos < Segment.dataStartPosition) return -1;
            
            // get data segment
            Segment seg = _segmentManager.getSegment(segInd);
            if(seg == null) return -1;
            
            // read data length
            int size = _addressFormat.getDataSize(address);
            int len = (size == 0) ? seg.readInt(segPos) : size;
            
            // transfer data to a writable channel
            if (len > 0) {
                seg.transferTo(segPos + 4, len, channel);
            }
            
            return len;
        } catch(Exception e) {
            return -1;
        }
    }
1334974
protected void sendBuf(final OtpErlangPid from, final String dest,
            final OtpOutputStream payload) throws IOException {
        if (!connected) {
            throw new IOException("Not connected");
        }
        @SuppressWarnings("resource")
        final OtpOutputStream header = new OtpOutputStream(headerLen);

        // preamble: 4 byte length + "passthrough" tag + version
        header.write4BE(0); // reserve space for length
        header.write1(passThrough);
        header.write1(version);

        // header info
        header.write_tuple_head(4);
        header.write_long(regSendTag);
        header.write_any(from);
        if (sendCookie) {
            header.write_atom(localNode.cookie());
        } else {
            header.write_atom("");
        }
        header.write_atom(dest);

        // version for payload
        header.write1(version);

        // fix up length in preamble
        header.poke4BE(0, header.size() + payload.size() - 4);

        do_send(header, payload);
    }
209348
@Override
  public void write(byte []buffer, int offset, int length,
                    boolean isEnd)
    throws IOException
  {
    int position = _position;
    
    if (length < 0) {
      throw new IllegalArgumentException();
    }
    
    if (_indexAddress < position + length) {
      throw new IllegalArgumentException(L.l("Segment write overflow pos=0x{0} len=0x{1} entry-head=0x{2} seg-len=0x{3}. {4}",
                                          Long.toHexString(_position),
                                          Long.toHexString(length),
                                          Long.toHexString(_indexAddress),
                                          Long.toHexString(_segment.length()),
                                          _segment));
    }
    

    //try (StoreWrite sOut = _readWrite.openWrite(_segment.getAddress(),
    //                                                _segment.getLength())) {
    
    _sOut.write(_segment.getAddress() + position, buffer, offset, length);

    _position = position + length;
      
    _isDirty = true;
  }
1048247
public static void setBytes(long address, byte[] buffer, int bufferOffset, int count)
    {
        assert buffer != null;
        assert !(bufferOffset < 0 || count < 0 || bufferOffset + count > buffer.length);
        setBytes(buffer, bufferOffset, address, count);
    }
261794
function encodeAttachmentMITRegister(buffer, offset, symbol, content, address) {
    offset = buffer.writeUInt8(Constants.MIT.STATUS.REGISTER, offset);
    offset += encodeString(buffer, symbol, offset);
    offset += encodeString(buffer, address, offset);
    offset += encodeString(buffer, content, offset);
    return offset;
}
584340
function TXRequest(options) {
  if (!(this instanceof TXRequest))
    return new TXRequest(options);

  this.hash = encoding.NULL_HASH;
  this.indexes = [];

  if (options)
    this.fromOptions(options);
}