package bitcoinml
Install
Dune Dependency
Authors
Maintainers
Sources
md5=bc06a6aaa41e1c443d8c5179241e4eb7
sha512=4f9004cb956117566c4643f6a64ffa03f0469866df6fd77f50316b4a42b50ff3be0a866cdfe20fdd4ae733d056dab18948aabe2187e9695aee46cd3981902e45
Description
Bitcoin data-structures library for OCaml. Modules documentation is available at https://dakk.github.io/bitcoinml/
Published: 08 Mar 2019
README
BitcoinML
Bitcoin data-structures library for OCaml.
Features
Bitcoinml provides support for the following data-structures:
Address (with also bech32 addresses)
Block
Block_lazy (lazy block evaluation)
Hash
Merkleroot
Script (script execution, common pattern recognizer)
Tx (In, Out, Witness)
Varint (CompactSize)
Params (network parameters for BTC, XTN and BCH)
Segwit
The library is now fully compatible with segwit transactions (from version 0.3.0). The parser automatically recognizes a segwit transaction, and parses/serializes it correctly. For those who want to avoid this behaviour, there are the *_legacy
functions which disable segwit.
Sexp serialization
For every type of the library, bitcoinml also offers sexp to_string
readable serialization:
(
(hash 8139979112e894a14f8370438a471d23984061ff83a9eba0bc7a34433327ec21)
(version 1)
(txin(
(
(out_hash 56f87210814c8baef7068454e517a70da2f2103fc3ac7f687e32a228dc80e115)
(out_n 3)
(script(((OP_DATA 22 00141d7cd6c75c2e86f4cbf98eaed221b30bd9a0b928))23))
(witness_script(
(3045022100f764287d3e99b1474da9bec7f7ed236d6c81e793b20c4b5aa1f3051b9a7daa63022016a198031d5554dbb855bdbe8534776a4be6958bd8d530dc001c32b828f6f0ab01 038262a6c6cec93c2d3ecd6c6072efea86d02ff8e3328bbd0242b20af3425990ac)))
(sequence -1))))
(txout(
(
(value 99987100)
(script((OP_DUP OP_HASH160(OP_DATA 20 1d7cd6c75c2e86f4cbf98eaed221b30bd9a0b928)OP_EQUALVERIFY OP_CHECKSIG)25)))))
(locktime 0)
(size 108)
(vsize 136)
(witness((
(hash 6bf4e4dfb860cf0906f49c836700b130ac78cc391c72a0911c94cdec4dcb10ec)
(marker 0)
(flag 1)
(size 110))))
)
This implies that for each type there are the t_of_sexp
and sexp_of_t
conversion functions.
Installation
opam install bitcoinml
Documentation
The odoc autogenerated documentation is available here: https://dakk.github.io/bitcoinml/
Examples
You can find some examples in the test/test.ml file.
Block parse/serialize: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L101
Block header parse/serialize: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L92
Merkleroot of transcation list: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L109
Address conversion: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L130
Transaction parse/serialize: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L55
Segwit transaction parse/serialize: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L64
Output script spendable by: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L50
Script parse: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L30
Script serialize: https://github.com/dakk/bitcoinml/blob/master/test/test.ml#L41
License
Copyright (c) 2016-2017 Davide Gessa
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Donations
Feel free to donate bitcoin to the developer: 13TRVwiqLMveg9aPAmZgcAix5ogKVgpe4T