diff --git a/docs/developer_guide/sending_funds.md b/docs/developer_guide/sending_funds.md index c694c6e80..a820e1c44 100644 --- a/docs/developer_guide/sending_funds.md +++ b/docs/developer_guide/sending_funds.md @@ -1,6 +1,6 @@ # Sending funds -The following are examples of sending funds using monero-ts. +The following are examples of sending funds using monero-ts. See [MoneroTxConfig](https://moneroecosystem.org/monero-ts/typedocs/classes/MoneroTxConfig.html) for all options. ```typescript // create a transaction to send funds to an address, but do not relay diff --git a/src/main/ts/daemon/model/MoneroDaemonConfig.ts b/src/main/ts/daemon/model/MoneroDaemonConfig.ts index a4eb779ea..a5efe711c 100644 --- a/src/main/ts/daemon/model/MoneroDaemonConfig.ts +++ b/src/main/ts/daemon/model/MoneroDaemonConfig.ts @@ -5,9 +5,16 @@ import MoneroRpcConnection from "../../common/MoneroRpcConnection"; */ export default class MoneroDaemonConfig { + /** Server config to monerod. */ server: string | Partial; + + /** Proxy requests to monerod to a worker (default true). */ proxyToWorker: boolean; + + /** Command to start monerod as a child process. */ cmd: string[]; + + /** Interval in milliseconds to poll the daemon for updates (default 20000). */ pollInterval: number; /** diff --git a/src/main/ts/wallet/model/MoneroDestination.ts b/src/main/ts/wallet/model/MoneroDestination.ts index 2bffdc3c6..e41e3127a 100644 --- a/src/main/ts/wallet/model/MoneroDestination.ts +++ b/src/main/ts/wallet/model/MoneroDestination.ts @@ -6,7 +6,10 @@ import MoneroError from "../../common/MoneroError"; */ export default class MoneroDestination { + /** Destination address to send funds to. */ address: string; + + /** Amount to send to destination address. */ amount: bigint; /** diff --git a/src/main/ts/wallet/model/MoneroTxConfig.ts b/src/main/ts/wallet/model/MoneroTxConfig.ts index 54588de2e..5ecf5b231 100644 --- a/src/main/ts/wallet/model/MoneroTxConfig.ts +++ b/src/main/ts/wallet/model/MoneroTxConfig.ts @@ -1,29 +1,65 @@ import assert from "assert"; import MoneroDestination from "./MoneroDestination"; import MoneroError from "../../common/MoneroError"; +import MoneroTxPriority from "./MoneroTxPriority"; /** * Configures a transaction to send, sweep, or create a payment URI. */ export default class MoneroTxConfig { + /** Single destination address (required unless `destinations` provided). */ address: string; + + /** Single destination amount (required unless `destinations provided). */ amount: bigint; + + /** Source account index to transfer funds from (required unless sweeping key image). */ accountIndex: number; + + /** Source subaddress index to send funds from (default all). */ subaddressIndex: number; + + /** Source subaddresses to send funds from (default all). */ subaddressIndices: number[]; + + /** Relay the transaction to peers to commit to the blockchain if true (default false). */ relay: boolean; - priority: number; + + /** Transaction priority to adjust the miner fee (default MoneroTxPriority.NORMAL). */ + priority: MoneroTxPriority; + + /** Multiple destinations to send funds to, if applicable. */ destinations: Partial[]; + + /** List of destination indices to split the miner fee (optional). */ subtractFeeFrom: number[]; + + /** Payment ID for the transaction. */ paymentId: string; + + /** Minimum height or timestamp for the transaction to unlock (default 0). */ unlockTime: bigint; + + /** Miner fee (calculated automatically). */ fee: bigint; + + /** Transaction note saved locally with the wallet (optional). */ note: string; + + /** Recipient name saved locally with the wallet (optional). */ recipientName: string; + + /** Allow funds to be transferred using multiple transactions if necessary (default false). */ canSplit: boolean; + + /** For sweep requests, include outputs below this amount when sweeping wallet, account, subaddress, or all unlocked funds. */ belowAmount: bigint; + + /** For sweep requests, sweep each subaddress individually instead of together if true. */ sweepEachSubaddress: boolean; + + /** For sweep requests, key image of the output to sweep. */ keyImage: string; /** @@ -158,7 +194,7 @@ export default class MoneroTxConfig { return (this.destinations[0] as MoneroDestination).getAmount(); } - addDestination(destinationOrAddress: MoneroDestination | string, amount?: bigint) { + addDestination(destinationOrAddress: MoneroDestination | string, amount?: bigint): MoneroTxConfig { if (typeof destinationOrAddress === "string") return this.addDestination(new MoneroDestination(destinationOrAddress, amount)); assert(destinationOrAddress instanceof MoneroDestination); if (this.destinations === undefined) this.destinations = []; diff --git a/src/main/ts/wallet/model/MoneroWalletConfig.ts b/src/main/ts/wallet/model/MoneroWalletConfig.ts index 9047dd89d..72bc80e34 100644 --- a/src/main/ts/wallet/model/MoneroWalletConfig.ts +++ b/src/main/ts/wallet/model/MoneroWalletConfig.ts @@ -8,26 +8,67 @@ import MoneroUtils from "../../common/MoneroUtils"; */ export default class MoneroWalletConfig { + /** Path to the wallet to open or create. */ path: string; + + /** Password of the wallet to open or create. */ password: string; + + /** Network type of the wallet to open or create. */ networkType: MoneroNetworkType; + + /** Server config to monerod or monero-wallet-rpc. */ server: string | Partial; + + /** Govern the wallet's server connection. */ connectionManager: MoneroConnectionManager; + + /** Seed of the wallet to ceate (random wallet created if neither seed nor keys given). */ seed: string; + + /** Offset to derive a new seed from the given seed to recover a secret wallet. */ seedOffset: string; + + /** Indicates if the wallet seed is multisig. */ isMultisig: boolean; + + /** Primary address of the wallet to create (only provide if restoring from keys). */ primaryAddress: string; + + /** Private view key of the wallet to create. */ privateViewKey: string; + + /** Private spend key of the wallet to create. */ privateSpendKey: string; + + /** Block height to start scanning from (defaults to 0 unless generating random wallet). */ restoreHeight: number; + + /** Language of the wallet's seed phrase (defaults to "English" or auto-detected). */ language: string; + + /** Specifies if the currently open RPC wallet should be saved before being closed. */ saveCurrent: boolean; + + /** Proxies wallet operations to a worker in order to not block the main thread (default true). */ proxyToWorker: boolean; + + /** Node.js compatible file system to use (defaults to disk or in-memory FS if browser). */ fs: any; + + /** Wallet keys data to open. */ keysData: Uint8Array; + + /** Wallet cache data to open. */ cacheData: Uint8Array; + + /** Number of accounts to scan (optional). */ accountLookahead: number; + + /** Number of subaddresses to scan per account (optional). */ subaddressLookahead: number; + + /** Command to start monero-wallet-rpc as a child process. */ cmd: string[]; /**