-
Notifications
You must be signed in to change notification settings - Fork 28
feat(rpc): add z_validateaddress endpoint
#389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nachog00
wants to merge
59
commits into
dev
Choose a base branch
from
implement-z_validateaddress
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
b715dce
Add ZValidateAddressResponse struct for RPC responses
nachog00 e584359
Merge branch 'dev' into implement-z_validateaddress
zancas ec88ac8
Merge branch 'dev' into implement-z_validateaddress
dorianvp 80c7a84
chore(`z_validateaddress`): initial structs
dorianvp e122406
chore(`z_validateaddress`): initial impl
dorianvp 0716b4d
chore(`z_validateaddress`): expose endpoint
dorianvp 657055f
docs(`z_validateaddress`): add doc comments
dorianvp 3a48403
chore(`z_validateaddress`): merge variants into `Known`
dorianvp a2a4257
chore(`z_validateaddress`): use cleaner API & some tests
dorianvp 78e8ad0
Merge branch 'dev' into implement-z_validateaddress
dorianvp 728a0cc
chore(`z_validateaddress`): fmt
dorianvp 3afa4f0
fix(`z_validateaddress`): `fetch_service` test
dorianvp 41570e9
fix(`z_validateaddress`): add remaining tests
dorianvp dffa47e
fix(`z_validateaddress`): comment out sprout validation
dorianvp a4f72c1
fix(`z_validateaddress`): `fetch_service` test
dorianvp 73bb823
fix(`z_validateaddress`): address comments
dorianvp 7d84149
fix(`z_validateaddress`): add error type
dorianvp 4c6aac1
Merge branch 'dev' into implement-z_validateaddress
dorianvp ad09e27
Merge branch 'dev' into implement-z_validateaddress
dorianvp 8a0a588
chore(`z_validateaddress`): remove comment
dorianvp 2c25bfd
fix(`z_validateaddress`): address comments
dorianvp e23ba87
Merge branch 'dev' into implement-z_validateaddress
dorianvp 47b6756
add testvectors
dorianvp bf12e1a
Merge branch 'dev' into implement-z_validateaddress
dorianvp 4380d4f
fix: post-merge fixes
dorianvp f6436a0
docs(`z_validateaddress`): better doc-comments
dorianvp 688c2e9
Merge branch 'dev' into implement-z_validateaddress
dorianvp 1c1b653
chore(`z_validateaddress`): use testvectors
dorianvp f51301c
chore(`z_validateaddress`): rename `ZValidateAddress` to `ZValidateAd…
dorianvp bd67120
chore(`z_validateaddress`): stricter invalid deser
dorianvp 95f6648
chore(`z_validateaddress`): fix doc comment
dorianvp 3b4d080
chore(`z_validateaddress`): default `is_mine` to `IsMine::Unknown`
dorianvp 6765f98
chore(`z_validateaddress`): fix tests
dorianvp 754230f
Merge branch 'dev' into implement-z_validateaddress
zancas 2c09e29
Merge branch 'dev' into implement-z_validateaddress
dorianvp d5d7202
chore(`z_validateaddress`): dry up tests
dorianvp c6f9319
chore(`z_validateaddress`): rename for clarity
dorianvp 5e01626
Merge branch 'dev' into implement-z_validateaddress
dorianvp 049b20f
Further helperized run_z_validate_suite, expposing inconsistencies.
fluidvanadium 755f504
Dbg removed.
fluidvanadium 68d45e1
cargo clippy --fix --tests --all-features
fluidvanadium 075a8e3
trailing whitespace clipper
fluidvanadium d480b3a
cargo fmt
fluidvanadium ff9a4a8
add tracing to integration tests
fluidvanadium 30ddea4
Use qualified paths instead of single-use imports.
fluidvanadium 809674c
Added tracing debug message.
fluidvanadium 601d437
Zebra now uses diversifier and diversified_transmission_key.
fluidvanadium 73c76ab
Add tracing.
fluidvanadium ea627f0
Merge branch 'dev' into implement-z_validateaddress
dorianvp bcbd2c2
Merge branch 'dev' into implement-z_validateaddress
dorianvp 547a5aa
Fixed conflicts.
fluidvanadium 395dbfc
Fix check fail on deprecation.
fluidvanadium 5b57d4d
Merge branch 'dev' into implement-z_validateaddress
fluidvanadium 356d01b
Updated test to use upgraded framework.
fluidvanadium 727a45d
Merge branch 'dev' into implement-z_validateaddress
fluidvanadium 73f9180
Removed IsMine enum.
fluidvanadium 78d0586
Configured tests to expect no ismine parameter.
fluidvanadium 7be2b57
Separated validate sapling behavior under test.
fluidvanadium af15f87
Merged dev
fluidvanadium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,132 @@ | ||
| //! Helpers for integration-tests go here. | ||
| //! | ||
| //! This crate also exposes test-vectors. | ||
|
|
||
| pub mod rpc { | ||
| pub mod json_rpc { | ||
| pub const VALID_P2PKH_ADDRESS: &str = "tmVqEASZxBNKFTbmASZikGa5fPLkd68iJyx"; | ||
| pub const VALID_P2SH_ADDRESS: &str = "t2MjoXQ2iDrjG9QXNZNCY9io8ecN4FJYK1u"; | ||
|
|
||
| pub const VALID_SPROUT_ADDRESS: &str = "ztfhKyLouqi8sSwjRm4YMQdWPjTmrJ4QgtziVQ1Kd1e9EsRHYKofjoJdF438FwcUQnix8yrbSrzPpJJNABewgNffs5d4YZJ"; | ||
| pub const VALID_PAYING_KEY: &str = | ||
| "c8e8797f1fb5e9cf6b2d000177c5994119279a2629970a4f669aed1362a4cca5"; | ||
| pub const VALID_TRANSMISSION_KEY: &str = | ||
| "480f78d61bdd7fc4b4edeef9f6305b29753057ab1008d42ded1a3364dac2d83c"; | ||
|
|
||
| pub const VALID_SAPLING_ADDRESS: &str = "zregtestsapling1jalqhycwumq3unfxlzyzcktq3n478n82k2wacvl8gwfxk6ahshkxmtp2034qj28n7gl92ka5wca"; | ||
| pub const VALID_DIVERSIFIER: &str = "977e0b930ee6c11e4d26f8"; | ||
| pub const VALID_DIVERSIFIED_TRANSMISSION_KEY: &str = | ||
| "553ef2f328096a7c2aac6dec85b76b6b9243e733dc9db2eacce3eb8c60592c88"; | ||
|
|
||
| pub const VALID_UNIFIED_ADDRESS: &str = "uregtest1njwg60x0jarhyuuxrcdvw854p68cgdfe85822lmclc7z9vy9xqr7t49n3d97k2dwlee82skwwe0ens0rc06p4vr04tvd3j9ckl3qry83ckay4l4ngdq9atg7vuj9z58tfjs0mnsgyrnprtqfv8almu564z498zy6tp2aa569tk8fyhdazyhytel2m32awe4kuy6qq996um3ljaajj36"; | ||
| } | ||
|
|
||
| pub mod z_validate_address { | ||
| use std::future::Future; | ||
|
|
||
| use zaino_fetch::jsonrpsee::response::z_validate_address::{ | ||
| KnownZValidateAddress, ValidZValidateAddress, ZValidateAddressResponse, | ||
| }; | ||
| use zaino_testutils::ValidatorKind; | ||
|
|
||
| use crate::rpc::json_rpc::{ | ||
| VALID_DIVERSIFIED_TRANSMISSION_KEY, VALID_DIVERSIFIER, VALID_P2PKH_ADDRESS, | ||
| VALID_P2SH_ADDRESS, VALID_SAPLING_ADDRESS, VALID_UNIFIED_ADDRESS, | ||
| }; | ||
|
|
||
| pub fn assert_known_valid_eq( | ||
| resp: ZValidateAddressResponse, | ||
| expected: ValidZValidateAddress, | ||
| label: &str, | ||
| ) { | ||
| match resp { | ||
| ZValidateAddressResponse::Known(KnownZValidateAddress::Valid(actual)) => { | ||
| assert_eq!(actual, expected, "mismatch for {label}") | ||
| } | ||
| other => panic!( | ||
| "Unexpected ZValidateAddressResponse for {label}: {:#?}", | ||
| other | ||
| ), | ||
| } | ||
| } | ||
|
|
||
| pub async fn run_z_validate_suite<F, Fut>(rpc_call: &F) | ||
| where | ||
| // Any callable that takes an address and returns the response (you can unwrap inside) | ||
| F: Fn(String) -> Fut, | ||
| Fut: Future<Output = ZValidateAddressResponse>, | ||
| { | ||
| // P2PKH | ||
| let expected_p2pkh = ValidZValidateAddress::p2pkh(VALID_P2PKH_ADDRESS.to_string()); | ||
| assert_known_valid_eq( | ||
| rpc_call(VALID_P2PKH_ADDRESS.to_string()).await, | ||
| expected_p2pkh, | ||
| "P2PKH", | ||
| ); | ||
|
|
||
| // P2SH | ||
| let expected_p2sh = ValidZValidateAddress::p2sh(VALID_P2SH_ADDRESS.to_string()); | ||
| assert_known_valid_eq( | ||
| rpc_call(VALID_P2SH_ADDRESS.to_string()).await, | ||
| expected_p2sh, | ||
| "P2SH", | ||
| ); | ||
|
|
||
| // Note: It could be the case that Zaino needs to support Sprout. For now, it's been disabled. | ||
|
|
||
| // let expected_sprout = ZValidateAddress::sprout("ztfhKyLouqi8sSwjRm4YMQdWPjTmrJ4QgtziVQ1Kd1e9EsRHYKofjoJdF438FwcUQnix8yrbSrzPpJJNABewgNffs5d4YZJ".to_string(), "c8e8797f1fb5e9cf6b2d000177c5994119279a2629970a4f669aed1362a4cca5".to_string(), "480f78d61bdd7fc4b4edeef9f6305b29753057ab1008d42ded1a3364dac2d83c".to_string()); | ||
|
|
||
| // let fs_sprout = zcashd_subscriber | ||
| // .z_validate_address("ztfhKyLouqi8sSwjRm4YMQdWPjTmrJ4QgtziVQ1Kd1e9EsRHYKofjoJdF438FwcUQnix8yrbSrzPpJJNABewgNffs5d4YZJ".to_string()) | ||
| // .await | ||
| // .unwrap(); | ||
|
|
||
| // assert_eq!(fs_sprout, expected_sprout); | ||
|
|
||
| // Sapling (differs by validator) | ||
|
|
||
| // Unified (differs by validator) | ||
| let expected_unified = | ||
| ValidZValidateAddress::unified(VALID_UNIFIED_ADDRESS.to_string()); | ||
| assert_known_valid_eq( | ||
| rpc_call(VALID_UNIFIED_ADDRESS.to_string()).await, | ||
| expected_unified, | ||
| "Unified", | ||
| ); | ||
|
|
||
| // Invalids | ||
| let by_len = rpc_call("t1123456789ABCDEFGHJKLMNPQRSTUVWXY".to_string()).await; | ||
| let all_zeroes = rpc_call("t1000000000000000000000000000000000".to_string()).await; | ||
| assert_eq!(by_len, ZValidateAddressResponse::invalid()); | ||
| assert_eq!(all_zeroes, ZValidateAddressResponse::invalid()); | ||
| } | ||
|
|
||
| pub async fn run_z_validate_sapling<F, Fut>(rpc_call: &F) | ||
| where | ||
| // Any callable that takes an address and returns the response (you can unwrap inside) | ||
| F: Fn(String) -> Fut, | ||
| Fut: Future<Output = ZValidateAddressResponse>, | ||
| { | ||
| // Sapling (differs by validator) | ||
| let expected_sapling = ValidZValidateAddress::sapling( | ||
| VALID_SAPLING_ADDRESS.to_string(), | ||
| Some(VALID_DIVERSIFIER.to_string()), | ||
| Some(VALID_DIVERSIFIED_TRANSMISSION_KEY.to_string()), | ||
| ); | ||
| } | ||
|
|
||
| pub async fn run_z_validate_sapling_legacy<F, Fut>(rpc_call: &F) | ||
| where | ||
| // Any callable that takes an address and returns the response (you can unwrap inside) | ||
| F: Fn(String) -> Fut, | ||
| Fut: Future<Output = ZValidateAddressResponse>, | ||
| { | ||
| // Sapling (differs by validator) | ||
| let expected_sapling = ValidZValidateAddress::sapling( | ||
| VALID_SAPLING_ADDRESS.to_string(), | ||
| None::<String>, | ||
| None::<String>, | ||
| ); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.