libsv / go-bt Goto Github PK
View Code? Open in Web Editor NEWThe go-to Bitcoin Transaction (BT) Go library.
Home Page: https://pkg.go.dev/mod/github.com/libsv/go-bt
License: ISC License
The go-to Bitcoin Transaction (BT) Go library.
Home Page: https://pkg.go.dev/mod/github.com/libsv/go-bt
License: ISC License
Can we have this please:
(tx *Tx) GetTxIDByte() []byte
I want to save the bytes on my storage.
Many thanks.
See this test:
https://github.com/mrz1836/go-bt/blob/5a57029d39d4d9a89ba65e2f7c098c70419467a8/tx_test.go#L223
I would expect the fee to be closer to 0.5
We shouldn't have Inputs or Outputs used in insolation without a tx in v2 like we do in v1. For example https://github.com/libsv/go-bt/blob/master/txinput.go#L14 Causes a lot of issues especially with devs who aren't used to Bitcoin or the library
If we have any types of tx scripts (not just standard ones), txs can be unlocked in many different ways. Previously we only unlocked scripts using signatures which is why we only have the tx.Sign function. This should probably be renamed to tx.Unlock(ctx context, inputIndex uint64, unlocker Unlocker, shf sighashflag).
Greetings
first of all thank you for creating this awesome library. I just started diving into Bitcoin development (and Golang) recently and this library, on top of others, is a big help when getting things done the Bitcoin way.
However, one feature that has now come to my attention, as I am trying to solve some more complex problems is Multi Signature Transactions.
Would it be possible for you guys to implement those into the library?
So far I've found an old repository from 2014 (https://github.com/soroushjp/go-bitcoin-multisig) that does it, but it's outdated and many dependencies are broken. It can perhaps serve as a starting point on how to implement things.
I thought about trying to implement it myself, however, I am still to green when it comes to Bitcoin, and I think to keep things secure and usable in the long run, it's probably better if I ask you guys.
Currently through our code we have references to opcode
and opCode
, in both internal var names and error types.
This inconstency should be address before releasing v2, to prevent it become annoying and introducing the need for either accepting inconsistent behaviour, or releasing a breaking change.
I am personally going to argue for opcode
and Opcode
to be used, instead of opCode
and OpCode
, as in written English it is only one word and officially written as opcode
.
I have deployed and mint a brc20, now I want to transfer to other addresses, I have completed the first step of transfer {"p": "brc-20", "op": "transfer", "tick": "xxxx", "amt": "1"},I got the inscription id, how should I transfer this inscription out in the second step?
thanks
Is your feature request related to a problem? Please describe.
Signing/unlocking in v2 is really complicated at times
Describe the solution you'd like
Should be refactored to be made easier (potentially in a breaking way so might need to do v3). Also passing in input script and sats as function params instead having them on the input and then returning an error when trying to sign/unlock and those fields aren't added.
The following locking/unlocking script combo fail on our interpreter, but pass on others:
Locking script:
017b0300000000000003000000000000615779577957795779577957795779577952007600a26976529f699454958c6b6c766b796c766b796c766b796c766b796c756b6b6b6b75757575757575756c6c6c6c53795f007600a26976529f695195946b6c766b796c7587696152795279527953007600a26976539f699451958c6b6c766b796c756b7575756c011600539500937600a26976569f695195946b6c766b796c759c696152795279527953517600a26976539f699451958c6b6c766b796c756b7575756c011600539551937600a26976569f695195946b6c766b796c759c696152795279527953527600a26976539f699451958c6b6c766b796c756b7575756c011600539552937600a26976569f695195946b6c766b796c759c6975757575615779577957795779577957795779577952517600a26976529f699454958c6b6c766b796c766b796c766b796c766b796c756b6b6b6b75757575757575756c6c6c6c53795f517600a26976529f695195946b6c766b796c7587696152795279527953007600a26976539f699451958c6b6c766b796c756b7575756c011651539500937600a26976569f695195946b6c766b796c759c696152795279527953517600a26976539f699451958c6b6c766b796c756b7575756c011651539551937600a26976569f695195946b6c766b796c759c696152795279527953527600a26976539f699451958c6b6c766b796c756b7575756c011651539552937600a26976569f695195946b6c766b796c759c697575757558795c799c777777777777777777777777777777777777
Unlocking script:
000000000000017b0300000003000000
The following locking and unlocking script combo pass on python but fail on our interpreter.
from bitcoinx import Script, TxOutput, Tx, TxInput, TxInputContext, InterpreterLimits, MinerPolicy
prev_locking_script = Script.from_hex('510140000000000061587961007901687f7700005279517f75007f77007901fd8763615379537f75517f77007901007e81517a7561537a75527a527a5379535479937f75537f77527a75517a67007901fe8763615379557f75517f77007901007e81517a7561537a75527a527a5379555479937f75557f77527a75517a67007901ff8763615379597f75517f77007901007e81517a7561537a75527a527a5379595479937f75597f77527a75517a67615379517f75007f77007901007e81517a7561537a75527a527a5379515479937f75517f77527a75517a6868685179517a75517a75517a75517a7561517a7561610079007982775179517951947f755179549451947f77007981527951799454945194517a75517a75517a75517a7561517951797f75537a75527a527a610000537953797f770079537a75527a527a00527a75517a756161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561597a75587a587a587a587a587a587a587a587a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161587a75577a577a577a577a577a577a577a61005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561577a75567a567a567a567a567a567a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161567a75557a557a557a557a557a615c796100792097dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff0262102ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382210ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800206c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810201008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c011179011179855679aa616100790079517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81517a756157795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff0061517951795179517997527a75517a5179009f635179517993527a75517a685179517a75517a7561527a75517a517951795296a0630079527994527a75517a68537982775279827754527993517993013051797e527e53797e57797e527e52797e5579517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7e56797e0079517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a756100795779ac517a75517a75517a75517a75517a75517a75517a75517a75517a7561517a7561695f79011179ac69607959007600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959517600a26976529f695295946b6c766b796c766b796c75517a517a758767006864607959517600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959007600a26976529f695295946b6c766b796c766b796c75517a517a758767006867516869607959007600a26976529f695295946b6c766b796c766b796c75517a517a75876358007600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958007600a26976529f695295946b6c766b796c766b796c75007a517a755e7994587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757558517600a26976529f695295946b6c766b796c766b796c75007a517a755e7993567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a75756758517600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958517600a26976529f695295946b6c766b796c766b796c75007a517a755e7994567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a757558007600a26976529f695295946b6c766b796c766b796c75007a517a755e7993587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757568616158007600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75616159007600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e6159517600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75617e6159517600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e5579615179007982775480517951797e0051807e517a75517a75617e517a75616100795d79007958806152790079827700517902fd009f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a75675179030000019f6301fd615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f6301fe615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179090000000000000000019f6301ff615279585179517951938000795179827751947f75007f77517a75517a75517a75617e517a7568686868007953797e517a75517a75517a75617e517a75517a75610079aa615f79007982775179517958947f7551790128947f77517a75517a756187777777777777777777777777777777777777776a2102d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645c01642102eec2540661b0c39d271570742413bd02932dd0093493fd0beced0b7f93addec4004700000000')
unlocking_script = Script.from_hex('2102d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645c47304402200b1aec4c835daf464cae038e9cb0354ba5675bd5cb8173f30cb8f0f3afc4b98802200857d6c199fa166553fa145906c1ef88159774ed30c727611d0a35c0f60d36b6412102eec2540661b0c39d271570742413bd02932dd0093493fd0beced0b7f93addec401284ddc110100000011b50e4920bc7f0bbd4ae0a0a649b8ded6f187c889c0829bfc7dea9345a5788e3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e706650445884e5db9de218238671572340b207ee85b628074e7e467096c267266bff77a400000000fd3d11510140000000000061587961007901687f7700005279517f75007f77007901fd8763615379537f75517f77007901007e81517a7561537a75527a527a5379535479937f75537f77527a75517a67007901fe8763615379557f75517f77007901007e81517a7561537a75527a527a5379555479937f75557f77527a75517a67007901ff8763615379597f75517f77007901007e81517a7561537a75527a527a5379595479937f75597f77527a75517a67615379517f75007f77007901007e81517a7561537a75527a527a5379515479937f75517f77527a75517a6868685179517a75517a75517a75517a7561517a7561610079007982775179517951947f755179549451947f77007981527951799454945194517a75517a75517a75517a7561517951797f75537a75527a527a610000537953797f770079537a75527a527a00527a75517a756161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561597a75587a587a587a587a587a587a587a587a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161587a75577a577a577a577a577a577a577a61005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561577a75567a567a567a567a567a567a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161567a75557a557a557a557a557a615c796100792097dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff0262102ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382210ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800206c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810201008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c011179011179855679aa616100790079517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81517a756157795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff0061517951795179517997527a75517a5179009f635179517993527a75517a685179517a75517a7561527a75517a517951795296a0630079527994527a75517a68537982775279827754527993517993013051797e527e53797e57797e527e52797e5579517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7e56797e0079517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a756100795779ac517a75517a75517a75517a75517a75517a75517a75517a75517a7561517a7561695f79011179ac69607959007600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959517600a26976529f695295946b6c766b796c766b796c75517a517a758767006864607959517600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959007600a26976529f695295946b6c766b796c766b796c75517a517a758767006867516869607959007600a26976529f695295946b6c766b796c766b796c75517a517a75876358007600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958007600a26976529f695295946b6c766b796c766b796c75007a517a755e7994587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757558517600a26976529f695295946b6c766b796c766b796c75007a517a755e7993567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a75756758517600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958517600a26976529f695295946b6c766b796c766b796c75007a517a755e7994567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a757558007600a26976529f695295946b6c766b796c766b796c75007a517a755e7993587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757568616158007600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75616159007600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e6159517600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75617e6159517600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e5579615179007982775480517951797e0051807e517a75517a75617e517a75616100795d79007958806152790079827700517902fd009f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a75675179030000019f6301fd615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f6301fe615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179090000000000000000019f6301ff615279585179517951938000795179827751947f75007f77517a75517a75517a75617e517a7568686868007953797e517a75517a75517a75617e517a75517a75610079aa615f79007982775179517958947f7551790128947f77517a75517a756187777777777777777777777777777777777777776a2102d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645c01642102eec2540661b0c39d271570742413bd02932dd0093493fd0beced0b7f93addec4004700000000e093040000000000ffffffffa3859e0eb272976e0eb3bab2773c035d2c5be10c7bee63433285bb98744c14800000000041000000030e6403')
new_locking_script = Script.from_hex('510140000000000061587961007901687f7700005279517f75007f77007901fd8763615379537f75517f77007901007e81517a7561537a75527a527a5379535479937f75537f77527a75517a67007901fe8763615379557f75517f77007901007e81517a7561537a75527a527a5379555479937f75557f77527a75517a67007901ff8763615379597f75517f77007901007e81517a7561537a75527a527a5379595479937f75597f77527a75517a67615379517f75007f77007901007e81517a7561537a75527a527a5379515479937f75517f77527a75517a6868685179517a75517a75517a75517a7561517a7561610079007982775179517951947f755179549451947f77007981527951799454945194517a75517a75517a75517a7561517951797f75537a75527a527a610000537953797f770079537a75527a527a00527a75517a756161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561597a75587a587a587a587a587a587a587a587a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161587a75577a577a577a577a577a577a577a61005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a7561577a75567a567a567a567a567a567a6161005279005179547951937f7554797f77815479768b567a75557a557a557a557a557a750079014c9f630079547a75537a537a537a527955795579937f7555797f77527a75517a670079014c9c63615279557951937f7555797f77007901007e81517a7561547a75537a537a537a54795193557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014d9c63615279557952937f7555797f77007901007e81517a7561547a75537a537a537a54795293557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670079014e9c63615279557954937f7555797f77007901007e81517a7561547a75537a537a537a54795493557a75547a547a547a547a547975527955795579937f7555797f77527a75517a670069686868685479547993557a75547a547a547a547a5479755179517a75517a75517a75517a75618161567a75557a557a557a557a557a615c796100792097dfd76851bf465e8f715593b217714858bbe9570ff3bd5e33840a34e20ff0262102ba79df5f8ae7604a9830f03c7933028186aede0675a16f025dc4f8be8eec0382210ac407f0e4bd44bfc207355a778b046225a7068fc59ee7eda43ad905aadbffc800206c266b30e6a1319c66dc401e5bd6b432ba49688eecd118297041da8074ce0810201008ce7480da41702918d1ec8e6849ba32b4d65b1e40dc669c31a1e6306b266c011179011179855679aa616100790079517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81517a756157795679567956795679537956795479577995939521414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff0061517951795179517997527a75517a5179009f635179517993527a75517a685179517a75517a7561527a75517a517951795296a0630079527994527a75517a68537982775279827754527993517993013051797e527e53797e57797e527e52797e5579517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7e56797e0079517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a75517a756100795779ac517a75517a75517a75517a75517a75517a75517a75517a75517a7561517a7561695f79011179ac69607959007600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959517600a26976529f695295946b6c766b796c766b796c75517a517a758767006864607959517600a26976529f695295946b6c766b796c766b796c75517a517a7587635e7959007600a26976529f695295946b6c766b796c766b796c75517a517a758767006867516869607959007600a26976529f695295946b6c766b796c766b796c75517a517a75876358007600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958007600a26976529f695295946b6c766b796c766b796c75007a517a755e7994587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757558517600a26976529f695295946b6c766b796c766b796c75007a517a755e7993567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a75756758517600a26976529f695295946b6c766b796c766b796c75007a517a755e79a26958517600a26976529f695295946b6c766b796c766b796c75007a517a755e7994567a75557a557a557a557a557a58517600a26976529f695295946b6c766b796c766b796c75007a517a757558007600a26976529f695295946b6c766b796c766b796c75007a517a755e7993587a75577a577a577a577a577a577a577a58007600a26976529f695295946b6c766b796c766b796c75007a517a757568616158007600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75616159007600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e6159517600a26976529f695295946b6c766b796c766b796c75517a517a7500798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a75617e6159517600a26976529f695295946b6c766b796c766b796c75007a517a75610079009c6301006700796800798277005179014c9f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a756751790200019f63014c615279515179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179030000019f63014d615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f63014e615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a7567006968686868007953797e517a75517a75517a7561517a75617e5579615179007982775480517951797e0051807e517a75517a75617e517a75616100795d79007958806152790079827700517902fd009f63615179515179517951938000795179827751947f75007f77517a75517a75517a7561517a75675179030000019f6301fd615279525179517951938000795179827751947f75007f77517a75517a75517a75617e517a756751790500000000019f6301fe615279545179517951938000795179827751947f75007f77517a75517a75517a75617e517a75675179090000000000000000019f6301ff615279585179517951938000795179827751947f75007f77517a75517a75517a75617e517a7568686868007953797e517a75517a75517a75617e517a75517a75610079aa615f79007982775179517958947f7551790128947f77517a75517a756187777777777777777777777777777777777777776a2102d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645c013c2102eec2540661b0c39d271570742413bd02932dd0093493fd0beced0b7f93addec401284800000000')
tx_version = 1
tx_locktime = 0x00000000
utxo_satoshis = 300000
utxo = TxOutput(utxo_satoshis, prev_locking_script)
utxo_idx = 0
n_sequence = 0xffffffff
prev_txid = bytes.fromhex('a477ff6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458')[::-1]
curr_in = TxInput(prev_txid, utxo_idx, unlocking_script, n_sequence)
curr_tx = Tx(tx_version, [curr_in], [], tx_locktime)
input_idx = 0
context = TxInputContext(curr_tx, input_idx, utxo, is_utxo_after_genesis=True)
tx_out = TxOutput(value=222222, script_pubkey=new_locking_script)
context.tx.outputs.append(tx_out)
policies = [
# A fairly restrictive policy
MinerPolicy(100_000, 64, 20_000, 1_000, 16),
# A loose policy
MinerPolicy(10_000_000, 256, 10_000_000, 32_000, 256)
]
interpreter_limits = InterpreterLimits(policies[1], is_genesis_enabled=True, is_consensus=True, base_flags='consensus')
print(context.verify_input(interpreter_limits))
As this lib is based on full node running on bsvd, I wonder if it can support RPC connection on official bitcoind node?
It seems bsvd couldn't keep up with official upgrades, so it will also raise issues on go-bt I guess...
Output 0 https://classic.whatsonchain.com/tx/6148dd49af06ecec4e0f31cf3b1c6f6bb499a8bfab267c93a8b74deb6cf838b5
panic: runtime error: index out of range [0] with length 0
goroutine 33104 [running]:
github.com/libsv/go-bt/bscript.(*Script).IsMultisigOut(0xc002b4ef18?)
github.com/libsv/[email protected]/bscript/script.go:305 +0xe5
Replicate:
package main
import (
"github.com/libsv/go-bt"
)
func main() {
tx, err := bt.NewTxFromString(tx)
if err != nil {
panic(err)
}
print(tx.GetTxID())
for _, output := range tx.Outputs {
output.LockingScript.IsMultisigOut()
}
}
var tx = "01000000022e131b16fa4d47669b8b3a3054fb0662234372124b6478b9fbcec2430ad17bba010000006a47304402206cb269cc20a402db8eefc5a3249bd86ee868331ed3bd006ecb99c56c751069fe02203536e06213f16b0febc39c7b72092732bfdf3f76a40b4a174b3d7b629ba9d8b74121026e83f3dcd977f6da9d6b349cd8928ae64cf1d5b2584b31144af80eb4e924af86ffffffff9ab6798431849f8f109e3144b6d48a267bee184b5100cca41ad17e98300aec0b000000006a47304402205ba281ed79f25a1ff9b5045b486ea7e412555802c42ea50f107143b3d4781edc02207d2ec6d42087407d072c755618b8ebb43416470261bf571d8511339e66a0a8814121026e83f3dcd977f6da9d6b349cd8928ae64cf1d5b2584b31144af80eb4e924af86ffffffff02e803000000000000084c000400d3016787dcb30100000000001976a91451015d3f83aed2d79c084877dfee20f32769229a88ac00000000"
Refactor to use tx.SignOff
instead of tx.Unlock
and mainly so that we have unsignedTx
instead of lockedTx
or incompleteTx
There are 3 conflicting examples in this repo for the same transaction.
Package module names don't match the filestructure... unintuitive and messy.
Generally needs harmonising with the readme so its enjoyable to use.
Currently, OP_RETURN
after genesis are handled using a special case error code, ErrOK
, which results in some pretty funky and unintuitive code.
So for example, on OP_RETURN
, we check to see if we're in a post genesis context, and if we are and aren't in a conditional, we return success()
:
func opcodeReturn(op *ParsedOpcode, t *thread) error {
if !t.afterGenesis {
return errs.NewError(errs.ErrEarlyReturn, "script returned early")
}
t.earlyReturnAfterGenesis = true
if len(t.condStack) == 0 {
// Terminate the execution as successful. The remaining of the script does not affect the validity (even in
// presence of unbalanced IFs, invalid opcodes etc)
return success()
}
return nil
}
Success is just a wrapping for ErrOK
:
func success() errs.Error {
return errs.NewError(errs.ErrOK, "success")
}
Then, in the thread executor, when we execute the opcode we check for this special case error:
if err := t.executeOpcode(opcode); err != nil {
if ok := errs.IsErrorCode(err, errs.ErrOK); ok {
// If returned early, move onto the next script
t.shiftScript()
return t.scriptIdx >= len(t.scripts), nil
}
return true, err
}
This creates sections in our codebase where an error mightn't actually be an error, and it would be really nice if we could move away from this, even if it was something as simple as a state flag on interpreter.thread
.
We should standardise/define our errors...
Right now the JSON structure just follows what's in the bitcoin node (as well as WoC). Unfortunately that isn't the most consistent and clean structure (value/satoshis, scriptsig/scriptpubkey, etc.). I don't think we should constrain the library to fit that. go-bt should be as consistent and clean as possible and we can just add a tx.ToNodeJSON() method or something like that to compensate for that in the short term and then at some point we'll probably just deprecate that.
Is it possible to have tx.GetInputs()[0].PreviousTxIDAsBytes
?
Thanks a lot.
Make internal struct fields private and no accessible externally except throught the right functions.
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.