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

[Sui Sign Error] When i use sui sign transaction, i got null information #3843

Closed
weixuefeng opened this issue May 17, 2024 · 12 comments
Closed
Labels
bug Something isn't working

Comments

@weixuefeng
Copy link
Contributor

i use wallet core sign txBytes. i got empty. not unSignedTx, no signature, no debugString !

i got txBytes: AAACAAgA4fUFAAAAAAAgDPEBaSJaJRETsxmNyB0VunIob3M1OoIS8DutEL0PCpkCAgABAQAAAQEDAAAAAAEBAIdFNNZpoeEtRVLQEfYM0lx46xschKfJ5EnfmtpnCHNFAQDUBmObgpOd26p42IT8ABXrYTxYmCTgdv/w2WaDAhhJwB7zBQAAAAAg/M0At5v4FrSuDsud8gentX4EIzGADgYCipczvtYS17qHRTTWaaHhLUVS0BH2DNJceOsbHISnyeRJ35raZwhzRe8CAAAAAAAACLEiAAAAAAAA

and call

    Sui.SigningInput input = Sui.SigningInput(
        privateKey: privateKeyHex.toUint8List(),
        signDirectMessage: Sui.SignDirect(unsignedTxMsg: txBytes));
    Sui.SigningOutput output = Sui.SigningOutput.fromBuffer(
        AnySigner.sign(input.writeToBuffer(), TWCoinType.TWCoinTypeSui)
            .toList());

then i got empty:

@weixuefeng weixuefeng added the bug Something isn't working label May 17, 2024
@satoshiotomakan
Copy link
Collaborator

Hi @weixuefeng, the problem should be with the Protobuf message you try to pass to the AnySigner.sign function, because I checked the txBytes, and it should be signed normally.
Could you please tell if the code worked before the last release?

@weixuefeng
Copy link
Contributor Author

weixuefeng commented May 17, 2024

yes. before i merge tw_sui code, it works good.

AnySigner.sign also works for another chain, they are worked.

@satoshiotomakan
Copy link
Collaborator

Could you please send me the encoded signing input without private key, I'll check what can be the problem.
Is it also possible you have local changes that may be the reason?

@weixuefeng
Copy link
Contributor Author

 Log.d("sui: ${suiCoinInfo.toJson()}");
    var fee = await calculateFee(targetAddress, signerAddress, amount);
    var objectId =
        calculateObject((BigInt.parse(amount) + fee).toString(), suiCoinInfo);
    Log.d("target: $targetAddress, signerAddress: $signerAddress, amount: $amount, object: ${objectId!.toPrettyString()}, fee: ${fee.toString()}");
    var txBytes = await unSafePaySui(
        targetAddress, signerAddress, amount, objectId!, fee.toString());
    Log.d("txbytes: $txBytes");
    Sui.SigningInput input = Sui.SigningInput(
        privateKey: privateKeyHex.toUint8List(),
        signDirectMessage: Sui.SignDirect(unsignedTxMsg: txBytes));
    Sui.SigningOutput output = Sui.SigningOutput.fromBuffer(
        AnySigner.sign(input.writeToBuffer(), TWCoinType.TWCoinTypeSui)
            .toList());
    Log.d(output.toDebugString());

log:

target: 0x767257adc15340d5745f4fddd79220fbed425bffa4429c26c0c1c759fdadc427, signerAddress: 0x0cf10169225a251113b3198dc81d15ba72286f73353a8212f03bad10bd0f0a99, amount: 1000000, object: [0x09e187b5ae3028c7df2e4c80936ad99b6ef4cf775a31cc43d93a158486ecc657,], fee: 2273544

txBytes: AAACAAhAQg8AAAAAAAAgdnJXrcFTQNV0X0/d15Ig++1CW/+kQpwmwMHHWf2txCcCAgABAQAAAQEDAAAAAAEBAAzxAWkiWiURE7MZjcgdFbpyKG9zNTqCEvA7rRC9DwqZAQnhh7WuMCjH3y5MgJNq2Ztu9M93WjHMQ9k6FYSG7MZXXDKgBgAAAAAgxvotjRfTbuVKv1L8z5WNIcQGBYz81Tnr29VSuKajDVQM8QFpIlolEROzGY3IHRW6cihvczU6ghLwO60QvQ8Kme8CAAAAAAAACLEiAAAAAAAA

@satoshiotomakan
Copy link
Collaborator

Sorry, I meant Sui.SigningInput.writeToBuffer().toHex()
But please do not set privateKeyHex before sending the SigningInput encoded data

@satoshiotomakan
Copy link
Collaborator

@weixuefeng, have you run ./tools/generate-files script? Probably, some protobuf files have not been recompiled
Or Rust release binaries have not been updated

@weixuefeng
Copy link
Contributor Author

yes. i had run the ./tools/generate-files i'll check it later.

@weixuefeng
Copy link
Contributor Author

Sorry, I meant Sui.SigningInput.writeToBuffer().toHex() But please do not set privateKeyHex before sending the SigningInput encoded data

yes. if you have txBytes. you can got Sui.SigningInput.writeToBuffer().toHex(), i'll check it.

@satoshiotomakan
Copy link
Collaborator

Hi @weixuefeng, did you have a chance to check Sui.SigningInput.writeToBuffer().toHex()?

@weixuefeng
Copy link
Contributor Author

0x0a2077f7b65eec2bf69003ce7ce103d47e81d6229b302829475e4d0a375b370b124912a7020aa4024141414341416967686745414141414141414167646e4a5872634654514e563058302f64313549672b2b3143572f2b6b5170776d774d48485766327478436343416741424151414141514544414141414141454241417a7841576b695769555245374d5a6a636764466270794b47397a4e54714345764137725243394477715a41516e68683757754d436a483379354d674a4e71325a7475394d3933576a484d51396b3646595347374d5a584c495431427741414141416743514d5666675136563179515773554e5966712f6d476a315051344351324b5135366e66736f51786f53514d38514670496c6f6c45524f7a475933494852573663696876637a553667684c774f3630517651384b6d6534434141414141414141394b73694141414141414141

@satoshiotomakan

@satoshiotomakan
Copy link
Collaborator

Thanks @weixuefeng, as I thought, this SigningInput was generated using the legacy Protobuf API.

0x0a2077f7b65eec2bf69003ce7ce103d47e81d6229b302829475e4d0a375b370b124912a7020aa4024141414341416967686745414141414141414167646e4a5872634654514e563058302f64313549672b2b3143572f2b6b5170776d774d48485766327478436343416741424151414141514544414141414141454241417a7841576b695769555245374d5a6a636764466270794b47397a4e54714345764137725243394477715a41516e68683757754d436a483379354d674a4e71325a7475394d3933576a484d51396b3646595347374d5a584c495431427741414141416743514d5666675136563179515773554e5966712f6d476a315051344351324b5135366e66736f51786f53514d38514670496c6f6c45524f7a475933494852573663696876637a553667684c774f3630517651384b6d6534434141414141414141394b73694141414141414141

We've updated indexes slightly: SigningInput.sign_direct_message had 2 index, now it's 3: https://github.com/trustwallet/wallet-core/pull/3769/files

Could you please try to clean the cache of the Android app, or even compile the entire object from scratch?

@weixuefeng
Copy link
Contributor Author

got it!. thanks for your reply @satoshiotomakan

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

2 participants