Comments (5)
Hi @angelscry,
you are currently sending a https request to horizon to obtain the account data. As a result you receive the error message from Horizon that the account id is invalid.
Why don't you use only the KeyPair Class to check if the account id is valid. Like for example:
$isValid = true;
try {
KeyPair::fromAccountId("GBEJWZEYDCJIKBW7PZKIJPRHD6WSPNETCEDV5UWRLDBLKXA7QT2DTLVF");
} catch (Exception $e) {
$isValid = false;
}
By doing this you do not have to send data to Horizon to check if the account id is valid and there is no error message.
from stellar-php-sdk.
Hi @angelscry,
your account id is invalid, it has an invalid checksum.
You can see the same result if you use it in stellar laboratory
$kp = KeyPair::fromAccountId("GBEJWZEYDCJIKBW7PZKIJPRHD6WSPNETCEDV5UWRLDBLKXA7QT2DTLVF");
will also fail with:
InvalidArgumentException : invalid checksum in encoded data
from stellar-php-sdk.
Thank you for you quick reply. I think I expressed myself badly... Sorry...
Basically I want to test if an account id is valid or not by only using stellar-php-sdk. The account id into my script example is voluntarily wrong. As it is wrong, I want to be able to handle the corresponding error message. In my script I expected to only display :
Error: The request you sent was invalid in some way.
But it actually display :
{ "type": "https://stellar.org/horizon-errors/bad_request", "title": "Bad Request", "status": 400, "detail": "The request you sent was invalid in some way.", "extras": { "invalid_field": "account_id", "reason": "Account ID must start with
G and contain 56 alphanum characters" } } Error: The request you sent was invalid in some way.
How to not have { "type": "https://stellar.org/horizon-errors/bad_request", "title": "Bad Request", "status": 400, "detail": "The request you sent was invalid in some way.", "extras": { "invalid_field": "account_id", "reason": "Account ID must start with
G and contain 56 alphanum characters" } }
displayed?
I have try to hide error messages and handle error messages, but it did not work. Or maybe I do something wrong...
from stellar-php-sdk.
Ho... That's effectively a more simple way to proceed.
Thank you.
from stellar-php-sdk.
yw
from stellar-php-sdk.
Related Issues (17)
- Cant get this to work. HOT 3
- Set home domain HOT 1
- Build XDR to be signed HOT 5
- Bug in SetOptionsOperation HOT 5
- A bug in XdrDecoder HOT 1
- txRep HOT 2
- WebAuth Issue HOT 1
- Order book requests are not working HOT 2
- Bip39.php does not comply with psr-4 autoloading standard. Skipping.
- Error from $sdk->submitTransaction($transaction); is propagating to api response()
- Can't get it to work HOT 4
- Protocol 19 SDK Support HOT 1
- create a non-native coin object
- Call to a member function getAccountId() on null HOT 1
- A few bugs HOT 1
- Get Asset Images HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stellar-php-sdk.