Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .dialyzer_ignore.exs

This file was deleted.

37 changes: 5 additions & 32 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,22 @@ name: Elixir CI
on: [push, pull_request]

jobs:
build_with_opt_24:
name: Build and test older versions ${{matrix.elixir}}-otp-${{matrix.otp}}
runs-on: ubuntu-latest
strategy:
matrix:
otp: ['24.0']
elixir: ['1.12.0', '1.13.0', '1.14.0']
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Restore dependencies cache
uses: actions/cache@v2
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
- name: format and lint
run: mix lint.all

build_with_opt_25:
build_with_opt_26:
name: Build and test ${{matrix.elixir}}-otp-${{matrix.otp}}
runs-on: ubuntu-latest
strategy:
matrix:
otp: ['25.0']
elixir: ['1.13.0', '1.14.0']
otp: ['27.0']
elixir: ['1.18.1']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-elixir@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Restore dependencies cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.16.1-otp-26
erlang 26.2.1
elixir 1.18.1-otp-27
erlang 27.0.1
2 changes: 1 addition & 1 deletion lib/bech32.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Bitcoinex.Bech32 do
import Bitwise

@gen [0x3B6A57B2, 0x26508E6D, 0x1EA119FA, 0x3D4233DD, 0x2A1462B3]
@data_charset_list 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
@data_charset_list ~c"qpzry9x8gf2tvdw0s3jn54khce6mua7l"
@data_charset_map @data_charset_list
|> Enum.zip(0..Enum.count(@data_charset_list))
|> Enum.into(%{})
Expand Down
6 changes: 3 additions & 3 deletions lib/segwit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ defmodule Bitcoinex.Segwit do

defp is_program_length_valid?(_, _), do: false

defp parse_network('bc'), do: {:ok, :mainnet}
defp parse_network('tb'), do: {:ok, :testnet}
defp parse_network('bcrt'), do: {:ok, :regtest}
defp parse_network(~c"bc"), do: {:ok, :mainnet}
defp parse_network(~c"tb"), do: {:ok, :testnet}
defp parse_network(~c"bcrt"), do: {:ok, :regtest}
defp parse_network(_), do: {:error, :invalid_network}

defp witness_version_to_bech_encoding(0), do: :bech32
Expand Down
4 changes: 3 additions & 1 deletion lib/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ defmodule Bitcoinex.Transaction.In do

input = %In{
prev_txid:
Base.encode16(<<:binary.decode_unsigned(prev_txid, :big)::little-size(256)>>, case: :lower),
Base.encode16(<<:binary.decode_unsigned(prev_txid, :big)::little-size(256)>>,
case: :lower
),
prev_vout: prev_vout,
script_sig: Base.encode16(script_sig, case: :lower),
sequence_no: sequence_no
Expand Down
21 changes: 1 addition & 20 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule Bitcoinex.MixProject do
elixir: "~> 1.11",
package: package(),
start_permanent: Mix.env() == :prod,
dialyzer: dialyzer(),
deps: deps(),
aliases: aliases(),
description: description(),
Expand All @@ -27,7 +26,6 @@ defmodule Bitcoinex.MixProject do
defp deps do
[
{:credo, "~> 1.6", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.2.0", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.10", only: :test},
{:mix_test_watch, "~> 1.1", only: :dev, runtime: false},
{:stream_data, "~> 0.1", only: :test},
Expand All @@ -41,29 +39,12 @@ defmodule Bitcoinex.MixProject do
[
"lint.all": [
"format --check-formatted",
"credo --strict --only warning",
"dialyzer --halt-exit-status"
"credo --strict --only warning"
],
compile: ["compile --warnings-as-errors"]
]
end

# Dialyzer configuration
defp dialyzer do
[
plt_file: plt_file(),
flags: [
:error_handling
],
ignore_warnings: ".dialyzer_ignore.exs"
]
end

# Use a custom PLT directory for CI caching.
defp plt_file do
{:no_warn, "_plts/dialyzer.plt"}
end

defp package do
[
files: ~w(lib test .formatter.exs mix.exs README.md UNLICENSE CHANGELOG.md SECURITY.md),
Expand Down
12 changes: 10 additions & 2 deletions scripts/decode_psbt.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ defmodule DecodePSBT do
{:ok, script} = Script.parse_script(script_pub_key)
{:ok, address} = Script.to_address(script, :mainnet)

sighash_type =
if sighash_type != nil do
Bitcoinex.Utils.little_to_int(sighash_type)
else
nil
end

note =
if sighash_type != nil and sighash_type != 0x01 do
"🚨🚨🚨 WARNING: NON-STANDARD SIGHASH TYPE: #{sighash_name(sighash_type)} 🚨🚨🚨"
Expand All @@ -116,7 +123,7 @@ defmodule DecodePSBT do
end

# map between a sighash's int and a name
@spec sighash_name(non_neg_integer)
@spec sighash_name(non_neg_integer()) :: String.t()
defp sighash_name(n) do
case n do
0x00 -> "SIGHASH_DEFAULT" # for Segwit v1 (taproot) inputs only
Expand All @@ -125,7 +132,8 @@ defmodule DecodePSBT do
0x03 -> "SIGHASH_SINGLE"
0x81 -> "SIGHASH_ALL/ANYONECANPAY"
0x82 -> "SIGHASH_NONE/ANYONECANPAY"
0x82 -> "SIGHASH_SINGLE/ANYONECANPAY"
0x83 -> "SIGHASH_SINGLE/ANYONECANPAY"
_ -> "UNKNOWN"
end
end

Expand Down
Loading