|
1 year ago | |
---|---|---|
dist | 1 year ago | |
examples/example1 | 1 year ago | |
lib | 1 year ago | |
tests | 1 year ago | |
.gitignore | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 1 year ago | |
build.sh | 1 year ago | |
info.txt | 1 year ago | |
package.json | 1 year ago | |
tsconfig.json | 1 year ago | |
typedoc.js | 1 year ago | |
yarn.lock | 1 year ago |
https://git.fedoragold.com/jojapoppa/fedoragold-wallet-backend.git
Provides an interface to the FedoraGold (FED) network, allowing wallet applications to be built.
You can view the documentation here
You can see a list of all the other classes on the right side of the screen.
Note that you will need to prefix them all with WB.
to access them, if you are not using typescript style imports, assuming you imported with const WB = require('fedoragold-wallet-backend')
.
You can find an example project in the examples folder.
const WB = require('fedoragold-wallet-backend');
(async () => {
const daemon = new WB.Daemon('127.0.0.1', 11898);
/* OR
const daemon = new WB.Daemon('blockapi.turtlepay.io', 443);
*/
const wallet = WB.WalletBackend.createWallet(daemon);
console.log('Created wallet');
await wallet.start();
console.log('Started wallet');
wallet.saveWalletToFile('mywallet.wallet', 'hunter2');
/* Make sure to call stop to let the node process exit */
wallet.stop();
})().catch(err => {
console.log('Caught promise rejection: ' + err);
});
import { WalletBackend, Daemon, IDaemon } from 'fedoragold-wallet-backend';
(async () => {
const daemon: IDaemon = new Daemon('127.0.0.1', 11898);
/* OR
const daemon: IDaemon = new Daemon('blockapi.turtlepay.io', 443);
*/
const wallet: WalletBackend = WalletBackend.createWallet(daemon);
console.log('Created wallet');
await wallet.start();
console.log('Started wallet');
wallet.saveWalletToFile('mywallet.wallet', 'hunter2');
/* Make sure to call stop to let the node process exit */
wallet.stop();
})().catch(err => {
console.log('Caught promise rejection: ' + err);
});
There are a few features which you may wish to configure that are worth mentioning.
Auto optimization is enabled by default. This makes the wallet automatically send fusion transactions when needed to keep the wallet permanently optimized.
To enable/disable this feature, use the following code:
wallet.enableAutoOptimization(false); // disables auto optimization
By default, coinbase transactions are not scanned. This is due to the majority of people not having solo mined any blocks.
If you wish to enable coinbase transaction scanning, run this line of code:
wallet.scanCoinbaseTransactions(true)
By default, the logger is disabled. You can enable it like so:
wallet.setLogLevel(WB.LogLevel.DEBUG);
and in typescript:
wallet.setLogLevel(LogLevel.DEBUG);
The logger uses console.log, i.e. it outputs to stdout.
If you want to change this, or want more control over what messages are logged, you can provide a callback for the logger to call.
wallet.setLoggerCallback((prettyMessage, message, level, categories) => {
if (categories.includes(WB.LogCategory.SYNC)) {
console.log(prettyMessage);
}
});
and in typescript:
wallet.setLoggerCallback((prettyMessage, message, level, categories) => {
if (categories.includes(LogCategory.SYNC)) {
console.log(prettyMessage);
}
});
In this example, we only print messages that fall into the SYNC category.
You can view available categories and log levels in the documentation.
/sync/raw
sendTransactionBasic
and sendTransactionAdvanced
now also returns the node fee and destinations sent to.sendAll
. See the new docs for more information.sendPreparedTransaction
sendRawPreparedTransaction
deletePreparedTransaction
includeFusions
param to getNumTransactions
The return type of both sendTransactionBasic
and sendTransactionAdvanced
has
changed. The type of the fee
parameter for sendTransactionAdvanced
has changed.
`git clone https://git.fedoragold.com/jojapoppa/fedoragold-wallet-backend
cd fedoragold-wallet-backend
npm install -g yarn
(Skip this if you already have yarn installed)
yarn install
yarn build
Generated javascript files will be written to the dist/lib/ folder.
yarn test
- This will run the basic tests
yarn test-all
- This will run all tests, including performance tests.
lib/
folder)yarn docs
yarn test
, or yarn test-all
if you have a local daemon running.