Skip to content

[bug] finalize_transaction returns NULL if the final transaction size is greater than 1023 bytes #260

@raffecat

Description

@raffecat

Bug Report

Current behavior:

After adding 58 UTXOs via add_utxo, finalize_transaction returns NULL (we're trying to send a lot of Dogecoin.)

Upon investigation, it's because finalize_transaction calls get_raw_transaction, which then calls utils_uint8_to_hex, and that has an internal size limit of 1023 bytes (TO_UINT8_HEX_BUF_LEN/2-1). This is because it uses a static buffer buffer_uint8_to_hex with a fixed size of 2048 hex chars.

Also note that utils_uint8_to_hex returns a pointer to this static buffer, as does get_raw_transaction and finally finalize_transaction ends up returning this static buffer address out through the public API, which might be surprising.

Expected behavior

finalize_transaction should return the encoded hex form of the transaction, even for transactions larger than 1023 bytes (2046 hex chars.)

Steps to reproduce:

Test case: #261

However any transaction with more than ~25 UTXOs will hit the size limit.

libdogecoin commit

0.1.5-dev @ c8955d2, self-compiled

The same code is also present on 0.2.0-dev

Machine specs

  • OS: Mac OS 12.7.6
  • CPU: M1 Max
  • RAM: 32 GB
  • Disk size: ugh 2TB
  • Disk Type (HD/SDD): SSD

Extra information

FAILED - test_transaction() - Line 540
Expect: not NULL
Receive: NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions