Browse Source

Use partial transaction to retrieve fees

This prevent unnecessary HTTP calls.
gre-patch-1
meriadec 6 years ago
parent
commit
6ced74745c
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 2
      package.json
  2. 3
      src/commands/libcoreGetFees.js
  3. 3
      src/commands/libcoreSignAndBroadcast.js
  4. 8
      yarn.lock

2
package.json

@ -40,7 +40,7 @@
"@ledgerhq/hw-app-xrp": "^4.25.0",
"@ledgerhq/hw-transport": "^4.24.0",
"@ledgerhq/hw-transport-node-hid": "4.24.0",
"@ledgerhq/ledger-core": "2.0.0-rc.12",
"@ledgerhq/ledger-core": "2.0.0-rc.13",
"@ledgerhq/live-common": "4.6.0",
"animated": "^0.2.2",
"async": "^2.6.1",

3
src/commands/libcoreGetFees.js

@ -75,7 +75,8 @@ const cmd: Command<Input, Result> = createCommand(
njsWalletCurrency,
BigNumber(transaction.feePerByte),
)
const transactionBuilder = bitcoinLikeAccount.buildTransaction()
const isPartial = true
const transactionBuilder = bitcoinLikeAccount.buildTransaction(isPartial)
if (!isValidAddress(core, njsWalletCurrency, transaction.recipient)) {
// FIXME this is a bug in libcore. later it will probably check this and we can remove this check
throw new InvalidAddress()

3
src/commands/libcoreSignAndBroadcast.js

@ -227,7 +227,8 @@ export async function doSignAndBroadcast({
const njsWalletCurrency = njsWallet.getCurrency()
const amount = bigNumberToLibcoreAmount(core, njsWalletCurrency, BigNumber(transaction.amount))
const fees = bigNumberToLibcoreAmount(core, njsWalletCurrency, BigNumber(transaction.feePerByte))
const transactionBuilder = bitcoinLikeAccount.buildTransaction()
const isPartial = false
const transactionBuilder = bitcoinLikeAccount.buildTransaction(isPartial)
// TODO: check if is valid address. if not, it will fail silently on invalid

8
yarn.lock

@ -1756,10 +1756,10 @@
dependencies:
events "^3.0.0"
"@ledgerhq/ledger-core@2.0.0-rc.12":
version "2.0.0-rc.12"
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.12.tgz#bdd3e4b601acb0c74c640f40bea2609bb5e4b0f4"
integrity sha512-nwPAmDlGGSx/nRzwxKodmN1KBKtFmElE0FkbbAn1s0xiX6C8wMPRWPtD7oTufJ5MsfSfJg4ELsscEiaHFbZFKA==
"@ledgerhq/ledger-core@2.0.0-rc.13":
version "2.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-2.0.0-rc.13.tgz#a07ac7ee1f0bd3f91699158cb46c6ce8e3b981b5"
integrity sha512-HV7PV5UAB5LVnBtF9hYsRHPt9IG0bIXOsWxU43D4h5RZlkZxDt3j8EQv2Yy1s/y4aHj5bnmBYWw4RxCH2QVR3A==
dependencies:
"@ledgerhq/hw-app-btc" "^4.7.3"
"@ledgerhq/hw-transport-node-hid" "^4.7.6"

Loading…
Cancel
Save