Skip to content

Commit

Permalink
Merge branch 'fixBccXrp' of github.com:kajoseph/bitcore
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsujlangston committed Nov 1, 2023
2 parents a73fc86 + 0fff6e4 commit e7d7d9e
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/bitcore-client/bin/wallet-bump-tx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const main = async () => {
// converting gasLimit and value with toString avoids a bigNumber warning
const params = { nonce, gasLimit: gasLimit.toString(), gasPrice, data, chainId, recipients: [{ address: to, amount: value.toString() }] };

const noChange = ['ETH', 'MATIC'].includes(wallet.chain);
params.change = noChange ? null : wallet.deriveAddress(wallet.addressIndex, true);
params.change = !wallet.isUtxoChain() ? null : wallet.deriveAddress(wallet.addressIndex, true);
const changeIdx = params.change ? wallet.addressIndex : null;
const tx = await wallet.newTx(params);
console.log('UnsignedRawTx: ', tx);
Expand Down
3 changes: 1 addition & 2 deletions packages/bitcore-client/bin/wallet-paypro
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ const main = async () => {
const utxos = await wallet.getUtxosArray();
const params = { recipients, feeRate, from, invoiceID, data, value, utxos };
params.nonce = Number(nonce);
const noChange = ['ETH', 'MATIC'].includes(wallet.chain);
params.change = noChange ? null : wallet.deriveAddress(wallet.addressIndex, true);
params.change = !wallet.isUtxoChain() ? null : wallet.deriveAddress(wallet.addressIndex, true);
const changeIdx = params.change ? wallet.addressIndex : null;
const unsignedTx = await wallet.newTx(params);
console.log(`unsignedRawTx: ${unsignedTx}`);
Expand Down
5 changes: 2 additions & 3 deletions packages/bitcore-client/bin/wallet-send
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ const main = async () => {
recipients,
from: lastAddress,
token
};
const noChange = ['ETH', 'MATIC'].includes(wallet.chain);
params.change = noChange ? null : wallet.deriveAddress(wallet.addressIndex, true);
};
params.change = !wallet.isUtxoChain() ? null : wallet.deriveAddress(wallet.addressIndex, true);
const changeIdx = params.change ? wallet.addressIndex : null;
const tx = await wallet.newTx(params);
console.log('unsignedRawTx: ', tx);
Expand Down
13 changes: 11 additions & 2 deletions packages/bitcore-client/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ export class Wallet {
}
}

/**
* Does this wallet use UTXOs?
* @returns {Boolean}
*/
isUtxoChain() {
// the toUpperCase() should not be necessary, but it's here just in case.
return ['BTC', 'BCH', 'DOGE', 'LTC'].includes(this.chain?.toUpperCase() || 'BTC');
}

lock() {
this.unlocked = undefined;
return this;
Expand Down Expand Up @@ -490,7 +499,7 @@ export class Wallet {
let decryptedParams = Encryption.bitcoinCoreDecrypt(addresses, passphrase);
decryptedKeys = [...decryptedParams.jsonlDecrypted];
}
if (!['ETH', 'MATIC'].includes(this.chain)) {
if (this.isUtxoChain()) {
// If changeAddressIdx == null, then save the change key at the current addressIndex (just in case)
const changeKey = await this.derivePrivateKey(true, changeAddressIdx == null ? this.addressIndex : changeAddressIdx);
await this.importKeys({ keys: [changeKey] });
Expand Down Expand Up @@ -596,7 +605,7 @@ export class Wallet {
}

private async _getChangeAddress() {
if (['ETH', 'MATIC'].includes(this.chain)) {
if (!this.isUtxoChain()) {
return;
}
const key = await this.derivePrivateKey(true, this.addressIndex);
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcore-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bitcore-p2p-cash/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bitcore-p2p-doge/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bitcore-p2p/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/crypto-wallet-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/crypto-wallet-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"info": "0.0.6-beta.0",
"ripple-binary-codec": "0.2.6",
"ripple-keypairs": "git+https://[email protected]/bitpay/ripple-keypairs.git#8d3a4643a8ddfce8222786e1e5a3e85a89a5b7f5",
"ripple-lib": "^1.8.0",
"ripple-lib": "1.8.0",
"web3": "1.4.0"
},
"devDependencies": {
Expand Down

0 comments on commit e7d7d9e

Please sign in to comment.