SVSignature.fromTxFormat constructor

SVSignature.fromTxFormat(
  1. String buffer
)

Constructs a signature for it's bitcoin-transaction-encoded form.

buffer - A hexadecimal string containing the signature from a bitcoin transaction.

Implementation

SVSignature.fromTxFormat(String buffer) {

    //allow empty signatures
    if (buffer.length == 0){
        _r = BigInt.one;
        _s = BigInt.one;
        _signature = ECSignature(_r!, _s!);
        _nhashtype = 1;
        return;
    }

    var decoded = HEX.decode(buffer);
    var nhashtype = decoded[decoded.length - 1];

    var derbuf = decoded.sublist(0, decoded.length - 1);
    _nhashtype = nhashtype; //this is OK. SighashType is already represented as HEX. No decoding needed

    // _parseDER(HEX.encode(derbuf));
    _decodeFlexDER(derbuf, false);

}