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

[Feature request] Add to GraphQL API or ClientSDK way to get Tx_hash before broadcasting to the network. #9378

Open
SerhiiYakhin opened this issue Aug 16, 2021 · 5 comments · Fixed by #9394
Assignees
Labels

Comments

@SerhiiYakhin
Copy link

Hi,
I develop my wallet and I want to add Mina support to it.
For this I desperately need to know Transaction Hash of signed transaction BEFORE I will broadcast it through
sendPayment(signature: SignatureInput, input: SendPaymentInput!): SendPaymentPayload!

I investigate:

In the last two I see how you get tx hash - but it's challenging to rewrite and bind it to my NodeJS.
I think that for experienced and talented Mina developers it can be done pretty fast.
And I am sure that this will greatly help all developers to integrate Mina.

Kinda like

GraphQL Schema query:

# Retrieve a payment hash
#
# Arguments
# signature: If a signature is provided, this transaction is
# considered signed and ready to be broadcasted to the network without requiring a
# private key
# input: [Not documented]
paymentHash(signature: SignatureInput, input: SendPaymentInput!): String!

Or

ClientSDK:

/** 
  * Retrieve hash of a signed payment.
  *
  * @param signedPayment - A signed payment transaction
  * @returns Transaction hash
   */
export const getPaymentHash: (signedPayment:signed<payment>) => string;

or

export type signed<signable> = {
  readonly publicKey: publicKey; 
  readonly signature: signature; 
  readonly payload: signable;
  readonly hash: string;
};
@mrmr1993
Copy link
Member

To reply to your comment here:

@mrmr1993 where did you get tx ID?
From the PaymentPayload?
I need the feature to get tx_hash from the signed transaction body.
Like described here #9378

Maybe you can help with it, please)

I'm not aware of an existing API for this, aside from the the GraphQL APIs for transactions submitted to a network. In the meantime, you may find it helpful to run an isolated local node with mina daemon --seed --proof-level none, to which you can send GraphQL commands. Of course, that won't help for transactions that aren't compatible with the node's ledger, since they will be rejected outright.

I was surprised that this wasn't already in the SDK tbh. @bkase / @MartinMinkov, seems like an easy add?

@LukeWang-crypto
Copy link

we are integrating Mina, and need getPaymentHash in sdk as well. Please help us to add this function.

@mrmr1993 mrmr1993 linked a pull request Aug 26, 2021 that will close this issue
5 tasks
@mrmr1993
Copy link
Member

Opened PR #9394 for this.

@shimkiv shimkiv added the triage label Jul 14, 2022
@vae520283995
Copy link

vae520283995 commented Aug 19, 2022

In the last two I see how you get tx hash - but it's challenging to rewrite and bind it to my NodeJS.

@SerhiiYakhin I don't see any other implementation except in the ClientSDK

@mrmr1993 I have a signed transaction for rosetta, can you tell me how to generate the hash from this json?

"signed_transaction": "{\"signature\":\"D32FE641A6D4DF2C09880C8055E8CAF42DCEE43819BED63CBCB2BFE24914C51A0B669F692567C07191448BE39A1DFD205C0A173B7CEC14983C490686B40D4D01\",\"payment\":{\"to\":\"B62qjXBHo2QVrHF3P1Dt7JnqoNQ4u1qCTrLbwfq3bnvcoaDogq2BXH4\",\"from\":\"B62qjXBHo2QVrHF3P1Dt7JnqoNQ4u1qCTrLbwfq3bnvcoaDogq2BXH4\",\"fee\":\"5500000\",\"token\":\"1\",\"nonce\":\"0\",\"memo\":null,\"amount\":\"1\",\"valid_until\":\"4294967295\"},\"stake_delegation\":null,\"create_token\":null,\"create_token_account\":null,\"mint_tokens\":null}"
"transaction_identifier": {
        "hash": "CkpZB49SPeoapP25cLf8sDNhqhmZJXB9eKLxiJLqkRVWi4j37psu4"
    }

I'm not familiar with ocaml, can you describe the specific details in language, or show it in pseudocode in other languages?
I've been stuck for a week because of this

@robinbb
Copy link

robinbb commented Oct 12, 2022

@mrmr1993 I see that PR #9394 was merged. Did you intend for that work to close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants