Browse Source
Merge pull request #391 from meriadec/btc-like-tx-fix
Pass sigHashType & isSegwit to signTransaction
master
Meriadec Pillet
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
17 additions and
5 deletions
-
package.json
-
src/commands/libcoreSignAndBroadcast.js
-
yarn.lock
|
|
@ -41,7 +41,7 @@ |
|
|
|
"@ledgerhq/hw-app-xrp": "^4.12.0", |
|
|
|
"@ledgerhq/hw-transport": "^4.12.0", |
|
|
|
"@ledgerhq/hw-transport-node-hid": "^4.12.0", |
|
|
|
"@ledgerhq/ledger-core": "^1.2.1", |
|
|
|
"@ledgerhq/ledger-core": "^1.3.0", |
|
|
|
"@ledgerhq/live-common": "2.11.0", |
|
|
|
"axios": "^0.18.0", |
|
|
|
"babel-runtime": "^6.26.0", |
|
|
|
|
|
@ -6,6 +6,7 @@ import { createCommand, Command } from 'helpers/ipc' |
|
|
|
import { withDevice } from 'helpers/deviceAccess' |
|
|
|
import { getWalletIdentifier } from 'helpers/libcore' |
|
|
|
import { fromPromise } from 'rxjs/observable/fromPromise' |
|
|
|
import { getCryptoCurrencyById } from '@ledgerhq/live-common/lib/helpers/currencies' |
|
|
|
|
|
|
|
type BitcoinLikeTransaction = { |
|
|
|
amount: number, |
|
|
@ -55,7 +56,18 @@ const cmd: Command<Input, Result> = createCommand( |
|
|
|
transactionBuilder.setFeesPerByte(fees) |
|
|
|
|
|
|
|
const builded = await transactionBuilder.build() |
|
|
|
const signedTransaction = await core.signTransaction(hwApp, builded) |
|
|
|
const sigHashType = core.helpers.bytesToHex( |
|
|
|
njsWalletCurrency.bitcoinLikeNetworkParameters.SigHash, |
|
|
|
) |
|
|
|
|
|
|
|
const currency = getCryptoCurrencyById(account.currencyId) |
|
|
|
const signedTransaction = await core.signTransaction({ |
|
|
|
hwApp, |
|
|
|
transaction: builded, |
|
|
|
sigHashType, |
|
|
|
supportsSegwit: currency.supportsSegwit, |
|
|
|
isSegwit: account.isSegwit, |
|
|
|
}) |
|
|
|
|
|
|
|
const txHash = await njsAccount |
|
|
|
.asBitcoinLikeAccount() |
|
|
|
|
|
@ -1451,9 +1451,9 @@ |
|
|
|
dependencies: |
|
|
|
events "^2.0.0" |
|
|
|
|
|
|
|
"@ledgerhq/ledger-core@^1.2.1": |
|
|
|
version "1.2.1" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-1.2.1.tgz#8176a4fa9182d8e0fe4456cbdc4701e4e6e25145" |
|
|
|
"@ledgerhq/ledger-core@^1.3.0": |
|
|
|
version "1.3.0" |
|
|
|
resolved "https://registry.yarnpkg.com/@ledgerhq/ledger-core/-/ledger-core-1.3.0.tgz#2b26d43c4a8973e00e0c6671a2da5183ef0ce229" |
|
|
|
dependencies: |
|
|
|
"@ledgerhq/hw-app-btc" "^4.7.3" |
|
|
|
"@ledgerhq/hw-transport-node-hid" "^4.7.6" |
|
|
|