Skip to content

sendrawtransaction returns array instead of txid string #33

@shruggr

Description

@shruggr

The sendrawtransaction handler at services/rpc/handlers.go:801 returns []*ResponseWrapper (an array) instead of the transaction ID as a string.

Current code

res, err := d.SendTransaction(context.Background(), tx)
if err != nil {
    return nil, &bsvjson.RPCError{
        Code:    bsvjson.ErrRPCInvalidParameter,
        Message: "TX rejected: " + err.Error(),
    }
}

return res, nil  // Returns []*ResponseWrapper

Expected

Per the handler documentation (line 754) and standard Bitcoin RPC behavior, it should return the transaction ID as a string.

Fix

return tx.TxIDStr(), nil

Error received by clients

json: cannot unmarshal array into Go struct field Response[...].result of type string

Tested on v0.11.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions