I’m trying to
inscribe a Transfer of BRC-20send an amount of Bitcoin from and to a single address. Would this possible?
Yes you can pay from an address back to the same address, though obviously you need to make an allowance for a fee, so the returned amount is less or you need an extra input to cover the fee.
This is not what is implied by the error message. It is not the source of your problem creating a valid Schnorr signature.
const script = [
pubkey.toString("hex"),
"OP_CHECKSIG",
"OP_0",
"OP_IF",
toHexString(ec.encode("ord")),
"01",
toHexString(mimetype),
"OP_0",
toHexString(content),
"OP_ENDIF",
].join(" ");
const leafScript = bitcoin.script.fromASM(script);
I’m unfamiliar with this Javascript .fromASM
function. Presumably it adds the appropriate opcodes for the implicit data pushes? For example the pubkey.toString("hex"),
has to eventually be prefixed with opcode 0x20
as the opcode for pushing 32-bytes. I’d check what .fromASM
produces.
I’m also puzzled by ec.encode("ord")
– it seems to be converting a UTF-8 string to UTF-8 unless your source is actually in some encoding that is not a superset of 7-bit ASCII.
My understanding of the network encoding of the relevant script is at How to differentiate between BTC transactions and BRC20 transactions on a blockchain?