Page MenuHomePhabricator

[chronik] Add address.rs from givelotus/bitcoinsuite into bitcoinsuite-chronik-client
Needs RevisionPublic

Authored by hazzarust on Sun, Apr 13, 14:03.

Details

Reviewers
tobias_ruck
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Summary

This code creates Bitcoin Cash addresses using CashAddress format, with features like:

Hash encoding for address types (P2PKH, P2SH)

Error handling during address creation

Supports multiple address types for flexibility

Validates address format for correctness

Test Plan

Please set BUILD_DIR env to export BUILD_DIR="/path/to/build_dir
UNIX: ./contrib/teamcity/build-configurations.py build-bitcoinsuite-chronik-client

Event Timeline

Owners added a reviewer: Restricted Owners Package.Sun, Apr 13, 14:03

Tail of the build log:

      data: "abc"
    }
  }
}
time_first_seen: 1744553504
size: 178
])
2025-04-13T14:11:45.066000Z TestFramework (INFO): Stopping nodes
2025-04-13T14:11:45.169000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250413_141143/setup_scripts/chronik-client_plugins_0
2025-04-13T14:11:45.169000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250413_141143/setup_scripts/chronik-client_plugins_0/test_framework.log
2025-04-13T14:11:45.169000Z TestFramework (ERROR): 
2025-04-13T14:11:45.169000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20250413_141143/setup_scripts/chronik-client_plugins_0' to consolidate all logs
2025-04-13T14:11:45.170000Z TestFramework (ERROR): 
2025-04-13T14:11:45.170000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2025-04-13T14:11:45.170000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2025-04-13T14:11:45.170000Z TestFramework (ERROR): 
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_plugins.py started
setup_scripts/chronik-client_plugins.py failed, Duration: 2 s

stdout:

stderr:


TEST                                    | STATUS    | DURATION

setup_scripts/chronik-client_plugins.py | ✖ Failed  | 2 s

ALL                                     | ✖ Failed  | 2 s (accumulated) 
Runtime: 2 s

Test runner for chronik-client_plugins completed with code 1
----------------------|---------|----------|---------|---------|------------------------------------
File                  | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                  
----------------------|---------|----------|---------|---------|------------------------------------
All files             |   31.16 |    12.31 |   28.39 |   31.13 |                                    
 chronik-client       |     100 |      100 |     100 |     100 |                                    
  index.ts            |     100 |      100 |     100 |     100 |                                    
 chronik-client/proto |   23.53 |     9.16 |   17.05 |   23.74 |                                    
  chronik.ts          |   23.53 |     9.16 |   17.05 |   23.74 | ...4,6520-6523,6529-6571,6607-6616 
 chronik-client/src   |   67.21 |    49.69 |   65.41 |   66.48 |                                    
  ChronikClient.ts    |   60.38 |    48.69 |   63.63 |   60.38 | ...6,1357-1365,1373-1438,1446-1451 
  failoverProxy.ts    |   79.43 |    58.06 |   69.23 |   78.84 | ...286-289,292,301,308,312,317,321 
  hex.ts              |   89.47 |       50 |      75 |   87.87 | 58,66-68                           
  validation.ts       |    75.6 |       40 |      75 |   72.97 | 17,21,33,38-49,62-63               
----------------------|---------|----------|---------|---------|------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='988']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='3170']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='258']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2095']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='161']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='567']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='976']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='3135']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/chronik-client-integration-tests-junit.xml': No such file or directory
Build chronik-client-integration-tests failed with exit code 1

Please don't review

Removed serial and deserial, removed useless lifetimes, changed from_le_bytes to from_be_hex and thus handled array -> str conversion

tobias_ruck added a subscriber: tobias_ruck.
tobias_ruck added inline comments.
modules/bitcoinsuite-chronik-client/Cargo.toml
37 ↗(On Diff #53465)

remove unused dependency

modules/bitcoinsuite-chronik-client/src/address.rs
1 ↗(On Diff #53465)

this should be in bitcoinsuite-core

64 ↗(On Diff #53465)

move this into the FromStr::parse below

115 ↗(On Diff #53465)

you can remove this, only makes sense with Cow

124 ↗(On Diff #53465)

same here

149 ↗(On Diff #53465)

avoid the _ prefix—it indicates that it might be unused, but we don't want that.

instead either just remove the _ prefix or put them all into a mod inner {} for special safekeeping

269 ↗(On Diff #53465)
This revision now requires changes to proceed.Mon, Apr 14, 09:36