Skip to content
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

WalletCore Swallow exceptions , Make debugging much harder #3707

Open
johnnyluo opened this issue Feb 28, 2024 · 1 comment
Open

WalletCore Swallow exceptions , Make debugging much harder #3707

johnnyluo opened this issue Feb 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@johnnyluo
Copy link

To be honest , I am not sure this should be a bug or a feature request
Describe the bug
I have been using WalletCore as a library in my own wallet app, and I am using it in IOS, swift and xcode, so I have been use it quite a lot recently , and find out WalletCore usually swallow all the exceptions, let me give you an example.
The follow function , it catch all exceptions , and return empty instead, there is no logging , nothing

TWData *_Nonnull TWTransactionCompilerCompileWithSignatures(enum TWCoinType coinType, TWData *_Nonnull txInputData, const struct TWDataVector *_Nonnull signatures, const struct TWDataVector *_Nonnull publicKeys) {
    Data result;
    try {
        assert(txInputData != nullptr);
        const Data inputData = data(TWDataBytes(txInputData), TWDataSize(txInputData));
        assert(signatures != nullptr);
        const auto signaturesVec = createFromTWDataVector(signatures);
        assert(publicKeys != nullptr);
        const auto publicKeysVec = createFromTWDataVector(publicKeys);

        result  = TransactionCompiler::compileWithSignatures(coinType, inputData, signaturesVec, publicKeysVec);
    } catch (...) {} // return empty
    return TWDataCreateWithBytes(result.data(), result.size());
}

This make debug issues quite hard , at least it cost me a least more than a day to figure out why the function return empty bytes.

  • For Bitcoin , the signature need to be in DER format , otherwise it return empty, and no error ,
  • For ETH , the signature need to R+S+RecoveryID , it is not DER format
  • For ETH , the public key , you don't have to pass in the public key , or if you do want to , make sure the public key is in secp256k1Extended

If the function can bubble up the exception , or error message will greatly help debugging.
I raised it here in hope we could make it better

To Reproduce

Expected behavior
bubble up the exceptions

Screenshots

Additional context

@johnnyluo johnnyluo added the bug Something isn't working label Feb 28, 2024
@satoshiotomakan
Copy link
Collaborator

Hi @johnnyluo, that's also right. We introduced an error system in Rust, but it's not available in C++ FFI yet.
Hope we have time this year to work on it to improve UX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@johnnyluo @satoshiotomakan and others