diff --git a/rpcwebsocket.go b/rpcwebsocket.go index d32bf774..15120eb0 100644 --- a/rpcwebsocket.go +++ b/rpcwebsocket.go @@ -549,9 +549,9 @@ func (*wsNotificationManager) removeSpentRequest(ops map[btcwire.OutPoint]map[ch // txHexString returns the serialized transaction encoded in hexadecimal. func txHexString(tx *btcutil.Tx) string { - var buf bytes.Buffer + buf := bytes.NewBuffer(make([]byte, 0, tx.MsgTx().SerializeSize())) // Ignore Serialize's error, as writing to a bytes.buffer cannot fail. - tx.MsgTx().Serialize(&buf) + tx.MsgTx().Serialize(buf) return hex.EncodeToString(buf.Bytes()) }