Skip to content

Commit

Permalink
further fixes of txhashes and output version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mkv-vcm committed Sep 28, 2021
1 parent 0a3701a commit b22a0ff
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 104 deletions.
7 changes: 6 additions & 1 deletion src/interactions/serialization/txOutput.ts
Expand Up @@ -4,6 +4,7 @@ import type { Version } from "../../types/public"
import { unreachable } from "../../utils/assert"
import { hex_to_buf, uint8_to_buf, uint32_to_buf, uint64_to_buf, serializeOptionFlag } from "../../utils/serialize"
import { serializeAddressParams } from "./addressParams"
import { getCompatibility } from "../getVersion"

function serializeTxOutputDestination(
destination: OutputDestination,
Expand Down Expand Up @@ -34,10 +35,14 @@ export function serializeTxOutputBasicParams(
output: ParsedOutput,
version: Version,
): Buffer {
const dataHashHexBuffer = getCompatibility(version).supportsAlonso
? serializeOptionFlag(output.dataHashHex != null)
: Buffer.from([])

return Buffer.concat([
serializeTxOutputDestination(output.destination, version),
uint64_to_buf(output.amount),
uint32_to_buf(output.tokenBundle.length as Uint32_t),
serializeOptionFlag(output.dataHashHex != null),
dataHashHexBuffer,
])
}

0 comments on commit b22a0ff

Please sign in to comment.