src/encoder.js
function writeScriptPayToPubKeyHash(address, buffer, offset) {
    offset = buffer.writeUInt8(25, offset); //Script length
    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;
}
function writeScriptPayToPubKeyHash(address, buffer, offset) {
    offset = buffer.writeUInt8(25, offset); //Script length
    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;
}
function writeScriptPayToPubKeyHash ( address , buffer , offset ) { offset = buffer . writeUInt8 ( 25 , offset ) ; //Script length 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 ; }
Write p2pkh to the given buffer.
@param {String} address
@param {Buffer} buffer
@param {Number} offset
@returns {Number} new offset
Write p2pkh to the given buffer .