Skip to content

Commit

Permalink
πŸ› FIX: more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
riverrun46 committed Sep 25, 2023
1 parent 4b180b1 commit e0a8dea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ export const signTransactions = async (
// find out if this transaction depends on previous ones
// if so, we need to update the prevTxId of the current one
if (toSign.dependsOn !== undefined) {
// structure replace
// structure dependencies
const wrongTxId = tx.inputs[inputIndex].prevTxId.toString('hex')
const prevTxId = signedTransactions[toSign.dependsOn].txid

// data replace
// data dependencies
let wrongDataTxId: string
let prevDataTxId: string
if (toSign.dataDependsOn) {
if (toSign.dataDependsOn !== undefined) {
const dataDependentTx = new mvc.Transaction(toSignTransactionsWithDependsOn[toSign.dataDependsOn].txHex)
wrongDataTxId = dataDependentTx.id
prevDataTxId = signedTransactions[toSign.dataDependsOn].txid
Expand All @@ -189,9 +189,11 @@ export const signTransactions = async (
prevDataTxId = prevTxId
}

// update the prevTxId of the current tx
tx.inputs[inputIndex].prevTxId = Buffer.from(prevTxId, 'hex')

// if hasMetaId is true, we need to also update the parent txid written in OP_RETURN
// based on the wrongDataTxId and prevDataTxId
if (hasMetaId) {
const { messages: metaIdMessages, outputIndex } = await parseLocalTransaction(tx)

Expand Down

0 comments on commit e0a8dea

Please sign in to comment.