Skip to content

Commit

Permalink
RSK support for Bitcore Wallet Client
Browse files Browse the repository at this point in the history
  • Loading branch information
alepc253 committed Nov 8, 2021
1 parent a278220 commit b201f13
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/bitcore-wallet-client/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var Bitcore_ = {
eth: CWC.BitcoreLib,
xrp: CWC.BitcoreLib,
doge: CWC.BitcoreLibDoge,
ltc: CWC.BitcoreLibLtc
ltc: CWC.BitcoreLibLtc,
rsk: CWC.BitcoreLib
};
var Mnemonic = require('bitcore-mnemonic');
var url = require('url');
Expand Down Expand Up @@ -468,7 +469,7 @@ export class API extends EventEmitter {
if (!_.includes(Constants.COINS, coin))
return cb(new Error('Invalid coin'));

if (coin == 'eth')
if (coin == 'eth' || coin == 'rsk' || coin == 'rbtc')
return cb(new Error('ETH not supported for this action'));

var B = Bitcore_[coin];
Expand Down Expand Up @@ -703,6 +704,7 @@ export class API extends EventEmitter {
switch (chain) {
case 'XRP':
case 'ETH':
case 'RSK':
const unsignedTxs = t.uncheckedSerialize();
const signedTxs = [];
for (let index = 0; index < signatures.length; index++) {
Expand Down Expand Up @@ -2515,7 +2517,7 @@ export class API extends EventEmitter {
// * @return {Callback} cb - Return error (if exists) and nonce
// */
getNonce(opts, cb) {
$.checkArgument(opts.coin == 'eth', 'Invalid coin: must be "eth"');
$.checkArgument(opts.coin == 'eth' || opts.coin == 'rsk', 'Invalid coin: must be "eth"');

var qs = [];
qs.push(`coin=${opts.coin}`);
Expand Down Expand Up @@ -2933,6 +2935,7 @@ export class API extends EventEmitter {
['doge', 'testnet'],
['ltc', 'testnet'],
['ltc', 'livenet'],
['rsk', 'livenet'],
['btc', 'livenet', true],
['bch', 'livenet', true],
['doge', 'livenet', true],
Expand Down
4 changes: 3 additions & 1 deletion packages/bitcore-wallet-client/src/lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const Constants = {
'gusd',
'busd',
'dai',
'wbtc'
'wbtc',
'rsk',
'rbtc'
],
ERC20: ['usdc', 'pax', 'gusd', 'busd', 'dai', 'wbtc'],
UTXO_COINS: ['btc', 'bch', 'doge', 'ltc'],
Expand Down
3 changes: 2 additions & 1 deletion packages/bitcore-wallet-client/src/lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const Bitcore_ = {
eth: Bitcore,
xrp: Bitcore,
doge: BitcoreLibDoge,
ltc: BitcoreLibLtc
ltc: BitcoreLibLtc,
rsk: Bitcore
};
const PrivateKey = Bitcore.PrivateKey;
const PublicKey = Bitcore.PublicKey;
Expand Down
2 changes: 2 additions & 0 deletions packages/bitcore-wallet-client/src/lib/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ export class Credentials {
coin = '3';
} else if (this.coin == 'ltc') {
coin = '2';
} else if (this.coin == 'rsk' || this.coin == 'rbtc') {
coin = '137';
} else {
throw new Error('unknown coin: ' + this.coin);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/bitcore-wallet-client/src/lib/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ export class Key {
coinCode = '3';
} else if (opts.coin == 'ltc') {
coinCode = '2';
} else if (opts.coin == 'rsk' || opts.coin == 'rbtc') {
coinCode = '137';
} else {
throw new Error('unknown coin: ' + opts.coin);
}
Expand Down

0 comments on commit b201f13

Please sign in to comment.