monero-nodejs-libwallet
Advanced tools
Comparing version 0.2.6 to 0.3.0
@@ -50,9 +50,35 @@ export = monero; | ||
type Wallet = { | ||
type Transfer = { | ||
amount: string; | ||
address: string; | ||
}; | ||
type TransactionInfo = { | ||
id: string; | ||
direction: 'in' | 'out'; | ||
pending: boolean; | ||
failed: boolean; | ||
amount: string; | ||
fee: string; | ||
blockHeight: number; | ||
subAddresses: string; | ||
subAddrAccount: string; | ||
label: string; | ||
confirmations: number; | ||
unlockTime: number; | ||
timestamp: number; | ||
paymentId: number; | ||
transfers: Transfer[]; | ||
}; | ||
interface Wallet { | ||
address(): string; | ||
seed(): string; | ||
on(event: 'newBlock', callback: (height: number) => void): Wallet; | ||
on(event: 'unconfirmedMoneyReceived' | 'moneyReceived' | 'moneySpent', callback: (tx: string, amount: number) => void): Wallet; | ||
on(event: 'refreshed' | 'updated', callback: () => void): Wallet; | ||
off(event?: WalletEvent): Wallet; | ||
on(event: 'newBlock', callback: (height: number) => void): PersonalWallet | MultisigWallet; | ||
on( | ||
event: 'unconfirmedMoneyReceived' | 'moneyReceived' | 'moneySpent', | ||
callback: (tx: string, amount: string) => void, | ||
): PersonalWallet | MultisigWallet; | ||
on(event: 'refreshed' | 'updated', callback: () => void): PersonalWallet | MultisigWallet; | ||
off(event?: WalletEvent): PersonalWallet | MultisigWallet; | ||
store(): Promise<void>; | ||
@@ -65,2 +91,3 @@ createTransaction(options: { | ||
}): Promise<Transaction>; | ||
history(): TransactionInfo[]; | ||
path(): string; | ||
@@ -73,7 +100,7 @@ network(): Network; | ||
publicMultisigSignerKey(): string; | ||
setPassword(password: string): Wallet; | ||
setRefreshFromBlockHeight(height: number): Wallet; | ||
setPassword(password: string): PersonalWallet | MultisigWallet; | ||
setRefreshFromBlockHeight(height: number): PersonalWallet | MultisigWallet; | ||
getRefreshFromBlockHeight(): string; | ||
connected(): boolean; | ||
setTrustedDaemon(value: boolean): Wallet; | ||
setTrustedDaemon(value: boolean): PersonalWallet | MultisigWallet; | ||
trustedDaemon(): boolean; | ||
@@ -88,5 +115,2 @@ balance(): string; | ||
multisigState(): MultisigState; | ||
signMessage(message: string): string; // non-multisig only | ||
verifySignedMessage(message: string, address: string, signature: string): boolean; // non-multisig only | ||
signMultisigParticipant(message: string): string; // multisig only | ||
verifyMessageWithPublicKey(message: string, key: string, signature: string): boolean; | ||
@@ -99,4 +123,13 @@ getMultisigInfo(): string; | ||
restoreMultisigTransaction(sign: string): Promise<Transaction>; | ||
}; | ||
} | ||
interface MultisigWallet extends Wallet { | ||
signMultisigParticipant(message: string): string; | ||
} | ||
interface PersonalWallet extends Wallet { | ||
signMessage(message: string): string; | ||
verifySignedMessage(message: string, address: string, signature: string): boolean; | ||
} | ||
function setupLog(level: number, output?: string): void; | ||
@@ -109,3 +142,3 @@ function createWallet(options: { | ||
language?: Language, | ||
}): Promise<Wallet>; | ||
}): Promise<PersonalWallet | MultisigWallet>; | ||
function openWallet(options: { | ||
@@ -117,3 +150,3 @@ path: string, | ||
language?: Language, | ||
}): Promise<Wallet>; | ||
}): Promise<PersonalWallet | MultisigWallet>; | ||
function recoveryWallet(options: { | ||
@@ -126,3 +159,3 @@ path: string, | ||
restoreHeight?: number, | ||
}): Promise<Wallet>; | ||
}): Promise<PersonalWallet>; | ||
function walletExists(path: string): boolean; | ||
@@ -129,0 +162,0 @@ function genPaymentId(): string; |
{ | ||
"name": "monero-nodejs-libwallet", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"description": "Monero libwallet native addon. Under development at the moment", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -249,2 +249,31 @@ # monero-nodejs-libwallet | ||
### history | ||
Returns array of transaction info objects: | ||
```js | ||
wallet.history().forEach((txInfo) => { | ||
console.log("id : " + txInfo.id); // transaction id (hash) | ||
console.log("direction : " + txInfo.direction); // 'in' for incoming transactions, 'out' for outcoming ones | ||
console.log("pending : " + txInfo.pending); // 'true' if transaction has been included in a block | ||
console.log("failed : " + txInfo.failed); // 'true' if transaction hasn't been sent due to errors | ||
console.log("amount : " + txInfo.amount); // transaction amount (in atomic monero units as string) | ||
console.log("fee : " + txInfo.fee); // transaction fee (in atomic monero units as string) | ||
console.log("block height : " + txInfo.blockHeight); // block height containing this transaction. 0 if pending | ||
console.log("subaddresses: " + txInfo.subAddresses); // account subaddresses affected by this transaction | ||
console.log("subAddrAccount : " + txInfo.subAddrAccount); // accounts affected by this transaction | ||
console.log("label : " + txInfo.label); // account label | ||
console.log("confirmations : " + txInfo.confirmations); // number of transaction's confirmations | ||
console.log("unlock time : " + txInfo.unlockTime); // transaction unlock time | ||
console.log("timestamp : " + txInfo.timestamp); // transaction timestamp | ||
console.log("payment id : " + txInfo.paymentId); // payment id. '0000000000000000' if absent | ||
txInfo.transfers.forEach((transfer) => { // transaction's transfers if any (not available if wallet has been restored) | ||
console.log("\ttransfer amount: " + transfer.amount); // transfer amount | ||
console.log("\ttransfer address: " + transfer.address); // transfer address | ||
}); | ||
}) | ||
``` | ||
**Note**: if you restored your wallet or resynced it from the begining you won't have `transfers` in wallet's history. | ||
### path | ||
@@ -251,0 +280,0 @@ Returns current wallet file path: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1977421
32201
529