Comments (8)
Hah, I just pushed a change that allows you to do this: mhanne@5366a03
Now you can give it just the prev_out_hash, index and pk_script to create an input:
i.prev_out(prev_out.get_tx.hash, prev_out.tx_idx, prev_out.pk_script)
from bitcoin-ruby.
@mhanne thanks, just to be clear, do they take plain hex string arugments? (or do they require objects / binary strings?)
For example, would the following work?
# https://blockchain.info/tx/108cb6bc3c8607a707dde49fceb10ad7bbe037260a6fd9e1b0e2f30e73180481/0
i.prev_out("108cb6bc3c8607a707dde49fceb10ad7bbe037260a6fd9e1b0e2f30e73180481", 0, "76a914419fb60d29b320764ed2ae6e77a16648a4e1853c88ac")
from bitcoin-ruby.
Ugh.. I see how this can be confusing, actually the hash is hex-encoded, but the pk_script is expected as a raw binary string... It's not consistent in itself, but it's the format that usually comes out of the other helpers so I figured it was the most intuitive. Should add more documentation about it though.
from bitcoin-ruby.
Yeah it would be nice to have a bit more consistency but I think for now this should be fine:
It does seem a little bit jenky haha
i.prev_out("108cb6bc3c8607a707dde49fceb10ad7bbe037260a6fd9e1b0e2f30e73180481", 0, ["76a914419fb60d29b320764ed2ae6e77a16648a4e1853c88ac"].pack("H*"))
Thank you very much for this commit. Do you have plans to add documentations for this?
I can also do it if you don't plan to add change the interface which is i.prev_out(hex_string, integer, binary_string)
As for what is intuitive, I feel that a lot of developers might not run a full node with bitcoin-ruby. I personally use an API (which outputs hex strings) and use bitcoin ruby to handle the protocol. So binary string is a bit harder to work with.
from bitcoin-ruby.
Hmm, to be honest, I still think it makes more sense this way... It's awkward in your case, because you are getting the tx from blockchain.info. But if you get it from bitcoin-ruby, these are the formats you have at hand for the tx hash / pk script and they are used like this everywhere else.
The deeper reason for the difference is that the pk_script is deserialized from the binary tx payload received from the network, but the tx hash is computed from that data. Transforming the pk_script into hex every time (and back at some point) would be a huge performance hit. And always having to convert the hash would be a huge inconvenience, since everyone only uses the hex form for it (since it's not actually included in the blockchain and therefore not that space-critical).
I think I will change the interface to also make it accept a single TxOut object. But I don't know when I'll get to it, and since these particular parameters won't change and still be awkward from your perspective, it would be great if you could add some comments about it :)
from bitcoin-ruby.
Thanks for the explaination, in this case I think this makes sense. Let's keep the interface this way then.
I am happy to add some documentation for i.prev_out(hex_string, integer, binary_string)
and will make a pull request in a separate issue
from bitcoin-ruby.
@mhanne do you have plans to deploy this latest to rubygems anytime soon?
from bitcoin-ruby.
The gem is mostly a fallback, the suggested way to use bitcoin-ruby is to enter the git repo in your Gemfile or clone/build it yourself. The lian/master branch should always be stable, and I try to keep mine that way too (albeit with less success). Usually @lian only updates the gem when there are important bugfixes (which there are now... ;)
from bitcoin-ruby.
Related Issues (20)
- raise exceptions instead of returning NIL
- How to convert transaction to hex format? HOT 3
- How to convert hash160 script to Script object?
- Webbtc is not longer alive, better remove it from the README
- Add BitcoinSV Support HOT 1
- Supporting openssl 1.1.0 HOT 1
- litecoin HOT 1
- Why do we need openssl.rb?
- Invalid DLL file names on Windows OpenSSL 1.1.0 / 1.1.1
- Mac os iterm2 fish 'irb' terminated by signal SIGABRT (Abort)
- Is this gem is threadsafe? HOT 5
- Connect Node
- Undefined method 'bytesize' for nil:NilClass Error HOT 9
- Can this be used for dogecoin? HOT 1
- undefined method `each' for nil:NilClass (NoMethodError) HOT 9
- How do I correctly use the second output that sends remaining btc back to me?
- Can an the value of a prev_out be less than the amount I am sending?
- undefined method `dsa_sign_asn1' HOT 4
- Supporting openssl 3.0 HOT 1
- Add bitcoin as a topic to this repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitcoin-ruby.