btcsuite / btcscript Goto Github PK
View Code? Open in Web Editor NEWImplements the bitcoin transaction script language - a package from btcd
Implements the bitcoin transaction script language - a package from btcd
I see func PayToAddrScript(addr btcutil.Address) ([]byte, error)
will allow me to create the script but how can I do the reverse and figure out that a script is a pay to address/public key hash?
SignatureScript and SignTxOutput use a byte for hashType.
Would this be better represented as a typed parameter instead?
type SigHashType byte
There probably is a good reason why it isn't already represented like this and I would be interested to know why.
Make signatures with non-canonical data pushes non-standard, to match bitcoind.
btcscript
uses go-spew (great name) for a variety of logging purposes.
Unfortunately go-spew uses unsafe
which is not allowed by the App Engine runtime. Any idea how we can get around this and make btcscript
compatible with App Engine?
11:59:26 2014-02-19 [ERR] BMGR: Failed to process block 000000001881dccfeda317393c261f76d09e399e15e27d280e5368420f442632: validate of input 2 from transaction 7155ef87b3b794f5315770499945ddd535c873b9a2135a0eb1661b8904b66b25 failed: execute fail,
fail on stack (input script bytes 00250021024ab33c3a547a37293eb875b4bbdbd473e9d4bafdf35687e79744dcd70f6e4de251ae, prev output script bytes a9142c6b107fdf106f226f3fa327ba36d6e3cac73df087)
Unless I am completely missing something, I think I have a problem with isScriptHash's implementation (https://github.com/conformal/btcscript/blob/5beafbd2d8be535c6a8f439b08d1c970da25b7bc/script.go#L247)
It checks if the script has a prefix of OP_HASH160 OP_DATA_20 OP_EQUAL while my understanding of P2SH transaction format is this: OP_HASH160 scriptHash OP_EQUAL. In fact, btcscript itself does this: https://github.com/conformal/btcscript/blob/5beafbd2d8be535c6a8f439b08d1c970da25b7bc/script.go#L1029-L1034
Thank you for creating and maintaining btcscript.
As far as I can see, there is currently no possibility for external packages to parse the bytes from btcwire.MsgTx.TxOut[i].PkScript to an array of opcodes. The function parseScript achieves that, but is not exported.
In order to further process the script it is necessary that the fields of opcode and parsedOpcode are accessible.
Example of what could be possible:
func printScriptPubkey(txOut *btcwire.TxOut) {
scriptPubkey, _ := btcscript.ParseScript(txOut.PkScript)
for _, op := range scriptPubkey {
log.Println(op.Opcode.Name)
}
}
Create an API in which given a script, returns an array of []byte's containing the script data objects for OP_DATA_* and OP_PUSHDATA*.
This is needed for bloom filtering.
Hey there,
I'd like to construct some custom scripts (functionality it's similar to PayToScriptHashScript(), but the payload is different).
Sadly, opcodemap and unparseScript are private.
Any chance of making those public?
Thanks
[11:21:08 2013-10-07] [WRN] [CHAN] tx 1b8bb29b851c555d1f34ab61df8f910ea0fc60d09f66dd2c9b16464b8ae1c931 failed input 0, err Invalid Opcode
[11:21:08 2013-10-07] [ERR] [BTCD] [BMGR] Failed to process block 000000000017538a71d012de3a73fcc22415b2aabf7329133c0109aa0a75b4b4: Invalid Opcode
This is due to the fact that btcscript errors on scripts with invalid opcodes regardless of them being executed or not while bitcoind has rather "interesting" handling in that it doesn't explode on invalid opcodes unless they are executed. It doesn't seem like a particularly good idea to allow invalid opcodes in a transaction script regardless of them being executed or not, but to be compatible, the same behavior is required.
The relevant code from bitcoind is:
else if (fExec || (OP_IF <= opcode && opcode <= OP_ENDIF))
switch (opcode)
{
Hi,
I'm using btcec for a Ripple node implementation and I'm wanting to send DER encoded ECDSA signatures to other nodes. This function perhaps belongs in btcec?
Thanks for the incredibly useful code!
Cheers,
Donovan.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.