Title: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: BlackHatCoiner on June 18, 2022, 04:19:36 PM As far as I know, with Core you can only create transaction with createrawtransaction (https://developer.bitcoin.org/reference/rpc/createrawtransaction.html). But, from what I can see in the examples, you can either create a script that pays to an address or to an OP_RETURN.
My question is, can you create custom scripts with createrawtransaction, besides those four? Code: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG (for P2PKH) Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: NotATether on June 19, 2022, 04:20:39 AM send RPC call has a parameter in the JSON dictionary of the first argument to allow you to specify arbitrary hex data for an address (which I assume represents a locking script).
You can see for yourself in the documentation: Quote send [{"address":amount},{"data":"hex"},...] ( conf_target "estimate_mode" fee_rate options ) EXPERIMENTAL warning: this call may be changed in future releases. Send a transaction. Arguments: 1. outputs (json array, required) The outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one 'data' object. For convenience, a dictionary, which holds the key-value pairs directly, is also accepted. [ { (json object) "address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC }, { (json object) "data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data }, ... ] ...etc As you can see, it does not specifically define the function of "data", nor gives any examples that use it, so this is my best-guess assumption. Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: nc50lc on June 19, 2022, 04:37:08 AM But, from what I can see in the examples, you can either create a script that pays to an address or to an OP_RETURN. My assumption is the "data" key-value pair in the output is just OP_RETURN, it wont process scripts;My question is, can you create custom scripts with createrawtransaction, besides those four? Reason is, it automatically prepend 0x6A to the value which is OP_RETURN. The "address" key-value pair will only take addresses and the amount to be sent. -Title- If you want to spend a custom script's UTXO, its txid and vout should be entered in the inputs array of createrawtransaction,then indicate the custom "scriptPubKey", "redeemScript" or "witnessScript" in prevtxs when signing the transaction: signrawtransactionwithkey (https://developer.bitcoin.org/reference/rpc/signrawtransactionwithkey.html?highlight=signrawtransactionwithkey#argument-3-prevtxs) Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: BlackHatCoiner on June 19, 2022, 01:07:15 PM send RPC call has a parameter in the JSON dictionary of the first argument to allow you to specify arbitrary hex data for an address (which I assume represents a locking script). Yes, but you can only input an address there. P2PKH, P2SH, P2WPKH, P2WSH and P2TR (that I have forgotten to mention in OP). Not a custom script.As you can see, it does not specifically define the function of "data", nor gives any examples that use it, so this is my best-guess assumption. The value of data is taken as OP_RETURN data.Code: (network: testnet) Code: ("Bitcoin Core") createrawtransaction "[{\"txid\":\"46f1bfbe99e12841841e131b8ce04c4708881d8facc4729c16c97d78bcfad3c8\",\"vout\":0}]" "[{\"data\":\"aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087\"}]" See? My assumption is the "data" key-value pair in the output is just OP_RETURN, it wont process scripts; Exactly.Reason is, it automatically prepend 0x6A to the value which is OP_RETURN. If you want to spend a custom script's UTXO [...] I don't want to spend a custom script's UTXO. I want to create the custom script's UTXO.Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: achow101 on June 20, 2022, 03:01:26 AM No, you cannot.
Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: nc50lc on June 20, 2022, 04:46:39 AM If you want to spend a custom script's UTXO [...] I don't want to spend a custom script's UTXO. I want to create the custom script's UTXO.Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: NotATether on June 20, 2022, 12:17:25 PM A custom script should be derived into an address to be useable in createrawtransaction, thus to create a UTXO, send bitcoins to the derived address normally. Most likely it would require feeding the transaction parameters with the custom script into custom software (might even be just a hacked up C program) that outputs a raw transaction which can then be signed and broadcasted using Bitcoin Core - since achow said they can't be created in Core anyway. Title: Re: Can you spend to a custom scriptPubKey with Bitcoin Core? Post by: litecoin_messiah on June 27, 2022, 04:59:24 AM http://bitcoin-script-debugger.visvirial.com/?input=OP_1
Outputs can be… you know what i cant explain just check out the tool ;). |