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

How to append arbitrary data to tx-extra? #265

Open
akildemir opened this issue Jan 26, 2025 · 2 comments
Open

How to append arbitrary data to tx-extra? #265

akildemir opened this issue Jan 26, 2025 · 2 comments

Comments

@akildemir
Copy link

Hi, I have been trying to create a tx with arbitrary data in the NONCE field of tx-extra.

So far I tried getEtxra and setExtra functions(to get the already populated extra and append what I need and set it back) on the MoneroTxWallet type. But getEtxra returns undefined on a createTx result. And when just call setExtra then extra only becomes the extra I set, so tx becomes invalid.

Is there a way to do that using this lib? Here is little snippet of what I tried:

    // create the tx
    const tx = await this.wallet.createTx({
      address: to,
      amount: BigInt(amount_to_send),
      accountIndex: 0,
      relay: false,
    });

    // update tx-extra
    const NONCE_FIELD = Buffer.from([2]);
    const new_extra = Buffer.concat([tx.getExtra(), NONCE_FIELD, data]);
    tx.setExtra(new_extra);

    return this.wallet.relayTx(tx);

this returns Failed to commit tx error. Because when I print the tx I see there is an "extra" field now(that didn't exist before hence I was getting undefined) that is equal to data I set.

Thanks in advance.

@woodser
Copy link
Owner

woodser commented Jan 26, 2025

As far as I can tell, monero-wallet-rpc does not support setting arbitrary extra data when creating transactions, and the libraries mirror the capabilities of monero-wallet-rpc.

I've opened an issue to set arbitrator data in monero-wallet-rpc, then the libraries can inherit that functionality: monero-project/monero#9731

@akildemir
Copy link
Author

Oh got it. Thanks.

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

No branches or pull requests

2 participants