|
|
@ -28,6 +28,7 @@ type BitcoinLikeTransaction = { |
|
|
|
|
|
|
|
type Input = { |
|
|
|
accountId: string, |
|
|
|
blockHeight: number, |
|
|
|
currencyId: string, |
|
|
|
derivationMode: string, |
|
|
|
seedIdentifier: string, |
|
|
@ -43,7 +44,17 @@ type Result = { type: 'signed' } | { type: 'broadcasted', operation: OperationRa |
|
|
|
|
|
|
|
const cmd: Command<Input, Result> = createCommand( |
|
|
|
'libcoreSignAndBroadcast', |
|
|
|
({ accountId, currencyId, derivationMode, seedIdentifier, xpub, index, transaction, deviceId }) => |
|
|
|
({ |
|
|
|
accountId, |
|
|
|
blockHeight, |
|
|
|
currencyId, |
|
|
|
derivationMode, |
|
|
|
seedIdentifier, |
|
|
|
xpub, |
|
|
|
index, |
|
|
|
transaction, |
|
|
|
deviceId, |
|
|
|
}) => |
|
|
|
Observable.create(o => { |
|
|
|
let unsubscribed = false |
|
|
|
const currency = getCryptoCurrencyById(currencyId) |
|
|
@ -52,6 +63,7 @@ const cmd: Command<Input, Result> = createCommand( |
|
|
|
doSignAndBroadcast({ |
|
|
|
accountId, |
|
|
|
currency, |
|
|
|
blockHeight, |
|
|
|
derivationMode, |
|
|
|
seedIdentifier, |
|
|
|
xpub, |
|
|
@ -81,6 +93,7 @@ const cmd: Command<Input, Result> = createCommand( |
|
|
|
async function signTransaction({ |
|
|
|
hwApp, |
|
|
|
currency, |
|
|
|
blockHeight, |
|
|
|
transaction, |
|
|
|
derivationMode, |
|
|
|
sigHashType, |
|
|
@ -88,6 +101,7 @@ async function signTransaction({ |
|
|
|
}: { |
|
|
|
hwApp: Btc, |
|
|
|
currency: CryptoCurrency, |
|
|
|
blockHeight: number, |
|
|
|
transaction: *, |
|
|
|
derivationMode: string, |
|
|
|
sigHashType: number, |
|
|
@ -96,7 +110,12 @@ async function signTransaction({ |
|
|
|
const additionals = [] |
|
|
|
let expiryHeight |
|
|
|
if (currency.id === 'bitcoin_cash' || currency.id === 'bitcoin_gold') additionals.push('bip143') |
|
|
|
if (currency.id === 'zcash') expiryHeight = Buffer.from([0x00, 0x00, 0x00, 0x00]) |
|
|
|
if (currency.id === 'zcash') { |
|
|
|
expiryHeight = Buffer.from([0x00, 0x00, 0x00, 0x00]) |
|
|
|
if (blockHeight >= 419200) { |
|
|
|
additionals.push('sapling') |
|
|
|
} |
|
|
|
} |
|
|
|
const rawInputs = transaction.getInputs() |
|
|
|
|
|
|
|
const hasExtraData = currency.id === 'zcash' |
|
|
@ -168,6 +187,7 @@ async function signTransaction({ |
|
|
|
export async function doSignAndBroadcast({ |
|
|
|
accountId, |
|
|
|
derivationMode, |
|
|
|
blockHeight, |
|
|
|
seedIdentifier, |
|
|
|
currency, |
|
|
|
xpub, |
|
|
@ -182,6 +202,7 @@ export async function doSignAndBroadcast({ |
|
|
|
accountId: string, |
|
|
|
derivationMode: string, |
|
|
|
seedIdentifier: string, |
|
|
|
blockHeight: number, |
|
|
|
currency: CryptoCurrency, |
|
|
|
xpub: string, |
|
|
|
index: number, |
|
|
@ -224,6 +245,7 @@ export async function doSignAndBroadcast({ |
|
|
|
signTransaction({ |
|
|
|
hwApp: new Btc(transport), |
|
|
|
currency, |
|
|
|
blockHeight, |
|
|
|
transaction: builded, |
|
|
|
sigHashType: parseInt(sigHashType, 16), |
|
|
|
hasTimestamp, |
|
|
|