Skip to content

Commit

Permalink
Add missing binding methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tmalahie committed Oct 10, 2024
1 parent d9e5d96 commit bcfe295
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function validateTypes(values, expectedTypes) {
exports.AssetSchema = AssetSchema = {
Nia: "Nia",
Cfa: "Cfa",
Uda: "Uda",
};

exports.BitcoinNetwork = BitcoinNetwork = {
Expand Down Expand Up @@ -126,6 +127,17 @@ exports.generateKeys = function generateKeys(bitcoinNetwork) {
return JSON.parse(lib.rgblib_generate_keys(bitcoinNetwork));
};

exports.restoreKeys = function (bitcoinNetwork, mnemonic) {
validateEnumValues(
{ bitcoinNetwork },
{
bitcoinNetwork: BitcoinNetwork,
},
);
validateTypes({ mnemonic }, { mnemonic: "string" });
return JSON.parse(lib.rgblib_restore_keys(bitcoinNetwork, mnemonic));
};

exports.WalletData = class WalletData {
constructor(walletData) {
validateProperties(walletData, [
Expand Down Expand Up @@ -233,6 +245,61 @@ exports.Wallet = class Wallet {
return lib.rgblib_get_address(this.wallet);
}

getBtcBalance(online, skipSync) {
const params = { online, skipSync };
const expectedTypes = {
online: "object",
skipSync: "boolean",
};
validateTypes(params, expectedTypes);
return JSON.parse(lib.rgblib_get_btc_balance(this.wallet, online, skipSync));
}

getAssetBalance(assetId) {
const params = { assetId };
const expectedTypes = {
assetId: "string",
};
validateTypes(params, expectedTypes);
return JSON.parse(lib.rgblib_get_asset_balance(this.wallet, assetId));
}

listTransactions(online, skipSync) {
const params = { online, skipSync };
const expectedTypes = {
online: "object",
skipSync: "boolean",
};
validateTypes(params, expectedTypes);
return JSON.parse(lib.rgblib_list_transactions(this.wallet, online, skipSync));
}

sendBtc(online, address, amount, feeRate, skipSync) {
const params = {
online,
address,
amount,
feeRate,
skipSync,
};
const expectedTypes = {
online: "object",
address: "string",
amount: "u64",
feeRate: "f32",
skipSync: "boolean",
};
validateTypes(params, expectedTypes);
return lib.rgblib_send_btc(
this.wallet,
online,
address,
amount,
feeRate,
skipSync,
);
}

goOnline(skipConsistencyCheck, electrumUrl) {
const params = { skipConsistencyCheck, electrumUrl };
const expectedTypes = {
Expand Down Expand Up @@ -363,6 +430,34 @@ exports.Wallet = class Wallet {
);
}

listTransfers(assetId) {
const params = {
assetId,
};
const expectedTypes = {
assetId: "string",
};
validateTypes(params, expectedTypes);
return JSON.parse(lib.rgblib_list_transfers(this.wallet, assetId));
}

listUnspents(online, settledOnly, skipSync) {
const params = {
online,
settledOnly,
skipSync,
};
const expectedTypes = {
online: "object",
settledOnly: "boolean",
skipSync: "boolean",
};
validateTypes(params, expectedTypes);
return JSON.parse(
lib.rgblib_list_unspents(this.wallet, online, settledOnly, skipSync),
);
}

refresh(online, assetId, filter, skipSync) {
const params = {
online,
Expand Down

0 comments on commit bcfe295

Please sign in to comment.