I would suggest using Python to accomplish this. pybitcointools have what you need to be able to deserialize a hex transaction to JSON, and manipulate that and then serialize again to be able to sign and broadcast via support for blockchain.info.
This example will rebuild the standard script from the ground up:
>>> opdup = 0x76
>>> ophash160 = 0xA9
>>> push20 = 0x14
>>> opeqver = 0x88
>>> opchecksig = 0xAC
>>> pubkeyhash = 0x2dbde30815faee5bf221d6688ebad7e12f7b2b1a
We are going to append hex values by moving them bitwise.
- OP_DUP OP_HASH160 2dbde30815faee5bf221d6688ebad7e12f7b2b1a OP_EQUALVERIFY OP_CHECKSIG
- This is the hex we want 76a9142dbde30815faee5bf221d6688ebad7e12f7b2b1a88ac
This is one way of doing it
>>> quickfix = 0xff
>>> asm = quickfix
>>> asm = asm << 8 | opdup
>>> asm = asm << 8 | ophash160
>>> asm = asm << 8 | push20
>>> asm = asm << 8*20 | pubkeyhash
>>> asm = asm << 8 | opeqver
>>> asm = asm << 8 | opchecksig
Ant then to check if its the same:
>>> almost = hex(asm)
>>> ready = almost.partition("0xff")[2]
>>> print(ready)
Hope this is what you are after :-)
1As long as no
"; drop table wallet;"is possible. – LateralFractal – 2013-10-25T04:52:32.2601Little Bobby Tables, is that you?! – RLH – 2013-10-25T17:10:28.790
1
Don't most nodes reject custom scripts? That's what Blockchain.info's "strange transactions" are, right?
– KJ O – 2013-10-25T20:52:40.8331
As far as I know, only transactions containing the "disabled" opcodes found here are rejected by nodes: https://en.bitcoin.it/wiki/Script
– bvpx – 2013-10-25T21:17:52.850Maybe this Node.js tool can help https://github.com/jgarzik/txtool
– Jonas Oestman – 2013-10-31T05:03:04.113have a look at bitcore-lib – Badr Bellaj – 2017-08-26T09:05:52.650