From 61d64e27e516f3052fd7c976a500a6173df9553a Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Sat, 29 Mar 2025 18:17:30 -0300 Subject: [PATCH 1/9] add anyonecanpay --- scripts/decode_psbt.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/decode_psbt.exs b/scripts/decode_psbt.exs index 0e3b51a..7e1b1da 100644 --- a/scripts/decode_psbt.exs +++ b/scripts/decode_psbt.exs @@ -116,7 +116,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 @@ -125,7 +125,7 @@ defmodule DecodePSBT do 0x03 -> "SIGHASH_SINGLE" 0x81 -> "SIGHASH_ALL/ANYONECANPAY" 0x82 -> "SIGHASH_NONE/ANYONECANPAY" - 0x82 -> "SIGHASH_SINGLE/ANYONECANPAY" + 0x83 -> "SIGHASH_SINGLE/ANYONECANPAY" end end From 04db442c4b776f46cbc5a829852acbfa840bded8 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Sat, 29 Mar 2025 21:23:18 -0300 Subject: [PATCH 2/9] update psbt script --- scripts/decode_psbt.exs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/decode_psbt.exs b/scripts/decode_psbt.exs index 7e1b1da..2d9596a 100644 --- a/scripts/decode_psbt.exs +++ b/scripts/decode_psbt.exs @@ -100,6 +100,8 @@ defmodule DecodePSBT do {:ok, script} = Script.parse_script(script_pub_key) {:ok, address} = Script.to_address(script, :mainnet) + sighash_type = Bitcoinex.Utils.little_to_int(sighash_type) + note = if sighash_type != nil and sighash_type != 0x01 do "🚨🚨🚨 WARNING: NON-STANDARD SIGHASH TYPE: #{sighash_name(sighash_type)} 🚨🚨🚨" @@ -126,6 +128,7 @@ defmodule DecodePSBT do 0x81 -> "SIGHASH_ALL/ANYONECANPAY" 0x82 -> "SIGHASH_NONE/ANYONECANPAY" 0x83 -> "SIGHASH_SINGLE/ANYONECANPAY" + _ -> "UNKNOWN" end end From f669b750997294866a48c50a005915bbb9fbb994 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Mon, 31 Mar 2025 17:07:46 -0400 Subject: [PATCH 3/9] update github actions --- .github/workflows/elixir.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index cb703d8..0c9ef2a 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -35,17 +35,17 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - otp: ['25.0'] - elixir: ['1.13.0', '1.14.0'] + otp: ['25.0', '26.0'] + elixir: ['1.13.0', '1.14.0', '1.16.0'] 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') }} From 161690a6614313d025dcf27150df179af8d4b355 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Mon, 31 Mar 2025 17:15:28 -0400 Subject: [PATCH 4/9] fix cicd --- .github/workflows/elixir.yml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 0c9ef2a..802f434 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -11,14 +11,14 @@ jobs: otp: ['24.0'] elixir: ['1.12.0', '1.13.0', '1.14.0'] 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') }} @@ -35,8 +35,35 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - otp: ['25.0', '26.0'] - elixir: ['1.13.0', '1.14.0', '1.16.0'] + otp: ['25.0'] + elixir: ['1.13.0', '1.14.0'] + steps: + - 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@v4 + 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_26: + name: Build and test ${{matrix.elixir}}-otp-${{matrix.otp}} + runs-on: ubuntu-latest + strategy: + matrix: + otp: ['26.0'] + elixir: ['1.16.0'] steps: - uses: actions/checkout@v4 - name: Set up Elixir From 473a261de430e84a67a3f2ccb8943787e22f0654 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Mon, 31 Mar 2025 17:17:38 -0400 Subject: [PATCH 5/9] fmt --- lib/bech32.ex | 2 +- lib/segwit.ex | 6 +++--- lib/transaction.ex | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/bech32.ex b/lib/bech32.ex index 6e31ab8..5558228 100644 --- a/lib/bech32.ex +++ b/lib/bech32.ex @@ -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(%{}) diff --git a/lib/segwit.ex b/lib/segwit.ex index 1ebeb33..c7c19ca 100644 --- a/lib/segwit.ex +++ b/lib/segwit.ex @@ -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 diff --git a/lib/transaction.ex b/lib/transaction.ex index 1956d03..87e7635 100644 --- a/lib/transaction.ex +++ b/lib/transaction.ex @@ -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 From 91f44bed155ab7822f0c052fe0491ac102582a27 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Tue, 1 Apr 2025 10:40:22 -0400 Subject: [PATCH 6/9] handle nil sighash --- scripts/decode_psbt.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/decode_psbt.exs b/scripts/decode_psbt.exs index 2d9596a..4219c1a 100644 --- a/scripts/decode_psbt.exs +++ b/scripts/decode_psbt.exs @@ -100,7 +100,12 @@ defmodule DecodePSBT do {:ok, script} = Script.parse_script(script_pub_key) {:ok, address} = Script.to_address(script, :mainnet) - sighash_type = Bitcoinex.Utils.little_to_int(sighash_type) + 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 From 77a2ffa14d194a2049bc84bc6ad8e3fce5c30e54 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Tue, 1 Apr 2025 10:45:03 -0400 Subject: [PATCH 7/9] fix cicd --- .github/workflows/elixir.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 802f434..de8865a 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -63,7 +63,7 @@ jobs: strategy: matrix: otp: ['26.0'] - elixir: ['1.16.0'] + elixir: ['1.16.1'] steps: - uses: actions/checkout@v4 - name: Set up Elixir From 79b2d9bf268a4e297e87d2d1246b1ca87779d0f0 Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Wed, 2 Apr 2025 17:02:21 -0400 Subject: [PATCH 8/9] bump versions and remove testing of older elixir versions --- .github/workflows/elixir.yml | 60 ++---------------------------------- .tool-versions | 4 +-- 2 files changed, 5 insertions(+), 59 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index de8865a..f820db7 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -3,67 +3,13 @@ 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@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@v4 - 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: - 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'] - steps: - - 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@v4 - 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_26: name: Build and test ${{matrix.elixir}}-otp-${{matrix.otp}} runs-on: ubuntu-latest strategy: matrix: - otp: ['26.0'] - elixir: ['1.16.1'] + otp: ['27.0'] + elixir: ['1.18.1'] steps: - uses: actions/checkout@v4 - name: Set up Elixir @@ -82,4 +28,4 @@ jobs: - name: Run tests run: mix test - name: format and lint - run: mix lint.all + run: mix format --check-formatted diff --git a/.tool-versions b/.tool-versions index 53ee0b1..3ef3e5a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.16.1-otp-26 -erlang 26.2.1 +elixir 1.18.1-otp-27 +erlang 27.0.1 \ No newline at end of file From d91cf41b44453558c9e9a840f171cdb951d639af Mon Sep 17 00:00:00 2001 From: Sachin Meier Date: Wed, 2 Apr 2025 17:05:10 -0400 Subject: [PATCH 9/9] rm dialyzer --- .dialyzer_ignore.exs | 2 -- .github/workflows/elixir.yml | 2 +- mix.exs | 21 +-------------------- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 .dialyzer_ignore.exs diff --git a/.dialyzer_ignore.exs b/.dialyzer_ignore.exs deleted file mode 100644 index 0d4f101..0000000 --- a/.dialyzer_ignore.exs +++ /dev/null @@ -1,2 +0,0 @@ -[ -] diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index f820db7..c855c16 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -28,4 +28,4 @@ jobs: - name: Run tests run: mix test - name: format and lint - run: mix format --check-formatted + run: mix lint.all diff --git a/mix.exs b/mix.exs index 1f614c5..2f99001 100644 --- a/mix.exs +++ b/mix.exs @@ -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(), @@ -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}, @@ -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),