About Electron Cash error "The transaction was rejected because it is too large"

0 93
Avatar for coiner
Written by
3 years ago
Topics: BCH, Crytocurrencies

In one of comments for my previous post "For noise.cash users: How to reduce Bitcoin Cash network fee," someone said his transaction was rejected because it is too large in Electron Cash wallet.

I know the error occurred due to long transaction size, but what is the maximum transaction size to be valid? As a developer, I was kind of curious...

So I dig into the Electron Cash source code, found the following section:

// Electron-Cash\electroncash\network.py
 
 elif r"tx-size" in server_msg or r"bad-txns-oversize" in server_msg:
            return _("The transaction was rejected because it is too large (in bytes).")

The "server_msg" is coming from bitcoin cash server, not from Electron Cash client.

So I looked for "bad-txns-oversize" in bitcoin cash server code and found some kind of transaction limit in consensus section.

// bitcoin-cash-node\src\consensus\tx_check.cpp

static bool CheckTransactionCommon(const CTransaction &tx,
                                   CValidationState &state) {
    ...
	
    // Size limit
    if (::GetSerializeSize(tx, PROTOCOL_VERSION) > MAX_TX_SIZE) {
        return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize");
    }

MAX_TX_SIZE is defined in consensus.h as follows:

/** The maximum allowed size for a transaction, in bytes */
inline constexpr uint64_t MAX_TX_SIZE = ONE_MEGABYTE;

So basically the max transaction size is limited to 1MB.

If someone has too many transaction inputs or too many transaction outputs in a single transaction AND so if the transaction size is greater than 1MB, the transaction will be invalid.

Noisers (noise.cash users) can get various amount of tip (for example, $0.01, $0.05, $0.10). It doesn't matter how much is received per tip. What it matters is the number of tips you received. Because each tip becomes a "transaction input" within a spending transaction and each transaction input will increase the size. So if you have too many transaction inputs, you might want to move your fund multiple times instead of moving all at once.

4
$ 0.30
$ 0.25 from @TheRandomRewarder
$ 0.05 from @Pantera
Avatar for coiner
Written by
3 years ago
Topics: BCH, Crytocurrencies

Comments