diff --git a/packages/stack/src/blockchain/blockchain-inmemory.ts b/packages/stack/src/blockchain/blockchain-inmemory.ts index 4fb5111..9d39a21 100644 --- a/packages/stack/src/blockchain/blockchain-inmemory.ts +++ b/packages/stack/src/blockchain/blockchain-inmemory.ts @@ -156,11 +156,19 @@ export class BlockchainInMemory extends BaseBlockchain { ); } + // Check if the transaction has a mempool input, if there is one, we need to set the height to -1 to indicate that it uses an unconfirmed input + const hasMempoolInput = tx.getInputs().some((input) => { + const tx = this.transactions.get(binToHex(input.outpointTransactionHash)); + if (!tx) return false; + + return tx.height <= 0; + }); + // Add the transaction. this.addTransaction({ hash: tx.toHash(), transaction: tx, - height: 0, + height: hasMempoolInput ? -1 : 0, }); // Notify our address and transaction subscribers. @@ -330,10 +338,11 @@ export class BlockchainInMemory extends BaseBlockchain { for (const tx of this.transactions.values()) { tx.transaction.getOutputs().forEach((output, outpointIndex) => { const utxo: BlockchainUTXO = { - height: 0, + height: tx.height, utxo: UTXO.from(new Outpoint(tx.hash.toBytes(), outpointIndex), { valueSatoshis: output.valueSatoshis, lockingBytecode: output.lockingBytecode, + token: output.token, }), }; utxoMap.set(`${tx.hash.toHex()}:${outpointIndex}`, utxo);