@@ -15,22 +15,22 @@ defmodule BitcoinLib.Transaction.Output do
1515 Extracts a transaction output from a bitstring
1616
1717 ## Examples
18- iex> <<0xf0ca052a010000001976a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac00000000::304>>
19- ...> |> BitcoinLib.Transaction.Output.extract_from
20- {
21- :ok,
22- %BitcoinLib.Transaction.Output{
23- value: 4999990000,
24- script_pub_key: [
25- %BitcoinLib.Script.Opcodes.Stack.Dup{},
26- %BitcoinLib.Script.Opcodes.Crypto.Hash160{},
27- %BitcoinLib.Script.Opcodes.Data{value: <<0xcbc20a7664f2f69e5355aa427045bc15e7c6c772::160>>},
28- %BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{},
29- %BitcoinLib.Script.Opcodes.Crypto.CheckSig{script: <<0x76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac::200>>}
30- ]
31- },
32- <<0, 0, 0, 0>>
33- }
18+ iex> <<0xf0ca052a010000001976a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac00000000::304>>
19+ ...> |> BitcoinLib.Transaction.Output.extract_from
20+ {
21+ :ok,
22+ %BitcoinLib.Transaction.Output{
23+ value: 4999990000,
24+ script_pub_key: [
25+ %BitcoinLib.Script.Opcodes.Stack.Dup{},
26+ %BitcoinLib.Script.Opcodes.Crypto.Hash160{},
27+ %BitcoinLib.Script.Opcodes.Data{value: <<0xcbc20a7664f2f69e5355aa427045bc15e7c6c772::160>>},
28+ %BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{},
29+ %BitcoinLib.Script.Opcodes.Crypto.CheckSig{script: <<0x76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac::200>>}
30+ ]
31+ },
32+ <<0, 0, 0, 0>>
33+ }
3434 """
3535 @ spec extract_from ( binary ( ) ) :: { :ok , % Output { } , bitstring ( ) } | { :error , binary ( ) }
3636 def extract_from ( << value :: little - 64 , remaining :: bitstring >> ) do
@@ -48,20 +48,19 @@ defmodule BitcoinLib.Transaction.Output do
4848 Encodes an output into a bitstring
4949
5050 ## Examples
51-
52- iex> %BitcoinLib.Transaction.Output{
53- ...> script_pub_key: [
54- ...> %BitcoinLib.Script.Opcodes.Stack.Dup{},
55- ...> %BitcoinLib.Script.Opcodes.Crypto.Hash160{},
56- ...> %BitcoinLib.Script.Opcodes.Data{value: <<0xf86f0bc0a2232970ccdf4569815db500f1268361::160>>},
57- ...> %BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{},
58- ...> %BitcoinLib.Script.Opcodes.Crypto.CheckSig{}
59- ...> ],
60- ...> value: 129000000
61- ...> } |> BitcoinLib.Transaction.Output.encode
62- <<0x4062b00700000000::64>> <> # value
63- <<0x19::8>> <> # script_pub_key size
64- <<0x76a914f86f0bc0a2232970ccdf4569815db500f126836188ac::200>> # script_pub_key
51+ iex> %BitcoinLib.Transaction.Output{
52+ ...> script_pub_key: [
53+ ...> %BitcoinLib.Script.Opcodes.Stack.Dup{},
54+ ...> %BitcoinLib.Script.Opcodes.Crypto.Hash160{},
55+ ...> %BitcoinLib.Script.Opcodes.Data{value: <<0xf86f0bc0a2232970ccdf4569815db500f1268361::160>>},
56+ ...> %BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{},
57+ ...> %BitcoinLib.Script.Opcodes.Crypto.CheckSig{}
58+ ...> ],
59+ ...> value: 129000000
60+ ...> } |> BitcoinLib.Transaction.Output.encode
61+ <<0x4062b00700000000::64>> <> # value
62+ <<0x19::8>> <> # script_pub_key size
63+ <<0x76a914f86f0bc0a2232970ccdf4569815db500f126836188ac::200>> # script_pub_key
6564 """
6665 @ spec encode ( % Output { } ) :: bitstring ( )
6766 def encode ( % Output { } = output ) do
0 commit comments