Git Product home page Git Product logo

Comments (12)

woodser avatar woodser commented on July 30, 2024

1bff0aa should resolve the unexpected token issue.

Regarding multisig, the library should be consistent with monero-wallet-rpc which gives the error Needs multisig export info from more participants if the number of imported peer multisig hexes is less than threshold - 1.

I observe importing 1 peer multisig hex at a time to a 2/3 wallet later gives the error "-35: Failed to sign multisig tx: This signature was made with stale data: export fresh multisig data, which other participants must then use." when signing a tx, which may be an issue in monero-wallet-rpc. These should be tracked separately and with monero-project.

from monero-ts.

OxMarco avatar OxMarco commented on July 30, 2024

Ok I solved the problem of the trailing < by enabling cors on the daemon and by disabling the webWorker that was somehow blocking the call
let daemon = await monerojs.connectToDaemonRpc("http://localhost:18081", "username", "password", true, 5000, false);

Regarding the question about multisig import, considering the case of 2/3 wallets, it is expected that two signers (thus N-1) can exchange info and complete the sync procedure. The stale data error happens with signing and submitting the transaction and isn't involved in the sync procedure (export from A then import from B, then viceversa) while the error Needs multisig export info from more participants shouldn't be raised by a 2/3 wallet as long as the import function argument is not null.

This is my current test setup:

let hex = '4d6f6...'; // taken from RPC function export_multisig_info()
walletRpc.importMultisigHex(hex);

Here is the data exchanged, as you can see it seems legit

export data: 4d6f6e65726f206d756c74697369672065...dae4c8755e29f1dc2a82f86ef76b9e3b28b64040c
import data: 4d6f6e65726f206d756c74697369672065...bda4f7388d75d83014f100bae7682e324529f47f0c

from monero-ts.

woodser avatar woodser commented on July 30, 2024

Ok I solved the problem of the trailing < by enabling cors on the daemon

This allowed the library to successfully connect from a browser. 1bff0aa makes it so an informative error is given if it can't connect instead of the reported unexpected token.

and by disabling the webWorker that was somehow blocking the call

The web worker runs local daemon and wallet operations off the main thread so the browser doesn't block. If you elaborate on this issue I can look into it further.

the error Needs multisig export info from more participants shouldn't be raised by a 2/3 wallet as long as the import function argument is not null.

This was the result of the library expecting a string[] passed to importMultisigHex(). b20ae82 adds support for passing a single string.

The stale data error happens with signing and submitting the transaction

This behavior should now be consistent with monero-wallet-rpc if there is an issue here.

from monero-ts.

OxMarco avatar OxMarco commented on July 30, 2024

Can't you just use an async callback to connect to the daemon, similarly to the wallet RPC? Apparently the webWorker blocks the execution or returns an invalid handle, raising the error.

Regarding the importMultisigHex() I still get the same error. I think you need to stick to the curl example here

  • for a single key

curl http://localhost:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"import_multisig_info","params":{"info":["...multisig_info..."]}}' -H 'Content-Type: application/json'

  • for multiple keys

curl http://localhost:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"import_multisig_info","params":{"info":["...multisig_info...", "...multisig_info..."]}}' -H 'Content-Type: application/json'

The info parameter needs to have an array, despite having just a single element.

from monero-ts.

woodser avatar woodser commented on July 30, 2024

The info parameter needs to have an array, despite having just a single element.

I reverted importMultisigHex() back to expect string[], throwing an error if not given. 5c3878d

I don't get the error Needs multisig export info from more participants with this change in the RPC or WASM wallets.

Please let me know if you see any behavior different from monero-wallet-rpc.

from monero-ts.

OxMarco avatar OxMarco commented on July 30, 2024

Ok solved, it was necessary to put the string inside an array.

let multisig_info = "40er2c5...";
importMultisigHex([multisig_info]);

Something useful adding to the documentation
When calling sweepUnlocked() or createTxs(), how can I get the txKey to sign and submit the transfer?

Thank you for your support

from monero-ts.

woodser avatar woodser commented on July 30, 2024

5c3878d should enforce passing an array. The input type is documented here.

When calling sweepUnlocked() or createTxs(), how can I get the txKey to sign and submit the transfer?

The transaction key can be retrieved with tx.getKey().

To get unsigned tx hex for signing and submitting transactions created with createTxs() or sweepUnlock() from view-only and offline wallets:

let txs = await viewOnlyWallet.createTxs(...);
let unsignedTxHex = txs[0].getTxSet().getUnsignedTxHex()
let signedTxHex = await offlineWallet.signTxs(unsignedTxHex)
let submittedTxHashes = await offlineWallet.submitTxs(signedTxHex).

More documentation on view-only and offline wallets here.

Or of course you can call createTxs() or sweepUnlock() with relay: false and relay the returned txs later.

from monero-ts.

OxMarco avatar OxMarco commented on July 30, 2024

Sorry that's not possible.
TypeError: tx.getKey is not a function. (In 'tx.getKey()', 'tx.getKey' is undefined)

sweepUnlocked() returns an instance of MoneroTxWallet but the method getKey is missing

Maybe tx[0].getKey() ?

The returned txKey should be consistent with the documentation:

multisig_txset - string. The set of signing keys used in a multisig transaction (empty for non-multisig).

from monero-ts.

woodser avatar woodser commented on July 30, 2024

getKey() is a function on the type MoneroTxWallet. createTxs() and sweepUnlocked() return MoneroTxWallet[] so the tx key can be retrieved with:

let txs = await wallet.createTxs(...);
let txKey = txs[0].getKey()

But this is different from tx hex to sign and submit.

If the wallet is a normal, non-view-only, non-offline, non-multisig wallet, you can call createTxs() or sweepUnlocked() with relay: false then call txs[0].getMetadata() to get a string which can be relayed with relayTx() to submit the tx.

If the wallet is view-only, you can get the common tx set shared among txs to get the unsigned tx hex to sign and submit:

let txs = await viewOnlyWallet.createTxs(...);
let unsignedTxHex = txs[0].getTxSet().getUnsignedTxHex();
let signedTxHex = await offlineWallet.signTxs(unsignedTxHex);
let submittedTxHashes = await offlineWallet.submitTxs(signedTxHex);

If the wallet is multisig, you can get the common tx set shared among txs to get the multisig tx hex to sign among participants:

let txs = await multisigWallet.createTxs(...);
let multisigTxHex = txs[0].getTxSet().getMultisigTxHex();

There are tests I can point you to for usage examples if needed.

from monero-ts.

OxMarco avatar OxMarco commented on July 30, 2024

Have you tested the multisig signing process?
I struggle to get a valid txSet.

let tx = await walletRpc.sweepUnlocked({ address:'4x35...', relay: true});
console.log( tx[0].getTxSet().getMultisigTxHex() )

when sending the key to sign and submit the transaction I get an invalid multisig_txset error, something that has never happened when using monero C++ library.

from monero-ts.

woodser avatar woodser commented on July 30, 2024

Have you tested the multisig signing process?

Yes, sweepUnlocked() is tested with a multisig wallet here.

from monero-ts.

woodser avatar woodser commented on July 30, 2024

Closing this since the original issue is resolved. Please open another issue if further help is needed.

from monero-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.