@xchainjs/xchain-monero 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/lib/client.d.ts +76 -0
- package/lib/const.d.ts +15 -0
- package/lib/crypto/address.d.ts +15 -0
- package/lib/crypto/base58monero.d.ts +13 -0
- package/lib/crypto/bulletproofsPlus.d.ts +23 -0
- package/lib/crypto/clsag.d.ts +31 -0
- package/lib/crypto/ecdh.d.ts +33 -0
- package/lib/crypto/hashToPoint.d.ts +15 -0
- package/lib/crypto/keyImage.d.ts +12 -0
- package/lib/crypto/keys.d.ts +19 -0
- package/lib/crypto/pedersen.d.ts +22 -0
- package/lib/crypto/stealth.d.ts +49 -0
- package/lib/daemon.d.ts +96 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.esm.js +2525 -0
- package/lib/index.js +2538 -0
- package/lib/lws.d.ts +88 -0
- package/lib/scanner.d.ts +51 -0
- package/lib/tx/builder.d.ts +45 -0
- package/lib/tx/decoySelection.d.ts +29 -0
- package/lib/tx/serialize.d.ts +43 -0
- package/lib/tx/types.d.ts +56 -0
- package/lib/types.d.ts +24 -0
- package/lib/utils.d.ts +52 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# `@xchainjs/xchain-monero`
|
|
2
|
+
|
|
3
|
+
Monero (XMR) client for XChainJS — a pure JavaScript implementation with no WASM dependencies.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a Monero client that implements the standard XChainJS `XChainClient` interface. It supports address derivation, balance queries, transaction history, fee estimation, and transaction building/broadcasting.
|
|
8
|
+
|
|
9
|
+
Key design decisions:
|
|
10
|
+
|
|
11
|
+
- **Pure JS** — Uses `@noble/curves`, `@noble/hashes`, and `micro-key-producer` for all cryptographic operations. No native modules or WASM, so it works in both Node.js and browser environments.
|
|
12
|
+
- **MyMonero LWS** — Balance and UTXO queries go through a Light Wallet Server (LWS) API, defaulting to `api.mymonero.com`.
|
|
13
|
+
- **Monero Daemon RPC** — Fee estimation and transaction broadcasting use a standard Monero daemon node.
|
|
14
|
+
- **SLIP-10 key derivation** — Derives Monero spend/view keys from a BIP-39 mnemonic via SLIP-10 (`m/44'/128'/account'`).
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @xchainjs/xchain-monero
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Client, defaultXMRParams } from '@xchainjs/xchain-monero'
|
|
26
|
+
import { Network } from '@xchainjs/xchain-client'
|
|
27
|
+
|
|
28
|
+
const client = new Client({
|
|
29
|
+
...defaultXMRParams,
|
|
30
|
+
network: Network.Mainnet,
|
|
31
|
+
phrase: 'your mnemonic phrase here',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Get address
|
|
35
|
+
const address = await client.getAddressAsync()
|
|
36
|
+
|
|
37
|
+
// Get balance
|
|
38
|
+
const balances = await client.getBalance(address)
|
|
39
|
+
|
|
40
|
+
// Transfer
|
|
41
|
+
const txHash = await client.transfer({
|
|
42
|
+
recipient: '4...',
|
|
43
|
+
amount: baseAmount(1000000000000, 12), // 1 XMR
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Architecture
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
src/
|
|
51
|
+
├── client.ts # XChainClient implementation
|
|
52
|
+
├── const.ts # Chain constants, default params
|
|
53
|
+
├── types.ts # Client parameter types
|
|
54
|
+
├── utils.ts # Address derivation, key helpers
|
|
55
|
+
├── lws.ts # MyMonero Light Wallet Server API
|
|
56
|
+
├── daemon.ts # Monero daemon RPC client
|
|
57
|
+
└── tx/
|
|
58
|
+
├── builder.ts # Transaction construction
|
|
59
|
+
├── serialize.ts # Binary serialization
|
|
60
|
+
├── decoySelection.ts # Ring member (decoy) selection
|
|
61
|
+
└── types.ts # Transaction types
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AssetInfo, BaseXChainClient, Fees, PreparedTx, TxHash, TxHistoryParams } from '@xchainjs/xchain-client';
|
|
2
|
+
import { Address } from '@xchainjs/xchain-util';
|
|
3
|
+
import { Balance, Tx, TxParams, TxsPage, XMRClientParams } from './types';
|
|
4
|
+
export declare class Client extends BaseXChainClient {
|
|
5
|
+
private explorerProviders;
|
|
6
|
+
private daemonUrls;
|
|
7
|
+
private lwsUrls;
|
|
8
|
+
private lwsLoggedIn;
|
|
9
|
+
private restoreHeight;
|
|
10
|
+
/** Cached scan state for daemon fallback */
|
|
11
|
+
private scanCache;
|
|
12
|
+
constructor(params?: XMRClientParams);
|
|
13
|
+
getAssetInfo(): AssetInfo;
|
|
14
|
+
getExplorerUrl(): string;
|
|
15
|
+
getExplorerAddressUrl(address: Address): string;
|
|
16
|
+
getExplorerTxUrl(txID: TxHash): string;
|
|
17
|
+
getFullDerivationPath(walletIndex: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get the current address asynchronously.
|
|
20
|
+
* Derives keys from mnemonic and encodes as Monero address (pure JS, no WASM).
|
|
21
|
+
*/
|
|
22
|
+
getAddressAsync(index?: number): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use getAddressAsync instead
|
|
25
|
+
*/
|
|
26
|
+
getAddress(): string;
|
|
27
|
+
validateAddress(address: Address): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get balance via LWS, falling back to daemon scanning if LWS is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
getBalance(address: Address): Promise<Balance[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get transaction fees via daemon RPC.
|
|
34
|
+
*/
|
|
35
|
+
getFees(): Promise<Fees>;
|
|
36
|
+
/**
|
|
37
|
+
* Get transaction details by hash via daemon RPC.
|
|
38
|
+
*/
|
|
39
|
+
getTransactionData(txId: string): Promise<Tx>;
|
|
40
|
+
/**
|
|
41
|
+
* Get transaction history via LWS, falling back to daemon scanning.
|
|
42
|
+
* Due to Monero privacy, counterparty addresses are unavailable;
|
|
43
|
+
* the own address is used with net amount for from/to.
|
|
44
|
+
*/
|
|
45
|
+
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
|
|
46
|
+
/**
|
|
47
|
+
* Transfer XMR to a recipient address.
|
|
48
|
+
* Builds a complete RingCT transaction with CLSAG signatures and Bulletproofs+ range proof.
|
|
49
|
+
*/
|
|
50
|
+
transfer(params: TxParams): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Broadcast a signed transaction hex to the network.
|
|
53
|
+
* Note: The returned hash is keccak256 of the raw tx blob, which differs from
|
|
54
|
+
* the canonical Monero txid (three-hash construction). Use transfer() for the correct txid.
|
|
55
|
+
*/
|
|
56
|
+
broadcastTx(txHex: string): Promise<TxHash>;
|
|
57
|
+
/**
|
|
58
|
+
* Prepare an unsigned transaction.
|
|
59
|
+
* Monero transactions require private key context for ring signature
|
|
60
|
+
* construction, so this method is not supported.
|
|
61
|
+
*/
|
|
62
|
+
prepareTx(_params: TxParams): Promise<PreparedTx>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the private view key hex for a wallet index.
|
|
65
|
+
*/
|
|
66
|
+
private getViewKeyHex;
|
|
67
|
+
/**
|
|
68
|
+
* Derives private spend key from BIP-39 mnemonic via SLIP-10 derivation.
|
|
69
|
+
*/
|
|
70
|
+
private getPrivateSpendKey;
|
|
71
|
+
/**
|
|
72
|
+
* Scan the blockchain via daemon RPC to find owned outputs.
|
|
73
|
+
* Uses cached results and scans incrementally from the last scanned height.
|
|
74
|
+
*/
|
|
75
|
+
private daemonScan;
|
|
76
|
+
}
|
package/lib/const.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Asset } from '@xchainjs/xchain-util';
|
|
2
|
+
import { XMRClientParams } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Monero chain symbol
|
|
5
|
+
*/
|
|
6
|
+
export declare const XMRChain: "XMR";
|
|
7
|
+
/**
|
|
8
|
+
* Monero native asset decimals (piconero = 10^-12 XMR)
|
|
9
|
+
*/
|
|
10
|
+
export declare const XMR_DECIMALS = 12;
|
|
11
|
+
/**
|
|
12
|
+
* Monero native asset
|
|
13
|
+
*/
|
|
14
|
+
export declare const AssetXMR: Asset;
|
|
15
|
+
export declare const defaultXMRParams: XMRClientParams;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a standard Monero address from public spend/view keys.
|
|
3
|
+
* Format: [1-byte prefix][32-byte pubSpend][32-byte pubView][4-byte checksum]
|
|
4
|
+
* Result is 69 bytes → 95 base58 characters.
|
|
5
|
+
*/
|
|
6
|
+
export declare const encodeAddress: (publicSpendKey: Uint8Array, publicViewKey: Uint8Array, networkType: number) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a standard Monero address into its public spend/view keys.
|
|
9
|
+
* Validates the checksum.
|
|
10
|
+
*/
|
|
11
|
+
export declare const decodeAddress: (address: string) => {
|
|
12
|
+
publicSpendKey: Uint8Array;
|
|
13
|
+
publicViewKey: Uint8Array;
|
|
14
|
+
networkType: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monero's custom base58 encoding.
|
|
3
|
+
* Unlike Bitcoin's base58, Monero encodes in fixed 8-byte blocks → 11-char blocks.
|
|
4
|
+
* The last block may be shorter depending on remaining bytes.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Encodes a Uint8Array using Monero's base58 scheme.
|
|
8
|
+
*/
|
|
9
|
+
export declare const cnBase58Encode: (data: Uint8Array) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a Monero base58-encoded string to Uint8Array.
|
|
12
|
+
*/
|
|
13
|
+
export declare const cnBase58Decode: (encoded: string) => Uint8Array;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bulletproofs+ range proof implementation for Monero.
|
|
3
|
+
* Proves amounts are in [0, 2^64) without revealing them.
|
|
4
|
+
*
|
|
5
|
+
* Reference: monero/src/ringct/bulletproofs_plus.cc
|
|
6
|
+
*/
|
|
7
|
+
import type { BPPlusProof } from '../tx/types';
|
|
8
|
+
/**
|
|
9
|
+
* Generate a Bulletproofs+ range proof.
|
|
10
|
+
*
|
|
11
|
+
* @param amounts - Array of amounts (bigint, each < 2^64)
|
|
12
|
+
* @param masks - Array of blinding factors (32-byte scalars)
|
|
13
|
+
* @returns BP+ proof
|
|
14
|
+
*/
|
|
15
|
+
export declare function bulletproofPlusProve(amounts: bigint[], masks: Uint8Array[]): BPPlusProof;
|
|
16
|
+
/**
|
|
17
|
+
* Verify a Bulletproofs+ range proof.
|
|
18
|
+
*
|
|
19
|
+
* @param proof - BP+ proof to verify
|
|
20
|
+
* @param commitments - Output commitments (the actual commitments, NOT /8)
|
|
21
|
+
* @returns true if valid
|
|
22
|
+
*/
|
|
23
|
+
export declare function bulletproofPlusVerify(proof: BPPlusProof, commitments: Uint8Array[]): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLSAG (Concise Linkable Spontaneous Anonymous Group) signature.
|
|
3
|
+
* Used in Monero RingCT for input authorization + commitment balance proof.
|
|
4
|
+
*
|
|
5
|
+
* Reference: monero/src/ringct/rctSigs.cpp (CLSAG_Gen, verRctCLSAGSimple)
|
|
6
|
+
*/
|
|
7
|
+
import type { ClsagSig, RingMember } from '../tx/types';
|
|
8
|
+
/**
|
|
9
|
+
* CLSAG signing.
|
|
10
|
+
*
|
|
11
|
+
* @param message - 32-byte transaction prefix hash
|
|
12
|
+
* @param ring - Ring members (dest + mask for each)
|
|
13
|
+
* @param Cout - Pseudo-output commitment (C_offset)
|
|
14
|
+
* @param secretKey - Signer's one-time private key (p)
|
|
15
|
+
* @param secretMask - Commitment mask difference: z = input_mask - pseudo_out_mask
|
|
16
|
+
* @param realIndex - Index of real signer in ring
|
|
17
|
+
* @param keyImage - Pre-computed key image (p * Hp(P[l]))
|
|
18
|
+
* @returns CLSAG signature
|
|
19
|
+
*/
|
|
20
|
+
export declare function clsagSign(message: Uint8Array, ring: RingMember[], Cout: Uint8Array, secretKey: Uint8Array, secretMask: Uint8Array, realIndex: number, keyImage: Uint8Array): ClsagSig;
|
|
21
|
+
/**
|
|
22
|
+
* CLSAG verification.
|
|
23
|
+
*
|
|
24
|
+
* @param message - 32-byte transaction prefix hash
|
|
25
|
+
* @param ring - Ring members (dest + mask for each)
|
|
26
|
+
* @param Cout - Pseudo-output commitment
|
|
27
|
+
* @param keyImage - Key image
|
|
28
|
+
* @param sig - CLSAG signature to verify
|
|
29
|
+
* @returns true if valid
|
|
30
|
+
*/
|
|
31
|
+
export declare function clsagVerify(message: Uint8Array, ring: RingMember[], Cout: Uint8Array, keyImage: Uint8Array, sig: ClsagSig): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECDH-based amount encryption/decryption for Monero RingCT.
|
|
3
|
+
*
|
|
4
|
+
* Shared secret: ss = 8 * r * A (or 8 * a * R)
|
|
5
|
+
* Amount mask: first 8 bytes of keccak256("amount" || Hs(ss || index))
|
|
6
|
+
* Encrypted amount: XOR of 8-byte LE amount with mask
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Derive ECDH shared secret point from tx private key and recipient's public view key.
|
|
10
|
+
* Returns the compressed point bytes of r*A.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deriveSharedSecret(txPrivKey: Uint8Array, pubViewKey: Uint8Array): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Compute the 1-byte view tag for an output.
|
|
15
|
+
* view_tag = keccak256("view_tag" || derivation || varint(outputIndex))[0]
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeViewTag(sharedSecret: Uint8Array, outputIndex: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Encrypt an amount using ECDH-derived mask.
|
|
20
|
+
* @param amount - Amount in piconero (bigint)
|
|
21
|
+
* @param sharedSecret - ECDH shared secret (r*A compressed bytes)
|
|
22
|
+
* @param outputIndex - Output index for key derivation
|
|
23
|
+
* @returns 8-byte encrypted amount
|
|
24
|
+
*/
|
|
25
|
+
export declare function encryptAmount(amount: bigint, sharedSecret: Uint8Array, outputIndex: number): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Decrypt an amount using ECDH-derived mask.
|
|
28
|
+
* @param encrypted - 8-byte encrypted amount
|
|
29
|
+
* @param sharedSecret - ECDH shared secret (a*R compressed bytes)
|
|
30
|
+
* @param outputIndex - Output index for key derivation
|
|
31
|
+
* @returns Decrypted amount in piconero
|
|
32
|
+
*/
|
|
33
|
+
export declare function decryptAmount(encrypted: Uint8Array, sharedSecret: Uint8Array, outputIndex: number): bigint;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monero's hash_to_ec / ge_fromfe_frombytes_vartime implementation.
|
|
3
|
+
* Ported from CoinSpace/monerolib (pure JS Monero library).
|
|
4
|
+
*
|
|
5
|
+
* Maps arbitrary data to an ed25519 point. This is NOT standard hash-to-curve
|
|
6
|
+
* (RFC 9380) — it matches Monero's specific algorithm from crypto-ops.c.
|
|
7
|
+
*/
|
|
8
|
+
declare const ExtPoint: import("@noble/curves/abstract/edwards").EdwardsPointCons;
|
|
9
|
+
type Point = InstanceType<typeof ExtPoint>;
|
|
10
|
+
/**
|
|
11
|
+
* Hash arbitrary data to an ed25519 point (Monero's hash_to_ec).
|
|
12
|
+
* Algorithm: ge_fromfe_frombytes_vartime
|
|
13
|
+
*/
|
|
14
|
+
export declare function hashToPoint(data: Uint8Array): Point;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key image generation for Monero ring signatures.
|
|
3
|
+
* KI = x * Hp(P) where x is the private key and P is the public key.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a key image from a private/public key pair.
|
|
7
|
+
* KI = x * Hp(P)
|
|
8
|
+
* @param privKey - Private key (32-byte scalar LE)
|
|
9
|
+
* @param pubKey - Corresponding public key (32-byte compressed point)
|
|
10
|
+
* @returns Key image as 32-byte compressed point
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateKeyImage(privKey: Uint8Array, pubKey: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derives an ed25519 public key from a raw private key scalar.
|
|
3
|
+
* Unlike standard EdDSA (which applies SHA-512 + clamping), Monero uses the raw scalar directly.
|
|
4
|
+
*/
|
|
5
|
+
export declare const secretKeyToPublicKey: (privateKey: Uint8Array) => Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* Derives the private view key from a private spend key.
|
|
8
|
+
* view_key = sc_reduce32(keccak256(spend_key))
|
|
9
|
+
*/
|
|
10
|
+
export declare const derivePrivateViewKey: (privateSpendKey: Uint8Array) => Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Derives all four Monero keys from a private spend key.
|
|
13
|
+
*/
|
|
14
|
+
export declare const deriveKeyPairs: (privateSpendKey: Uint8Array) => {
|
|
15
|
+
privateSpendKey: Uint8Array;
|
|
16
|
+
publicSpendKey: Uint8Array;
|
|
17
|
+
privateViewKey: Uint8Array;
|
|
18
|
+
publicViewKey: Uint8Array;
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pedersen commitment scheme for Monero.
|
|
3
|
+
* C = mask*G + amount*H
|
|
4
|
+
*/
|
|
5
|
+
declare const ExtPoint: import("@noble/curves/abstract/edwards").EdwardsPointCons;
|
|
6
|
+
type Point = InstanceType<typeof ExtPoint>;
|
|
7
|
+
/**
|
|
8
|
+
* Get the Pedersen generator H.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getH(): Point;
|
|
11
|
+
/**
|
|
12
|
+
* Create a Pedersen commitment: C = mask*G + amount*H
|
|
13
|
+
* @param mask - Blinding factor (32-byte scalar LE)
|
|
14
|
+
* @param amount - Amount to commit to (bigint)
|
|
15
|
+
*/
|
|
16
|
+
export declare function commit(mask: Uint8Array, amount: bigint): Point;
|
|
17
|
+
/**
|
|
18
|
+
* Create a zero-mask commitment for fees: C = 0*G + amount*H = amount*H
|
|
19
|
+
* Used for fee commitments where the mask is publicly known to be 0.
|
|
20
|
+
*/
|
|
21
|
+
export declare function zeroCommit(amount: bigint): Point;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monero stealth address (one-time address) derivation.
|
|
3
|
+
*
|
|
4
|
+
* Output key: P = Hs(r*A || i)*G + B
|
|
5
|
+
* - r: tx private key
|
|
6
|
+
* - A: recipient's public view key
|
|
7
|
+
* - B: recipient's public spend key
|
|
8
|
+
* - i: output index
|
|
9
|
+
* - Hs: keccak256 -> sc_reduce32 (hash to scalar)
|
|
10
|
+
*
|
|
11
|
+
* Input key recovery: x = Hs(a*R || i) + b
|
|
12
|
+
* - a: recipient's private view key
|
|
13
|
+
* - R: tx public key (r*G)
|
|
14
|
+
* - b: recipient's private spend key
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Derive the one-time output public key for a transaction output.
|
|
18
|
+
* P = Hs(r*A || i)*G + B
|
|
19
|
+
*
|
|
20
|
+
* @param txPrivKey - Transaction private key r (32 bytes)
|
|
21
|
+
* @param recipPubViewKey - Recipient's public view key A (32 bytes)
|
|
22
|
+
* @param recipPubSpendKey - Recipient's public spend key B (32 bytes)
|
|
23
|
+
* @param outputIndex - Output index i
|
|
24
|
+
* @returns One-time public key P (32 bytes)
|
|
25
|
+
*/
|
|
26
|
+
export declare function deriveOutputKey(txPrivKey: Uint8Array, recipPubViewKey: Uint8Array, recipPubSpendKey: Uint8Array, outputIndex: number): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Derive the one-time private key for spending a received output.
|
|
29
|
+
* x = Hs(a*R || i) + b
|
|
30
|
+
*
|
|
31
|
+
* @param txPubKey - Transaction public key R = r*G (32 bytes)
|
|
32
|
+
* @param privViewKey - Recipient's private view key a (32 bytes)
|
|
33
|
+
* @param privSpendKey - Recipient's private spend key b (32 bytes)
|
|
34
|
+
* @param outputIndex - Output index i
|
|
35
|
+
* @returns One-time private key x (32 bytes)
|
|
36
|
+
*/
|
|
37
|
+
export declare function deriveInputKey(txPubKey: Uint8Array, privViewKey: Uint8Array, privSpendKey: Uint8Array, outputIndex: number): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Check if an output belongs to us.
|
|
40
|
+
* Computes P' = Hs(a*R || i)*G + B and checks if P' == P.
|
|
41
|
+
*
|
|
42
|
+
* @param txPubKey - Transaction public key R (32 bytes)
|
|
43
|
+
* @param privViewKey - Our private view key a (32 bytes)
|
|
44
|
+
* @param pubSpendKey - Our public spend key B (32 bytes)
|
|
45
|
+
* @param outputKey - The output's public key P (32 bytes)
|
|
46
|
+
* @param outputIndex - Output index i
|
|
47
|
+
* @returns true if the output belongs to us
|
|
48
|
+
*/
|
|
49
|
+
export declare function isOutputForUs(txPubKey: Uint8Array, privViewKey: Uint8Array, pubSpendKey: Uint8Array, outputKey: Uint8Array, outputIndex: number): boolean;
|
package/lib/daemon.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monero daemon HTTP JSON-RPC client.
|
|
3
|
+
* Provides raw RPC calls without depending on monero-ts.
|
|
4
|
+
*/
|
|
5
|
+
interface TxEntry {
|
|
6
|
+
tx_hash: string;
|
|
7
|
+
as_hex: string;
|
|
8
|
+
block_height: number;
|
|
9
|
+
block_timestamp: number;
|
|
10
|
+
in_pool: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface SendRawTxResponse {
|
|
13
|
+
status: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
double_spend: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get fee estimate from daemon.
|
|
19
|
+
* Returns fee per byte in piconero.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getFeeEstimate: (url: string) => Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Get transaction details by hash(es).
|
|
24
|
+
*/
|
|
25
|
+
export declare const getTransactions: (url: string, txHashes: string[]) => Promise<TxEntry[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Get outputs by global indices (for building ring members).
|
|
28
|
+
*/
|
|
29
|
+
export interface OutputEntry {
|
|
30
|
+
key: string;
|
|
31
|
+
mask: string;
|
|
32
|
+
unlocked: boolean;
|
|
33
|
+
height: number;
|
|
34
|
+
txid: string;
|
|
35
|
+
}
|
|
36
|
+
export declare const getOuts: (url: string, outputs: {
|
|
37
|
+
amount: number;
|
|
38
|
+
index: number;
|
|
39
|
+
}[]) => Promise<OutputEntry[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Get output distribution for decoy selection.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getOutputDistribution: (url: string, fromHeight?: number, toHeight?: number) => Promise<{
|
|
44
|
+
distribution: number[];
|
|
45
|
+
startHeight: number;
|
|
46
|
+
base: number;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Get current blockchain height.
|
|
50
|
+
*/
|
|
51
|
+
export declare const getHeight: (url: string) => Promise<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Get block data at a specific height, including transaction hashes.
|
|
54
|
+
*/
|
|
55
|
+
export interface BlockHeader {
|
|
56
|
+
height: number;
|
|
57
|
+
timestamp: number;
|
|
58
|
+
num_txes: number;
|
|
59
|
+
}
|
|
60
|
+
export declare const getBlock: (url: string, height: number) => Promise<{
|
|
61
|
+
header: BlockHeader;
|
|
62
|
+
txHashes: string[];
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Get transactions with decoded JSON for output scanning.
|
|
66
|
+
*/
|
|
67
|
+
export interface DecodedTxEntry {
|
|
68
|
+
tx_hash: string;
|
|
69
|
+
as_json: string;
|
|
70
|
+
block_height: number;
|
|
71
|
+
block_timestamp: number;
|
|
72
|
+
in_pool: boolean;
|
|
73
|
+
}
|
|
74
|
+
export declare const getTransactionsDecoded: (url: string, txHashes: string[]) => Promise<DecodedTxEntry[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Get block headers for a range of heights in a single RPC call.
|
|
77
|
+
*/
|
|
78
|
+
export interface BlockHeaderEntry {
|
|
79
|
+
height: number;
|
|
80
|
+
timestamp: number;
|
|
81
|
+
num_txes: number;
|
|
82
|
+
}
|
|
83
|
+
export declare const getBlockHeadersRange: (url: string, startHeight: number, endHeight: number) => Promise<BlockHeaderEntry[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Get block tx hashes for a specific height.
|
|
86
|
+
* Returns just the tx_hashes array (excludes miner tx).
|
|
87
|
+
*/
|
|
88
|
+
export declare const getBlockTxHashes: (url: string, height: number) => Promise<{
|
|
89
|
+
txHashes: string[];
|
|
90
|
+
timestamp: number;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Broadcast a raw transaction hex to the network.
|
|
94
|
+
*/
|
|
95
|
+
export declare const sendRawTransaction: (url: string, txHex: string) => Promise<SendRawTxResponse>;
|
|
96
|
+
export {};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Client } from './client';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './const';
|
|
4
|
+
export type { LWSLoginResponse, LWSAddressInfoResponse, LWSAddressTxsResponse, LWSTxInfo, LWSUnspentOutsResponse, LWSUnspentOutput, } from './lws';
|
|
5
|
+
export type { MoneroTransaction, TxInput, TxOutput, ClsagSig, BPPlusProof, RctSignatures, RingMember } from './tx/types';
|
|
6
|
+
export type { SpendableOutput, Destination, BuiltTransaction } from './tx/builder';
|
|
7
|
+
export type { OwnedOutput } from './scanner';
|
|
8
|
+
export { scanBlocks, computeBalance, getUnspentOutputs } from './scanner';
|