Bitcoin.jl Documentation
A Bitcoin library for Julia
Functions
Address
Bitcoin.h160_2_address
— Function.Vector{UInt8} -> String
Returns a String representing a Bitcoin address
Missing docstring for address
. Check Documenter's build log for details.
Bitcoin.wif
— Function.wif(kp::KeyPair, compressed::Bool=true, testnet::Bool=false) -> String
Returns a KeyPair in Wallet Import Format Compressed is set to true if not provided. Testnet is set to false by default.
Transaction
Missing docstring for Bitcoin.txfetch
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txparse
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txserialize
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txhash
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txid
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txfee
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txsighash256
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txsighash
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txinputverify
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txverify
. Check Documenter's build log for details.
Bitcoin.txsigninput
— Function.Signs the input using the private key
Bitcoin.txpushsignature
— Function.Append Signature to the Script Pubkey of TxIn at index
Bitcoin.iscoinbase
— Function.Returns whether this transaction is a coinbase transaction or not
Bitcoin.coinbase_height
— Function.Returns the height of the block this coinbase transaction is in Returns nothing
if this transaction is not a coinbase transaction
Inbound Transaction
Missing docstring for Bitcoin.txinparse
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txinserialize
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txinvalue
. Check Documenter's build log for details.
Missing docstring for Bitcoin.txin_scriptpubkey
. Check Documenter's build log for details.
Outband Transaction
Bitcoin.txoutparse
— Method. txoutparse(s::IOBuffer) -> TxOut
Takes a byte stream and parses the tx_output at the start return a TxOut object
Missing docstring for Bitcoin.txoutserialize(tx::TxOut)
. Check Documenter's build log for details.
Script
Bitcoin.scriptparse
— Function.scriptparse(::GenericIOBuffer) -> Script
Returns a Script object from an IOBuffer
Missing docstring for Bitcoin.scriptevaluate
. Check Documenter's build log for details.
Bitcoin.p2pkh_script
— Function.Takes a hash160 && returns the p2pkh scriptPubKey
Bitcoin.p2sh_script
— Function.Takes a hash160 && returns the p2sh scriptPubKey
Bitcoin.is_p2pkh
— Function.Returns whether this follows the OPDUP OPHASH160 <20 byte hash> OPEQUALVERIFY OPCHECKSIG pattern.
Bitcoin.is_p2sh
— Function.Returns whether this follows the OPHASH160 <20 byte hash> OPEQUAL pattern.
Bitcoin.script2address
— Function.Returns the address corresponding to the script
OP
Bitcoin.op_ripemd160
— Function.Return RIPEMD160 hash of top item
Bitcoin.op_sha1
— Function.Return SHA1 hash of top item
Bitcoin.op_sha256
— Function.Return SHA256 hash of top item
Bitcoin.op_hash160
— Function.Return RIPEMD160(SHA256(x)) hash of top item
Bitcoin.op_hash256
— Function.Return SHA256(SHA256(x)) hash of top item
Bitcoin.op_checksig
— Function.Pop a public key and signature and validate the signature for the transaction's hashed data, return TRUE if matching
Bitcoin.op_checksigverify
— Function.Same as CHECKSIG, then OP_VERIFY to halt if not TRUE
Bitcoin.op_checkmultisig
— Function.Run CHECKSIG for each pair of signature and public key provided. All must match. Bug in implementation pops an extra value, prefix with OP_NOP as workaround
Bitcoin.op_checkmultisigverify
— Function.Same as CHECKMULTISIG, then OP_VERIFY to halt if not TRUE
Bitcoin.op_checklocktimeverify
— Function.Marks transaction as invalid if the top stack item is greater than the transaction's nLockTime field, otherwise script eveluation continues as though an OP_NOP was executed. Transaction is also invalid if 1. the stack is empty; or 2. the top stack item is negative; or 3. the top stack item is greater than or equal to 500000000 while the transaction's nLockTime field is less than 500000000, or vice versa; or 4. the input's nSequence field is equal to 0xffffffff. The precise semantics are described in BIP-65
Bitcoin.op_checksequenceverify
— Function.Marks transaction as invalid if the relative lock time of the input (enforced by BIP-68 with nSequence) is not equal to or longer than the value of the top stack item. The precise semantics are described in BIP-112
Block
Missing docstring for Bitcoin.blockparse
. Check Documenter's build log for details.
Secp256k1.serialize
— Function.serialize(P::Point; compressed::Bool) -> Vector{UInt8}
Serialize a Point
to its SEC format
compressed=true
by default
serialize(x::Signature) -> Vector{UInt8}
Serialize a Signature
to DER format
serialize(n::CompactSizeUInt) -> Vector{UInt8}
Returns the bytes serialization of a CompactSizeUInt
serialize(tx::TxIn) -> Vector{UInt8}
Returns the byte serialization of the transaction input
serialize(tx::TxOut) -> Vector{UInt8}
Returns the byte serialization of the transaction output
serialize(tx::Tx) -> Vector{UInt8}
Returns the byte serialization of the transaction
Returns the 80 byte block header
Returns the byte serialization of the entire network message
Peer -> Vector{UInt8}
Returns the serialization of a Peer
serialize(version::VersionMessage) -> Vector{UInt8}
Serialize this message to send over the network
Serialize this message to send over the network protocol version is 4 bytes little-endian number of hashes is a varint start block is in little-endian end block is also in little-endian
Base.hash
— Function.hash(x[, h::UInt])
Compute an integer hash code such that isequal(x,y)
implies hash(x)==hash(y)
. The optional second argument h
is a hash code to be mixed with the result.
New types should implement the 2-argument form, typically by calling the 2-argument hash
method recursively in order to mix hashes of the contents with each other (and with h
). Typically, any type that implements hash
should also implement its own ==
(hence isequal
) to guarantee the property mentioned above. Types supporting subtraction (operator -
) should also implement widen
, which is required to hash values inside heterogeneous arrays.
Binary hash of the legacy serialization
Returns the hash256 interpreted little endian of the block
Bitcoin.id
— Function.id(tx::Tx) -> String
Returns an hexadecimal string of the transaction hash
Human-readable hexadecimal of the block hash
Bitcoin.bip9
— Function.Returns whether this block is signaling readiness for BIP9
BIP9 is signalled if the top 3 bits are 001
remember version is 32 bytes so right shift 29 (>> 29) and see if
that is 001
Bitcoin.bip91
— Function.Returns whether this block is signaling readiness for BIP91
BIP91 is signalled if the 5th bit from the right is 1
shift 4 bits to the right and see if the last bit is 1
Bitcoin.bip141
— Function.Returns whether this block is signaling readiness for BIP141
BIP91 is signalled if the 2nd bit from the right is 1
shift 1 bit to the right and see if the last bit is 1
Bitcoin.target
— Function.Returns the proof-of-work target based on the bits
last byte is exponent
the first three bytes are the coefficient in little endian
the formula is: coefficient * 256**(exponent-3)
Bitcoin.difficulty
— Function.Returns the block difficulty based on the bits
difficulty is (target of lowest difficulty) / (block's target)
lowest difficulty has bits that equal 0xffff001d
Bitcoin.check_pow
— Function.Returns whether this block satisfies proof of work
get the hash256 of the serialization of this block
interpret this hash as a little-endian number
return whether this integer is less than the target
Buy me a cup of coffee
Index
Base.hash
Bitcoin.bip141
Bitcoin.bip9
Bitcoin.bip91
Bitcoin.check_pow
Bitcoin.coinbase_height
Bitcoin.difficulty
Bitcoin.h160_2_address
Bitcoin.id
Bitcoin.is_p2pkh
Bitcoin.is_p2sh
Bitcoin.iscoinbase
Bitcoin.op_checklocktimeverify
Bitcoin.op_checkmultisig
Bitcoin.op_checkmultisigverify
Bitcoin.op_checksequenceverify
Bitcoin.op_checksig
Bitcoin.op_checksigverify
Bitcoin.op_hash160
Bitcoin.op_hash256
Bitcoin.op_ripemd160
Bitcoin.op_sha1
Bitcoin.op_sha256
Bitcoin.p2pkh_script
Bitcoin.p2sh_script
Bitcoin.script2address
Bitcoin.scriptparse
Bitcoin.target
Bitcoin.txoutparse
Bitcoin.txpushsignature
Bitcoin.txsigninput
Bitcoin.wif
Secp256k1.serialize