Skip to content

Commit

Permalink
add field comments to MoneroTxConfig, MoneroWalletConfig, MoneroDaemo…
Browse files Browse the repository at this point in the history
…nConfig
  • Loading branch information
woodser committed Oct 12, 2023
1 parent 93d5e86 commit a438520
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/developer_guide/sending_funds.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/main/ts/daemon/model/MoneroDaemonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ import MoneroRpcConnection from "../../common/MoneroRpcConnection";
*/
export default class MoneroDaemonConfig {

/** Server config to monerod. */
server: string | Partial<MoneroRpcConnection>;

/** 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;

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/ts/wallet/model/MoneroDestination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
40 changes: 38 additions & 2 deletions src/main/ts/wallet/model/MoneroTxConfig.ts
Original file line number Diff line number Diff line change
@@ -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<MoneroDestination>[];

/** 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;

/**
Expand Down Expand Up @@ -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 = [];
Expand Down
41 changes: 41 additions & 0 deletions src/main/ts/wallet/model/MoneroWalletConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MoneroRpcConnection>;

/** 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[];

/**
Expand Down

0 comments on commit a438520

Please sign in to comment.